svn commit: r18817 - trunk/src/argouml-app/src/org/argouml: application cognitive/ui ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2010-10-27 08:52:25-0700
New Revision: 18817

Modified:
   trunk/src/argouml-app/src/org/argouml/application/Main.java
   trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java
   trunk/src/argouml-app/src/org/argouml/ui/NavigatorPane.java
   trunk/src/argouml-app/src/org/argouml/ui/SplashScreen.java
   trunk/src/argouml-app/src/org/argouml/ui/StatusBar.java

Log:
Refactor startup to allow anything with a ProgressMonitor interface instead of just the hardwired splash screen

Modified: trunk/src/argouml-app/src/org/argouml/application/Main.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/application/Main.java?view=diff&pathrev=18817&r1=18816&r2=18817
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/application/Main.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/application/Main.java	2010-10-27 08:52:25-0700
@@ -75,6 +75,7 @@
 import org.argouml.cognitive.ui.ToDoPane;
 import org.argouml.configuration.Configuration;
 import org.argouml.i18n.Translator;
+import org.argouml.kernel.Project;
 import org.argouml.kernel.ProjectManager;
 import org.argouml.model.Model;
 import org.argouml.moduleloader.InitModuleLoader;
@@ -215,7 +216,7 @@
 
             st.mark("perspectives");
             if (splash != null) {
-                splash.getStatusBar().showProgress(75);
+                splash.updateProgress(75);
             }
 
             st.mark("open window");
