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 |
} |