svn commit: r17376 - trunk/src/argouml-app/src/org/argouml/ui
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-10-07 08:12:17-0700
New Revision: 17376
Modified:
trunk/src/argouml-app/src/org/argouml/ui/ActionExportXMI.java
trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java
trunk/src/argouml-app/src/org/argouml/ui/SaveSwingWorker.java
Log:
Pass an exit flag into SaveSwingWorker
Modified: trunk/src/argouml-app/src/org/argouml/ui/ActionExportXMI.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ActionExportXMI.java?view=diff&pathrev=17376&r1=17375&r2=17376
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ActionExportXMI.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ActionExportXMI.java 2009-10-07 08:12:17-0700
@@ -85,7 +85,7 @@
name = pm.fixXmiExtension(name);
theFile = new File(theFile.getParent(), name);
ProjectBrowser.getInstance().trySaveWithProgressMonitor(
- false, theFile);
+ false, theFile, false);
}
}
}
Modified: trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java?view=diff&pathrev=17376&r1=17375&r2=17376
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java 2009-10-07 08:12:17-0700
@@ -976,14 +976,18 @@
return;
}
if (response == JOptionPane.YES_OPTION) {
+ // The trySave method results in the save taking place in another thread.
+ // If that completes without error the ProjectBrowser.exit() method will
+ // be called which will actually exist the system.
trySave(ProjectManager.getManager().getCurrentProject() != null
&& ProjectManager.getManager().getCurrentProject()
- .getURI() != null);
- if (saveAction.isEnabled()) {
- return;
- }
+ .getURI() != null,
+ false, true);
}
}
+ }
+
+ public void exit() {
saveScreenConfiguration();
Configuration.save();
System.exit(0);
@@ -1139,6 +1143,21 @@
* the current project already had one
*/
public void trySave(boolean overwrite, boolean saveNewFile) {
+ trySave(overwrite, saveNewFile, false);
+ }
+
+ /**
+ * Try to save the project.
+ * @param overwrite if true, then we overwrite without asking
+ * @param saveNewFile if true, we'll ask for a new file even if
+ * the current project already had one
+ * @param exitAfterSave The application will exit when the save has
+ * completed successfully
+ */
+ public void trySave(
+ final boolean overwrite,
+ boolean saveNewFile,
+ final boolean exitAfterSave) {
URI uri = ProjectManager.getManager().getCurrentProject().getURI();
File file = null;
@@ -1185,7 +1204,7 @@
}
// let's call the real save method
- trySaveWithProgressMonitor(overwrite, file);
+ trySaveWithProgressMonitor(overwrite, file, exitAfterSave);
}
/**
@@ -1212,7 +1231,10 @@
*
* TODO: Separate this into a Swing specific class - tfm
*/
- public void trySaveWithProgressMonitor(boolean overwrite, File file) {
+ public void trySaveWithProgressMonitor(
+ final boolean overwrite,
+ final File file,
+ final boolean exit) {
if (!PersistenceManager.getInstance().confirmOverwrite(
ArgoFrame.getFrame(), overwrite, file)) {
return;
@@ -1229,8 +1251,9 @@
SaveSwingWorker worker = new SaveSwingWorker(
ProjectManager.getManager().getCurrentProject(),
- file);
- Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
+ file,
+ exit);
+ LOG.info("Starting save thread");
worker.start();
}
Modified: trunk/src/argouml-app/src/org/argouml/ui/SaveSwingWorker.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SaveSwingWorker.java?view=diff&pathrev=17376&r1=17375&r2=17376
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SaveSwingWorker.java (original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SaveSwingWorker.java 2009-10-07 08:12:17-0700
@@ -48,6 +48,7 @@
private final File file;
private boolean result;
private Project project;
+ private boolean exitAfterSave;
/**
* Deprecated constructor for SaveSwingWorker.
@@ -70,11 +71,13 @@
*/
public SaveSwingWorker(
final Project project,
- final File aFile) {
+ final File aFile,
+ final boolean exit) {
super("ArgoSaveProjectThread");
overwrite = true;
file = aFile;
this.project = project;
+ exitAfterSave = exit;
}
/**
@@ -119,9 +122,13 @@
public void finished() {
super.finished();
if (result) {
- ProjectBrowser.getInstance().buildTitleWithCurrentProjectName();
- // TODO: Why isn't this done in save?
- UndoManager.getInstance().empty();
+ if (exitAfterSave) {
+ ProjectBrowser.getInstance().exit();
+ } else {
+ ProjectBrowser.getInstance().buildTitleWithCurrentProjectName();
+ // TODO: Why isn't this done in save?
+ UndoManager.getInstance().empty();
+ }
}
}
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2404551
To unsubscribe from this discussion, e-mail: [[email protected]].