Revision 41217
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ProjectExtension.java | ||
---|---|---|
129 | 129 |
IconThemeHelper.registerIcon("project", "project-icon", this); |
130 | 130 |
} |
131 | 131 |
|
132 |
private void loadInitialProject() { |
|
133 |
String[] theArgs = PluginServices.getArguments(); |
|
134 |
String lastArg = theArgs[theArgs.length - 1]; |
|
135 |
if (lastArg != null) { |
|
136 |
if (lastArg.toLowerCase().endsWith( |
|
137 |
Project.FILE_EXTENSION.toLowerCase())) { |
|
138 |
LOG.info("Loading project '" + lastArg + "'."); |
|
139 |
try { |
|
140 |
File projectFile = new File(lastArg); |
|
141 |
setProject(readProject(projectFile)); |
|
142 |
PluginServices.getMainFrame().setTitle( |
|
143 |
projectFile.getName()); |
|
144 |
projectPath = projectFile.getAbsolutePath(); |
|
145 |
return; |
|
146 |
} catch (Exception ex) { |
|
147 |
LOG.warn("Can't load project from file '" + lastArg + "'.", |
|
148 |
ex); |
|
149 |
ApplicationManager application = ApplicationLocator |
|
150 |
.getManager(); |
|
151 |
application.messageDialog("_Can_not_open_the_project", |
|
152 |
"_Open_project", JOptionPane.WARNING_MESSAGE); |
|
153 |
} |
|
154 |
} |
|
155 |
} |
|
156 |
setProject(ProjectManager.getInstance().createProject()); |
|
157 |
p.setName(PluginServices.getText(this, "untitled")); |
|
158 |
p.setModified(false); |
|
159 |
PluginServices.getMainFrame().setTitle( |
|
160 |
PluginServices.getText(this, "sin_titulo")); |
|
161 |
setProject(p); |
|
162 |
showProjectWindow(); |
|
163 |
} |
|
164 | 132 |
|
165 |
/** |
|
166 |
* @see com.iver.mdiApp.plugins.IExtension#postInitialize() |
|
167 |
*/ |
|
168 |
public void postInitialize() { |
|
169 |
try { |
|
170 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
171 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
172 |
public void run() { |
|
173 |
loadInitialProject(); |
|
174 |
} |
|
175 |
}); |
|
176 |
} else { |
|
177 |
loadInitialProject(); |
|
178 |
} |
|
179 |
} catch (Exception e) { |
|
180 |
LOG.warn("Can't load initial project.",e); |
|
181 |
} |
|
182 |
} |
|
183 | 133 |
|
134 |
|
|
135 |
|
|
184 | 136 |
public ProjectWindow getProjectFrame() { |
185 | 137 |
if (projectFrame == null) { |
186 | 138 |
projectFrame = new ProjectWindow(); |
... | ... | |
359 | 311 |
return; |
360 | 312 |
} |
361 | 313 |
// ProjectDocument.initializeNUMS(); |
362 |
PluginServices.getMDIManager().closeAllWindows(); |
|
314 |
|
|
363 | 315 |
|
364 | 316 |
projectFile = jfc.getSelectedFile(); |
365 | 317 |
} |
318 |
|
|
319 |
PluginServices.getMDIManager().closeAllWindows(); |
|
366 | 320 |
|
367 | 321 |
Project o = readProject(projectFile); |
368 | 322 |
setPath(projectFile.getAbsolutePath()); |
... | ... | |
393 | 347 |
|
394 | 348 |
} |
395 | 349 |
|
350 |
|
|
351 |
private void createEmptyProject() { |
|
352 |
setProject(ProjectManager.getInstance().createProject()); |
|
353 |
p.setName(PluginServices.getText(this, "untitled")); |
|
354 |
p.setModified(false); |
|
355 |
PluginServices.getMainFrame().setTitle( |
|
356 |
PluginServices.getText(this, "sin_titulo")); |
|
357 |
setProject(p); |
|
358 |
showProjectWindow(); |
|
359 |
} |
|
360 |
|
|
361 |
/** |
|
362 |
* @see com.iver.mdiApp.plugins.IExtension#postInitialize() |
|
363 |
*/ |
|
364 |
public void postInitialize() { |
|
365 |
try { |
|
366 |
if( !SwingUtilities.isEventDispatchThread() ) { |
|
367 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
368 |
public void run() { |
|
369 |
createEmptyProject(); |
|
370 |
} |
|
371 |
}); |
|
372 |
} else { |
|
373 |
createEmptyProject(); |
|
374 |
} |
|
375 |
} catch (Exception e) { |
|
376 |
LOG.warn("Can't load initial project.",e); |
|
377 |
} |
|
378 |
} |
|
379 |
|
|
380 |
|
|
396 | 381 |
/** |
397 | 382 |
* Escribe el proyecto en XML. |
398 | 383 |
* |
Also available in: Unified diff