svn commit: r17687 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-12-19 08:32:51-0800
New Revision: 17687
Added:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetter.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetterImpl.java
Removed:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLActionAsynchronousCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLActionSynchCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndNavigableCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndOrderingCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndTargetScopeCheckbox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLBehavioralFeatureQueryCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLClassActiveCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLDerivedCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLFeatureOwnerScopeCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementAbstractCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementLeafCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementRootCheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLTaggedValueCheckBox.java
Modified:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
Log:
Replace entire UMLComboBox hierarchy with ComboBox and GetterSetter
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java?view=markup&pathrev=17687
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java 2009-12-19 08:32:51-0800
@@ -0,0 +1,127 @@
+// $Id: Checkbox.java 15920 2008-10-14 18:03:33Z bobtarling $
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.Action;
+import javax.swing.JCheckBox;
+
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.ui.LookAndFeelMgr;
+import org.argouml.ui.UndoableAction;
+
+class CheckBox extends JCheckBox
+ implements PropertyChangeListener {
+
+ /**
+ * The class uid
+ */
+ private static final long serialVersionUID = 2654856740168885592L;
+
+ private Object target;
+ private String propertyName;
+
+ /**
+ * The action that will be called when the checkbox changes
+ */
+ private Action action;
+
+ private final GetterSetter getterSetter;
+
+ /**
+ * Constructor for UMLCheckBox.
+ * @param text the text of the check box
+ * @param a the action we're going to listen to
+ * @param name the property set name
+ */
+ public CheckBox(final String propertyName, final Object target, GetterSetter getterSetter) {
+ super(Translator.localize("label." + propertyName));
+
+ this.getterSetter = getterSetter;
+ this.propertyName = propertyName;
+ this.target = target;
+
+ setFont(LookAndFeelMgr.getInstance().getStandardFont());
+
+ build();
+
+ action = new SetAction(getterSetter, target, propertyName);
+ setActionCommand((String) action.getValue(Action.ACTION_COMMAND_KEY));
+ }
+
+ /**
+ * Add listeners when the component is placed on its parent
+ */
+ public void addNotify() {
+ addActionListener(action);
+ Model.getPump().addModelEventListener(
+ this, target, propertyName);
+ }
+
+ /**
+ * Remove all listeners when the component is removed from its parent
+ */
+ public void removeNotify() {
+ removeActionListener(action);
+ Model.getPump().removeModelEventListener(
+ this, target, propertyName);
+ }
+
+ /*
+ * The property value has changed so rebuild our view.
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent evt) {
+ build();
+ }
+
+ /*
+ * @see org.argouml.uml.ui.UMLCheckBox#buildModel()
+ */
+ private void build() {
+ if (getterSetter != null) {
+ setSelected((Boolean) getterSetter.get(target, propertyName));
+ }
+ }
+
+ private static class SetAction extends UndoableAction {
+
+ /**
+ * The class uid
+ */
+ private static final long serialVersionUID = -2708077474004286682L;
+
+ private final GetterSetter getterSetter;
+ private final String propertyName;
+ private Object target;
+
+ /**
+ * Constructor for ActionSetElementOwnershipSpecification.
+ */
+ protected SetAction(
+ final GetterSetter getterSetter,
+ final Object target,
+ final String propertyName) {
+ super(Translator.localize("Set"), null);
+ this.target = target;
+ this.getterSetter = getterSetter;
+ this.propertyName = propertyName;
+ // Set the tooltip string:
+ putValue(Action.SHORT_DESCRIPTION,
+ Translator.localize("Set"));
+ }
+
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ */
+ public void actionPerformed(ActionEvent e) {
+ super.actionPerformed(e);
+ CheckBox source = (CheckBox) e.getSource();
+ this.getterSetter.set(target, source.isSelected(), propertyName);
+ }
+ }
+}
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetter.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetter.java?view=markup&pathrev=17687
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetter.java 2009-12-19 08:32:51-0800
@@ -0,0 +1,24 @@
+package org.argouml.core.propertypanels.ui;
+
+abstract class GetterSetter {
+
+ /**
+ * Set a UML property by property name
+ * @param handle the element to which a property must be set
+ * @param value the new property value
+ * @param propertyName the property name
+ */
+ abstract void set(Object handle, Object value, String propertyName);
+
+ /**
+ * Get a UML property by property name
+ * @param handle the element from which a property must be return
+ * @param value the new property value
+ * @param propertyName the property name
+ */
+ abstract Object get(Object handle, String propertyName);
+
+ static GetterSetter getGetterSetter() {
+ return new GetterSetterImpl();
+ }
+}
\ No newline at end of file
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetterImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetterImpl.java?view=markup&pathrev=17687
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/GetterSetterImpl.java 2009-12-19 08:32:51-0800
@@ -0,0 +1,110 @@
+// $Id: PopupMenuNewEvent.java 15918 2008-10-14 06:40:41Z mvw $
+
+package org.argouml.core.propertypanels.ui;
+
+import org.argouml.model.Model;
+
+/**
+ * Property getters and setters
+ * @author Bob Tarling
+ */
+class GetterSetterImpl extends GetterSetter {
+
+ /**
+ * Set a UML property by property name
+ * @param handle the element to which a property must be set
+ * @param value the new property value
+ * @param propertyName the property name
+ */
+ public void set(Object handle, Object value, String propertyName) {
+ if ("isAbstract".equals(propertyName)) {
+ Model.getCoreHelper().setAbstract(handle, (Boolean) value);
+ } else if ("isLeaf".equals(propertyName)) {
+ Model.getCoreHelper().setLeaf(handle, (Boolean) value);
+ } else if ("isRoot".equals(propertyName)) {
+ Model.getCoreHelper().setRoot(handle, (Boolean) value);
+ } else if ("isActive".equals(propertyName)) {
+ Model.getCoreHelper().setActive(handle, (Boolean) value);
+ } else if ("ownerScope".equals(propertyName)) {
+ Model.getCoreHelper().setStatic(handle, (Boolean) value);
+ } else if ("targetScope".equals(propertyName)) {
+ // Have we handled UML2 here?
+ Model.getCoreHelper().setStatic(handle, (Boolean) value);
+ } else if ("isQuery".equals(propertyName)) {
+ Model.getCoreHelper().setQuery(handle, (Boolean) value);
+ } else if ("isNavigable".equals(propertyName)) {
+ Model.getCoreHelper().setNavigable(handle, (Boolean) value);
+ } else if ("ordering".equals(propertyName)) {
+ if ((Boolean) value) {
+ Model.getCoreHelper().setOrdering(handle,
+ Model.getOrderingKind().getOrdered());
+ } else {
+ Model.getCoreHelper().setOrdering(handle,
+ Model.getOrderingKind().getUnordered());
+ }
+ } else if ("isAsynchronous".equals(propertyName)) {
+ Model.getCommonBehaviorHelper().setAsynchronous(
+ handle,
+ (Boolean) value);
+ } else if ("isSynch".equals(propertyName)) {
+ Model.getActivityGraphsHelper().setSynch(
+ handle,
+ (Boolean) value);
+ } else if ("derived".equals(propertyName)) {
+ Object taggedValue = Model.getFacade().getTaggedValue(handle, (String) propertyName);
+ if (taggedValue == null) {
+ taggedValue =
+ Model.getExtensionMechanismsFactory().buildTaggedValue(
+ (String) propertyName, "");
+ Model.getExtensionMechanismsHelper().addTaggedValue(
+ handle, taggedValue);
+ }
+ if ((Boolean) value) {
+ Model.getCommonBehaviorHelper().setValue(taggedValue, "true");
+ } else {
+ Model.getCommonBehaviorHelper().setValue(taggedValue, "false");
+ }
+ }
+ }
+
+ /**
+ * Get a UML property by property name
+ * @param handle the element from which a property must be return
+ * @param value the new property value
+ * @param propertyName the property name
+ */
+ public Object get(Object handle, String propertyName) {
+ if ("isAbstract".equals(propertyName)) {
+ return Model.getFacade().isAbstract(handle);
+ } else if ("isLeaf".equals(propertyName)) {
+ return Model.getFacade().isLeaf(handle);
+ } else if ("isRoot".equals(propertyName)) {
+ return Model.getFacade().isRoot(handle);
+ } else if ("isActive".equals(propertyName)) {
+ return Model.getFacade().isActive(handle);
+ } else if ("ownerScope".equals(propertyName)) {
+ return Model.getFacade().isStatic(handle);
+ } else if ("targetScope".equals(propertyName)) {
+ // Have we handled UML2 here?
+ return Model.getFacade().isStatic(handle);
+ } else if ("isQuery".equals(propertyName)) {
+ return Model.getFacade().isQuery(handle);
+ } else if ("isNavigable".equals(propertyName)) {
+ return Model.getFacade().isNavigable(handle);
+ } else if ("ordering".equals(propertyName)) {
+ return Model.getFacade().getOrdering(handle) == Model.getOrderingKind().getOrdered();
+ } else if ("isAsynchronous".equals(propertyName)) {
+ return Model.getFacade().isAsynchronous(handle);
+ } else if ("isSynch".equals(propertyName)) {
+ return Model.getFacade().isSynch(handle);
+ } else if ("derived".equals(propertyName)) {
+ Object tv = Model.getFacade().getTaggedValue(handle, propertyName);
+ if (tv != null) {
+ String tag = Model.getFacade().getValueOfTag(tv);
+ return ("true".equals(tag));
+ }
+ return false;
+ }
+ return null;
+ }
+}
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=17687&r1=17686&r2=17687
==============================================================================
--- 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 2009-12-19 08:32:51-0800
@@ -275,40 +275,43 @@
final JPanel panel,
final Object target,
final CheckBoxMeta prop) {
- UMLCheckBox checkbox = null;
final String propertyName = prop.getName();
- if ("isAbstract".equals(propertyName)) {
- checkbox = new UMLGeneralizableElementAbstractCheckBox(propertyName, target);
+ GetterSetter getterSetter = GetterSetter.getGetterSetter();
+
+ CheckBox checkbox = null;
+ if ("derived".equals(propertyName)) {
+ checkbox = new CheckBox(propertyName, target, getterSetter);
+ } else if ("isAbstract".equals(propertyName)) {
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("isLeaf".equals(propertyName)) {
- checkbox = new UMLGeneralizableElementLeafCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("isRoot".equals(propertyName)) {
- checkbox = new UMLGeneralizableElementRootCheckBox(propertyName, target);
- } else if ("derived".equals(propertyName)) {
- checkbox = new UMLDerivedCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("isActive".equals(propertyName)) {
- checkbox = new UMLClassActiveCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("ownerScope".equals(propertyName)) {
- checkbox = new UMLFeatureOwnerScopeCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("targetScope".equals(propertyName)) {
// TODO: An alternative property name will need to be inserted for
// UML 2.x
- checkbox = new UMLAssociationEndTargetScopeCheckbox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("isQuery".equals(propertyName)) {
- checkbox = new UMLBehavioralFeatureQueryCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("isNavigable".equals(propertyName)) {
- checkbox = new UMLAssociationEndNavigableCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("ordering".equals(propertyName)) {
- checkbox = new UMLAssociationEndOrderingCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("isAsynchronous".equals(propertyName)) {
- checkbox = new UMLActionAsynchronousCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
} else if ("isSynch".equals(propertyName)) {
- checkbox = new UMLActionSynchCheckBox(propertyName, target);
+ checkbox = new CheckBox(propertyName, target, getterSetter);
+ } else if ("derived".equals(propertyName)) {
+ checkbox = new CheckBox(propertyName, target, getterSetter);
}
if (checkbox != null) {
- checkbox.setTarget(target);
panel.add(checkbox);
}
}
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLActionAsynchronousCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLActionAsynchronousCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLActionSynchCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLActionSynchCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndNavigableCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndNavigableCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndOrderingCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndOrderingCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndTargetScopeCheckbox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationEndTargetScopeCheckbox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLBehavioralFeatureQueryCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLBehavioralFeatureQueryCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLClassActiveCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLClassActiveCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLDerivedCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLDerivedCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLFeatureOwnerScopeCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLFeatureOwnerScopeCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementAbstractCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementAbstractCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementLeafCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementLeafCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementRootCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLGeneralizableElementRootCheckBox.java?view=markup&pathrev=17686
Removed: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLTaggedValueCheckBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLTaggedValueCheckBox.java?view=markup&pathrev=17686
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2431735
To unsubscribe from this discussion, e-mail: [[email protected]].