svn commit: r15571 - branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml: diagram/static_structure/ui ui/foundation/core

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bszanto
Date: 2008-08-15 05:34:51-0700
New Revision: 15571

Modified:
   branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/diagram/static_structure/ui/ClassCreateWizard.java
   branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java

Log:
An empty type can now be selected for the operations return and in parameters.

Modified: branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/diagram/static_structure/ui/ClassCreateWizard.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/diagram/static_structure/ui/ClassCreateWizard.java?view=diff&rev=15571&p1=branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/diagram/static_structure/ui/ClassCreateWizard.java&p2=branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/diagram/static_structure/ui/ClassCreateWizard.java&r1=15570&r2=15571
==============================================================================
--- branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/diagram/static_structure/ui/ClassCreateWizard.java	(original)
+++ branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/diagram/static_structure/ui/ClassCreateWizard.java	2008-08-15 05:34:51-0700
@@ -165,22 +165,22 @@
         Model.getCoreHelper().setName(classNode, txtName.getText());
         
         // adding attributes
-        Vector<Object> attList = new Vector<Object>();
-        for (Object temp : attributes) {
-            if (temp != null) {
-                attList.add(temp);
+        Vector<Object> attList = new Vector<Object>(); 
+        for (Attribute temp : attributes) {
+            if (temp.getAttribute() != null) {
+                attList.add(temp.getAttribute());
             }
         }
-
         Model.getCoreHelper().setAttributes(classNode, attList);
         
         // adding operations
         Vector<Object> opList = new Vector<Object>();
-        for (Object temp : attributes) {
-            if (temp != null) {
-                opList.add(temp);
+        for (Operation temp : operations) {
+            if (temp.getOperation() != null) {
+                opList.add(temp.getOperation());
             }
         }
+
         Model.getCoreHelper().setOperations(classNode, opList);
         
         dialog.setVisible(false);
@@ -304,11 +304,13 @@
         visibility.setPreferredSize(
                 new Dimension((int) (1.3 * ClassCreateWizard.WIDTH / 10), 25));
 
-        UMLComboBoxModel2 model = new UMLStructuralFeatureTypeComboBoxModel();
+        UMLComboBoxModel2 model = 
+            new UMLStructuralFeatureTypeComboBoxModel(true);
         returnParam = Model.getCoreFactory().createParameter();
         model.setTarget(returnParam);
         outType = new UMLComboBox2(model,
                 ActionSetStructuralFeatureType.getInstance());
+        outType.setSelectedIndex(0);
         outType.setPreferredSize(
                 new Dimension((2 * ClassCreateWizard.WIDTH / 10), 25));      
 
@@ -316,11 +318,12 @@
         name.setPreferredSize(
                 new Dimension((int) (1.7 * ClassCreateWizard.WIDTH / 10), 25));
         
-        model = new UMLStructuralFeatureTypeComboBoxModel();
+        model = new UMLStructuralFeatureTypeComboBoxModel(true);
         inParam = Model.getCoreFactory().createParameter();
         model.setTarget(inParam);
         inType = new UMLComboBox2(model,
                 ActionSetStructuralFeatureType.getInstance());
+        inType.setSelectedIndex(0);
         inType.setPreferredSize(
                 new Dimension((2 * ClassCreateWizard.WIDTH / 10), 25));
         
@@ -352,7 +355,8 @@
             helper.setVisibility(operation, vis);
             
             // the return param
-            if (outType.getSelectedIndex() != -1) {
+            if (outType.getSelectedIndex() != -1 
+                    && !outType.getSelectedItem().equals(" ")) {
                 helper.setType(returnParam, outType.getSelectedObjects()[0]);
                 helper.setKind(returnParam, 
                         Model.getDirectionKind().getReturnParameter());
@@ -361,6 +365,7 @@
             
             // the in param
             if (inType.getSelectedIndex() != -1 
+                    && !inType.getSelectedItem().equals(" ")
                     && paramName.getText().length() > 0) {
                 helper.setType(inParam, inType.getSelectedObjects()[0]);
                 helper.setKind(inParam, 

Modified: branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java?view=diff&rev=15571&p1=branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java&p2=branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java&r1=15570&r2=15571
==============================================================================
--- branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java	(original)
+++ branches/gsoc2008/feature4_5142_bszanto/src/org/argouml/uml/ui/foundation/core/UMLStructuralFeatureTypeComboBoxModel.java	2008-08-15 05:34:51-0700
@@ -52,6 +52,15 @@
 //        Model.getPump().addClassModelEventListener(this,
 //                Model.getMetaTypes().getNamespace(), "ownedElement");
     }
+    
+    /**
+     * Constructor for UMLStructuralFeatureTypeComboBoxModel.
+     * @param clearable if the box should have a " " attribute.
+     * 
+     */
+    public UMLStructuralFeatureTypeComboBoxModel(boolean clearable) {
+        super("type", clearable);
+    }
 
     /*
      * This is explained by WFR 2 of a StructuralFeature: 
@@ -95,6 +104,11 @@
 	// list contains deleted elements (eg after a new project is loaded)
 	// so remove all the old contents first
         removeAllElements();
+        
+        // if the comboBox is clearable an "empty" object should also exist
+        if (isClearable()) {
+            addElement(" ");
+        }
         addAll(elements);
     }
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.