@@ -479,18 +480,18 @@
     private static void openProject(SimpleTimer st, SplashScreen splash,
             ProjectBrowser pb, URL urlToOpen) {
         if (splash != null) {
-            splash.getStatusBar().showProgress(40);
+            splash.updateProgress(40);
         }
         
         st.mark("open project");
         Designer.disableCritiquing();
         Designer.clearCritiquing();
 
-        boolean projectLoaded = false;
+        Project project = null;
         if (urlToOpen != null) {
             if (splash != null) {
                 Object[] msgArgs = {projectName};
-                splash.getStatusBar().showStatus(
+                splash.showStatus(
                         Translator.messageFormat(
                                 "statusmsg.bar.readingproject",
                                 msgArgs));
@@ -502,21 +503,20 @@
             System.err.println("The filename is " + filename);
             System.err.println("The file is " + file);
             System.err.println("File.exists = " + file.exists());
-            projectLoaded = pb.loadProject(file, true, null);
+            project =  pb.loadProject2(file, true, null);
         } else {
             if (splash != null) {
-                splash.getStatusBar().showStatus(
+                splash.showStatus(
                         Translator.localize(
                                 "statusmsg.bar.defaultproject"));
             }
         }
 
-        if (!projectLoaded) {
+        if (project != null) {
             // Although this looks redundant, it's needed to get all
             // the initialization state set correctly.  
             // Too many side effects as part of initialization!
-            ProjectManager.getManager().setCurrentProject(
-                    ProjectManager.getManager().getCurrentProject());
+            ProjectManager.getManager().setCurrentProject(project);
             ProjectManager.getManager().setSaveEnabled(false);
         }
 
@@ -554,8 +554,8 @@
     private static void updateProgress(SplashScreen splash, int percent,
             String message) {
         if (splash != null) {
-            splash.getStatusBar().showStatus(Translator.localize(message));
-            splash.getStatusBar().showProgress(percent);
+            splash.showStatus(Translator.localize(message));
+            splash.updateProgress(percent);
         }
     }
 
@@ -864,7 +864,7 @@
      */
     private static ProjectBrowser initializeGUI(SplashScreen splash) {
         // make the projectbrowser
-        JPanel todoPane = new ToDoPane(splash);
+        JPanel todoPane = new ToDoPane();
 	ProjectBrowser pb = ProjectBrowser.makeInstance(splash, true, todoPane);
 
 	JOptionPane.setRootFrame(pb);

Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java?view=diff&pathrev=18817&r1=18816&r2=18817
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ui/ToDoPane.java	2010-10-27 08:52:25-0700
@@ -128,15 +128,21 @@
     private JLabel countLabel;
     private Object lastSel;
 
-
     /**
      * Construct the ToDoPane.
-     *
-     * @param splash if not null, then we have to show progress in the splash
+     * @param splash Unused parameter for backwards compatibility.
+     * 
+     * @deprecated for 0.31.7 by tfmorris.  Use 0-arg constructor.
+     */
+    @Deprecated
+    public ToDoPane(@SuppressWarnings("unused") SplashScreen splash) {
+        this();
+    }
+    
+    /**
+     * Construct the ToDoPane.
      */
-    // TODO: This should take a ProgressMonitor or something more generic
-    // (or nothing at all since it doesn't do that much work)
-    public ToDoPane(SplashScreen splash) {
+    public ToDoPane() {
 
         setLayout(new BorderLayout());
 
@@ -165,12 +171,6 @@
         setRoot(Designer.theDesigner().getToDoList());
         Designer.theDesigner().getToDoList().addToDoListListener(this);
 
-        if (splash != null) {
-            splash.getStatusBar().showStatus(
-	            Translator.localize("statusmsg.bar.making-todopane"));
-            splash.getStatusBar().showProgress(25);
-        }
-
         setPerspectives(buildPerspectives());
 
         setMinimumSize(new Dimension(120, 100));

Modified: trunk/src/argouml-app/src/org/argouml/ui/NavigatorPane.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/NavigatorPane.java?view=diff&pathrev=18817&r1=18816&r2=18817
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/NavigatorPane.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/NavigatorPane.java	2010-10-27 08:52:25-0700
@@ -49,6 +49,7 @@
 import javax.swing.JToolBar;
 
 import org.argouml.i18n.Translator;
+import org.argouml.taskmgmt.ProgressMonitor;
 import org.argouml.ui.explorer.ActionPerspectiveConfig;
 import org.argouml.ui.explorer.DnDExplorerTree;
 import org.argouml.ui.explorer.ExplorerTree;
@@ -79,8 +80,40 @@
      * and a configuration dialog to tailor the perspectives.
      *
      * @param splash The splash screen where to show progress.
+     * @deprecated for 0.31.7 by tfmorris.  
+     * Use {@link NavigatorPane#NavigatorPane(ProgressMonitor)}.
      */
+    @Deprecated
     public NavigatorPane(SplashScreen splash) {
+        this(splash, null);
+    }
+
+    /**
+     * Construct a new navigator panel.<p>
+     *
+     * This panel consists of a Combobox to select a navigation
+     * perspective, a combobox to select ordering,
+     * a JTree to display the UML model,
+     * and a configuration dialog to tailor the perspectives.
+     *
+     * @param pm ProgressMonitor to receive progress updates.  May be null.
+     */
+    @Deprecated
+    public NavigatorPane(ProgressMonitor pm) {
+        this(null, pm);
+    }
+    
+    /**
+     * Constructs a new navigator panel.<p>
+     *
+     * This panel consists of a Combobox to select a navigation
+     * perspective, a combobox to select ordering,
+     * a JTree to display the UML model,
+     * and a configuration dialog to tailor the perspectives.
+     *
+     * @param splash The splash screen where to show progress.
+     */
+    private NavigatorPane(SplashScreen splash, ProgressMonitor pm) {
 
         JComboBox perspectiveCombo = new PerspectiveComboBox();
         JComboBox orderByCombo = new JComboBox();
@@ -113,6 +146,10 @@
             splash.getStatusBar().showStatus(Translator.localize(
 		    "statusmsg.bar.making-navigator-pane-perspectives"));
             splash.getStatusBar().showProgress(25);
+        } else if (pm != null) {
+            pm.updateSubTask(Translator.localize(
+                    "statusmsg.bar.making-navigator-pane-perspectives"));
+            pm.updateProgress(25);
         }
 
         perspectiveCombo.addItemListener((ExplorerTreeModel) tree.getModel());

Modified: trunk/src/argouml-app/src/org/argouml/ui/SplashScreen.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/SplashScreen.java?view=diff&pathrev=18817&r1=18816&r2=18817
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/SplashScreen.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/SplashScreen.java	2010-10-27 08:52:25-0700
@@ -49,12 +49,14 @@
 import javax.swing.JWindow;
 import javax.swing.border.EtchedBorder;
 
+import org.argouml.taskmgmt.ProgressEvent;
+import org.argouml.taskmgmt.ProgressMonitor;
 import org.tigris.gef.ui.IStatusBar;
 
 /**
  * The splash screen.
  */
-public class SplashScreen extends JWindow implements IStatusBar {
+public class SplashScreen extends JWindow implements IStatusBar, ProgressMonitor {
 
     private StatusBar statusBar = new StatusBar();
     
@@ -67,7 +69,7 @@
      * The constructor.
      */
     public SplashScreen() {
-        this("Loading ArgoUML...", "Splash");
+        this("Splash");
     }
 
     /**
@@ -76,7 +78,7 @@
      * @param title the title of the window
      * @param iconName the icon for the window
      */
-    private SplashScreen(String title, String iconName) {
+    private SplashScreen(String iconName) {
 	super();
 
 	setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
@@ -105,7 +107,11 @@
 
     /**
      * @return the status bar of this dialog
+     * @deprecated for 0.31.7 by tfmorris. Use methods from the
+     *             {@link IStatusBar} interface implemented by this class 
+     *             e.g. {@link #showStatus(String)}/
      */
+    @Deprecated
     public StatusBar getStatusBar() {
         return statusBar;
     }
@@ -148,4 +154,41 @@
         return paintCalled;
     }
 
+    public void progress(ProgressEvent event) throws InterruptedException {
+        statusBar.progress(event);        
+    }
+
+    public void updateProgress(int progress) {
+        statusBar.updateProgress(progress);
+    }
+
+    public void updateSubTask(String name) {
+        statusBar.updateSubTask(name);
+    }
+
+    public void updateMainTask(String name) {
+        statusBar.updateMainTask(name);
+    }
+
+    public boolean isCanceled() {
+        return false;
+    }
+
+    public void setMaximumProgress(int max) {
+        statusBar.setMaximumProgress(max);
+    }
+
+    public void notifyNullAction() {
+        // ignored - will never be called
+    }
+
+    public void notifyMessage(String title, String introduction, String message) {
+        // TODO: Auto-generated method stub
+        
+    }
+
+    public void close() {
+        // TODO: Auto-generated method stub        
+    }
+
 }

Modified: trunk/src/argouml-app/src/org/argouml/ui/StatusBar.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/StatusBar.java?view=diff&pathrev=18817&r1=18816&r2=18817
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/StatusBar.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/StatusBar.java	2010-10-27 08:52:25-0700
@@ -47,13 +47,17 @@
 import javax.swing.JProgressBar;
 import javax.swing.border.EtchedBorder;
 
+import org.argouml.taskmgmt.ProgressEvent;
+import org.argouml.taskmgmt.ProgressMonitor;
 import org.tigris.gef.ui.IStatusBar;
 
 /**
  * The status bar.
  *
  */
-public class StatusBar extends JPanel implements Runnable, IStatusBar {
+public class StatusBar 
+extends JPanel 
+implements Runnable, IStatusBar, ProgressMonitor {
 
     private JLabel msg = new JLabel();
     private JProgressBar progress = new JProgressBar();
@@ -136,4 +140,39 @@
 	repaint();
     }
 
+    public void progress(ProgressEvent event) throws InterruptedException {
+        // TODO: Auto-generated method stub
+    }
+
+    public void updateProgress(int value) {
+        progress.setValue(value);
+    }
+
+    public void updateSubTask(String name) {
+        msg.setText(name);
+    }
+
+    public void updateMainTask(String name) {
+        msg.setText(name);
+    }
+
+    public boolean isCanceled() {
+        return false;
+    }
+
+    public void setMaximumProgress(int max) {
+        progress.setMaximum(max);        
+    }
+
+    public void notifyNullAction() {}
+
+    public void notifyMessage(String title, String introduction, String message) {
+        // TODO: Auto-generated method stub
+        
+    }
+
+    public void close() {
+        setVisible(false);        
+    }
+
 }

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2676193

To unsubscribe from this discussion, e-mail: [[email protected]].
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.