Index: core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java =================================================================== RCS file: /shared/data/ccvs/repository/core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java,v retrieving revision 1.44 diff -u -r1.44 PersistenceManager.java --- core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java 29 Mar 2007 21:38:29 -0000 1.44 +++ core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java 26 Jun 2007 12:19:18 -0000 @@ -60,6 +60,7 @@ import org.openide.util.NbBundle; import org.openide.util.io.SafeException; import org.openide.windows.TopComponent; +import org.openide.windows.WindowManager; import org.openide.xml.XMLUtil; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -658,7 +659,9 @@ public boolean isTopComponentPersistent (TopComponent tc) { int persistenceType = tc.getPersistenceType(); if ((TopComponent.PERSISTENCE_NEVER == persistenceType) - || ((TopComponent.PERSISTENCE_ONLY_OPENED == persistenceType) && !tc.isOpened())) { + || ((TopComponent.PERSISTENCE_ONLY_OPENED == persistenceType) && !tc.isOpened()) + || ((WindowManager.getDefault().isEditorTopComponent(tc))) + ) { return false; } return true; Index: projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java =================================================================== RCS file: /shared/data/ccvs/repository/projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java,v retrieving revision 1.25 diff -u -r1.25 Hacks.java --- projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java 7 Feb 2007 19:39:47 -0000 1.25 +++ projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java 26 Jun 2007 12:19:18 -0000 @@ -109,6 +109,18 @@ }); } + /** Registers callback to load projects after winsys initialization. + */ + public static void hookProjectLoading() { + WindowManager.getDefault().invokeWhenUIReady(new Runnable() { + + public void run() { + OpenProjectList.getDefault().initialize(); + } + + }); + } + /** Forces reload of panels in TemplateWizard. Public method updateState doesn't re-read * the new panels from new iterator. Index: projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java =================================================================== RCS file: /shared/data/ccvs/repository/projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java,v retrieving revision 1.68 diff -u -r1.68 OpenProjectList.java --- projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java 29 Mar 2007 01:47:24 -0000 1.68 +++ projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java 26 Jun 2007 12:19:18 -0000 @@ -121,6 +121,8 @@ private PropertyChangeListener infoListener; + private boolean inited = false; + OpenProjectList() { openProjects = new ArrayList(); openProjectsModuleInfos = new HashMap>(); @@ -133,44 +135,52 @@ }; pchSupport = new PropertyChangeSupport( this ); recentProjects = new RecentProjectList(10); // #47134 + recentTemplates = new ArrayList(); } // Implementation of the class --------------------------------------------- public static OpenProjectList getDefault() { + synchronized ( OpenProjectList.class ) { + if ( INSTANCE == null ) { + INSTANCE = new OpenProjectList(); + } + } + return INSTANCE; + } + + public void initialize() { boolean needNotify = false; Project[] inital = null; synchronized ( OpenProjectList.class ) { - if ( INSTANCE == null ) { - needNotify = true; - INSTANCE = new OpenProjectList(); - INSTANCE.openProjects = loadProjectList(); - inital = INSTANCE.openProjects.toArray(new Project[0]); - INSTANCE.recentTemplates = new ArrayList( OpenProjectListSettings.getInstance().getRecentTemplates() ); - URL mainProjectURL = OpenProjectListSettings.getInstance().getMainProjectURL(); - // Load recent project list - INSTANCE.recentProjects.load(); - for( Iterator it = INSTANCE.openProjects.iterator(); it.hasNext(); ) { - Project p = (Project)it.next(); - INSTANCE.addModuleInfo(p); - // Set main project - try { - if ( mainProjectURL != null && - mainProjectURL.equals( p.getProjectDirectory().getURL() ) ) { - INSTANCE.mainProject = p; - } - } - catch( FileStateInvalidException e ) { - // Not a main project + needNotify = true; + List prjs = loadProjectList(); + open(prjs.toArray(new Project[prjs.size()]), false, false); + inital = openProjects.toArray(new Project[0]); + recentTemplates = new ArrayList( OpenProjectListSettings.getInstance().getRecentTemplates() ); + URL mainProjectURL = OpenProjectListSettings.getInstance().getMainProjectURL(); + // Load recent project list + recentProjects.load(); + for(Project p: openProjects) { + INSTANCE.addModuleInfo(p); + // Set main project + try { + if ( mainProjectURL != null && + mainProjectURL.equals( p.getProjectDirectory().getURL() ) ) { + INSTANCE.mainProject = p; } - } + } + catch( FileStateInvalidException e ) { + // Not a main project + } } + inited = true; } if ( needNotify ) { //#68738: a project may open other projects in its ProjectOpenedHook: - for(Project p: new ArrayList(INSTANCE.openProjects)) { + for(Project p: new ArrayList(openProjects)) { notifyOpened(p); } @@ -178,8 +188,6 @@ if (inital != null) { log(createRecord("UI_INIT_PROJECTS", inital)); } - - return INSTANCE; } public void open( Project p ) { @@ -200,6 +208,7 @@ return ; } + Thread.dumpStack(); long start = System.currentTimeMillis(); if (asynchronously) { @@ -375,6 +384,7 @@ } public void close( Project projects[], boolean notifyUI ) { + Thread.dumpStack(); if (!ProjectUtilities.closeAllDocuments (projects, notifyUI )) { return; } @@ -554,9 +564,12 @@ // Used from ProjectUiModule static void shutdown() { if (INSTANCE != null) { - Iterator it = INSTANCE.openProjects.iterator(); - while (it.hasNext()) { - Project p = (Project)it.next(); + if (!ProjectUtilities.closeAllDocuments ( + INSTANCE.openProjects.toArray(new Project[INSTANCE.openProjects.size()]), false )) { // TODO need another mode to save everything + ERR.log(ErrorManager.WARNING, "Not all project files saved"); + } + + for (Project p: INSTANCE.openProjects) { notifyClosed(p); } } Index: projects/projectui/src/org/netbeans/modules/project/ui/ProjectUiModule.java =================================================================== RCS file: /shared/data/ccvs/repository/projects/projectui/src/org/netbeans/modules/project/ui/ProjectUiModule.java,v retrieving revision 1.6 diff -u -r1.6 ProjectUiModule.java --- projects/projectui/src/org/netbeans/modules/project/ui/ProjectUiModule.java 30 Jun 2006 21:27:20 -0000 1.6 +++ projects/projectui/src/org/netbeans/modules/project/ui/ProjectUiModule.java 26 Jun 2007 12:19:18 -0000 @@ -32,6 +32,7 @@ public void restored() { Hacks.keepCurrentProjectNameUpdated(); + Hacks.hookProjectLoading(); } public void close() { Index: projects/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java =================================================================== RCS file: /shared/data/ccvs/repository/projects/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java,v retrieving revision 1.39 diff -u -r1.39 ProjectUtilities.java --- projects/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java 20 Jun 2007 21:47:14 -0000 1.39 +++ projects/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java 26 Jun 2007 12:19:19 -0000 @@ -117,12 +117,14 @@ } private void doClose(Project[] projects, boolean notifyUI, Wrapper wr) { + ERR.log(Level.FINE, "doClose: {0} ", Arrays.toString(projects)); List listOfProjects = Arrays.asList(projects); Set openFiles = new HashSet(); final Set tc2close = new HashSet(); WindowManager wm = WindowManager.getDefault(); for (TopComponent tc : wm.getRegistry().getOpened()) { - //#84546 - this condituon should allow us to close just editor related TCs that are in any imaginable mode. + ERR.log(Level.FINE, "doClose: checking if {0} should be stored", tc); + //#84546 - this condition should allow us to close just editor related TCs that are in any imaginable mode. if (!wm.isOpenedEditorTopComponent(tc)) { continue; } @@ -133,6 +135,7 @@ Project owner = FileOwnerQuery.getOwner(fobj); if (listOfProjects.contains(owner)) { + ERR.log(Level.FINE, "doClose: storing {0}", tc); if (notifyUI) { openFiles.add(dobj); tc2close.add(tc);