Lines 74-79
Link Here
|
74 |
import org.openide.loaders.DataObject; |
74 |
import org.openide.loaders.DataObject; |
75 |
import org.openide.loaders.DataObjectNotFoundException; |
75 |
import org.openide.loaders.DataObjectNotFoundException; |
76 |
import org.openide.modules.ModuleInfo; |
76 |
import org.openide.modules.ModuleInfo; |
|
|
77 |
import org.openide.util.Exceptions; |
77 |
import org.openide.util.Lookup; |
78 |
import org.openide.util.Lookup; |
78 |
import org.openide.util.Mutex; |
79 |
import org.openide.util.Mutex; |
79 |
import org.openide.util.Mutex.Action; |
80 |
import org.openide.util.Mutex.Action; |
Lines 142-188
Link Here
|
142 |
|
143 |
|
143 |
// Implementation of the class --------------------------------------------- |
144 |
// Implementation of the class --------------------------------------------- |
144 |
|
145 |
|
145 |
public static OpenProjectList getDefault() { |
146 |
void deferredLoad() { |
146 |
boolean needNotify = false; |
147 |
RequestProcessor.getDefault().post(new Runnable() { |
|
|
148 |
public void run() { |
149 |
doDeferredLoad(); |
150 |
} |
151 |
}); |
152 |
} |
147 |
|
153 |
|
|
|
154 |
private void doDeferredLoad() { |
155 |
ProgressHandle handle = ProgressHandleFactory.createSystemHandle( |
156 |
NbBundle.getMessage(OpenProjectList.class, "LOAD_PROGRESS")); |
157 |
handle.start(); |
158 |
handle.switchToIndeterminate(); |
159 |
try { |
160 |
openProjects = loadProjectList(); |
148 |
Project[] inital = null; |
161 |
Project[] inital = null; |
149 |
synchronized ( OpenProjectList.class ) { |
|
|
150 |
if ( INSTANCE == null ) { |
151 |
needNotify = true; |
152 |
INSTANCE = new OpenProjectList(); |
153 |
INSTANCE.openProjects = loadProjectList(); |
154 |
inital = INSTANCE.openProjects.toArray(new Project[0]); |
162 |
inital = INSTANCE.openProjects.toArray(new Project[0]); |
155 |
INSTANCE.recentTemplates = new ArrayList<String>( OpenProjectListSettings.getInstance().getRecentTemplates() ); |
163 |
recentTemplates = new ArrayList<String>( OpenProjectListSettings.getInstance().getRecentTemplates() ); |
156 |
URL mainProjectURL = OpenProjectListSettings.getInstance().getMainProjectURL(); |
164 |
URL mainProjectURL = OpenProjectListSettings.getInstance().getMainProjectURL(); |
157 |
// Load recent project list |
165 |
// Load recent project list |
158 |
INSTANCE.recentProjects.load(); |
166 |
recentProjects.load(); |
159 |
for( Iterator it = INSTANCE.openProjects.iterator(); it.hasNext(); ) { |
167 |
for( Iterator it = INSTANCE.openProjects.iterator(); it.hasNext(); ) { |
160 |
Project p = (Project)it.next(); |
168 |
Project p = (Project)it.next(); |
161 |
INSTANCE.addModuleInfo(p); |
169 |
addModuleInfo(p); |
162 |
// Set main project |
170 |
// Set main project |
163 |
try { |
171 |
try { |
164 |
if ( mainProjectURL != null && |
172 |
if ( mainProjectURL != null && |
165 |
mainProjectURL.equals( p.getProjectDirectory().getURL() ) ) { |
173 |
mainProjectURL.equals( p.getProjectDirectory().getURL() ) ) { |
166 |
INSTANCE.mainProject = p; |
174 |
mainProject = p; |
167 |
} |
175 |
} |
168 |
} |
176 |
} |
169 |
catch( FileStateInvalidException e ) { |
177 |
catch( FileStateInvalidException e ) { |
170 |
// Not a main project |
178 |
// Not a main project |
171 |
} |
179 |
} |
172 |
} |
180 |
} |
|
|
181 |
if (inital != null) { |
182 |
log(createRecord("UI_INIT_PROJECTS", inital)); |
173 |
} |
183 |
} |
174 |
} |
184 |
Project[] oldprjs = new Project[0]; |
175 |
if ( needNotify ) { |
185 |
Project[] newprjs = openProjects.toArray(new Project[openProjects.size()]); |
|
|
186 |
pchSupport.firePropertyChange( PROPERTY_OPEN_PROJECTS, oldprjs, newprjs); |
176 |
//#68738: a project may open other projects in its ProjectOpenedHook: |
187 |
//#68738: a project may open other projects in its ProjectOpenedHook: |
177 |
for(Project p: new ArrayList<Project>(INSTANCE.openProjects)) { |
188 |
for(Project p: new ArrayList<Project>(openProjects)) { |
178 |
notifyOpened(p); |
189 |
notifyOpened(p); |
179 |
} |
190 |
} |
180 |
|
191 |
} finally { |
|
|
192 |
handle.finish(); |
181 |
} |
193 |
} |
182 |
if (inital != null) { |
|
|
183 |
log(createRecord("UI_INIT_PROJECTS", inital)); |
184 |
} |
194 |
} |
185 |
|
195 |
|
|
|
196 |
public static OpenProjectList getDefault() { |
197 |
synchronized ( OpenProjectList.class ) { |
198 |
if ( INSTANCE == null ) { |
199 |
INSTANCE = new OpenProjectList(); |
200 |
INSTANCE.openProjects = new ArrayList <Project>( |
201 |
Arrays.asList (new Project[] { |
202 |
new PleaseWaitProject() })); |
203 |
} |
204 |
} |
186 |
return INSTANCE; |
205 |
return INSTANCE; |
187 |
} |
206 |
} |
188 |
|
207 |
|