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

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2010-11-06 10:58:28-0700
New Revision: 18840

Modified:
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml
   trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java

Log:
Only show sibling buttons if model interface confirms them as legal.

Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml?view=diff&pathrev=18840&r1=18839&r2=18840
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml	(original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/metamodel.xml	2010-11-06 10:58:28-0700
@@ -540,7 +540,7 @@
     <attribute name="linkEnd" type="AssociationEnd" />
     <attribute name="associationEndRole" type="AssociationEnd" />
   </panel>
-  <panel name="Interface" new="Operation">
+  <panel name="Interface" new-child="Operation">
     <text name="name" type="Name" />
     <combo name="namespace" type="Namespace" />
     <optionbox name="visibility" type="VisibilityKind" />

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=18840&r1=18839&r2=18840
==============================================================================
--- 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	2010-11-06 10:58:28-0700
@@ -38,6 +38,9 @@
 
 package org.argouml.core.propertypanels.ui;
 
+import java.util.Collection;
+import java.util.List;
+
 import javax.swing.BoxLayout;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
@@ -152,19 +155,28 @@
             // list on property panel
             tb.add(new ActionNewStereotype());
             
-            for (Class<?> metaType : panelData.getNewChildElements()) {
-                tb.add(new ActionCreateContainedModelElement(metaType, target));
-            }
+            addCreateButtons(target, tb, panelData.getNewChildElements());
             
-            final Object parent = Model.getFacade().getModelElementContainer(target);
-
-            if (parent != null) {
-                for (Class<?> metaType : panelData.getNewSiblingElements()) {
-                    tb.add(new ActionCreateContainedModelElement(metaType, parent));
+            final Object parent =
+        	Model.getFacade().getModelElementContainer(target);
+            addCreateButtons(parent, tb, panelData.getNewSiblingElements());
+        }
+        panel.add(tb);
+    }
+    
+    private void addCreateButtons(
+	    final Object container, 
+	    final JToolBar tb,
+	    final Collection<Class<?>> metaTypes) {
+        if (container != null) {
+            for (Class<?> metaType : metaTypes) {
+                if (Model.getUmlFactory().isContainmentValid(
+            	    metaType, container)) {
+                    tb.add(new ActionCreateContainedModelElement(
+                    	metaType, container));
                 }
             }
         }
-        panel.add(tb);
     }
     
     private void buildTextArea(

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

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.