Author: bobtarling
Date: 2010-04-08 09:10:01-0700
New Revision: 18217

Modified:
   
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/panels.xml
   
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java

Log:
Issue 6058: If there are more than two create buttons then show them in a drop 
down toolbutton

Modified: 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/panels.xml
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/panels.xml?view=diff&pathrev=18217&r1=18216&r2=18217
==============================================================================
--- 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/panels.xml
        (original)
+++ 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/panels.xml
        2010-04-08 09:10:01-0700
@@ -3033,10 +3033,12 @@
     <singlerow name="entry" 
type="org.omg.uml.behavioralelements.commonbehavior.CallAction,org.omg.uml.behavioralelements.commonbehavior.CreateAction,org.omg.uml.behavioralelements.commonbehavior.DestroyAction,org.omg.uml.behavioralelements.commonbehavior.ReturnAction,org.omg.uml.behavioralelements.commonbehavior.SendAction,org.omg.uml.behavioralelements.commonbehavior.TerminateAction,org.omg.uml.behavioralelements.commonbehavior.UninterpretedAction,org.omg.uml.behavioralelements.commonbehavior.ActionSequence"
 />
     <singlerow name="exit" 
type="org.omg.uml.behavioralelements.commonbehavior.CallAction,org.omg.uml.behavioralelements.commonbehavior.CreateAction,org.omg.uml.behavioralelements.commonbehavior.DestroyAction,org.omg.uml.behavioralelements.commonbehavior.ReturnAction,org.omg.uml.behavioralelements.commonbehavior.SendAction,org.omg.uml.behavioralelements.commonbehavior.TerminateAction,org.omg.uml.behavioralelements.commonbehavior.UninterpretedAction,org.omg.uml.behavioralelements.commonbehavior.ActionSequence"
 />
     <singlerow name="doActivity" 
type="org.omg.uml.behavioralelements.commonbehavior.CallAction,org.omg.uml.behavioralelements.commonbehavior.CreateAction,org.omg.uml.behavioralelements.commonbehavior.DestroyAction,org.omg.uml.behavioralelements.commonbehavior.ReturnAction,org.omg.uml.behavioralelements.commonbehavior.SendAction,org.omg.uml.behavioralelements.commonbehavior.TerminateAction,org.omg.uml.behavioralelements.commonbehavior.UninterpretedAction,org.omg.uml.behavioralelements.commonbehavior.ActionSequence"
 label="label.do-activity" />
+    <separator />
     <list name="deferrableEvent" 
type="org.omg.uml.behavioralelements.statemachines.CallEvent,org.omg.uml.behavioralelements.statemachines.ChangeEvent,org.omg.uml.behavioralelements.statemachines.SignalEvent,org.omg.uml.behavioralelements.statemachines.TimeEvent"
 label="label.deferrable" />
+    <list name="internalTransition" type="Transition" 
label="label.internal-transitions" />
+    <separator />
     <list name="outgoing" type="Transition" />
     <list name="incoming" type="Transition" />    
-    <list name="internalTransition" type="Transition" 
label="label.internal-transitions" />
     
     <debug />
     <attribute name="visibility" type="VisibilityKind" />

Modified: 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java?view=diff&pathrev=18217&r1=18216&r2=18217
==============================================================================
--- 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java
    (original)
+++ 
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java
    2010-04-08 09:10:01-0700
@@ -254,7 +254,7 @@
         List metaTypes = null;
         final Action addAction;
         List<Action> newActions = null;
-        List<Command> additionalCommands = null;
+        List<Command> additionalNewCommands = null;
         
         if (model instanceof UMLModelElementListModel) {
             // Temporary until SimpleListModel is used for all
@@ -268,7 +268,7 @@
             target = ((org.argouml.core.propertypanels.ui.SimpleListModel) 
model).getUmlElement();
             metaType = ((org.argouml.core.propertypanels.ui.SimpleListModel) 
model).getMetaType();
             metaTypes = ((org.argouml.core.propertypanels.ui.SimpleListModel) 
model).getMetaTypes();
-            additionalCommands = 
((org.argouml.core.propertypanels.ui.SimpleListModel) 
model).getAdditionalCommands();
+            additionalNewCommands = 
((org.argouml.core.propertypanels.ui.SimpleListModel) 
model).getAdditionalCommands();
             scroll = new ScrollListImpl(model, 1);
             readonly = Model.getModelManagementHelper().isReadOnly(target);
         } else {
@@ -347,8 +347,8 @@
                     actions.addAll(newActions);
                 }
                 
