svn commit: r17666 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui

Bob Tarling <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2009-12-18 07:47:02-0800
New Revision: 17666

Added:
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ActionSetStructuralFeatureType.java
Modified:
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCallEventOperationComboBox.java
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBox.java
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMessageActivatorComboBox.java
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStructuralFeatureTypeComboBoxModel.java

Log:
Change type combo when model element changes

Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ActionSetStructuralFeatureType.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ActionSetStructuralFeatureType.java?view=markup&pathrev=17666
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ActionSetStructuralFeatureType.java	2009-12-18 07:47:02-0800
@@ -0,0 +1,85 @@
+// $Id: ActionSetStructuralFeatureType.java 13726 2007-11-04 20:21:13Z tfmorris $
+// Copyright (c) 1996-2007 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
+// and this paragraph appear in all copies.  This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason.  IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.Action;
+
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.ui.UndoableAction;
+
+/**
+ * @since Nov 3, 2002
+ * @author [email protected]
+ */
+class ActionSetStructuralFeatureType extends UndoableAction {
+
+    /**
+     * The class uid
+     */
+    private static final long serialVersionUID = 8227201276430122294L;
+    
+    /**
+     * Constructor for ActionSetStructuralFeatureType.
+     */
+    protected ActionSetStructuralFeatureType() {
+        super(Translator.localize("Set"), null);
+        // Set the tooltip string:
+        putValue(Action.SHORT_DESCRIPTION, 
+                Translator.localize("Set"));
+    }
+
+    /*
+     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+     */
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        super.actionPerformed(e);
+        assert (e.getSource() instanceof UMLComboBox);
+        Object oldClassifier = null;
+        final UMLComboBox box = (UMLComboBox) e.getSource();
+        final Object feature = box.getTarget();
+        assert (feature != null);
+        
+        oldClassifier = Model.getFacade().getType(feature);
+        
+        Object selectedClassifier = box.getSelectedItem();
+        System.out.println("The selected classifier is " + selectedClassifier);
+        
+        final Object newClassifier;
+        if (Model.getFacade().isAElement(selectedClassifier)) {
+            newClassifier = selectedClassifier;
+        } else {
+            newClassifier = null;
+        }
+        
+        if (newClassifier != oldClassifier) {
+            System.out.println("Setting the type to " + newClassifier);
+            Model.getCoreHelper().setType(feature, newClassifier);
+        }
+    }
+}

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java?view=diff&pathrev=17666&r1=17665&r2=17666
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java	2009-12-18 07:47:02-0800
@@ -38,7 +38,6 @@
 import org.argouml.i18n.Translator;
 import org.argouml.model.Model;
 import org.argouml.uml.ui.UMLCheckBox2;
-import org.argouml.uml.ui.UMLComboBox2;
 import org.argouml.uml.ui.UMLComboBoxNavigator;
 import org.argouml.uml.ui.UMLDerivedCheckBox;
 import org.argouml.uml.ui.UMLRadioButtonPanel;
@@ -51,7 +50,6 @@
 import org.argouml.uml.ui.foundation.core.ActionSetAssociationEndType;
 import org.argouml.uml.ui.foundation.core.ActionSetGeneralizationPowertype;
 import org.argouml.uml.ui.foundation.core.ActionSetModelElementNamespace;
-import org.argouml.uml.ui.foundation.core.ActionSetStructuralFeatureType;
 import org.argouml.uml.ui.foundation.core.UMLAssociationEndAggregationRadioButtonPanel;
 import org.argouml.uml.ui.foundation.core.UMLAssociationEndChangeabilityRadioButtonPanel;
 import org.argouml.uml.ui.foundation.core.UMLAssociationEndNavigableCheckBox;
@@ -372,7 +370,7 @@
                     model,
                     // TODO: The action is different for
                     // attributes and parameters. Issue #5222
