svn commit: r13884 - trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-12-08 02:41:53-0800
New Revision: 13884

Modified:
   trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/ActionSetTagDefinitionType.java
   trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/PropPanelTagDefinition.java

Log:
Issue 4936 - Updates based on work by Sergio Lopes to enable TagDefinition types other than String

Modified: trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/ActionSetTagDefinitionType.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/ActionSetTagDefinitionType.java?view=diff&rev=13884&p1=trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/ActionSetTagDefinitionType.java&p2=trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/ActionSetTagDefinitionType.java&r1=13883&r2=13884
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/ActionSetTagDefinitionType.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/ActionSetTagDefinitionType.java	2007-12-08 02:41:53-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 2006-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
@@ -28,19 +28,24 @@
 
 import javax.swing.Action;
 
+import org.apache.log4j.Logger;
 import org.argouml.i18n.Translator;
 import org.argouml.model.Model;
 import org.argouml.uml.ui.UMLComboBox2;
 import org.tigris.gef.undo.UndoableAction;
+
 /**
- * @since Nov 3, 2002
- * @author [email protected]
+ * Action to set the type of a TagDefinition. The tagType attribute of a
+ * TagDefinition is a Name of a UML metaclass (ie String).
  */
 public class ActionSetTagDefinitionType extends UndoableAction {
 
     private static final ActionSetTagDefinitionType SINGLETON =
         new ActionSetTagDefinitionType();
 
+    private static final Logger LOG = 
+    	Logger.getLogger(ActionSetTagDefinitionType.class);
+
     /**
      * Constructor for ActionSetTagDefinitionType.
      */
@@ -58,28 +63,29 @@
     public void actionPerformed(ActionEvent e) {
         super.actionPerformed(e);
         Object source = e.getSource();
-        Object oldClassifier = null;
-        Object newClassifier = null;
-        Object attr = null;
+        LOG.debug("Receiving " + e + "/" + e.getID() + "/"
+                + e.getActionCommand());
+        String oldType = null;
+        String newType = null;
+        Object tagDef = null;
         if (source instanceof UMLComboBox2) {
             UMLComboBox2 box = (UMLComboBox2) source;
-            Object o = box.getTarget();
-            if (Model.getFacade().isATagDefinition(o)) {
-                attr = o;
-                oldClassifier = Model.getFacade().getType(attr);
-            }
-            o = box.getSelectedItem();
-            if (Model.getFacade().isAClassifier(o)) {
-                newClassifier = o;
+            Object t = box.getTarget();
+            if (Model.getFacade().isATagDefinition(t)) {
+                tagDef = t;
+                oldType = (String) Model.getFacade().getType(tagDef);
             }
+            newType = (String) box.getSelectedItem();
+            LOG.debug("Selected item is " + newType);
         }
-        if (newClassifier != oldClassifier && attr != null) {
-            Model.getCoreHelper().setType(attr, newClassifier);
+        if (newType != null && !newType.equals(oldType) && tagDef != null) {
+            LOG.debug("New type is " + newType);
+            Model.getExtensionMechanismsHelper().setTagType(tagDef, newType);
         }
     }
-
+    
     /**
-     * @return Returns the sINGLETON.
+     * @return Returns the singleton instance.
      */
     public static ActionSetTagDefinitionType getInstance() {
         return SINGLETON;

Modified: trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/PropPanelTagDefinition.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/PropPanelTagDefinition.java?view=diff&rev=13884&p1=trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/PropPanelTagDefinition.java&p2=trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/PropPanelTagDefinition.java&r1=13883&r2=13884
==============================================================================
--- trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/PropPanelTagDefinition.java	(original)
+++ trunk/src_new/org/argouml/uml/ui/foundation/extension_mechanisms/PropPanelTagDefinition.java	2007-12-08 02:41:53-0800
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Copyright (c) 2005-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
@@ -49,20 +49,16 @@
 import org.argouml.uml.ui.UMLLinkedList;
 import org.argouml.uml.ui.UMLMultiplicityPanel;
 import org.argouml.uml.ui.UMLSearchableComboBox;
-import org.argouml.uml.ui.foundation.core.ActionSetStructuralFeatureType;
 import org.argouml.uml.ui.foundation.core.PropPanelModelElement;
 import org.argouml.uml.ui.foundation.core.UMLModelElementNamespaceComboBoxModel;
 import org.argouml.uml.ui.foundation.core.UMLStructuralFeatureTypeComboBoxModel;
 import org.tigris.gef.undo.UndoableAction;
 
 /**
- * The properties panel for a Class.
+ * The properties panel for a TagDefinition.
  */
 public class PropPanelTagDefinition extends PropPanelModelElement {
 
-    /**
-     * 
-     */
     private static final long serialVersionUID = 3563940705352568635L;
     private JComponent ownerSelector;
     private JComponent tdNamespaceSelector;
@@ -75,8 +71,8 @@
             new UMLTagDefinitionOwnerComboBoxModel();
     private UMLComboBoxModel2 tdNamespaceComboBoxModel = 
         new UMLTagDefinitionNamespaceComboBoxModel();
-    // Despite the misleading name the following class does the right thing
-    private static UMLStructuralFeatureTypeComboBoxModel typeComboBoxModel;
+    private static UMLMetaClassComboBoxModel typeComboBoxModel;
+
     private static UMLTagDefinitionTypedValuesListModel typedValuesListModel = 
         new UMLTagDefinitionTypedValuesListModel();
 
@@ -84,7 +80,7 @@
      * The combobox for the multiplicity of this type.
      */
     private JPanel multiplicityComboBox;
-
+    
     /**
      * Construct a property panel for TagDefinition elements.
      */
@@ -167,18 +163,11 @@
     public UMLComboBox2 getTypeComboBox() {
         if (typeComboBox == null) {
             if (typeComboBoxModel == null) {
-                typeComboBoxModel =
-                    new UMLStructuralFeatureTypeComboBoxModel();
-                // TODO: Replace by:
-//                new UMLTagDefinitionTagTypeComboBoxModel();
-                // or should it be a textField?
+                typeComboBoxModel = new UMLMetaClassComboBoxModel();
             }
             typeComboBox =
-                new UMLComboBox2(
-                                 typeComboBoxModel,
-                                 ActionSetStructuralFeatureType.getInstance());
-            // TODO: (?) Replace by:
-//                        new ActionSetTagDefinitionTagType();
+                    new UMLComboBox2(typeComboBoxModel,
+                            ActionSetTagDefinitionType.getInstance());
             typeComboBox.setEnabled(false);
         }
         return typeComboBox;
@@ -211,6 +200,7 @@
     /*
      * @see org.argouml.uml.ui.UMLComboBoxModel2#isValidElement(Object)
      */
+    @Override
     protected boolean isValidElement(Object o) {
         return Model.getFacade().isANamespace(o);
     }
@@ -218,19 +208,23 @@
     /*
      * @see org.argouml.uml.ui.foundation.core.UMLModelElementNamespaceComboBoxModel#buildModelList()
      */
+    @Override
     protected void buildModelList() {
-        Object model =
-            ProjectManager.getManager().getCurrentProject().getRoot();
+        Collection roots =
+            ProjectManager.getManager().getCurrentProject().getRoots();
         Collection c = new HashSet();
         c.add(null);
-        c.add(model);
-        c.addAll(Model.getModelManagementHelper().getAllNamespaces(model));
+        for (Object root : roots) {
+            c.add(root);
+            c.addAll(Model.getModelManagementHelper().getAllNamespaces(root));
+        }
         setElements(c);
     }
 
     /*
      * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
      */
+    @Override
     public void propertyChange(PropertyChangeEvent evt) {
         /*
          * Rebuild the list from scratch to be sure it's correct.
@@ -265,6 +259,7 @@
     /*
      * @see org.tigris.gef.undo.UndoableAction#actionPerformed(java.awt.event.ActionEvent)
      */
+    @Override
     public void actionPerformed(ActionEvent e) {
     	super.actionPerformed(e);
         Object source = e.getSource();
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.