Author: koen.aers(a)jboss.com
Date: 2009-02-06 11:40:25 -0500 (Fri, 06 Feb 2009)
New Revision: 13516
Removed:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultConnectionWrapperPropertySource.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultLabelWrapperPropertySource.java
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.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/DefaultConnectionWrapper.java
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.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/DefaultLabelWrapper.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:
- make wrappers implement IPropertySource
- add change property event
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultConnectionWrapperPropertySource.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultConnectionWrapperPropertySource.java 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultConnectionWrapperPropertySource.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -1,11 +0,0 @@
-package org.jboss.tools.flow.common.properties;
-
-import org.jboss.tools.flow.common.wrapper.ConnectionWrapper;
-
-public class DefaultConnectionWrapperPropertySource extends WrapperPropertySource {
-
- public DefaultConnectionWrapperPropertySource(ConnectionWrapper wrapper) {
- super(wrapper);
- }
-
-}
Deleted:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultLabelWrapperPropertySource.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultLabelWrapperPropertySource.java 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/DefaultLabelWrapperPropertySource.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -1,22 +0,0 @@
-package org.jboss.tools.flow.common.properties;
-
-import org.jboss.tools.flow.common.wrapper.DefaultLabelWrapper;
-
-public class DefaultLabelWrapperPropertySource extends WrapperPropertySource implements
IPropertyId {
-
- private DefaultLabelWrapper wrapper = null;
-
- public DefaultLabelWrapperPropertySource(DefaultLabelWrapper wrapper) {
- super(wrapper);
- this.wrapper = wrapper;
- }
-
- public void setPropertyValue(Object id, Object value) {
- if (NAME.equals(id)) {
- if (value instanceof String) {
- wrapper.setText((String)value);
- }
- }
- super.setPropertyValue(id, value);
- }
-}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/properties/WrapperPropertySource.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -59,6 +59,7 @@
public void setPropertyValue(Object id, Object value) {
if (elementPropertySource != null) {
elementPropertySource.setPropertyValue(id, value);
+ wrapper.notifyListeners(Wrapper.CHANGE_PROPERTY, id);
}
}
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 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/AbstractWrapper.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -3,6 +3,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
import org.jboss.tools.flow.common.model.Element;
public abstract class AbstractWrapper implements Wrapper {
@@ -25,14 +27,57 @@
public void removeListener(ModelListener listener) {
listeners.remove(listener);
}
-
- protected void notifyListeners(int change, Object object) {
+
+ public void notifyListeners(int change, Object object) {
ModelEvent event = new ModelEvent(change, object);
for (ModelListener listener: listeners) {
listener.modelChanged(event);
}
}
+ public Object getEditableValue() {
+ if (getPropertySource() != null) {
+ getPropertySource().getEditableValue();
+ }
+ return null;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (getPropertySource() != null) {
+ return getPropertySource().getPropertyDescriptors();
+ }
+ return null;
+ }
+
+ public Object getPropertyValue(Object id) {
+ if (getPropertySource() != null) {
+ return getPropertySource().getPropertyValue(id);
+ }
+ return null;
+ }
+
+ public boolean isPropertySet(Object id) {
+ if (getPropertySource() != null) {
+ return getPropertySource().isPropertySet(id);
+ }
+ return false;
+ }
+
+ public void resetPropertyValue(Object id) {
+ if (getPropertySource() != null) {
+ getPropertySource().resetPropertyValue(id);
+ }
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+ if (getPropertySource() != null) {
+ getPropertySource().setPropertyValue(id, value);
+ notifyListeners(CHANGE_PROPERTY, id);
+ }
+ }
+
+ protected abstract IPropertySource getPropertySource();
+
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
if (adapter == Element.class) {
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultConnectionWrapper.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -9,12 +9,12 @@
import org.jboss.tools.flow.common.model.Connection;
import org.jboss.tools.flow.common.model.DefaultConnection;
import org.jboss.tools.flow.common.model.Node;
-import org.jboss.tools.flow.common.properties.DefaultConnectionWrapperPropertySource;
+import org.jboss.tools.flow.common.properties.WrapperPropertySource;
public class DefaultConnectionWrapper extends AbstractConnectionWrapper {
- private DefaultConnectionWrapperPropertySource propertySource;
+ private IPropertySource propertySource;
public Connection getConnection() {
return (Connection)getElement();
@@ -79,19 +79,19 @@
return result;
}
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new WrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class) {
- return getPropertySource();
+ return this;
}
return super.getAdapter(adapter);
}
- private IPropertySource getPropertySource() {
- if (propertySource == null) {
- propertySource = new DefaultConnectionWrapperPropertySource(this);
- }
- return propertySource;
- }
-
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultContainerWrapper.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -124,19 +124,19 @@
}
}
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultContainerWrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class) {
- return getPropertySource();
+ return this;
}
return super.getAdapter(adapter);
}
- private IPropertySource getPropertySource() {
- if (propertySource == null) {
- propertySource = new DefaultContainerWrapperPropertySource(this);
- }
- return propertySource;
- }
-
}
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 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultFlowWrapper.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -62,19 +62,19 @@
this.acceptsElementStrategy = strategy;
}
- @SuppressWarnings("unchecked")
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultFlowWrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
+ @SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class) {
- return getPropertySource();
+ return this;
}
return super.getAdapter(adapter);
}
- private IPropertySource getPropertySource() {
- if (propertySource == null) {
- propertySource = new DefaultFlowWrapperPropertySource(this);
- }
- return propertySource;
- }
-
}
Modified:
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java
===================================================================
---
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultLabelWrapper.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -2,40 +2,43 @@
import org.eclipse.ui.views.properties.IPropertySource;
import org.jboss.tools.flow.common.properties.IPropertyId;
+import org.jboss.tools.flow.common.properties.WrapperPropertySource;
-public class DefaultLabelWrapper extends AbstractLabelWrapper {
+public class DefaultLabelWrapper extends AbstractLabelWrapper implements ModelListener {
private IPropertySource propertySource;
public DefaultLabelWrapper(Wrapper owner) {
if (owner != null) {
- propertySource = (IPropertySource)owner.getAdapter(IPropertySource.class);
setElement(owner.getElement());
}
}
public void setText(String text) {
- if (propertySource != null) {
- propertySource.setPropertyValue(IPropertyId.LABEL, text);
- notifyListeners(CHANGE_VISUAL, text);
- }
+ getPropertySource().setPropertyValue(IPropertyId.LABEL, text);
}
public String getText() {
- String result = null;
- if (propertySource != null) {
- result = (String)propertySource.getPropertyValue(IPropertyId.LABEL);
- }
- return result;
+ return (String)getPropertySource().getPropertyValue(IPropertyId.LABEL);
}
+ public void modelChanged(ModelEvent event) {
+ notifyListeners(event.getChange(), event.getChangedObject());
+ }
+
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new WrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
- if (adapter == IPropertySource.class && propertySource != null) {
- return propertySource;
+ if (adapter == IPropertySource.class) {
+ return this;
}
return super.getAdapter(adapter);
}
-
}
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 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/DefaultNodeWrapper.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -107,19 +107,19 @@
((DefaultConnectionWrapper) connection).getConnection());
}
+ protected IPropertySource getPropertySource() {
+ if (propertySource == null) {
+ propertySource = new DefaultNodeWrapperPropertySource(this);
+ }
+ return propertySource;
+ }
+
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class) {
- return getPropertySource();
+ return this;
}
return super.getAdapter(adapter);
}
- private IPropertySource getPropertySource() {
- if (propertySource == null) {
- propertySource = new DefaultNodeWrapperPropertySource(this);
- }
- return propertySource;
- }
-
}
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 2009-02-06
16:35:31 UTC (rev 13515)
+++
trunk/flow/plugins/org.jboss.tools.flow.common/src/org/jboss/tools/flow/common/wrapper/Wrapper.java 2009-02-06
16:40:25 UTC (rev 13516)
@@ -1,10 +1,11 @@
package org.jboss.tools.flow.common.wrapper;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.views.properties.IPropertySource;
import org.jboss.tools.flow.common.model.Element;
-public interface Wrapper extends IAdaptable {
+public interface Wrapper extends IAdaptable, IPropertySource {
int ADD_INCOMING_CONNECTION = 1;
int REMOVE_INCOMING_CONNECTION = 2;
@@ -13,6 +14,7 @@
int CHANGE_VISUAL = 5;
int ADD_ELEMENT = 6;
int REMOVE_ELEMENT = 7;
+ int CHANGE_PROPERTY = 8;
@@ -21,6 +23,6 @@
void addListener(ModelListener listener);
void removeListener(ModelListener listener);
+ void notifyListeners(int changeId, Object changedObject);
-
}