Author: bobtarling Date: 2010-04-07 10:27:16-0700 New Revision: 18216 Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/IconIdentifiable.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/Named.java Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCompositeStateSubvertexList.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCompositeStateSubvertexListModel.java Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/panels.xml trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RowSelector.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
Log: Issue 6048 and 6053. Give buttons to add states to state vertex control. Identify Pseudostate panel by its pseudostate kind Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java?view=diff&pathrev=18216&r1=18215&r2=18216 ============================================================================== --- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java (original) +++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java 2010-04-07 10:27:16-0700 @@ -3824,6 +3824,9 @@ if (handle instanceof ParameterDirectionKindEnum) { return handle.toString().replaceAll("pdk_", ""); } + if (handle instanceof PseudostateKind) { + return handle.toString().replaceAll("pk_", ""); + } if (handle instanceof ModelElement) { ModelElement me = (ModelElement) handle; return me.getName(); Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java?view=diff&pathrev=18216&r1=18215&r2=18216 ============================================================================== --- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java (original) +++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/UmlFactoryMDRImpl.java 2010-04-07 10:27:16-0700 @@ -583,7 +583,8 @@ // specifies valid elements for an ActionState to contain validContainmentMap.put(CompositeState.class, - new Class<?>[] { + new Class<?>[] { + Pseudostate.class, SynchState.class, StubState.class, CompositeState.class, SimpleState.class, FinalState.class, SubmachineState.class, CallAction.class, CreateAction.class, DestroyAction.class, ReturnAction.class, SendAction.class, TerminateAction.class, UninterpretedAction.class, ActionSequence.class }); @@ -864,6 +865,20 @@ } } else if (elementType == metaTypes.getSignal()) { element = Model.getStateMachinesFactory().buildSignalEvent(container); + } else if (elementType == metaTypes.getPseudostate() && container instanceof CompositeState) { + element = Model.getStateMachinesFactory().buildPseudoState(container); + } else if (elementType == metaTypes.getSynchState() && container instanceof CompositeState) { + element = Model.getStateMachinesFactory().buildSynchState(container); + } else if (elementType == metaTypes.getStubState() && container instanceof CompositeState) { + element = Model.getStateMachinesFactory().buildStubState(container); + } else if (elementType == metaTypes.getCompositeState() && container instanceof CompositeState) { + element = Model.getStateMachinesFactory().buildCompositeState(container); + } else if (elementType == metaTypes.getSimpleState() && container instanceof CompositeState) { + element = Model.getStateMachinesFactory().buildSimpleState(container); + } else if (elementType == metaTypes.getFinalState() && container instanceof CompositeState) { + element = Model.getStateMachinesFactory().buildFinalState(container); + } else if (elementType == metaTypes.getSubmachineState() && container instanceof CompositeState) { + element = Model.getStateMachinesFactory().buildSubmachineState(container); } else { // build all other elements using existing buildNode element = buildNode(elementType); Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/IconIdentifiable.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/IconIdentifiable.java?view=markup&pathrev=18216 ============================================================================== --- (empty file) +++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/IconIdentifiable.java 2010-04-07 10:27:16-0700 @@ -0,0 +1,20 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + */ + +package org.argouml.core.propertypanels.meta; + +import javax.swing.Icon; + +public interface IconIdentifiable { + public Icon getIcon(); +} Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/Named.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/Named.java?view=markup&pathrev=18216 ============================================================================== --- (empty file) +++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/Named.java 2010-04-07 10:27:16-0700 @@ -0,0 +1,18 @@ +/* $Id$ + ******************************************************************************* + * Copyright (c) 2010 Contributors - see below + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Bob Tarling + ******************************************************************************* + */ + +package org.argouml.core.propertypanels.meta; + +public interface Named { + String getName(); +} 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=18216&r1=18215&r2=18216 ============================================================================== --- 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-07 10:27:16-0700 @@ -2899,8 +2899,7 @@ <list name="incoming" type="Transition" /> <list name="internalTransition" type="Transition" label="label.internal-transitions" /> <separator /> - <list name="subvertex" type="StateVertex" /> - + <list name="subvertex" type="org.omg.uml.behavioralelements.statemachines.SynchState,org.omg.uml.behavioralelements.statemachines.StubState,org.omg.uml.behavioralelements.statemachines.CompositeState,org.omg.uml.behavioralelements.statemachines.SimpleState,org.omg.uml.behavioralelements.statemachines.FinalState,org.omg.uml.behavioralelements.statemachines.SubmachineState" /> <debug /> <attribute name="visibility" type="VisibilityKind" /> <attribute name="modifiers"> @@ -3078,7 +3077,7 @@ <list name="incoming" type="Transition" /> <list name="internalTransition" type="Transition" label="label.internal-transitions" /> <separator /> - <list name="subvertex" type="StateVertex" /> + <list name="subvertex" type="org.omg.uml.behavioralelements.statemachines.SynchState,org.omg.uml.behavioralelements.statemachines.StubState,org.omg.uml.behavioralelements.statemachines.CompositeState,org.omg.uml.behavioralelements.statemachines.SimpleState,org.omg.uml.behavioralelements.statemachines.FinalState,org.omg.uml.behavioralelements.statemachines.SubmachineState" /> <debug /> <attribute name="visibility" type="VisibilityKind" /> @@ -3620,7 +3619,7 @@ <attribute name="doActivity" type="Action" /> <attribute name="stateMachine" type="StateMachine" /> <list name="classifierInState" type="State" label="label.classifier-in-state" /> - <list name="subvertex" type="StateVertex" /> + <list name="subvertex" type="org.omg.uml.behavioralelements.statemachines.SynchState,org.omg.uml.behavioralelements.statemachines.StubState,org.omg.uml.behavioralelements.statemachines.CompositeState,org.omg.uml.behavioralelements.statemachines.SimpleState,org.omg.uml.behavioralelements.statemachines.FinalState,org.omg.uml.behavioralelements.statemachines.SubmachineState" /> <attribute name="submachine" type="StateMachine" /> <separator /> <attribute name="dynamicArguments" type="ArgListsExpression" /> Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java?view=diff&pathrev=18216&r1=18215&r2=18216 ============================================================================== --- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java (original) +++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManager.java 2010-04-07 10:27:16-0700 @@ -13,8 +13,11 @@ package org.argouml.core.propertypanels.model; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.swing.Action; @@ -58,6 +61,8 @@ public abstract Command getAddCommand(String propertyName, Object umlElement); + public abstract List<Command> getAdditionalCommands(String propertyName, Object umlElement); + /** This forces component to fully rebuild when items are added and removed * Used for pragmatic purposes but not advised long term we should remove this in time */ @@ -99,15 +104,18 @@ protected abstract class ListGetterSetter extends OptionGetterSetter { abstract boolean isValidElement(Object modelElement, String type); abstract Object getMetaType(); - Action getAddAction(Object modelElement) { - return null; - } - Action getRemoveAction(Object modelElement) { - return null; - } boolean isFullBuildOnly() { return false; } + /** + * Returns additional commands that cannot be deduced from the panel + * xml or other means. This is currently only used by + * SubvertexGetterSetter and should be removed as soon as we have some + * configurable way to replace. + * @param modelElement TODO + */ + public List<Command> getAdditionalCommands(Object modelElement) { + return Collections.emptyList(); + } } - } \ No newline at end of file Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java?view=diff&pathrev=18216&r1=18215&r2=18216 ============================================================================== --- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java (original) +++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/model/GetterSetterManagerImpl.java 2010-04-07 10:27:16-0700 @@ -20,14 +20,19 @@ import java.util.List; import java.util.StringTokenizer; +import javax.swing.Icon; import javax.swing.JOptionPane; import org.apache.log4j.Logger; +import org.argouml.application.helpers.ResourceLoaderWrapper; +import org.argouml.core.propertypanels.meta.IconIdentifiable; +import org.argouml.core.propertypanels.meta.Named; import org.argouml.i18n.Translator; import org.argouml.kernel.Command; import org.argouml.kernel.NonUndoableCommand; import org.argouml.kernel.ProjectManager; import org.argouml.model.Model; +import org.argouml.ui.targetmanager.TargetManager; import org.argouml.uml.ui.UMLAddDialog; import org.argouml.util.ArgoFrame; @@ -90,6 +95,7 @@ addGetterSetter("deferrableEvent", new DeferrableEventGetterSetter()); addGetterSetter("entry", new EntryActionGetterSetter()); addGetterSetter("action", new ActionGetterSetter()); + addGetterSetter("subvertex", new SubvertexGetterSetter()); // UML2 only addGetterSetter("ownedOperation", new FeatureGetterSetter()); @@ -196,6 +202,15 @@ } @Override + public List<Command> getAdditionalCommands(String propertyName, Object umlElement) { + BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName); + if (bgs instanceof ListGetterSetter) { + return ((ListGetterSetter) bgs).getAdditionalCommands(umlElement); + } + return null; + } + + @Override public Command getRemoveCommand(String propertyName, Object umlElement, Object objectToRemove) { BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName); if (bgs instanceof Removeable) { @@ -1084,6 +1099,114 @@ return Model.getMetaTypes().getAction(); } } + + private class SubvertexGetterSetter extends ListGetterSetter { + + public Collection getOptions(Object modelElement, String type) { + return Model.getFacade().getSubvertices(modelElement); + } + + public Object get(Object modelElement, String type) { + // not needed + return null; + } + + public void set(Object element, Object x) { + // not needed + } + + public boolean isValidElement(Object element, String type) { + return getOptions(element, type).contains(element); + } + + public Object getMetaType() { + return Model.getMetaTypes().getState(); + } + + /** + * Returns additional commands that cannot be deduced from the panel + * xml or other means. This is currently only used by + * SubvertexGetterSetter and should be removed as soon as we have some + * configurable way to replace. + */ + public List<Command> getAdditionalCommands(Object modelElement) { + final List<Command> commands = new ArrayList<Command>(6); + commands.add(new NewPseudoStateCommand( + modelElement, Model.getPseudostateKind().getFork())); + commands.add(new NewPseudoStateCommand( + modelElement, Model.getPseudostateKind().getJoin())); + commands.add(new NewPseudoStateCommand( + modelElement, Model.getPseudostateKind().getChoice())); + commands.add(new NewPseudoStateCommand( + modelElement, Model.getPseudostateKind().getDeepHistory())); + commands.add(new NewPseudoStateCommand( + modelElement, Model.getPseudostateKind().getShallowHistory())); + commands.add(new NewPseudoStateCommand( + modelElement, Model.getPseudostateKind().getInitial())); + commands.add(new NewPseudoStateCommand( + modelElement, Model.getPseudostateKind().getJunction())); + return commands; + } + + private class NewPseudoStateCommand extends NonUndoableCommand implements IconIdentifiable, Named { + + private final String label; + private final Object kind; + private final Icon icon; + private final Object target; + + /** + * A Command to create a new pseudostate inside some target model + * element. + * @param target the target model element the pseudo state should + * belong to + * @param kind the required kind of pseudostate + */ + NewPseudoStateCommand(Object target, Object kind) { + this.target = target; + this.kind = kind; + if (kind == Model.getPseudostateKind().getFork()) { + label = Translator.localize("label.pseudostate.fork"); + } else if (kind == Model.getPseudostateKind().getJoin()) { + label = Translator.localize("label.pseudostate.join"); + } else if (kind == Model.getPseudostateKind().getChoice()) { + label = Translator.localize("label.pseudostate.choice"); + } else if (kind == Model.getPseudostateKind().getDeepHistory()) { + label = Translator.localize("label.pseudostate.deephistory"); + } else if (kind == Model.getPseudostateKind().getShallowHistory()) { + label = Translator.localize("label.pseudostate.shallowhistory"); + } else if (kind == Model.getPseudostateKind().getInitial()) { + label = Translator.localize("label.pseudostate.initial"); + } else if (kind == Model.getPseudostateKind().getJunction()) { + label = Translator.localize("label.pseudostate.junction"); + } else { + throw new IllegalArgumentException( + kind + " is not a known PseudostateKind"); + } + icon = ResourceLoaderWrapper.lookupIcon( + Model.getFacade().getName(kind)); + } + + @Override + public Object execute() { + final Object ps = + Model.getStateMachinesFactory().buildPseudoState(target); + if (kind != null) { + Model.getCoreHelper().setKind(ps, kind); + } + TargetManager.getInstance().setTarget(ps); + return null; + } + + public Icon getIcon() { + return icon; + } + + public String getName() { + return label; + } + } + } private class TemplateParameterGetterSetter extends ListGetterSetter { Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java?view=diff&pathrev=18216&r1=18215&r2=18216 ============================================================================== --- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java (original) +++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ListFactory.java 2010-04-07 10:27:16-0700 @@ -40,7 +40,6 @@ import javax.swing.DefaultListModel; import javax.swing.JComponent; -import javax.swing.JList; import org.argouml.core.propertypanels.model.GetterSetterManager; @@ -130,10 +129,6 @@ model = new UMLAssociationEndSpecificationListModel(modelElement); } else if ("submachineState".equals(propName)) { model = new UMLStateMachineSubmachineStateListModel(modelElement); - } else if ("subvertex".equals(propName)) { - model = new UMLCompositeStateSubvertexListModel(modelElement); - JList l = new UMLCompositeStateSubvertexList((UMLModelElementListModel) model); - list = new OldScrollList(l); } else if ("supplier".equals(propName)) { model = new UMLDependencySupplierListModel(modelElement); } else if ("supplierDependency".equals(propName)) { 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=18216&r1=18215&r2=18216 ============================================================================== --- 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-07 10:27:16-0700 @@ -74,6 +74,8 @@ import org.apache.log4j.Logger; import org.argouml.application.helpers.ResourceLoaderWrapper; +import org.argouml.core.propertypanels.meta.IconIdentifiable; +import org.argouml.core.propertypanels.meta.Named; import org.argouml.i18n.Translator; import org.argouml.kernel.Command; import org.argouml.kernel.Project; @@ -252,6 +254,7 @@ List metaTypes = null; final Action addAction; List<Action> newActions = null; + List<Command> additionalCommands = null; if (model instanceof UMLModelElementListModel) { // Temporary until SimpleListModel is used for all @@ -265,6 +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(); scroll = new ScrollListImpl(model, 1); readonly = Model.getModelManagementHelper().isReadOnly(target); } else { @@ -343,6 +347,16 @@ actions.addAll(newActions); } + if (additionalCommands != null && !additionalCommands.isEmpty()) { + for (Command cmd : additionalCommands) { + if (cmd instanceof IconIdentifiable && cmd instanceof Named) { + actions.add(new CommandAction(cmd, ((Named)cmd).getName(), ((IconIdentifiable)cmd).getIcon())); + } else { + actions.add(new CommandAction(cmd)); + } + } + } + if (!actions.isEmpty()) { PopupToolBoxButton tb = new PopupToolBoxButton(actions.get(0), actions.size(), 1, true); for (Action action : actions) { @@ -386,6 +400,16 @@ } } + if (additionalCommands != null && !additionalCommands.isEmpty()) { + for (Command cmd : additionalCommands) { + if (cmd instanceof IconIdentifiable && cmd instanceof Named) { + actions.add(new CommandAction(cmd, ((Named)cmd).getName(), ((IconIdentifiable)cmd).getIcon())); + } else { + actions.add(new CommandAction(cmd)); + } + } + } + if (Model.getUmlHelper().isMovable(metaType)) { moveUpAction = new MoveUpAction(); moveDownAction = new MoveDownAction(); @@ -948,4 +972,26 @@ } } } + + private static class CommandAction extends UndoableAction { + + private final Command command; + + public CommandAction(Command cmd) { + super("", ResourceLoaderWrapper.lookupIcon("Remove")); + this.command = cmd; + } + + public CommandAction(Command cmd, String name, Icon icon) { + super(name, icon); + + this.command = cmd; + } + + @Override + public void actionPerformed(ActionEvent e) { + super.actionPerformed(e); + command.execute(); + } + } } Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java?view=diff&pathrev=18216&r1=18215&r2=18216 ============================================================================== --- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java (original) +++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java 2010-04-07 10:27:16-0700 @@ -117,6 +117,10 @@ return getterSetterManager.getAddCommand(propertyName, umlElement); } + public List<Command> getAdditionalCommands() { + return getterSetterManager.getAdditionalCommands(propertyName, umlElement); + } + /* * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) */ 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=18216&r1=18215&r2=18216 ============================================================================== --- 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-04-07 10:27:16-0700 @@ -49,6 +49,7 @@ import javax.swing.JToolBar; import javax.swing.border.TitledBorder; +import org.apache.log4j.Logger; import org.argouml.application.helpers.ResourceLoaderWrapper; import org.argouml.core.propertypanels.meta.CheckBoxMeta; import org.argouml.core.propertypanels.meta.PanelMeta; @@ -65,6 +66,8 @@ * Creates the XML Property panels */ class SwingUIFactory { + + private static final Logger LOG = Logger.getLogger(SwingUIFactory.class); public SwingUIFactory() { @@ -79,31 +82,38 @@ public void createGUI ( final Object target, final JPanel panel) throws Exception { - PanelMeta data = - XMLPropPanelFactory.getInstance().getPropertyPanelsData( - Model.getMetaTypes().getName(target)); - - createLabel(target, panel); - - for (PropertyMeta prop : data.getProperties()) { - if ("text".equals(prop.getControlType())) { - buildTextboxPanel(panel, target, prop); - } else if ("combo".equals(prop.getControlType())) { - buildComboPanel(panel, target, prop); - } else if ("checkgroup".equals(prop.getControlType())) { - buildCheckGroup(panel, target, prop); - } else if ("optionbox".equals(prop.getControlType())) { - buildOptionBox(panel, target, prop); - } else if ("singlerow".equals(prop.getControlType())) { - buildSingleRow(panel, target, prop); - } else if ("list".equals(prop.getControlType())) { - buildList(panel, target, prop); - } else if ("textarea".equals(prop.getControlType())) { - buildTextArea(panel, target, prop); - } else if ("separator".equals(prop.getControlType())) { - panel.add(LabelledLayout.getSeparator()); + PanelMeta data = + XMLPropPanelFactory.getInstance().getPropertyPanelsData( + Model.getMetaTypes().getName(target)); + + createLabel(target, panel); + + for (PropertyMeta prop : data.getProperties()) { + try { + if ("text".equals(prop.getControlType())) { + buildTextboxPanel(panel, target, prop); + } else if ("combo".equals(prop.getControlType())) { + buildComboPanel(panel, target, prop); + } else if ("checkgroup".equals(prop.getControlType())) { + buildCheckGroup(panel, target, prop); + } else if ("optionbox".equals(prop.getControlType())) { + buildOptionBox(panel, target, prop); + } else if ("singlerow".equals(prop.getControlType())) { + buildSingleRow(panel, target, prop); + } else if ("list".equals(prop.getControlType())) { + buildList(panel, target, prop); + } else if ("textarea".equals(prop.getControlType())) { + buildTextArea(panel, target, prop); + } else if ("separator".equals(prop.getControlType())) { + panel.add(LabelledLayout.getSeparator()); + } + } catch (Exception e) { + throw new IllegalStateException( + "Exception caught building control " + prop.getControlType() + + " for property " + prop.getName() + " on panel for " + + target, e); + } } - } } /** @@ -113,13 +123,24 @@ */ private void createLabel (Object target, JPanel panel) { final String metaTypeName = Model.getMetaTypes().getName(target); - ToolBarFactory tbf = new ToolBarFactory(new Object[0]); + final ToolBarFactory tbf = new ToolBarFactory(new Object[0]); tbf.setRollover(true); - JToolBar tb = tbf.createToolBar(); - tb.add(new JLabel(metaTypeName, ResourceLoaderWrapper.lookupIconResource(metaTypeName), JLabel.LEFT)); + final JToolBar tb = tbf.createToolBar(); + final String label; + + if (Model.getFacade().isAPseudostate(target)) { + // TODO: We need some way of driving this from panel xml rather + // than hard coded test + Object pseudostateKind = Model.getFacade().getKind(target); + label = Model.getFacade().getName(pseudostateKind); + } else { + label = metaTypeName; + } + tb.add(new JLabel(label, ResourceLoaderWrapper.lookupIconResource(label), JLabel.LEFT)); if (!Model.getModelManagementHelper().isReadOnly(target)) { tb.add(new NavigateUpAction(target)); + // TODO: This should not be hard coded but should be driven from the panel xml if (Model.getFacade().isAAttribute(target) || Model.getFacade().isAOperation(target) || Model.getFacade().isAReception(target) Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCompositeStateSubvertexList.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCompositeStateSubvertexList.java?view=markup&pathrev=18215 Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCompositeStateSubvertexListModel.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCompositeStateSubvertexListModel.java?view=markup&pathrev=18215 ------------------------------------------------------ http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2513034 To unsubscribe from this discussion, e-mail: [[email protected]].
