This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 108120
Collapse All | Expand All

(-)core/windows/src/org/netbeans/core/windows/persistence/PersistenceManager.java (-1 / +4 lines)
Lines 60-65 Link Here
60
import org.openide.util.NbBundle;
60
import org.openide.util.NbBundle;
61
import org.openide.util.io.SafeException;
61
import org.openide.util.io.SafeException;
62
import org.openide.windows.TopComponent;
62
import org.openide.windows.TopComponent;
63
import org.openide.windows.WindowManager;
63
import org.openide.xml.XMLUtil;
64
import org.openide.xml.XMLUtil;
64
import org.xml.sax.EntityResolver;
65
import org.xml.sax.EntityResolver;
65
import org.xml.sax.InputSource;
66
import org.xml.sax.InputSource;
Lines 658-664 Link Here
658
    public boolean isTopComponentPersistent (TopComponent tc) {
659
    public boolean isTopComponentPersistent (TopComponent tc) {
659
        int persistenceType = tc.getPersistenceType();
660
        int persistenceType = tc.getPersistenceType();
660
        if ((TopComponent.PERSISTENCE_NEVER == persistenceType)
661
        if ((TopComponent.PERSISTENCE_NEVER == persistenceType)
661
        || ((TopComponent.PERSISTENCE_ONLY_OPENED == persistenceType) && !tc.isOpened())) {
662
        || ((TopComponent.PERSISTENCE_ONLY_OPENED == persistenceType) && !tc.isOpened())
663
        || ((WindowManager.getDefault().isEditorTopComponent(tc)))
664
                ) {
662
            return false;
665
            return false;
663
        }
666
        }
664
        return true;
667
        return true;
(-)projects/projectui/src/org/netbeans/modules/project/ui/Hacks.java (+12 lines)
Lines 109-114 Link Here
109
        });
109
        });
110
    }
110
    }
111
    
111
    
112
    /** Registers callback to load projects after winsys initialization.
113
     */
114
    public static void hookProjectLoading() {
115
        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
116
117
            public void run() {
118
                OpenProjectList.getDefault().initialize();
119
            }
120
            
121
        });
122
    }
123
    
112
    
124
    