-                if (additionalCommands != null && 
!additionalCommands.isEmpty()) {
-                       for (Command cmd : additionalCommands) {
+                if (additionalNewCommands != null && 
!additionalNewCommands.isEmpty()) {
+                       for (Command cmd : additionalNewCommands) {
                                if (cmd instanceof IconIdentifiable && cmd 
instanceof Named) {
                             actions.add(new CommandAction(cmd, 
((Named)cmd).getName(), ((IconIdentifiable)cmd).getIcon()));
                                } else {
@@ -373,7 +373,7 @@
                // TODO: Lets build this into a separate buildToolbar method
                        
                 // Create actions and expander if we have multiple rows
-                final ArrayList<Action> actions = new ArrayList<Action>(6);
+                final ArrayList actions = new ArrayList(6);
                 
                 // Create add and remove buttons if needed first
                 if (addAction != null) {
@@ -388,6 +388,7 @@
                 }
 
                 // then any new buttons
+                List<Action> createActions = new ArrayList<Action>();
                 for (Object meta : metaTypes) {
                     if (Model.getUmlFactory().isContainmentValid(meta, 
target)) {
                         final String label =
@@ -396,36 +397,46 @@
                                 meta,
                                 target,
                                 label);
-                        actions.add(createAction);
+                        createActions.add(createAction);
                     }
                 }
 
-                if (additionalCommands != null && 
!additionalCommands.isEmpty()) {
-                       for (Command cmd : additionalCommands) {
+                if (additionalNewCommands != null && 
!additionalNewCommands.isEmpty()) {
+                       for (Command cmd : additionalNewCommands) {
                                if (cmd instanceof IconIdentifiable && cmd 
instanceof Named) {
-                            actions.add(new CommandAction(cmd, 
((Named)cmd).getName(), ((IconIdentifiable)cmd).getIcon()));
+                            createActions.add(new CommandAction(cmd, 
((Named)cmd).getName(), ((IconIdentifiable)cmd).getIcon()));
                                } else {
-                            actions.add(new CommandAction(cmd));
+                                       createActions.add(new 
CommandAction(cmd));
                                }
                        }
                 }
                 
+                if (createActions.size() > 2) {
+                       actions.add(createActions.toArray());
+                } else {
+                    actions.addAll(createActions);
+                }
+                
+                List<Action> navigateActions = new ArrayList<Action>();
                 if (Model.getUmlHelper().isMovable(metaType)) {
                     moveUpAction = new MoveUpAction();
                     moveDownAction = new MoveDownAction();
                     moveTopAction = new MoveTopAction();
                     moveBottomAction = new MoveBottomAction();
-                    actions.add(moveUpAction);
-                    actions.add(moveDownAction);
-                    actions.add(moveTopAction);
-                    actions.add(moveBottomAction);
+                    navigateActions.add(moveUpAction);
+                    navigateActions.add(moveDownAction);
+                    navigateActions.add(moveTopAction);
+                    navigateActions.add(moveBottomAction);
                 } else {
                     moveUpAction = null;
                     moveDownAction = null;
                     moveTopAction = null;
                     moveBottomAction = null;
                 }
+                actions.addAll(navigateActions);
 
+                Object[] actionsArray = actions.toArray();
+                
                 final ToolBarFactory tbf = new ToolBarFactory(actions);
                 toolbar = tbf.createToolBar();
                 toolbar.setRollover(true);

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

To unsubscribe from this discussion, e-mail: 
[[email protected]].

Reply via email to