svn commit: r14892 - branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml: persistence ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: hudsonb
Date: 2008-06-09 08:34:33-0700
New Revision: 14892

Modified:
   branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/persistence/PersistenceManager.java
   branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/ui/ProjectBrowser.java

Log:
Moved confirmOverwrite from PersistenceManager to ProjectBrowser.



This is a step towards removing any Swing UI dependencies from the PersistenceManager, leaving the UI to the users of the PersistenceManager (on the Swing side ProjectBrowser, and on the SWT side the DiagramEditor).



A dependency on JFileChooser and FileFilter still remain.

Modified: branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/persistence/PersistenceManager.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/persistence/PersistenceManager.java?view=diff&rev=14892&p1=branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/persistence/PersistenceManager.java&p2=branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/persistence/PersistenceManager.java&r1=14891&r2=14892
==============================================================================
--- branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/persistence/PersistenceManager.java	(original)
+++ branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/persistence/PersistenceManager.java	2008-06-09 08:34:33-0700
@@ -24,7 +24,6 @@
 
 package org.argouml.persistence;
 
-import java.awt.Component;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.OutputStream;
@@ -37,7 +36,6 @@
 import java.util.List;
 
 import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
 import javax.swing.filechooser.FileFilter;
 
 import org.argouml.configuration.Configuration;
@@ -362,36 +360,6 @@
     }
 
     /**
-     * Returns true if we are allowed to overwrite the given file.
-     *
-     * @param overwrite if true, then the user is not asked
-     * @param file the given file
-     * @return true if we are allowed to overwrite the given file
-     * @param frame the Component to display the confirmation dialog on
-     */
-    public boolean confirmOverwrite(Component frame, 
-            boolean overwrite, File file) {
-        if (file.exists() && !overwrite) {
-            String sConfirm =
-                Translator.messageFormat(
-                    "optionpane.confirm-overwrite",
-                    new Object[] {file});
-            int nResult =
-                JOptionPane.showConfirmDialog(
-                        frame,
-                        sConfirm,
-                        Translator.localize(
-                            "optionpane.confirm-overwrite-title"),
-                        JOptionPane.YES_NO_OPTION,
-                        JOptionPane.QUESTION_MESSAGE);
-            if (nResult != JOptionPane.YES_OPTION) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
      * Get the last message which caused loading to fail. Used for junit tests.
      *
      * @return the last message which caused loading to fail

Modified: branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/ui/ProjectBrowser.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/ui/ProjectBrowser.java?view=diff&rev=14892&p1=branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/ui/ProjectBrowser.java&p2=branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/ui/ProjectBrowser.java&r1=14891&r2=14892
==============================================================================
--- branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/ui/ProjectBrowser.java	(original)
+++ branches/gsoc2008/work_argoeclipse1_hudsonb/argouml-app/src/org/argouml/ui/ProjectBrowser.java	2008-06-09 08:34:33-0700
@@ -1343,7 +1343,7 @@
         ProjectFilePersister persister = null;
 
         try {
-            if (!PersistenceManager.getInstance().confirmOverwrite(
+            if (!confirmOverwrite(
                     ArgoFrame.getInstance(), overwrite, file)) {
                 return false;
             }
@@ -1929,6 +1929,36 @@
     }
     
     /**
+     * Returns true if we are allowed to overwrite the given file.
+     *
+     * @param overwrite if true, then the user is not asked
+     * @param file the given file
+     * @return true if we are allowed to overwrite the given file
+     * @param frame the Component to display the confirmation dialog on
+     */
+    public boolean confirmOverwrite(Component frame, 
+            boolean overwrite, File file) {
+        if (file.exists() && !overwrite) {
+            String sConfirm =
+                Translator.messageFormat(
+                    "optionpane.confirm-overwrite",
+                    new Object[] {file});
+            int nResult =
+                JOptionPane.showConfirmDialog(
+                        frame,
+                        sConfirm,
+                        Translator.localize(
+                            "optionpane.confirm-overwrite-title"),
+                        JOptionPane.YES_NO_OPTION,
+                        JOptionPane.QUESTION_MESSAGE);
+            if (nResult != JOptionPane.YES_OPTION) {
+                return false;
+            }
+        }
+        return true;
+    }
+    
+    /**
      * The UID.
      */
     private static final long serialVersionUID = 6974246679451284917L;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.