svn commit: r17700 - trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels: meta model module ui
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-12-23 02:40:18-0800
New Revision: 17700
Added:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/OldScrollList.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListFactory.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListImpl.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java
Modified:
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/PropertyMeta.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XMLPropertyPanelsHandler.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XmlSinglePanelHandler.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/module/XmlPropertyPanelsModule.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ComponentFactory.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/RadioButtonPanel.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/ScrollList.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SingleListFactory.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SwingUIFactory.java
trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMutableLinkedList.java
Log:
First commit using a replacement ListModel and a ListGetterSetter - current implementation is only for Attribute and Operation. Other lists are still built with previous model implementation.
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/PropertyMeta.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/PropertyMeta.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/PropertyMeta.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/PropertyMeta.java 2009-12-23 02:40:18-0800
@@ -35,6 +35,7 @@
*/
public class PropertyMeta {
+ private String controlType;
private String type;
private String name;
@@ -42,11 +43,16 @@
// TODO: this is a tree node, we must refine the tree structure
- public PropertyMeta (String theType, String theName) {
- this.type = theType;
- this.name = theName;
+ public PropertyMeta (String controlType, String name, String type) {
+ this.controlType = controlType;
+ this.name = name;
+ this.type = type;
}
+ public String getControlType() {
+ return controlType;
+ }
+
public String getType() {
return type;
}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XMLPropertyPanelsHandler.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XMLPropertyPanelsHandler.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XMLPropertyPanelsHandler.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XMLPropertyPanelsHandler.java 2009-12-23 02:40:18-0800
@@ -59,7 +59,7 @@
current.addCheckbox(record);
} else {
PropertyMeta record =
- new PropertyMeta(localName, attr.getValue("name"));
+ new PropertyMeta(localName, attr.getValue("name"), attr.getValue("type"));
if (hasChildren(localName)) {
current = record;
}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XmlSinglePanelHandler.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XmlSinglePanelHandler.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XmlSinglePanelHandler.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/meta/XmlSinglePanelHandler.java 2009-12-23 02:40:18-0800
@@ -77,7 +77,7 @@
} else {
PropertyMeta record =
new PropertyMeta(localName,
- attr.getValue("name"));
+ attr.getValue("name"), attr.getValue("type"));
if (hasChildren(localName)) {
current = record;
}
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=17700&r1=17699&r2=17700
==============================================================================
--- 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 2009-12-23 02:40:18-0800
@@ -207,8 +207,8 @@
<!--
<list name="feature" type="Feature" />
-->
- <list name="attribute" type="Feature" />
- <list name="operation" type="Feature" />
+ <list name="feature" type="Attribute" />
+ <list name="feature" type="Operation" />
<list name="association" type="Classifier" />
<list name="ownedElement" type="ModelElement" />
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=17700&r1=17699&r2=17700
==============================================================================
--- 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 2009-12-23 02:40:18-0800
@@ -13,6 +13,8 @@
package org.argouml.core.propertypanels.model;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -32,18 +34,22 @@
* @param value the new property value
* @param propertyName the property name
*/
- public abstract void set(Object handle, Object value, String propertyName);
+ public abstract void set(Object umlElement, Object value, String propertyName);
/**
* Get a UML property by property name
- * @param handle the element from which a property must be return
+ * @param umlElement the element from which a property must be return
* @param value the new property value
* @param propertyName the property name
* @return the UML element or property
*/
- public abstract Object get(Object handle, String propertyName);
+ public abstract Object get(Object umlElement, String propertyName, String type);
- public abstract String[] getOptions(String propertyName);
+ public abstract Collection getOptions(Object umlElement, String propertyName, String type);
+
+ public abstract Object getMetaType(String propertyName);
+
+ public abstract boolean isValidElement(String propertyName, String type, Object umlElement);
public boolean contains(String propertyName) {
return getterSetterByPropertyName.containsKey(propertyName);
@@ -55,20 +61,27 @@
protected abstract class BaseGetterSetter {
- abstract Object get(Object modelElement);
+ abstract Object get(Object modelElement, String type);
abstract void set(Object modelElement, Object value);
}
- protected abstract class RadioGetterSetter extends BaseGetterSetter {
+ protected abstract class OptionGetterSetter extends BaseGetterSetter {
- private String[] options;
+ private Collection options;
- protected void setOptions(final String[] options) {
+ protected void setOptions(final Collection options) {
this.options = options;
}
- protected String[] getOptions() {
+ protected Collection getOptions(Object modelElement, String type) {
return options;
}
}
+
+
+ protected abstract class ListGetterSetter extends OptionGetterSetter {
+ abstract boolean isValidElement(Object modelElement, String type);
+ abstract Object getMetaType();
+ }
+
}
\ 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=17700&r1=17699&r2=17700
==============================================================================
--- 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 2009-12-23 02:40:18-0800
@@ -13,6 +13,10 @@
package org.argouml.core.propertypanels.model;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
import org.argouml.model.Model;
/**
@@ -50,6 +54,7 @@
addGetterSetter("kind", new ParameterDirectionGetterSetter());
addGetterSetter("changeability", new ChangeabilityGetterSetter());
addGetterSetter("concurrency", new ConcurrencyGetterSetter());
+ addGetterSetter("feature", new FeatureGetterSetter());
}
/**
@@ -80,30 +85,48 @@
* @param value the new property value
* @param propertyName the property name
*/
- public Object get(Object handle, String propertyName) {
+ public Object get(Object handle, String propertyName, String type) {
BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName);
if (bgs != null) {
- return bgs.get(handle);
+ return bgs.get(handle, type);
}
return null;
}
- public String[] getOptions(String propertyName) {
+ public Collection getOptions(Object umlElement, String propertyName, String type) {
BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName);
- if (bgs instanceof RadioGetterSetter) {
- return ((RadioGetterSetter) bgs).getOptions();
+ if (bgs instanceof OptionGetterSetter) {
+ return ((OptionGetterSetter) bgs).getOptions(umlElement, type);
}
return null;
}
+ public boolean isValidElement(String propertyName, String type, Object element) {
+ BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName);
+ if (bgs instanceof ListGetterSetter) {
+ return ((ListGetterSetter) bgs).isValidElement(element, type);
+ }
+
+ return false;
+ }
+
+ public Object getMetaType(String propertyName) {
+ BaseGetterSetter bgs = getterSetterByPropertyName.get(propertyName);
+ if (bgs instanceof ListGetterSetter) {
+ return ((ListGetterSetter) bgs).getMetaType();
+ }
+
+ return false;
+ }
+
/**
* The getter/setter for the Absrtact property
* @author Bob Tarling
*/
private class AbstractGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isAbstract(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -112,7 +135,7 @@
}
private class LeafGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isLeaf(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -121,7 +144,7 @@
}
private class RootGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isRoot(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -130,7 +153,7 @@
}
private class ActiveGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isActive(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -139,7 +162,7 @@
}
private class OwnerScopeGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isStatic(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -149,7 +172,7 @@
private class TargetScopeGetterSetter extends BaseGetterSetter {
// Have we handled UML2 here?
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isStatic(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -158,7 +181,7 @@
}
private class QueryGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isQuery(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -167,7 +190,7 @@
}
private class NavigableGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isNavigable(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -176,7 +199,7 @@
}
private class AsynchronousGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isAsynchronous(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -185,7 +208,7 @@
}
private class SynchGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().isSynch(modelElement);
}
public void set(Object modelElement, Object value) {
@@ -194,7 +217,7 @@
}
private class OrderingGetterSetter extends BaseGetterSetter {
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
return Model.getFacade().getOrdering(modelElement) ==
Model.getOrderingKind().getOrdered();
}
@@ -217,7 +240,7 @@
*/
private static final String TagName = "derived";
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
Object tv = Model.getFacade().getTaggedValue(modelElement, TagName);
if (tv != null) {
String tag = Model.getFacade().getValueOfTag(tv);
@@ -243,7 +266,7 @@
}
- public class VisibilityGetterSetter extends RadioGetterSetter {
+ public class VisibilityGetterSetter extends OptionGetterSetter {
/**
* Identifier for public visibility.
@@ -266,10 +289,10 @@
public static final String PACKAGE = "package";
public VisibilityGetterSetter() {
- setOptions(new String[] {PUBLIC, PACKAGE, PROTECTED, PRIVATE});
+ setOptions(Arrays.asList((new String[] {PUBLIC, PACKAGE, PROTECTED, PRIVATE})));
}
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
Object kind = Model.getFacade().getVisibility(modelElement);
if (kind == null) {
return null;
@@ -302,7 +325,7 @@
}
- private class AggregationGetterSetter extends RadioGetterSetter {
+ private class AggregationGetterSetter extends OptionGetterSetter {
/**
* Identifier for aggregate aggregation kind.
@@ -320,10 +343,10 @@
public static final String NONE = "none";
public AggregationGetterSetter() {
- setOptions(new String[] {AGGREGATE, COMPOSITE, NONE});
+ setOptions(Arrays.asList(new String[] {AGGREGATE, COMPOSITE, NONE}));
}
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
Object kind = Model.getFacade().getAggregation(modelElement);
if (kind == null) {
return null;
@@ -353,7 +376,7 @@
}
}
- private class ParameterDirectionGetterSetter extends RadioGetterSetter {
+ private class ParameterDirectionGetterSetter extends OptionGetterSetter {
/**
* Identifier for an "in" parameter.
@@ -376,14 +399,14 @@
public static final String RETURN = "return";
public ParameterDirectionGetterSetter() {
- setOptions(new String[] {
+ setOptions(Arrays.asList(new String[] {
IN,
OUT,
INOUT,
- RETURN});
+ RETURN}));
}
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
Object kind = Model.getFacade().getKind(modelElement);
if (kind == null) {
return null;
@@ -417,7 +440,7 @@
}
- private class ConcurrencyGetterSetter extends RadioGetterSetter {
+ private class ConcurrencyGetterSetter extends OptionGetterSetter {
/**
* Identifier for sequential concurrency.
@@ -435,13 +458,13 @@
public static final String CONCURRENT = "concurrent";
public ConcurrencyGetterSetter() {
- setOptions(new String[] {
+ setOptions(Arrays.asList(new String[] {
SEQUENTIAL,
GUARDED,
- CONCURRENT});
+ CONCURRENT}));
}
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
Object kind = Model.getFacade().getConcurrency(modelElement);
if (kind == null) {
return null;
@@ -470,7 +493,7 @@
}
- private class ChangeabilityGetterSetter extends RadioGetterSetter {
+ private class ChangeabilityGetterSetter extends OptionGetterSetter {
/**
* Identifier for addonly changeability.
@@ -489,10 +512,10 @@
public static final String FROZEN = "frozen";
public ChangeabilityGetterSetter() {
- setOptions(new String[] {ADDONLY, CHANGEABLE, FROZEN});
+ setOptions(Arrays.asList(new String[] {ADDONLY, CHANGEABLE, FROZEN}));
}
- public Object get(Object modelElement) {
+ public Object get(Object modelElement, String type) {
Object kind = Model.getFacade().getChangeability(modelElement);
if (kind == null) {
return null;
@@ -518,4 +541,43 @@
}
}
}
+
+ protected class FeatureGetterSetter extends ListGetterSetter {
+
+ public Collection getOptions(Object modelElement, String type) {
+ if ("Attribute".equals(type)) {
+ return Model.getFacade().getAttributes(modelElement);
+ } else if ("Operation".equals(type)) {
+ return Model.getFacade().getOperations(modelElement);
+ } else {
+ return Collections.EMPTY_LIST;
+ }
+ }
+
+ public Collection get(Object modelElement, String type) {
+ // not needed
+ return null;
+ }
+
+ public void set(Object element, Object x) {
+ // not needed
+ }
+
+ protected boolean isValidElement(Object element, String type) {
+
+ if ("Attribute".equals(type)
+ && !Model.getFacade().isAAttribute(element)) {
+ return false;
+ } else if ("Operation".equals(type)
+ && !Model.getFacade().isAOperation(element)) {
+ return false;
+ }
+
+ return get(element, type).contains(element);
+ }
+
+ public Object getMetaType() {
+ return Model.getMetaTypes().getAttribute();
+ }
+ }
}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/module/XmlPropertyPanelsModule.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/module/XmlPropertyPanelsModule.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/module/XmlPropertyPanelsModule.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/module/XmlPropertyPanelsModule.java 2009-12-23 02:40:18-0800
@@ -55,7 +55,7 @@
public boolean enable() {
- if (TabProps.replace) {
+// if (TabProps.replace) {
/* Set up the property panels for UML elements: */
try {
TabProps.disableCache();
@@ -66,15 +66,15 @@
LOG.error("Exception caught", e);
return false;
}
- } else {
- DetailsPane detailsPane = (DetailsPane) ProjectBrowser.getInstance().getDetailsPane();
- tempPanel = new TempTabPage();
- detailsPane.addTab(tempPanel, true);
-
- TempListener listener = new TempListener(tempPanel);
- TargetManager.getInstance().addTargetListener(listener);
- return true;
- }
+// } else {
+// DetailsPane detailsPane = (DetailsPane) ProjectBrowser.getInstance().getDetailsPane();
+// tempPanel = new TempTabPage();
+// detailsPane.addTab(tempPanel, true);
+//
+// TempListener listener = new TempListener(tempPanel);
+// TargetManager.getInstance().addTargetListener(listener);
+// return true;
+// }
}
public boolean disable() {
Modified: 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=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/CheckBox.java 2009-12-23 02:40:18-0800
@@ -112,7 +112,7 @@
*/
private void build() {
if (getterSetter != null) {
- setSelected((Boolean) getterSetter.get(modelElement, propertyName));
+ setSelected((Boolean) getterSetter.get(modelElement, propertyName, null));
}
}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ComponentFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ComponentFactory.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ComponentFactory.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ComponentFactory.java 2009-12-23 02:40:18-0800
@@ -41,5 +41,6 @@
*/
JComponent createComponent(
final Object modelElement,
- final String propName);
+ final String propName,
+ final String type);
}
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=17700&r1=17699&r2=17700
==============================================================================
--- 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 2009-12-23 02:40:18-0800
@@ -24,8 +24,11 @@
package org.argouml.core.propertypanels.ui;
+import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import javax.swing.JList;
+
+import org.argouml.core.propertypanels.model.GetterSetterManager;
import org.argouml.model.Model;
import org.argouml.uml.ui.behavior.use_cases.ActionAddExtendExtensionPoint;
import org.argouml.uml.ui.behavior.use_cases.ActionNewExtendExtensionPoint;
@@ -42,13 +45,14 @@
public JComponent createComponent(
final Object modelElement,
- final String propName) {
+ final String propName,
+ final String type) {
JComponent list = null;
- UMLModelElementListModel model = null;
+ DefaultListModel model = null;
if ("action".equals(propName)) {
model = new UMLActionSequenceActionListModel(modelElement);
- list = new ScrollList(new UMLActionSequenceActionList(model));
+ list = new OldScrollList(new UMLActionSequenceActionList((UMLModelElementListModel) model));
} else if ("actualArgument".equals(propName)) {
model = new UMLActionArgumentListModel(modelElement, propName);
} else if ("annotatedElement".equals(propName)) {
@@ -57,8 +61,8 @@
model = new UMLClassifierAssociationEndListModel(modelElement);
} else if ("associationRole".equals(propName)) {
model = new UMLAssociationAssociationRoleListModel(modelElement);
- } else if ("attribute".equals(propName)) {
- model = new UMLClassAttributeListModel(modelElement);
+// } else if ("attribute".equals(propName)) {
+// model = new UMLClassAttributeListModel(modelElement);
} else if ("availableContents".equals(propName)) {
model = new UMLClassifierRoleAvailableContentsListModel(modelElement);
} else if ("availableFeature".equals(propName)) {
@@ -85,26 +89,26 @@
model = new UMLSignalContextListModel(modelElement);
} else if ("deferrableEvent".equals(propName)) {
model = new UMLStateDeferrableEventListModel(modelElement);
- JList l = new UMLStateDeferrableEventList(model);
- list = new ScrollList(l);
+ JList l = new UMLStateDeferrableEventList((UMLModelElementListModel) model);
+ list = new OldScrollList(l);
} else if ("definedTag".equals(propName)) {
model = new UMLStereotypeTagDefinitionListModel(modelElement);
} else if ("deployedComponent".equals(propName)) {
model = new UMLNodeDeployedComponentListModel(modelElement);
} else if ("doActivity".equals(propName)) {
model = new UMLStateDoActivityListModel(modelElement);
- JList l = new UMLStateDoActivityList(model);
- list = new ScrollList(l);
+ JList l = new UMLStateDoActivityList((UMLModelElementListModel) model);
+ list = new OldScrollList(l);
} else if ("elementImport".equals(propName)) {
model = new UMLClassifierPackageImportsListModel(modelElement);
} else if ("entry".equals(propName)) {
model = new UMLStateEntryListModel(modelElement);
- JList l = new UMLStateEntryList(model);
- list = new ScrollList(l);
+ JList l = new UMLStateEntryList((UMLModelElementListModel) model);
+ list = new OldScrollList(l);
} else if ("exit".equals(propName)) {
model = new UMLStateExitListModel(modelElement);
- JList l = new UMLStateExitList(model);
- list = new ScrollList(l);
+ JList l = new UMLStateExitList((UMLModelElementListModel) model);
+ list = new OldScrollList(l);
} else if ("extend".equals(propName)) {
model = new UMLUseCaseExtendListModel(modelElement);
} else if ("extended_elements".equals(propName)) {
@@ -115,8 +119,8 @@
} else {
model = new UMLExtendExtensionPointListModel(modelElement, propName);
}
- } else if ("feature".equals(propName)) {
- model = new UMLClassifierFeatureListModel(modelElement);
+// } else if ("feature".equals(propName)) {
+// model = new UMLClassifierFeatureListModel(modelElement);
} else if ("generalization".equals(propName)) {
model = new UMLGeneralizableElementGeneralizationListModel(modelElement);
} else if ("include".equals(propName)) {
@@ -135,8 +139,8 @@
model = new UMLInteractionMessagesListModel(modelElement);
} else if ("method".equals(propName)) {
model = new UMLOperationMethodsListModel(modelElement);
- } else if ("operation".equals(propName)) {
- model = new UMLClassOperationListModel(modelElement);
+// } else if ("operation".equals(propName)) {
+// model = new UMLClassOperationListModel(modelElement);
} else if ("ownedElement".equals(propName)) {
model = new UMLNamespaceOwnedElementListModel(modelElement);
} else if ("outgoing".equals(propName)) {
@@ -163,7 +167,7 @@
model = new UMLComponentResidentListModel(modelElement);
} else if ("signal".equals(propName)) {
model = new UMLSignalEventSignalListModel(modelElement);
- list = new ScrollList(new UMLSignalEventSignalList(model));
+ list = new OldScrollList(new UMLSignalEventSignalList((UMLModelElementListModel) model));
} else if ("specialization".equals(propName)) {
model = new UMLGeneralizableElementSpecializationListModel(modelElement);
} else if ("specification".equals(propName)) {
@@ -172,8 +176,8 @@
model = new UMLStateMachineSubmachineStateListModel(modelElement);
} else if ("subvertex".equals(propName)) {
model = new UMLCompositeStateSubvertexListModel(modelElement);
- JList l = new UMLCompositeStateSubvertexList(model);
- list = new ScrollList(l);
+ JList l = new UMLCompositeStateSubvertexList((UMLModelElementListModel) model);
+ list = new OldScrollList(l);
} else if ("supplier".equals(propName)) {
model = new UMLDependencySupplierListModel(modelElement);
} else if ("supplierDependency".equals(propName)) {
@@ -190,6 +194,14 @@
model = new UMLModelElementTemplateParameterListModel(modelElement);
}
+ if (model == null) {
+ final GetterSetterManager getterSetterManager =
+ GetterSetterManager.getGetterSetter();
+ if (getterSetterManager.contains(propName)) {
+ model = new SimpleListModel(propName, type, modelElement, getterSetterManager);
+ }
+ }
+
if (list != null) {
return list;
}
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/OldScrollList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/OldScrollList.java?view=markup&pathrev=17700
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/OldScrollList.java 2009-12-23 02:40:18-0800
@@ -0,0 +1,161 @@
+// $Id: ScrollList.java 15914 2008-10-13 17:10:00Z bobtarling $
+// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.Point;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.ListModel;
+import javax.swing.ScrollPaneConstants;
+
+/**
+ * A scrollable list of items.<p>
+ * This makes sure that there is no horizontal
+ * scrollbar (which takes up too much screen real estate) and that sideways
+ * scrolling can be achieved instead with arrow keys.
+ * The component will automatically expand downward on mouse enter to
+ * give the user a view of as many items as possible.
+ *
+ * @author Bob Tarling
+ */
+class OldScrollList extends JScrollPane implements ScrollList, KeyListener {
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID = 6711776013279497682L;
+
+ /**
+ * The Component that this scroll is wrapping.
+ */
+ private UMLLinkedList list;
+
+ /**
+ * The height of the component when the mouse moved into it
+ */
+ int originalHeight;
+
+ /**
+ * Builds a JList from a given list model and wraps
+ * in a scrollable view.
+ * @param listModel The model from which to build the list
+ */
+ public OldScrollList(final DefaultListModel lm) {
+ setHorizontalScrollBarPolicy(
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ if (lm instanceof UMLModelElementListModel) {
+ UMLModelElementListModel listModel = (UMLModelElementListModel) lm;
+ if (listModel.getAddAction() == null && listModel.getNewAction() == null && listModel.getRemoveAction() == null) {
+ list = new UMLLinkedList(
+ listModel,
+ listModel.isShowIcon(),
+ listModel.isShowPath());
+ } else {
+ list = new UMLMutableLinkedList(
+ listModel,
+ listModel.getAddAction(),
+ listModel.getNewAction(),
+ listModel.getRemoveAction());
+ }
+ }
+ setViewportView(list);
+ }
+
+ /**
+ * Builds a JList from a given list model and wraps
+ * in a scrollable view.
+ * @param listModel The model from which to build the list
+ * @param visibleRowCount an integer specifying the preferred number of
+ * rows to display without requiring scrolling
+ */
+ public OldScrollList(ListModel listModel, int visibleRowCount) {
+ setHorizontalScrollBarPolicy(
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ list = new UMLLinkedList(listModel, true, true);
+ list.setVisibleRowCount(visibleRowCount);
+ setViewportView(list);
+ }
+
+ /**
+ * Builds a ScrollList from a given list model and wraps
+ * in a scrollable view.
+ * @param list The JList to wrap in a scroll
+ * @deprecated in 0.27.2 use any other ScrollList constructor
+ */
+ @Deprecated
+ public OldScrollList(JList alist) {
+ setHorizontalScrollBarPolicy(
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ this.list = (UMLLinkedList) alist;
+ setViewportView(list);
+ }
+
+ public ListModel getListModel() {
+ return list.getModel();
+ }
+
+
+ /**
+ * Examine key event to scroll left or right depending on key press
+ * @param e the key event to examine
+ */
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ final Point posn = getViewport().getViewPosition();
+ if (posn.x > 0) {
+ getViewport().setViewPosition(new Point(posn.x - 1, posn.y));
+ }
+ } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
+ final Point posn = getViewport().getViewPosition();
+ if (list.getWidth() - posn.x > getViewport().getWidth()) {
+ getViewport().setViewPosition(new Point(posn.x + 1, posn.y));
+ }
+ }
+ }
+
+ public void keyReleased(KeyEvent arg0) {
+ }
+
+ public void keyTyped(KeyEvent arg0) {
+ }
+
+ public void addNotify() {
+ super.addNotify();
+ list.addKeyListener(this);
+ }
+
+ public void removeNotify() {
+ super.removeNotify();
+ list.removeKeyListener(this);
+ }
+
+ public JList getList() {
+ return list;
+ }
+}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RadioButtonPanel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RadioButtonPanel.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RadioButtonPanel.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/RadioButtonPanel.java 2009-12-23 02:40:18-0800
@@ -19,6 +19,7 @@
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Collection;
import java.util.Enumeration;
import javax.swing.AbstractButton;
@@ -86,11 +87,12 @@
super(true);
setDoubleBuffered(true);
- final String[] options = getterSetterManager.getOptions(propertyName);
+ final Collection options =
+ getterSetterManager.getOptions(umlElement, propertyName, null);
setLayout(horizontal
? new GridLayout()
- : new FlexiGridLayout(0, options.length));
+ : new FlexiGridLayout(0, options.size()));
this.propertyName = propertyName;
this.getterSetterManager = getterSetterManager;
@@ -108,14 +110,14 @@
buttonGroup.add(new JRadioButton());
- for (String option : options) {
+ for (Object option : options) {
final String optionLabel =
Translator.localize("label." + propertyName + "-" + option);
final JRadioButton button = new JRadioButton(optionLabel);
button.addActionListener(action);
- button.setActionCommand(option);
+ button.setActionCommand((String) option);
button.setFont(font);
- button.setName(option);
+ button.setName((String) option);
buttonGroup.add(button);
add(button);
}
@@ -163,7 +165,7 @@
private void build() {
final String value =
- (String) getGetterSetter().get(umlElement, propertyName);
+ (String) getGetterSetter().get(umlElement, propertyName, null);
final Enumeration<AbstractButton> en =
buttonGroup.getElements();
if (value == null) {
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=17700&r1=17699&r2=17700
==============================================================================
--- 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 2009-12-23 02:40:18-0800
@@ -35,7 +35,9 @@
import java.util.Arrays;
import javax.swing.Action;
+import javax.swing.DefaultListModel;
import javax.swing.Icon;
+import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
@@ -201,7 +203,7 @@
* Constructor
* @param model The single item list model
*/
- public RowSelector(UMLModelElementListModel model) {
+ public RowSelector(DefaultListModel model) {
this(model, false, true);
}
@@ -210,13 +212,23 @@
* @param model The single item list model
* @param singleRow true if we only ever want a single row
*/
- public RowSelector(UMLModelElementListModel model, boolean expanded, boolean expandable) {
+ public RowSelector(DefaultListModel model, boolean expanded, boolean expandable) {
super(new BorderLayout());
this.expandable = expandable;
+ Object metaType = null;
- target = model.getTarget();
- Object metaType = model.getMetaType();
+ if (model instanceof UMLModelElementListModel) {
+ target = ((UMLModelElementListModel) model).getTarget();
+ metaType = ((UMLModelElementListModel) model).getMetaType();
+ scroll = new OldScrollList(model, 1);
+ } else if (model instanceof org.argouml.core.propertypanels.ui.SimpleListModel) {
+ target = ((org.argouml.core.propertypanels.ui.SimpleListModel) model).getUmlElement();
+ metaType = ((org.argouml.core.propertypanels.ui.SimpleListModel) model).getMetaType();
+ scroll = new ScrollListImpl(model, 1);
+ } else {
+ target = null;
+ }
LOG.info("Creating list for " + target);
@@ -224,23 +236,24 @@
LOG.info("metatype = " + metaType);
LOG.info("target = " + target);
- scroll = new ScrollList(model, 1);
- add(scroll);
+ add((JComponent) scroll);
- shrunkPreferredSize = scroll.getPreferredSize();
+ shrunkPreferredSize = ((JComponent) scroll).getPreferredSize();
- remove(scroll);
- scroll = new ScrollList(model);
+ remove(((JComponent) scroll));
- add(scroll);
- expandedPreferredSize = scroll.getPreferredSize();
- expandedMaximumSize = scroll.getMaximumSize();
+ scroll = ScrollListFactory.create(model);
+ JScrollPane jscroll = ((JScrollPane) scroll);
+
+ add(jscroll);
+ expandedPreferredSize = jscroll.getPreferredSize();
+ expandedMaximumSize = jscroll.getMaximumSize();
- scroll.setHorizontalScrollBarPolicy(
+ jscroll.setHorizontalScrollBarPolicy(
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
if (!expandable && !expanded) {
- scroll.setVerticalScrollBarPolicy(
+ jscroll.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_NEVER);
expander = null;
toolbar = null;
@@ -411,7 +424,11 @@
}
this.removeMouseListener(this);
getModel().removeListDataListener(this);
- ((UMLModelElementListModel) getModel()).removeModelEventListener();
+ if (getModel() instanceof UMLModelElementListModel) {
+ ((UMLModelElementListModel) getModel()).removeModelEventListener();
+ } else {
+ ((org.argouml.core.propertypanels.ui.SimpleListModel) getModel()).removeModelEventListener();
+ }
}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollList.java 2009-12-23 02:40:18-0800
@@ -1,45 +1,16 @@
-// $Id: ScrollList.java 15914 2008-10-13 17:10:00Z bobtarling $
-// Copyright (c) 1996-2007 The Regents of the University of California. All
-// Rights Reserved. Permission to use, copy, modify, and distribute this
-// software and its documentation without fee, and without a written
-// agreement is hereby granted, provided that the above copyright notice
-// and this paragraph appear in all copies. This software program and
-// documentation are copyrighted by The Regents of the University of
-// California. The software program and documentation are supplied "AS
-// IS", without any accompanying services from The Regents. The Regents
-// does not warrant that the operation of the program will be
-// uninterrupted or error-free. The end-user understands that the program
-// was developed for research purposes and is advised not to rely
-// exclusively on the program for any reason. IN NO EVENT SHALL THE
-// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
-// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
-// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
-// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
-// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
-// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
-// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
package org.argouml.core.propertypanels.ui;
-import java.awt.Container;
import java.awt.Point;
-import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.awt.event.MouseMotionListener;
+import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.ListModel;
import javax.swing.ScrollPaneConstants;
-import org.apache.log4j.Logger;
-
/**
* A scrollable list of items.<p>
* This makes sure that there is no horizontal
@@ -50,117 +21,6 @@
*
* @author Bob Tarling
*/
-class ScrollList extends JScrollPane implements KeyListener {
-
- private static final Logger LOG = Logger.getLogger(ScrollList.class);
-
- /**
- * The UID.
- */
- private static final long serialVersionUID = 6711776013279497682L;
-
- /**
- * The Component that this scroll is wrapping.
- */
- private UMLLinkedList list;
-
- /**
- * The height of the component when the mouse moved into it
- */
- int originalHeight;
-
- /**
- * Builds a JList from a given list model and wraps
- * in a scrollable view.
- * @param listModel The model from which to build the list
- */
- public ScrollList(final UMLModelElementListModel listModel) {
- setHorizontalScrollBarPolicy(
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- if (listModel.getAddAction() == null && listModel.getNewAction() == null && listModel.getRemoveAction() == null) {
- list = new UMLLinkedList(
- listModel,
- listModel.isShowIcon(),
- listModel.isShowPath());
- } else {
- list = new UMLMutableLinkedList(
- listModel,
- listModel.getAddAction(),
- listModel.getNewAction(),
- listModel.getRemoveAction());
- }
- setViewportView(list);
- }
-
- /**
- * Builds a JList from a given list model and wraps
- * in a scrollable view.
- * @param listModel The model from which to build the list
- * @param visibleRowCount an integer specifying the preferred number of
- * rows to display without requiring scrolling
- */
- public ScrollList(ListModel listModel, int visibleRowCount) {
- setHorizontalScrollBarPolicy(
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- list = new UMLLinkedList(listModel, true, true);
- list.setVisibleRowCount(visibleRowCount);
- setViewportView(list);
- }
-
- /**
- * Builds a ScrollList from a given list model and wraps
- * in a scrollable view.
- * @param list The JList to wrap in a scroll
- * @deprecated in 0.27.2 use any other ScrollList constructor
- */
- @Deprecated
- public ScrollList(JList alist) {
- setHorizontalScrollBarPolicy(
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- this.list = (UMLLinkedList) alist;
- setViewportView(list);
- }
-
- public ListModel getListModel() {
- return list.getModel();
- }
-
-
- /**
- * Examine key event to scroll left or right depending on key press
- * @param e the key event to examine
- */
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_LEFT) {
- final Point posn = getViewport().getViewPosition();
- if (posn.x > 0) {
- getViewport().setViewPosition(new Point(posn.x - 1, posn.y));
- }
- } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
- final Point posn = getViewport().getViewPosition();
- if (list.getWidth() - posn.x > getViewport().getWidth()) {
- getViewport().setViewPosition(new Point(posn.x + 1, posn.y));
- }
- }
- }
-
- public void keyReleased(KeyEvent arg0) {
- }
-
- public void keyTyped(KeyEvent arg0) {
- }
-
- public void addNotify() {
- super.addNotify();
- list.addKeyListener(this);
- }
-
- public void removeNotify() {
- super.removeNotify();
- list.removeKeyListener(this);
- }
-
- JList getList() {
- return list;
- }
+interface ScrollList {
+ JList getList();
}
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListFactory.java?view=markup&pathrev=17700
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListFactory.java 2009-12-23 02:40:18-0800
@@ -0,0 +1,16 @@
+package org.argouml.core.propertypanels.ui;
+
+import javax.swing.DefaultListModel;
+
+class ScrollListFactory {
+
+ static ScrollList create(DefaultListModel model) {
+ if (model instanceof UMLModelElementListModel) {
+ return new OldScrollList(model);
+ } else if (model instanceof org.argouml.core.propertypanels.ui.SimpleListModel) {
+ return new ScrollListImpl(
+ (org.argouml.core.propertypanels.ui.SimpleListModel) model);
+ }
+ return null;
+ }
+}
Added: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListImpl.java?view=markup&pathrev=17700
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/ScrollListImpl.java 2009-12-23 02:40:18-0800
@@ -0,0 +1,150 @@
+// $Id: ScrollList.java 15914 2008-10-13 17:10:00Z bobtarling $
+// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.core.propertypanels.ui;
+
+import java.awt.Point;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.ListModel;
+import javax.swing.ScrollPaneConstants;
+
+/**
+ * A scrollable list of items.<p>
+ * This makes sure that there is no horizontal
+ * scrollbar (which takes up too much screen real estate) and that sideways
+ * scrolling can be achieved instead with arrow keys.
+ * The component will automatically expand downward on mouse enter to
+ * give the user a view of as many items as possible.
+ *
+ * @author Bob Tarling
+ */
+class ScrollListImpl extends JScrollPane implements ScrollList, KeyListener {
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID = 6711776013279497682L;
+
+ /**
+ * The Component that this scroll is wrapping.
+ */
+ private UMLLinkedList list;
+
+ /**
+ * The height of the component when the mouse moved into it
+ */
+ int originalHeight;
+
+ /**
+ * Builds a JList from a given list model and wraps
+ * in a scrollable view.
+ * @param listModel The model from which to build the list
+ */
+ public ScrollListImpl(final org.argouml.core.propertypanels.ui.SimpleListModel listModel) {
+ setHorizontalScrollBarPolicy(
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ list = new UMLLinkedList(
+ listModel,
+ true,
+ false);
+ setViewportView(list);
+ }
+
+ /**
+ * Builds a JList from a given list model and wraps
+ * in a scrollable view.
+ * @param listModel The model from which to build the list
+ * @param visibleRowCount an integer specifying the preferred number of
+ * rows to display without requiring scrolling
+ */
+ public ScrollListImpl(ListModel listModel, int visibleRowCount) {
+ setHorizontalScrollBarPolicy(
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ list = new UMLLinkedList(listModel, true, true);
+ list.setVisibleRowCount(visibleRowCount);
+ setViewportView(list);
+ }
+
+ /**
+ * Builds a ScrollList from a given list model and wraps
+ * in a scrollable view.
+ * @param list The JList to wrap in a scroll
+ * @deprecated in 0.27.2 use any other ScrollList constructor
+ */
+ @Deprecated
+ public ScrollListImpl(JList alist) {
+ setHorizontalScrollBarPolicy(
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ this.list = (UMLLinkedList) alist;
+ setViewportView(list);
+ }
+
+ public ListModel getListModel() {
+ return list.getModel();
+ }
+
+
+ /**
+ * Examine key event to scroll left or right depending on key press
+ * @param e the key event to examine
+ */
+ public void keyPressed(KeyEvent e) {
+ if (e.getKeyCode() == KeyEvent.VK_LEFT) {
+ final Point posn = getViewport().getViewPosition();
+ if (posn.x > 0) {
+ getViewport().setViewPosition(new Point(posn.x - 1, posn.y));
+ }
+ } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
+ final Point posn = getViewport().getViewPosition();
+ if (list.getWidth() - posn.x > getViewport().getWidth()) {
+ getViewport().setViewPosition(new Point(posn.x + 1, posn.y));
+ }
+ }
+ }
+
+ public void keyReleased(KeyEvent arg0) {
+ }
+
+ public void keyTyped(KeyEvent arg0) {
+ }
+
+ public void addNotify() {
+ super.addNotify();
+ list.addKeyListener(this);
+ }
+
+ public void removeNotify() {
+ super.removeNotify();
+ list.removeKeyListener(this);
+ }
+
+ public JList getList() {
+ return list;
+ }
+}
Added: 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=markup&pathrev=17700
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SimpleListModel.java 2009-12-23 02:40:18-0800
@@ -0,0 +1,116 @@
+/* $Id$
+ *******************************************************************************
+ * Copyright (c) 2009 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 - Original implementation
+ *******************************************************************************
+ */
+
+package org.argouml.core.propertypanels.ui;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collection;
+import javax.swing.DefaultListModel;
+import javax.swing.SwingUtilities;
+
+import org.apache.log4j.Logger;
+import org.argouml.core.propertypanels.model.GetterSetterManager;
+import org.argouml.model.InvalidElementException;
+import org.argouml.model.Model;
+import org.argouml.model.RemoveAssociationEvent;
+
+/**
+ * The simplest model for a list of UML elements
+ */
+class SimpleListModel
+ extends DefaultListModel implements PropertyChangeListener {
+
+ /**
+ * The class uid
+ */
+ private static final long serialVersionUID = -8491023641828449064L;
+
+ private static final Logger LOG = Logger.getLogger(SimpleListModel.class);
+
+ /**
+ * A string indicator of the type of model element this control is to hold
+ */
+ private final String type;
+
+ private final Object umlElement;
+ private final String propertyName;
+
+ final private GetterSetterManager getterSetterManager;
+
+ SimpleListModel(
+ final String propertyName,
+ final String type,
+ final Object umlElement,
+ final GetterSetterManager getterSetterManager) {
+ super();
+ this.getterSetterManager = getterSetterManager;
+ this.type = type;
+ this.propertyName = propertyName;
+ this.umlElement = umlElement;
+
+ build();
+
+ Model.getPump().addModelEventListener(this, umlElement, propertyName);
+ }
+
+ public void removeModelEventListener() {
+ Model.getPump().removeModelEventListener(this, umlElement, propertyName);
+ }
+
+ public Object getMetaType() {
+ return getterSetterManager.getMetaType(propertyName);
+ }
+
+ /*
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ public void propertyChange(final PropertyChangeEvent e) {
+ Runnable doWorkRunnable = new Runnable() {
+ public void run() {
+ try {
+ if (e instanceof RemoveAssociationEvent) {
+ removeElement(
+ ((RemoveAssociationEvent) e).getChangedValue());
+ }
+ } catch (InvalidElementException e) {
+ LOG.debug("propertyChange accessed a deleted element ", e);
+ }
+ }
+ };
+ SwingUtilities.invokeLater(doWorkRunnable);
+ }
+
+ /**
+ * Delete and rebuild the model list from scratch.
+ */
+ private void build() {
+ try {
+ final Collection c = (Collection) getterSetterManager.getOptions(
+ umlElement,
+ propertyName,
+ type);
+ for (Object o : c) {
+ addElement(o);
+ }
+ } catch (InvalidElementException exception) {
+ LOG.debug("buildModelList threw exception for target "
+ + umlElement + ": "
+ + exception);
+ }
+ }
+
+ public Object getUmlElement() {
+ return umlElement;
+ }
+}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SingleListFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SingleListFactory.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SingleListFactory.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/SingleListFactory.java 2009-12-23 02:40:18-0800
@@ -35,7 +35,8 @@
public JComponent createComponent(
final Object modelElement,
- final String propName) {
+ final String propName,
+ final String type) {
UMLModelElementListModel model = 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=17700&r1=17699&r2=17700
==============================================================================
--- 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-23 02:40:18-0800
@@ -75,21 +75,21 @@
Model.getMetaTypes().getName(target));
for (PropertyMeta prop : data.getProperties()) {
- if ("text".equals(prop.getType())) {
+ if ("text".equals(prop.getControlType())) {
buildTextboxPanel(panel, target, prop);
- } else if ("combo".equals(prop.getType())) {
+ } else if ("combo".equals(prop.getControlType())) {
buildComboPanel(panel, target, prop);
- } else if ("checkgroup".equals(prop.getType())) {
+ } else if ("checkgroup".equals(prop.getControlType())) {
buildCheckGroup(panel, target, prop);
- } else if ("optionbox".equals(prop.getType())) {
+ } else if ("optionbox".equals(prop.getControlType())) {
buildOptionBox(panel, target, prop);
- } else if ("singlerow".equals(prop.getType())) {
+ } else if ("singlerow".equals(prop.getControlType())) {
buildSingleRow(panel, target, prop);
- } else if ("list".equals(prop.getType())) {
+ } else if ("list".equals(prop.getControlType())) {
buildList(panel, target, prop);
- } else if ("textarea".equals(prop.getType())) {
+ } else if ("textarea".equals(prop.getControlType())) {
buildTextArea(panel, target, prop);
- } else if ("separator".equals(prop.getType())) {
+ } else if ("separator".equals(prop.getControlType())) {
panel.add(LabelledLayout.getSeparator());
}
}
@@ -179,7 +179,7 @@
final SingleListFactory factory = new SingleListFactory();
final JComponent pane =
- factory.createComponent(target, prop.getName());
+ factory.createComponent(target, prop.getName(), prop.getType());
if (pane != null) {
addControl(panel, prop.getName(), pane);
@@ -192,8 +192,8 @@
final ListFactory factory = new ListFactory();
final JComponent list =
- factory.createComponent(target, prop.getName());
-
+ factory.createComponent(target, prop.getName(), prop.getType());
+
if (list != null) {
addControl(panel, prop.getName(), list);
}
Modified: trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMutableLinkedList.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMutableLinkedList.java?view=diff&pathrev=17700&r1=17699&r2=17700
==============================================================================
--- trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMutableLinkedList.java (original)
+++ trunk/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLMutableLinkedList.java 2009-12-23 02:40:18-0800
@@ -30,6 +30,7 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+import javax.swing.DefaultListModel;
import javax.swing.JPopupMenu;
import org.apache.log4j.Logger;
@@ -115,7 +116,7 @@
* @param theDeleteAction the action for deleting
* @param showIcon true if an icon should be shown
*/
- public UMLMutableLinkedList(UMLModelElementListModel dataModel,
+ public UMLMutableLinkedList(DefaultListModel dataModel,
AbstractActionAddModelElement2 theAddAction,
AbstractActionNewModelElement theNewAction,
AbstractActionRemoveElement theDeleteAction) {
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2432589
To unsubscribe from this discussion, e-mail: [[email protected]].