Author: koen.aers(a)jboss.com
Date: 2008-10-16 10:14:51 -0400 (Thu, 16 Oct 2008)
New Revision: 10887
Added:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/common/
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/common/properties/
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/common/properties/DefaultFlowPropertySource.java
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
Log:
flow properties in properties view
Added:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/common/properties/DefaultFlowPropertySource.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/common/properties/DefaultFlowPropertySource.java
(rev 0)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/common/properties/DefaultFlowPropertySource.java 2008-10-16
14:14:51 UTC (rev 10887)
@@ -0,0 +1,50 @@
+package org.jboss.tools.common.properties;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+import org.jboss.tools.flow.common.wrapper.DefaultFlowWrapper;
+
+public class DefaultFlowPropertySource implements IPropertySource {
+
+ private static final String NAME =
"org.jboss.tools.flow.common.model.DefaultFlow.name";
+
+ private DefaultFlowWrapper wrapper = null;
+ private IPropertyDescriptor[] propertyDescriptors;
+
+ public DefaultFlowPropertySource(DefaultFlowWrapper wrapper) {
+ this.wrapper = wrapper;
+ }
+ public Object getEditableValue() {
+ return null;
+ }
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (propertyDescriptors == null) {
+ propertyDescriptors = new IPropertyDescriptor[] {
+ new TextPropertyDescriptor(NAME, "Name") {}
+ };
+ }
+ return propertyDescriptors;
+ }
+ public Object getPropertyValue(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName();
+ }
+ return null;
+ }
+ public boolean isPropertySet(Object id) {
+ if (NAME.equals(id)) {
+ return wrapper.getName() != null;
+ }
+ return false;
+ }
+ public void resetPropertyValue(Object id) {
+ }
+ public void setPropertyValue(Object id, Object value) {
+ if (NAME.equals(id)) {
+ if (value instanceof String) {
+ wrapper.setName((String)value);
+ }
+ }
+ }
+}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java 2008-10-16
14:02:38 UTC (rev 10886)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/registry/ElementRegistry.java 2008-10-16
14:14:51 UTC (rev 10887)
@@ -83,7 +83,7 @@
}
((Element)element).setMetaData("configurationElement",
configurationElement);
Wrapper result = new DefaultConnectionWrapper();
- result.setElement(element);
+ result.setElement((Element)element);
return result;
}
@@ -97,7 +97,7 @@
}
((Node)element).setMetaData("configurationElement", configurationElement);
DefaultNodeWrapper result = new DefaultNodeWrapper();
- result.setElement(element);
+ result.setElement((Element)element);
AcceptsIncomingConnectionStrategy acceptsIncomingConnectionStrategy =
createAcceptsIncomingConnectionStrategy(configurationElement);
if (acceptsIncomingConnectionStrategy != null) {
acceptsIncomingConnectionStrategy.setNode((Node)element);
@@ -122,7 +122,7 @@
}
((Element) element).setMetaData("configurationElement",
configurationElement);
DefaultContainerWrapper result = new DefaultContainerWrapper();
- result.setElement(element);
+ result.setElement((Element)element);
AcceptsElementStrategy acceptsElementStrategy =
createAcceptsElementStrategy(configurationElement);
if (acceptsElementStrategy != null) {
acceptsElementStrategy.setContainer((Container)element);
@@ -184,7 +184,7 @@
}
((Element) element).setMetaData("configurationElement",
configurationElement);
DefaultFlowWrapper result = new DefaultFlowWrapper();
- result.setElement(element);
+ result.setElement((Element)element);
AcceptsElementStrategy acceptsElementStrategy =
createAcceptsElementStrategy(configurationElement);
if (acceptsElementStrategy != null) {
acceptsElementStrategy.setContainer((Container)result.getElement());
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java 2008-10-16
14:02:38 UTC (rev 10886)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractConnectionWrapper.java 2008-10-16
14:14:51 UTC (rev 10887)
@@ -20,6 +20,7 @@
import java.util.List;
import org.eclipse.draw2d.geometry.Point;
+import org.jboss.tools.flow.common.model.Element;
/**
* A connection between two model elements.
@@ -30,17 +31,17 @@
private static final long serialVersionUID = 1L;
- private Object element;
+ private Element element;
private NodeWrapper source;
private NodeWrapper target;
private transient List<Point> bendpoints = new ArrayList<Point>();
private transient List<ModelListener> listeners = new
ArrayList<ModelListener>();
- public void setElement(Object element) {
+ public void setElement(Element element) {
this.element = element;
}
- public Object getElement() {
+ public Element getElement() {
return element;
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java 2008-10-16
14:02:38 UTC (rev 10886)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java 2008-10-16
14:14:51 UTC (rev 10887)
@@ -1,15 +1,25 @@
package org.jboss.tools.flow.common.wrapper;
+import org.jboss.tools.flow.common.model.Element;
+
public abstract class AbstractWrapper implements Wrapper {
- private Object element;
+ private Element element;
- public void setElement(Object element) {
+ public void setElement(Element element) {
this.element = element;
}
- public Object getElement() {
+ public Element getElement() {
return element;
}
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == Element.class) {
+ return element;
+ }
+ return null;
+ }
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java 2008-10-16
14:02:38 UTC (rev 10886)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java 2008-10-16
14:14:51 UTC (rev 10887)
@@ -1,5 +1,8 @@
package org.jboss.tools.flow.common.wrapper;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.jboss.tools.common.properties.DefaultFlowPropertySource;
+import org.jboss.tools.flow.common.model.DefaultFlow;
import org.jboss.tools.flow.common.model.Flow;
import org.jboss.tools.flow.common.model.Node;
import org.jboss.tools.flow.common.strategy.AcceptsElementStrategy;
@@ -7,6 +10,15 @@
public class DefaultFlowWrapper extends AbstractFlowWrapper {
private AcceptsElementStrategy acceptsElementStrategy;
+ private DefaultFlowPropertySource propertySource;
+
+ public String getName() {
+ return ((DefaultFlow)getElement()).getName();
+ }
+
+ public void setName(String name) {
+ ((DefaultFlow)getElement()).setName(name);
+ }
public Integer getRouterLayout() {
Integer routerLayout = (Integer)
((Flow)getElement()).getMetaData("routerLayout");
@@ -49,5 +61,20 @@
public void setAcceptsElementStrategy(AcceptsElementStrategy strategy) {
this.acceptsElementStrategy = strategy;
}
+
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySource.class) {
+ return getPropertySource();
+ }
+ return super.getAdapter(adapter);
+ }
+ private IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultFlowPropertySource(this);
+ }
+ return propertySource;
+ }
+
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java 2008-10-16
14:02:38 UTC (rev 10886)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java 2008-10-16
14:14:51 UTC (rev 10887)
@@ -28,9 +28,8 @@
return getNode().getName();
}
- public void internalSetName(String name) {
+ protected void internalSetName(String name) {
getNode().setName(name);
- notifyListeners(CHANGE_VISUAL);
}
protected void internalSetConstraint(Rectangle constraint) {
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java 2008-10-16
14:02:38 UTC (rev 10886)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java 2008-10-16
14:14:51 UTC (rev 10887)
@@ -1,9 +1,13 @@
package org.jboss.tools.flow.common.wrapper;
-public interface Wrapper {
+import org.eclipse.core.runtime.IAdaptable;
+import org.jboss.tools.flow.common.model.Element;
+
+
+public interface Wrapper extends IAdaptable {
- void setElement(Object element);
- Object getElement();
+ void setElement(Element element);
+ Element getElement();
void addListener(ModelListener listener);
void removeListener(ModelListener listener);
Show replies by date