[jboss-svn-commits] JBL Code SVN: r23424 - in labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow: common/editor/editpart and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Oct 10 08:22:07 EDT 2008
Author: KrisVerlaenen
Date: 2008-10-10 08:22:07 -0400 (Fri, 10 Oct 2008)
New Revision: 23424
Modified:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ConnectionWrapperEditPart.java
Log:
JBRULES-1799: Show (X)OR split constraint information as connection label
- connections use constraint name as label
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java 2008-10-10 12:21:45 UTC (rev 23423)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java 2008-10-10 12:22:07 UTC (rev 23424)
@@ -34,6 +34,7 @@
private static final long serialVersionUID = 400L;
public static final int CHANGE_BENDPOINTS = 1;
+ public static final int CHANGE_LABEL = 2;
private ElementWrapper source;
private ElementWrapper target;
@@ -134,7 +135,7 @@
listeners.remove(listener);
}
- protected void notifyListeners(int change) {
+ public void notifyListeners(int change) {
ModelEvent event = new ModelEvent(change);
for (Iterator it = listeners.iterator(); it.hasNext(); ) {
ModelListener listener = (ModelListener) it.next();
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java 2008-10-10 12:21:45 UTC (rev 23423)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java 2008-10-10 12:22:07 UTC (rev 23424)
@@ -71,6 +71,8 @@
public void modelChanged(ModelEvent event) {
if (event.getChange() == ElementConnection.CHANGE_BENDPOINTS) {
refreshBendpoints();
+ } else if (event.getChange() == ElementConnection.CHANGE_LABEL) {
+ refreshLabel();
}
}
@@ -83,7 +85,10 @@
((ElementConnection) getModel()).removeListener(this);
super.deactivate();
}
-
+
+ protected void refreshLabel() {
+ }
+
protected void refreshBendpoints() {
List bendpoints = ((ElementConnection) getModel()).getBendpoints();
List constraint = new ArrayList();
@@ -94,6 +99,7 @@
}
protected void refreshVisuals() {
+ refreshLabel();
refreshBendpoints();
}
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java 2008-10-10 12:21:45 UTC (rev 23423)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java 2008-10-10 12:22:07 UTC (rev 23424)
@@ -55,10 +55,10 @@
}
public void connect(ElementWrapper source, ElementWrapper target) {
+ connection = new ConnectionImpl(
+ ((NodeWrapper) source).getNode(), Node.CONNECTION_DEFAULT_TYPE,
+ ((NodeWrapper) target).getNode(), Node.CONNECTION_DEFAULT_TYPE);
super.connect(source, target);
- Node from = ((NodeWrapper) getSource()).getNode();
- Node to = ((NodeWrapper) getTarget()).getNode();
- connection = new ConnectionImpl(from, Node.CONNECTION_DEFAULT_TYPE, to, Node.CONNECTION_DEFAULT_TYPE);
}
protected List<Point> internalGetBendpoints() {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java 2008-10-10 12:21:45 UTC (rev 23423)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java 2008-10-10 12:22:07 UTC (rev 23424)
@@ -27,8 +27,10 @@
import org.drools.eclipse.flow.ruleflow.view.property.constraint.ConstraintsPropertyDescriptor;
import org.drools.workflow.core.Connection;
import org.drools.workflow.core.Constraint;
+import org.drools.workflow.core.Node;
import org.drools.workflow.core.WorkflowProcess;
import org.drools.workflow.core.node.Split;
+import org.drools.workflow.core.node.Split.ConnectionRef;
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
@@ -52,6 +54,38 @@
getSplit().setName("Split");
setDescriptors();
}
+
+ public void setNode(Node node) {
+ super.setNode(node);
+ for (Connection connection: getSplit().getDefaultOutgoingConnections()) {
+ String label = null;
+ Constraint constraint = getSplit().internalGetConstraint(
+ new ConnectionRef(connection.getTo().getId(), connection.getToType()));
+ if (constraint != null) {
+ label = constraint.getName();
+ }
+ connection.setMetaData("label", label);
+ }
+ }
+
+ private void updateConnectionLabels() {
+ for (ElementConnection connection: getOutgoingConnections()) {
+ updateConnectionLabel(connection);
+ }
+ }
+
+ private void updateConnectionLabel(ElementConnection connection) {
+ ConnectionWrapper connectionWrapper = (ConnectionWrapper) connection;
+ String label = null;
+ Constraint constraint = getSplit().internalGetConstraint(
+ new ConnectionRef(connectionWrapper.getConnection().getTo().getId(),
+ connectionWrapper.getConnection().getToType()));
+ if (constraint != null) {
+ label = constraint.getName();
+ }
+ connectionWrapper.getConnection().setMetaData("label", label);
+ connectionWrapper.notifyListeners(ElementConnection.CHANGE_LABEL);
+ }
private void setDescriptors() {
descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 1];
@@ -99,10 +133,12 @@
if (TYPE.equals(id)) {
getSplit().setType(Split.TYPE_UNDEFINED);
notifyListeners(CHANGE_TYPE);
+ updateConnectionLabels();
} else if (CONSTRAINTS.equals(id)) {
for (Connection connection: getSplit().getDefaultOutgoingConnections()) {
getSplit().setConstraint(connection, null);
}
+ updateConnectionLabels();
} else {
super.resetPropertyValue(id);
}
@@ -113,6 +149,7 @@
if (TYPE.equals(id)) {
getSplit().setType(((Integer) value).intValue());
notifyListeners(CHANGE_TYPE);
+ updateConnectionLabels();
} else if (CONSTRAINTS.equals(id)) {
Iterator<Map.Entry<Split.ConnectionRef, Constraint>> iterator = ((Map<Split.ConnectionRef, Constraint>) value).entrySet().iterator();
while (iterator.hasNext()) {
@@ -130,6 +167,7 @@
}
getSplit().setConstraint(outgoingConnection, (Constraint) element.getValue());
}
+ updateConnectionLabels();
} else {
super.setPropertyValue(id, value);
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ConnectionWrapperEditPart.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ConnectionWrapperEditPart.java 2008-10-10 12:21:45 UTC (rev 23423)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ConnectionWrapperEditPart.java 2008-10-10 12:22:07 UTC (rev 23424)
@@ -2,12 +2,50 @@
import org.drools.eclipse.flow.common.editor.core.ElementConnectionFactory;
import org.drools.eclipse.flow.common.editor.editpart.ElementConnectionEditPart;
+import org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper;
import org.drools.eclipse.flow.ruleflow.core.ConnectionWrapperFactory;
+import org.eclipse.draw2d.Connection;
+import org.eclipse.draw2d.ConnectionEndpointLocator;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Label;
public class ConnectionWrapperEditPart extends ElementConnectionEditPart {
+
+ private Label sourceLabel;
protected ElementConnectionFactory getDefaultElementConnectionFactory() {
return new ConnectionWrapperFactory();
}
+ public ConnectionWrapper getConnectionWrapper() {
+ return (ConnectionWrapper) getModel();
+ }
+
+ protected IFigure createFigure() {
+ Connection result = (Connection) super.createFigure();
+ // add connection label
+ String label = (String) getConnectionWrapper().getConnection().getMetaData("label");
+ if (label != null) {
+ ConnectionEndpointLocator sourceEndpointLocator = new ConnectionEndpointLocator(result, true);
+ sourceEndpointLocator.setVDistance(15);
+ sourceLabel = new Label(label);
+ result.add(sourceLabel, sourceEndpointLocator);
+ }
+ return result;
+ }
+
+ protected void refreshLabel() {
+ super.refreshLabel();
+ String label = (String) getConnectionWrapper().getConnection().getMetaData("label");
+ if (sourceLabel != null) {
+ sourceLabel.setText(label == null ? "" : label);
+ } else if (label != null) {
+ Connection connection = (Connection) getFigure();
+ ConnectionEndpointLocator endpointLocator = new ConnectionEndpointLocator(connection, true);
+ endpointLocator.setVDistance(15);
+ sourceLabel = new Label(label);
+ connection.add(sourceLabel, endpointLocator);
+ }
+ }
+
}
More information about the jboss-svn-commits
mailing list