Author: tfmorris
Date: 2008-04-26 17:27:29-0700
New Revision: 14483

Modified:
   trunk/src/argouml-app/src/org/argouml/cognitive/ui/TabToDo.java
   trunk/src/argouml-app/src/org/argouml/cognitive/ui/WizStep.java
   trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddNote.java
   
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ModeCreateAssociationClass.java
   trunk/src/argouml-app/tests/org/argouml/ui/GUITestProjectBrowser.java

Log:
Refactor to keyboard focus listener into separate method.

Deprecate methods which couple ProjectBrowser to things unnecessarily and add 
TODOs to the few users

Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ui/TabToDo.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ui/TabToDo.java?view=diff&rev=14483&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ui/TabToDo.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ui/TabToDo.java&r1=14482&r2=14483
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ui/TabToDo.java     
(original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ui/TabToDo.java     
2008-04-26 17:27:29-0700
@@ -131,6 +131,9 @@
      * @param ws the panel to be shown
      */
     public void showStep(JPanel ws) {
+        // TODO: This should listen for new target events 
+        // fired by WizStep.updateTabToDo so that we
+        // can decouple it from the ProjectBrowser.
         if (lastPanel != null) {
             splitPane.remove(lastPanel);
        }

Modified: trunk/src/argouml-app/src/org/argouml/cognitive/ui/WizStep.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/cognitive/ui/WizStep.java?view=diff&rev=14483&p1=trunk/src/argouml-app/src/org/argouml/cognitive/ui/WizStep.java&p2=trunk/src/argouml-app/src/org/argouml/cognitive/ui/WizStep.java&r1=14482&r2=14483
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/cognitive/ui/WizStep.java     
(original)
+++ trunk/src/argouml-app/src/org/argouml/cognitive/ui/WizStep.java     
2008-04-26 17:27:29-0700
@@ -254,6 +254,8 @@
     protected void updateTabToDo() {
        TabToDo ttd =
            (TabToDo) ProjectBrowser.getInstance().getTab(TabToDo.class);
+       // TODO: TabToDo should listen for an event that this fires so that we
+       // can decouple from the ProjectBrowser.
        JPanel ws = getWizard().getCurrentPanel();
        if (ws instanceof WizStep) {
            ((WizStep) ws).setTarget(target);

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&rev=14483&p1=trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java&p2=trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java&r1=14482&r2=14483
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java        
(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/ProjectBrowser.java        
2008-04-26 17:27:29-0700
@@ -166,16 +166,11 @@
     private static boolean isMainApplication;
 
 
-    ////////////////////////////////////////////////////////////////
-    // class variables
-
     /**
      * Member attribute to contain the singleton.
      */
     private static ProjectBrowser theInstance;
 
-    ////////////////////////////////////////////////////////////////
-    // instance variables
 
     private String appName = "ProjectBrowser";
 
@@ -305,43 +300,47 @@
 
             // Add a listener to focus changes.
             // Rationale: reset the undo manager to start a new chain.
-            KeyboardFocusManager kfm =
-                KeyboardFocusManager.getCurrentKeyboardFocusManager();
-            kfm.addPropertyChangeListener(new PropertyChangeListener() {
-                private Object obj;
-
-                /*
-                 * @see 
java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
-                 */
-                public void propertyChange(PropertyChangeEvent evt) {
-                    if ("focusOwner".equals(evt.getPropertyName())
-                            && (evt.getNewValue() != null)
-                        /* We get many many events (why?), so let's filter: */
-                            && (obj != evt.getNewValue())) {
-                        obj = evt.getNewValue();
-                        // TODO: Bob says -
-                        // We're looking at focus change to
-                        // flag the start of an interaction. This
-                        // is to detect when focus is gained in a prop
-                        // panel field on the assumption edting of that
-                        // field is about to start.
-                        // Not a good assumption. We Need to see if we can get
-                        // rid of this.
-                        Project p = 
-                            ProjectManager.getManager().getCurrentProject();
-                        p.getUndoManager().startInteraction("Focus");
-                        /* This next line is ideal for debugging the taborder
-                         * (focus traversal), see e.g. issue 1849.
-                         */
-//                      System.out.println("Focus changed " + obj);
-                    }
-                }
-            });
+            addKeyboardFocusListener();
         }
         ArgoEventPump.addListener(ArgoEventTypes.ANY_HELP_EVENT, 
                 new HelpListener(getStatusBar()));
     }
 
+    private void addKeyboardFocusListener() {
+        KeyboardFocusManager kfm =
+            KeyboardFocusManager.getCurrentKeyboardFocusManager();
+        kfm.addPropertyChangeListener(new PropertyChangeListener() {
+            private Object obj;
+
+            /*
+             * @see 
java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+             */
+            public void propertyChange(PropertyChangeEvent evt) {
+                if ("focusOwner".equals(evt.getPropertyName())
+                        && (evt.getNewValue() != null)
+                    /* We get many many events (why?), so let's filter: */
+                        && (obj != evt.getNewValue())) {
+                    obj = evt.getNewValue();
+                    // TODO: Bob says -
+                    // We're looking at focus change to
+                    // flag the start of an interaction. This
+                    // is to detect when focus is gained in a prop
+                    // panel field on the assumption editing of that
+                    // field is about to start.
+                    // Not a good assumption. We Need to see if we can get
+                    // rid of this.
+                    Project p = 
+                        ProjectManager.getManager().getCurrentProject();
+                    p.getUndoManager().startInteraction("Focus");
+                    /* This next line is ideal for debugging the taborder
+                     * (focus traversal), see e.g. issue 1849.
+                     */
+//                      System.out.println("Focus changed " + obj);
+                }
+            }
+        });
+    }
+
     private void setApplicationIcon() {
         ImageIcon argoImage16x16 =
             ResourceLoaderWrapper.lookupIconResource("ArgoIcon16x16");
@@ -798,16 +797,18 @@
 
     /**
      * Get the tab page containing the properties.
-     *
+     * 
      * @return the TabProps tabpage
+     * @deprecated for 0.25.5 by tfmorris. No one should need to manipulate the
+     *             properties tab directly. The only place this is currently
+     *             used is in a test.
      */
+    @Deprecated
     public TabProps getTabProps() {
         // In theory there can be multiple details pane (work in
         // progress). It must first be determined which details
         // page contains the properties tab. Bob Tarling 7 Dec 2002
-        Iterator it = detailsPanesByCompassPoint.values().iterator();
-        while (it.hasNext()) {
-            DetailsPane detailsPane = (DetailsPane) it.next();
+        for (DetailsPane detailsPane : detailsPanesByCompassPoint.values()) {
             TabProps tabProps = detailsPane.getTabProps();
             if (tabProps != null) {
                 return tabProps;
@@ -818,17 +819,21 @@
 
     /**
      * Get the tab page instance of the given class.
-     *
+     * 
      * @param tabClass the given class
      * @return the tabpage
+     * @deprecated by for 0.25.5 by tfmorris. Tabs should register themselves
+     *             with whoever they need to communicate with in a distributed
+     *             fashion rather than relying on a central registry. Currently
+     *             the only place this is used is to communicate between 
WizStep
+     *             and TabToDo in the Cognitive subsystem.
      */
+    @Deprecated
     public AbstractArgoJPanel getTab(Class tabClass) {
         // In theory there can be multiple details pane (work in
         // progress). It must first be determined which details
         // page contains the properties tab. Bob Tarling 7 Dec 2002
-        Iterator it = detailsPanesByCompassPoint.values().iterator();
-        while (it.hasNext()) {
-            DetailsPane detailsPane = (DetailsPane) it.next();
+        for (DetailsPane detailsPane : detailsPanesByCompassPoint.values())  {
             AbstractArgoJPanel tab = detailsPane.getTab(tabClass);
             if (tab != null) {
                 return tab;
@@ -848,6 +853,7 @@
     /*
      * @see javax.swing.JFrame#getJMenuBar()
      */
+    @Override
     public JMenuBar getJMenuBar() {
         return menuBar;
     }
@@ -877,11 +883,14 @@
      * Find the tabpage with the given label and make it the front tab.
      *
      * @param tabName The tabpage label
+     * @deprecated for 0.25.5 by tfmorris. This is unused by ArgoUML. If there
+     *             are clients that require this functionality, it should be
+     *             delegated to some place more appropriate like a details
+     *             pane manager.
      */
+    @Deprecated
     public void selectTabNamed(String tabName) {
-        Iterator it = detailsPanesByCompassPoint.values().iterator();
-        while (it.hasNext()) {
-            DetailsPane detailsPane = (DetailsPane) it.next();
+        for (DetailsPane detailsPane : detailsPanesByCompassPoint.values()) {
             if (detailsPane.selectTabNamed(Translator.localize(tabName))) {
                 return;
             }
@@ -891,12 +900,15 @@
 
 
     /**
-     * Given a list of targets, displays the corresponding diagram.
-     * This method jumps to the diagram showing the targets,
-     * and scrolls to make it visible.
-     *
+     * Given a list of targets, displays the corresponding diagram. This method
+     * jumps to the diagram showing the targets, and scrolls to make it 
visible.
+     * 
      * @param targets Collection of targets to show
+     * @deprecated for 0.25.5 by tfmorris. This is unused by ArgoUML. If there
+     *             are clients that require this functionality, it should be
+     *             moved some place more appropriate like the Diagram 
subsystem.
      */
+    @Deprecated
     public void jumpToDiagramShowing(Collection targets) {
 
         if (targets == null || targets.size() == 0) {

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddNote.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddNote.java?view=diff&rev=14483&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddNote.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddNote.java&r1=14482&r2=14483
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddNote.java     
(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ActionAddNote.java     
2008-04-26 17:27:29-0700
@@ -79,12 +79,11 @@
                 .lookupIconResource("New Note"));
     }
 
-    ////////////////////////////////////////////////////////////////
-    // main methods
 
     /*
      * @see 
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
      */
+    @Override
     public void actionPerformed(ActionEvent ae) {
         super.actionPerformed(ae); //update all tools' enabled status
         Collection targets = TargetManager.getInstance().getModelTargets();
@@ -176,6 +175,9 @@
             // TODO: We need a better algorithm.
             point.x = elemFig.getX() + elemFig.getWidth() + DISTANCE;
             point.y = elemFig.getY();
+            // TODO: This can't depend on ProjectBrowser.  It needs to get
+            // the current drawing area from the Diagram subsystem or GEF
+            // better yet, it should just tell the Diagram to place it
             Rectangle drawingArea =
                 ProjectBrowser.getInstance().getEditorPane().getBounds();
             if (point.x + noteFig.getWidth() > drawingArea.getX()) {

Modified: 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ModeCreateAssociationClass.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ModeCreateAssociationClass.java?view=diff&rev=14483&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ModeCreateAssociationClass.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ModeCreateAssociationClass.java&r1=14482&r2=14483
==============================================================================
--- 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ModeCreateAssociationClass.java
        (original)
+++ 
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ModeCreateAssociationClass.java
        2008-04-26 17:27:29-0700
@@ -51,6 +51,7 @@
 
     private static final int DISTANCE = 80;
     
+    @Override
     protected void endAttached(FigEdge fe) {
         Layer lay = editor.getLayerManager().getActiveLayer();
         FigAssociationClass thisFig =
@@ -87,6 +88,8 @@
             (MutableGraphModel) editor.getGraphModel();
         mutableGraphModel.addNode(thisFig.getOwner());
 
+        // TODO: This can't depend on ProjectBrowser.  It needs to get
+        // the current drawing area from the Diagram subsystem or GEF
         Rectangle drawingArea =
             ProjectBrowser.getInstance()
                 .getEditorPane().getBounds();

Modified: trunk/src/argouml-app/tests/org/argouml/ui/GUITestProjectBrowser.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/tests/org/argouml/ui/GUITestProjectBrowser.java?view=diff&rev=14483&p1=trunk/src/argouml-app/tests/org/argouml/ui/GUITestProjectBrowser.java&p2=trunk/src/argouml-app/tests/org/argouml/ui/GUITestProjectBrowser.java&r1=14482&r2=14483
==============================================================================
--- trunk/src/argouml-app/tests/org/argouml/ui/GUITestProjectBrowser.java       
(original)
+++ trunk/src/argouml-app/tests/org/argouml/ui/GUITestProjectBrowser.java       
2008-04-26 17:27:29-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 2002-2007 The Regents of the University of California. All
+// Copyright (c) 2002-2008 The Regents of the University of California. All
 // Rights Reserved. Permission to use, copy, modify, and distribute this
 // software and its documentation without fee, and without a written
 // agreement is hereby granted, provided that the above copyright notice
@@ -62,9 +62,7 @@
         super(arg0);
     }
 
-    /*
-     * @see junit.framework.TestCase#setUp()
-     */
+    @Override
     public void setUp() throws Exception {
        super.setUp();
         InitializeModel.initializeDefault();
@@ -82,8 +80,9 @@
        ProjectBrowser pb = ProjectBrowser.getInstance();
        assertNotNull(pb.getLocale());
        assertNotNull(pb.getAppName());
-       assertNotNull(pb.getTabProps());
-       assertNotNull(pb.getStatusBar());
+       // ProjectBrowser exposes functionality, not components.
+//     assertNotNull(pb.getTabProps());
+//     assertNotNull(pb.getStatusBar());
        assertNotNull(pb.getJMenuBar());
        assertNotNull(pb.getEditorPane());
        assertNotNull(pb.getTodoPane());
@@ -100,7 +99,7 @@
     }
 
     /**
-     * Test the existance of public static members.
+     * Test the existence of public static members.
      */
     public void compileTestPublicStaticMembers() {
        Integer.valueOf(ProjectBrowser.DEFAULT_COMPONENTWIDTH
@@ -108,7 +107,7 @@
     }
 
     /**
-     * Test the existance of public members.
+     * Test the existence of public members.
      */
     public void compileTestPublicMembers() {
        assertNotNull(ProjectBrowser.getInstance().getDefaultFont());

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to