113
    /** Forces reload of panels in TemplateWizard. Public method updateState doesn't re-read
125
    /** Forces reload of panels in TemplateWizard. Public method updateState doesn't re-read
114
     * the new panels from new iterator.
126
     * the new panels from new iterator.
(-)projects/projectui/src/org/netbeans/modules/project/ui/OpenProjectList.java (-28 / +41 lines)
Lines 121-126 Link Here
121
    
121
    
122
    private PropertyChangeListener infoListener;
122
    private PropertyChangeListener infoListener;
123
    
123
    
124
    private boolean inited = false;
125
    
124
    OpenProjectList() {
126
    OpenProjectList() {
125
        openProjects = new ArrayList<Project>();
127
        openProjects = new ArrayList<Project>();
126
        openProjectsModuleInfos = new HashMap<ModuleInfo, List<Project>>();
128
        openProjectsModuleInfos = new HashMap<ModuleInfo, List<Project>>();
Lines 133-176 Link Here
133
        };
135
        };
134
        pchSupport = new PropertyChangeSupport( this );
136
        pchSupport = new PropertyChangeSupport( this );
135
        recentProjects = new RecentProjectList(10); // #47134
137
        recentProjects = new RecentProjectList(10); // #47134
138
        recentTemplates = new ArrayList<String>();
136
    }
139
    }
137
    
140
    
138
           
141
           
139
    // Implementation of the class ---------------------------------------------
142
    // Implementation of the class ---------------------------------------------
140
    
143
    
141
    public static OpenProjectList getDefault() {
144
    public static OpenProjectList getDefault() {
145
        synchronized ( OpenProjectList.class ) {
146
            if ( INSTANCE == null ) {
147
                INSTANCE = new OpenProjectList();
148
            }
149
        }
150
        return INSTANCE;
151
    }
152
    
153
    public void initialize() {
142
        boolean needNotify = false;
154
        boolean needNotify = false;
143
        
155
        
144
        Project[] inital = null;
156
        Project[] inital = null;
145
        synchronized ( OpenProjectList.class ) {
157
        synchronized ( OpenProjectList.class ) {
146
            if ( INSTANCE == null ) {
158
            needNotify = true;
147
                needNotify = true;
159
            List<Project> prjs = loadProjectList();
148
                INSTANCE = new OpenProjectList();
160
            open(prjs.toArray(new Project[prjs.size()]), false, false);
149
                INSTANCE.openProjects = loadProjectList();                
161
            inital = openProjects.toArray(new Project[0]);
150
                inital = INSTANCE.openProjects.toArray(new Project[0]);
162
            recentTemplates = new ArrayList<String>( OpenProjectListSettings.getInstance().getRecentTemplates() );
151
                INSTANCE.recentTemplates = new ArrayList<String>( OpenProjectListSettings.getInstance().getRecentTemplates() );
163
            URL mainProjectURL = OpenProjectListSettings.getInstance().getMainProjectURL();
152
                URL mainProjectURL = OpenProjectListSettings.getInstance().getMainProjectURL();
164
            // Load recent project list
153
                // Load recent project list
165
            recentProjects.load();
154
                INSTANCE.recentProjects.load();
166
            for(Project p: openProjects) {
155
                for( Iterator it = INSTANCE.openProjects.iterator(); it.hasNext(); ) {
167
                INSTANCE.addModuleInfo(p);
156
                    Project p = (Project)it.next();
168
                // Set main project
157
                    INSTANCE.addModuleInfo(p);
169
                try {
158
                    // Set main project
170
                    if ( mainProjectURL != null && 
159
                    try {
171
                         mainProjectURL.equals( p.getProjectDirectory().getURL() ) ) {
160
                        if ( mainProjectURL != null && 
172
                        INSTANCE.mainProject = p;
161
                             mainProjectURL.equals( p.getProjectDirectory().getURL() ) ) {
162
                            INSTANCE.mainProject = p;
163
                        }
164
                    }
165
                    catch( FileStateInvalidException e ) {
166
                        // Not a main project
167
                    }
173
                    }
168
                }          
174
                }
175
                catch( FileStateInvalidException e ) {
176
                    // Not a main project
177
                }
169
            }
178
            }
179
            inited = true;
170
        }
180
        }
171
        if ( needNotify ) {
181
        if ( needNotify ) {
172
            //#68738: a project may open other projects in its ProjectOpenedHook:
182
            //#68738: a project may open other projects in its ProjectOpenedHook:
173
            for(Project p: new ArrayList<Project>(INSTANCE.openProjects)) {
183
            for(Project p: new ArrayList<Project>(openProjects)) {
174
                notifyOpened(p);             
184
                notifyOpened(p);             
175
            }
185
            }
176
            
186
            
Lines 178-185 Link Here
178
        if (inital != null) {
188
        if (inital != null) {
179
            log(createRecord("UI_INIT_PROJECTS", inital));
189
            log(createRecord("UI_INIT_PROJECTS", inital));
180
        }
190
        }
181
        
182
        return INSTANCE;
183
    }
191
    }
184
    
192
    
185
    public void open( Project p ) {
193
    public void open( Project p ) {
Lines 200-205 Link Here
200
            return ;
208
            return ;
201
        }
209
        }
202
        
210
        
211
        Thread.dumpStack();
203
        long start = System.currentTimeMillis();
212
        long start = System.currentTimeMillis();
204
        
213
        
205
	if (asynchronously) {
214
	if (asynchronously) {
Lines 375-380 Link Here
375
    }
384
    }
376
       
385
       
377
    public void close( Project projects[], boolean notifyUI ) {
386
    public void close( Project projects[], boolean notifyUI ) {
387
        Thread.dumpStack();
378
        if (!ProjectUtilities.closeAllDocuments (projects, notifyUI )) {
388
        if (!ProjectUtilities.closeAllDocuments (projects, notifyUI )) {
379
            return;
389
            return;
380
        }
390
        }
Lines 554-562 Link Here
554
    // Used from ProjectUiModule
564
    // Used from ProjectUiModule
555
    static void shutdown() {
565
    static void shutdown() {
556
        if (INSTANCE != null) {
566
        if (INSTANCE != null) {
557
            Iterator it = INSTANCE.openProjects.iterator();
567
            if (!ProjectUtilities.closeAllDocuments (
558
            while (it.hasNext()) {
568
                    INSTANCE.openProjects.toArray(new Project[INSTANCE.openProjects.size()]), false )) { // TODO need another mode to save everything
559
                Project p = (Project)it.next();
569
                ERR.log(ErrorManager.WARNING, "Not all project files saved");
570
            }
571
            
572
            for (Project p: INSTANCE.openProjects) {
560
                notifyClosed(p);
573
                notifyClosed(p);
561
            }
574
            }
562
        }
575
        }
(-)projects/projectui/src/org/netbeans/modules/project/ui/ProjectUiModule.java (+1 lines)
Lines 32-37 Link Here
32
32
33
    public void restored() {
33
    public void restored() {
34
        Hacks.keepCurrentProjectNameUpdated();
34
        Hacks.keepCurrentProjectNameUpdated();
35
        Hacks.hookProjectLoading();
35
    }
36
    }
36
37
37
    public void close() {
38
    public void close() {
(-)projects/projectui/src/org/netbeans/modules/project/ui/ProjectUtilities.java (-1 / +4 lines)
Lines 117-128 Link Here
117
        }
117
        }
118
118
119
        private void doClose(Project[] projects, boolean notifyUI, Wrapper wr) {
119
        private void doClose(Project[] projects, boolean notifyUI, Wrapper wr) {
120
            ERR.log(Level.FINE, "doClose: {0} ", Arrays.toString(projects));
120
            List<Project> listOfProjects = Arrays.asList(projects);
121
            List<Project> listOfProjects = Arrays.asList(projects);
121
            Set<DataObject> openFiles = new HashSet<DataObject>();
122
            Set<DataObject> openFiles = new HashSet<DataObject>();
122
            final Set<TopComponent> tc2close = new HashSet<TopComponent>();
123
            final Set<TopComponent> tc2close = new HashSet<TopComponent>();
123
            WindowManager wm = WindowManager.getDefault();
124
            WindowManager wm = WindowManager.getDefault();
124
            for (TopComponent tc : wm.getRegistry().getOpened()) {
125
            for (TopComponent tc : wm.getRegistry().getOpened()) {
125
                //#84546 - this condituon should allow us to close just editor related TCs that are in any imaginable mode.
126
                ERR.log(Level.FINE, "doClose: checking if {0} should be stored", tc);
127
                //#84546 - this condition should allow us to close just editor related TCs that are in any imaginable mode.
126
                if (!wm.isOpenedEditorTopComponent(tc)) {
128
                if (!wm.isOpenedEditorTopComponent(tc)) {
127
                    continue;
129
                    continue;
128
                }
130
                }
Lines 133-138 Link Here
133
                    Project owner = FileOwnerQuery.getOwner(fobj);
135
                    Project owner = FileOwnerQuery.getOwner(fobj);
134
136
135
                    if (listOfProjects.contains(owner)) {
137
                    if (listOfProjects.contains(owner)) {
138
                        ERR.log(Level.FINE, "doClose: storing {0}", tc);
136
                        if (notifyUI) {
139
                        if (notifyUI) {
137
                            openFiles.add(dobj);
140
                            openFiles.add(dobj);
138
                            tc2close.add(tc);
141
                            tc2close.add(tc);

Return to bug 108120