-                    ActionSetStructuralFeatureType.getInstance());
+                    new ActionSetStructuralFeatureType());
             comp = combo;
         } else if ("base".equals(prop.getName())) {
             if (Model.getFacade().isAAssociationRole(target)) {

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCallEventOperationComboBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCallEventOperationComboBox.java?view=diff&pathrev=17666&r1=17665&r2=17666
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCallEventOperationComboBox.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCallEventOperationComboBox.java	2009-12-18 07:47:02-0800
@@ -28,18 +28,20 @@
 
 import org.argouml.model.Model;
 
-
-/**
- * @author [email protected]
- */
 class UMLCallEventOperationComboBox extends UMLSearchableComboBox {
+    
+    /**
+     * The class uid
+     */
+    private static final long serialVersionUID = -8008883017063694372L;
+
     /**
      * The constructor.
      *
-     * @param arg0 the model
+     * @param model the model
      */
-    public UMLCallEventOperationComboBox(UMLComboBoxModel arg0) {
-        super(arg0, null); // no external action; we do it ourselves
+    public UMLCallEventOperationComboBox(UMLComboBoxModel model) {
+        super(model, null); // no external action; we do it ourselves
         setEditable(false);
     }
 
@@ -56,8 +58,8 @@
             if (Model.getFacade().isACallEvent(target) 
                 && Model.getFacade().isAOperation(selected)) {
                 if (Model.getFacade().getOperation(target) != selected) {
-                    Model.getCommonBehaviorHelper()
-                        .setOperation(target, selected);
+                    Model.getCommonBehaviorHelper().setOperation(
+                            target, selected);
                 }
             }
         }

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBox.java?view=diff&pathrev=17666&r1=17665&r2=17666
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBox.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBox.java	2009-12-18 07:47:02-0800
@@ -35,41 +35,31 @@
 
 /**
  * ComboBox for UML modelelements. <p>
- *
- * This implementation does not use
- * reflection and seperates Model, View and Controller better then does
- * UMLComboBox. The ancient UMLComboBoxModel and UMLComboBox are
- * replaced with this implementation to improve performance.
  */
 class UMLComboBox extends JComboBox {
 
     /**
-     * Constructor for UMLComboBox2.
-     * @deprecated As of ArgoUml version unknown (before 0.13.5),
-     * replaced by {@link #UMLComboBox2(UMLComboBoxModel2, Action, boolean)}
-     * @param model the ComboBoxModel
+     * The class uid
      */
-    @Deprecated
-    protected UMLComboBox(UMLComboBoxModel model) {
-        super(model);
-        setFont(LookAndFeelMgr.getInstance().getStandardFont());
-        addActionListener(this);
-        addPopupMenuListener(model);
-    }
-
+    private static final long serialVersionUID = -7556056847962715552L;
+    
+    // TODO: Need to document what this is for
+    private Action action;
+    
     /**
-     * Constructor for UMLComboBox2. Via the given action, the
+     * Constructor for UMLComboBox. Via the given action, the
      * action for this combobox is done.
      * @param model the ComboBoxModel
-     * @param action the action
+     * @param action the action // TODO used for what/when?
      * @param showIcon true if an icon should be shown in front of the items
      */
     public UMLComboBox(UMLComboBoxModel model, Action action,
 			boolean showIcon) {
         super(model);
-        //setFont(LookAndFeelMgr.getInstance().getStandardFont());
-        addActionListener(action);
-        // setDoubleBuffered(true);
+        this.action = action;
+        if (action != null) {
+            addActionListener(action);
+        }
         setRenderer(new UMLListCellRenderer2(showIcon));
         addPopupMenuListener(model);
     }
@@ -77,11 +67,11 @@
     /**
      * The constructor.
      *
-     * @param arg0 the ComboBoxModel
-     * @param action the action
+     * @param model the ComboBoxModel
+     * @param action the action // TODO used for what/when?
      */
-    public UMLComboBox(UMLComboBoxModel arg0, Action action) {
-        this(arg0, action, true);
+    public UMLComboBox(UMLComboBoxModel model, Action action) {
+        this(model, action, true);
     }
 
     @Override
@@ -112,5 +102,9 @@
     @Override
     public void removeNotify() {
         ((UMLComboBoxModel) getModel()).removeModelEventListener();
+        if (action != null) {
+            removeActionListener(action);
+        }
+        removePopupMenuListener((UMLComboBoxModel) getModel());
     }
 }

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java?view=diff&pathrev=17666&r1=17665&r2=17666
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLComboBoxModel.java	2009-12-18 07:47:02-0800
@@ -184,24 +184,7 @@
      */
     public void modelChanged(UmlChangeEvent evt) {
         buildingModel = true;
-        if (evt instanceof AttributeChangeEvent) {
-            if (evt.getPropertyName().equals(propertySetName)) {
-                if (evt.getSource() == getTarget()
-                        && (isClearable || getChangedElement(evt) != null)) {
-                    Object elem = getChangedElement(evt);
-                    if (elem != null && !contains(elem)) {
-                        addElement(elem);
-                    }
-                    /* MVW: for this case, I had to move the 
-                     * call to setSelectedItem() outside the "buildingModel", 
-                     * otherwise the combo does not update 
-                     * with the new selection. See issue 5418. 
-                     **/
-                    buildingModel = false;
-                    setSelectedItem(elem);
-                }
-            }
-        } else if (evt instanceof DeleteInstanceEvent) {
+        if (evt instanceof DeleteInstanceEvent) {
             if (contains(getChangedElement(evt))) {
                 Object o = getChangedElement(evt);
                 removeElement(o);
@@ -211,7 +194,15 @@
                 if (evt.getPropertyName().equals(propertySetName) 
                     && (evt.getSource() == getTarget())) {
                     Object elem = evt.getNewValue();
-                    /* TODO: Here too? */
+                    if (elem != null && !contains(elem)) {
+                        addElement(elem);
+                    }
+                    /* MVW: for this case, I had to move the 
+                     * call to setSelectedItem() outside the "buildingModel", 
+                     * otherwise the combo does not update 
+                     * with the new selection. See issue 5418. 
+                     **/
+                    buildingModel = false;
                     setSelectedItem(elem);
                 } else {
                     Object o = getChangedElement(evt);

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMessageActivatorComboBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMessageActivatorComboBox.java?view=diff&pathrev=17666&r1=17665&r2=17666
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMessageActivatorComboBox.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMessageActivatorComboBox.java	2009-12-18 07:47:02-0800
@@ -42,12 +42,11 @@
     /**
      * Constructor for UMLMessageActivatorComboBox.
      * @param container the UI container
-     * @param arg0 the model
+     * @param model the model
      */
     public UMLMessageActivatorComboBox(
-        UMLComboBoxModel arg0) {
-        // TODO: This super constructor has been deprecated
-        super(arg0);
+        final UMLComboBoxModel model) {
+        super(model, null, false);
         setRenderer(new UMLListCellRenderer2(true));
     }
 

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStructuralFeatureTypeComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStructuralFeatureTypeComboBoxModel.java?view=diff&pathrev=17666&r1=17665&r2=17666
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStructuralFeatureTypeComboBoxModel.java	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLStructuralFeatureTypeComboBoxModel.java	2009-12-18 07:47:02-0800
@@ -32,7 +32,6 @@
 import org.argouml.kernel.Project;
 import org.argouml.kernel.ProjectManager;
 import org.argouml.model.Model;
-import org.argouml.model.UmlChangeEvent;
 import org.argouml.uml.util.PathComparator;
 
 /**

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

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.