[jboss-svn-commits] JBL Code SVN: r19904 - in labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin: src/main/java/org/drools/eclipse and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu May 8 08:06:22 EDT 2008
Author: KrisVerlaenen
Date: 2008-05-08 08:06:21 -0400 (Thu, 08 May 2008)
New Revision: 19904
Added:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/FixedConnectionAnchor.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/CompositeNodeEditPart.java
Modified:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/.classpath
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/WorkItemDefinitions.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstanceViewer.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstancesView.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementContainerFigure.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/AbstractNodeWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/CompositeNodeWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/DefaultNodeWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.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/core/StartNodeWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/TimerWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/WorkItemWrapper.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/WorkItemEditPart.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java
Log:
JBRULES-1549: Workflow Context
- swimlanes and exception scope as context
JBRULES-1550: Workflow timer
- timer node
JBRULES-1465: RuleFlow work items should allow plugging in custom editors
- Work items palette customizable by user
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/.classpath 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/.classpath 2008-05-08 12:06:21 UTC (rev 19904)
@@ -2,8 +2,6 @@
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
- <classpathentry combineaccessrules="false" kind="src" path="/drools-compiler"/>
- <classpathentry combineaccessrules="false" kind="src" path="/drools-core"/>
<classpathentry exported="true" kind="lib" path="lib/drools-compiler.jar" sourcepath="/drools-compiler"/>
<classpathentry exported="true" kind="lib" path="lib/drools-core.jar" sourcepath="/drools-core"/>
<classpathentry exported="true" kind="lib" path="lib/drools-decisiontables.jar"/>
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml 2008-05-08 12:06:21 UTC (rev 19904)
@@ -431,7 +431,7 @@
extensions="rf, ruleflow, rflow"
icon="icons/process.gif"
contributorClass="org.drools.eclipse.flow.common.editor.GenericActionBarContributor"
- class="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor2"
+ class="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor"
id="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor">
</editor>
</extension>
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/WorkItemDefinitions.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/WorkItemDefinitions.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/WorkItemDefinitions.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -9,6 +9,7 @@
import org.drools.process.core.WorkDefinition;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
@@ -18,26 +19,31 @@
}
public static Map<String, WorkDefinition> getWorkDefinitions(IResource resource) {
- return getWorkDefinitions(resource == null ? null : resource.getProject());
+ IProject project = resource.getProject();
+ if (project != null) {
+ try {
+ if (project.getNature("org.eclipse.jdt.core.javanature") != null) {
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject != null && javaProject.exists()) {
+ return getWorkDefinitions(javaProject);
+ }
+ }
+ } catch (CoreException e) {
+ DroolsEclipsePlugin.log(e);
+ }
+ }
+ return null;
}
- public static Map<String, WorkDefinition> getWorkDefinitions(IProject project) {
+ public static Map<String, WorkDefinition> getWorkDefinitions(IJavaProject project) {
if (project != null) {
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
+ ClassLoader newLoader = ProjectClassLoader.getProjectClassLoader(project);
try {
- if (project.getNature("org.eclipse.jdt.core.javanature") != null) {
- IJavaProject javaProject = JavaCore.create(project);
- newLoader = ProjectClassLoader.getProjectClassLoader(javaProject);
- }
- try {
- Thread.currentThread().setContextClassLoader(newLoader);
- return new RuleBaseConfiguration().getProcessWorkDefinitions();
- } finally {
- Thread.currentThread().setContextClassLoader(oldLoader);
- }
- } catch (Exception e) {
- DroolsEclipsePlugin.log(e);
+ Thread.currentThread().setContextClassLoader(newLoader);
+ return new RuleBaseConfiguration().getProcessWorkDefinitions();
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldLoader);
}
}
return new HashMap<String, WorkDefinition>();
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -109,7 +109,7 @@
* Return the current stack frame context, or a valid stack frame for the
* given value.
*/
- private static IJavaStackFrame getStackFrame(IValue value)
+ public static IJavaStackFrame getStackFrame(IValue value)
throws CoreException {
IStatusHandler handler = getStackFrameProvider();
if (handler != null) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstanceViewer.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstanceViewer.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstanceViewer.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -16,10 +16,15 @@
import org.drools.eclipse.flow.ruleflow.core.RuleFlowWrapperBuilder;
import org.drools.eclipse.flow.ruleflow.editor.editpart.RuleFlowEditPartFactory;
import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.editparts.ScalableRootEditPart;
import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
@@ -67,8 +72,10 @@
private GraphicalViewer graphicalViewer;
private CTabItem tabItem;
+ private String projectName;
- public ProcessInstanceTabItem(CTabFolder folder, String processInstanceId, String processId, List<String> nodeIds) {
+ public ProcessInstanceTabItem(CTabFolder folder, String processInstanceId, String processId, List<String> nodeIds, String projectName) {
+ this.projectName = projectName;
tabItem = new CTabItem(folder, SWT.NONE);
ProcessInfo processInfo = DroolsEclipsePlugin.getDefault().getProcessInfo(processId);
if (processInfo == null) {
@@ -85,17 +92,18 @@
graphicalViewer.createControl(composite);
graphicalViewer.getControl().setBackground(ColorConstants.listBackground);
graphicalViewer.setRootEditPart(new ScalableRootEditPart());
- // TODO fix this !
- graphicalViewer.setEditPartFactory(new RuleFlowEditPartFactory(null));
+ IJavaProject javaProject = getJavaProject(projectName);
+ graphicalViewer.setEditPartFactory(new RuleFlowEditPartFactory(javaProject));
setProcess(processInfo);
for (String nodeId: nodeIds) {
handleNodeInstanceSelection(nodeId);
- }
+ }
+ folder.setSelection(tabItem);
}
private void setProcess(ProcessInfo processInfo) {
RuleFlowProcess process = (RuleFlowProcess) processInfo.getProcess();
- ProcessWrapper processWrapper = RuleFlowWrapperBuilder.getProcessWrapper(process, null);
+ ProcessWrapper processWrapper = RuleFlowWrapperBuilder.getProcessWrapper(process, getJavaProject(projectName));
graphicalViewer.setContents(
processWrapper == null ? new RuleFlowProcessWrapper() : processWrapper);
}
@@ -122,14 +130,37 @@
}
}
- public void showProcessInstance(String processInstanceId, String processId, List nodeIds) {
+ public void showProcessInstance(String processInstanceId, String processId, List nodeIds, String projectName) {
processInstanceTabItems.put(processInstanceId,
- new ProcessInstanceTabItem(tabFolder, processInstanceId, processId, nodeIds));
+ new ProcessInstanceTabItem(tabFolder, processInstanceId, processId, nodeIds, projectName));
}
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// Do nothing
}
+
+ private IJavaProject getJavaProject(String projectName) {
+ if (projectName != null) {
+ projectName = projectName.trim();
+ if (projectName.length() > 0) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(projectName);
+ if (project != null) {
+ try {
+ if (project.getNature("org.eclipse.jdt.core.javanature") != null) {
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject.exists()){
+ return javaProject;
+ }
+ }
+ } catch (CoreException e) {
+ DroolsEclipsePlugin.log(e);
+ }
+ }
+ }
+ }
+ return null;
+ }
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstancesView.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstancesView.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ProcessInstancesView.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -4,12 +4,14 @@
import java.util.List;
import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.jdt.debug.core.IJavaArray;
import org.eclipse.jdt.debug.core.IJavaValue;
import org.eclipse.jdt.debug.core.IJavaVariable;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ISelection;
@@ -93,8 +95,14 @@
}
nodeIds.add(nodeId);
}
- // TODO: pass current java project, to retrieve work item definitions
- ((ProcessInstanceViewer) view).showProcessInstance(id, processId, nodeIds);
+ String projectName = null;
+ try {
+ projectName = processInstance.getLaunch().getLaunchConfiguration().getAttribute(
+ IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
+ } catch (CoreException e) {
+ DroolsEclipsePlugin.log(e);
+ }
+ ((ProcessInstanceViewer) view).showProcessInstance(id, processId, nodeIds, projectName);
}
}
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -321,7 +321,6 @@
int index = tokenText.indexOf("{");
if (index != -1) {
String substring = tokenText.substring(0, index);
- System.out.println(substring);
if (obj != null && obj.startsWith(substring)) {
thenode = child;
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -23,7 +23,9 @@
import java.util.EventObject;
import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.util.ProjectClassLoader;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -45,6 +47,8 @@
import org.eclipse.gef.ui.actions.ToggleGridAction;
import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.swt.SWT;
@@ -277,6 +281,31 @@
return ((IFileEditorInput) getEditorInput()).getFile();
}
+ public IProject getProject() {
+ IFile file = getFile();
+ if (file != null) {
+ return file.getProject();
+ }
+ return null;
+ }
+
+ public IJavaProject getJavaProject() {
+ IProject project = getProject();
+ if (project != null) {
+ try {
+ if (project.getNature("org.eclipse.jdt.core.javanature") != null) {
+ IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject.exists()){
+ return javaProject;
+ }
+ }
+ } catch (CoreException e) {
+ DroolsEclipsePlugin.log(e);
+ }
+ }
+ return null;
+ }
+
protected abstract void createModel(InputStream is);
public Object getAdapter(Class type) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -49,8 +49,8 @@
void addOutgoingConnection(ElementConnection connection);
void localAddOutgoingConnection(ElementConnection connection);
void removeOutgoingConnection(ElementConnection connection);
- boolean acceptsIncomingConnection(ElementConnection connection);
- boolean acceptsOutgoingConnection(ElementConnection connection);
+ boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source);
+ boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target);
void addListener(ModelListener listener);
void removeListener(ModelListener listener);
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -46,8 +46,8 @@
return false;
}
}
- return source.acceptsOutgoingConnection(connection)
- && target != null && target.acceptsIncomingConnection(connection);
+ return source.acceptsOutgoingConnection(connection, target)
+ && target != null && target.acceptsIncomingConnection(connection, source);
}
public void execute() {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -43,7 +43,7 @@
if (connection.getTarget().equals(target) && !connection.getSource().equals(oldSource))
return false;
}
- return newSource.acceptsOutgoingConnection(connection); //XXX
+ return newSource.acceptsOutgoingConnection(connection, target); //XXX
}
public void execute() {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -45,7 +45,7 @@
if (connection.getSource().equals(source) && !connection.getTarget().equals(oldTarget))
return false;
}
- return newTarget.acceptsIncomingConnection(connection);
+ return newTarget.acceptsIncomingConnection(connection, source);
}
public void execute() {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -17,7 +17,6 @@
import java.util.List;
-import org.drools.eclipse.flow.common.editor.GenericModelEditor;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ModelEvent;
@@ -29,6 +28,7 @@
import org.drools.eclipse.flow.common.editor.policy.ElementNodeEditPolicy;
import org.eclipse.draw2d.ChopboxAnchor;
import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Label;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
@@ -37,6 +37,7 @@
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.viewers.TextCellEditor;
/**
@@ -47,7 +48,7 @@
public abstract class ElementEditPart extends AbstractGraphicalEditPart implements NodeEditPart, ModelListener {
private DirectEditManager manager;
- private GenericModelEditor editor;
+ private IJavaProject project;
protected void createEditPolicies() {
installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementNodeEditPolicy());
@@ -133,19 +134,23 @@
}
private void performDirectEdit() {
+ Label label = ((ElementFigure) getFigure()).getLabel();
+ if (label == null) {
+ return;
+ }
if (manager == null) {
manager = new ElementDirectEditManager(this, TextCellEditor.class,
- new ElementCellEditorLocator(((ElementFigure) getFigure()).getLabel()));
+ new ElementCellEditorLocator(label));
}
manager.show();
}
- public void setEditor(GenericModelEditor editor) {
- this.editor = editor;
+ public void setProject(IJavaProject project) {
+ this.project = project;
}
- public GenericModelEditor getEditor() {
- return this.editor;
+ public IJavaProject getProject() {
+ return this.project;
}
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementContainerFigure.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementContainerFigure.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementContainerFigure.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -25,6 +25,7 @@
add(scrollpane);
scrollpane.setViewport(new FreeformViewport());
scrollpane.setContents(pane);
+ setBorder(new LineBorder(1));
}
public Label getLabel() {
Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/FixedConnectionAnchor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/FixedConnectionAnchor.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/FixedConnectionAnchor.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -0,0 +1,79 @@
+package org.drools.eclipse.flow.common.editor.editpart.figure;
+
+import org.eclipse.draw2d.AbstractConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.ScalableFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+public class FixedConnectionAnchor extends AbstractConnectionAnchor {
+
+ public boolean leftToRight = true;
+ public int offsetH;
+ public int offsetV;
+ public boolean topDown = true;
+
+ public FixedConnectionAnchor(IFigure owner) {
+ super(owner);
+ }
+
+ public void ancestorMoved(IFigure figure) {
+ if (figure instanceof ScalableFigure) {
+ return;
+ }
+ super.ancestorMoved(figure);
+ }
+
+ public Point getLocation(Point reference) {
+ Rectangle r = getOwner().getBounds();
+ int x, y;
+ if (topDown) {
+ y = r.y + offsetV;
+ } else {
+ y = r.bottom() - 1 - offsetV;
+ }
+ if (leftToRight) {
+ x = r.x + offsetH;
+ } else {
+ x = r.right() - 1 - offsetH;
+ }
+ Point p = new PrecisionPoint(x, y);
+ getOwner().translateToAbsolute(p);
+ return p;
+ }
+
+ public Point getReferencePoint() {
+ return getLocation(null);
+ }
+
+ public void setOffsetH(int offsetH) {
+ this.offsetH = offsetH;
+ fireAnchorMoved();
+ }
+
+ public void setOffsetV(int offsetV) {
+ this.offsetV = offsetV;
+ fireAnchorMoved();
+ }
+
+ public boolean equals(Object o) {
+ if (o instanceof FixedConnectionAnchor) {
+ FixedConnectionAnchor fa = (FixedConnectionAnchor) o;
+ if (fa.leftToRight == this.leftToRight
+ && fa.topDown == this.topDown && fa.offsetH == this.offsetH
+ && fa.offsetV == this.offsetV
+ && fa.getOwner() == this.getOwner()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return ((this.leftToRight ? 31 : 0) + (this.topDown ? 37 : 0)
+ + this.offsetH * 43 + this.offsetV * 47)
+ ^ this.getOwner().hashCode();
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/AbstractNodeWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/AbstractNodeWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/AbstractNodeWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -16,6 +16,8 @@
*/
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.workflow.core.Node;
import org.eclipse.draw2d.geometry.Rectangle;
@@ -68,4 +70,15 @@
width == null ? -1 : width,
height == null ? -1 : height);
}
+
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return source == null
+ || ((NodeWrapper) source).getNode().getNodeContainer() == getNode().getNodeContainer();
+ }
+
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return target == null
+ || ((NodeWrapper) target).getNode().getNodeContainer() == getNode().getNodeContainer();
+ }
+
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -17,6 +17,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.eclipse.flow.ruleflow.view.property.action.ActionPropertyDescriptor;
import org.drools.workflow.core.WorkflowProcess;
import org.drools.workflow.core.node.ActionNode;
@@ -58,12 +59,14 @@
return descriptors;
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
public Object getPropertyValue(Object id) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/CompositeNodeWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/CompositeNodeWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/CompositeNodeWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -63,12 +63,16 @@
return (CompositeNode) getNode();
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return getIncomingConnections().isEmpty()
+ && (source == null ||
+ ((NodeWrapper) source).getNode().getNodeContainer() == getNode().getNodeContainer());
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return getOutgoingConnections().isEmpty()
+ && (target == null ||
+ ((NodeWrapper) target).getNode().getNodeContainer() == getNode().getNodeContainer());
}
protected void internalAddElement(ElementWrapper element) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/DefaultNodeWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/DefaultNodeWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/DefaultNodeWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -2,6 +2,7 @@
import org.drools.eclipse.DroolsEclipsePlugin;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.workflow.core.Node;
import org.drools.workflow.core.NodeExtension;
@@ -23,12 +24,14 @@
}
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -16,6 +16,7 @@
*/
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.workflow.core.node.EndNode;
/**
@@ -36,11 +37,12 @@
return (EndNode) getNode();
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
return false;
}
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -17,6 +17,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.workflow.core.node.Join;
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
@@ -48,14 +49,11 @@
return (Join) getNode();
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return true;
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
- }
-
public IPropertyDescriptor[] getPropertyDescriptors() {
return descriptors;
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -17,6 +17,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.eclipse.flow.ruleflow.view.property.constraint.MilestoneConstraintPropertyDescriptor;
import org.drools.workflow.core.WorkflowProcess;
import org.drools.workflow.core.node.MilestoneNode;
@@ -57,12 +58,14 @@
return descriptors;
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
public Object getPropertyValue(Object id) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowWrapperBuilder.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -7,10 +7,12 @@
import java.util.Map;
import java.util.Set;
+import org.drools.eclipse.DroolsEclipsePlugin;
import org.drools.eclipse.WorkItemDefinitions;
import org.drools.eclipse.flow.common.editor.core.ElementContainer;
import org.drools.process.core.Work;
import org.drools.process.core.WorkDefinition;
+import org.drools.process.core.impl.WorkDefinitionImpl;
import org.drools.ruleflow.core.RuleFlowProcess;
import org.drools.workflow.core.Connection;
import org.drools.workflow.core.Node;
@@ -25,11 +27,11 @@
import org.drools.workflow.core.node.SubProcessNode;
import org.drools.workflow.core.node.TimerNode;
import org.drools.workflow.core.node.WorkItemNode;
-import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IJavaProject;
public class RuleFlowWrapperBuilder {
- public static RuleFlowProcessWrapper getProcessWrapper(RuleFlowProcess process, IResource resource) {
+ public static RuleFlowProcessWrapper getProcessWrapper(RuleFlowProcess process, IJavaProject project) {
if (process == null) {
return null;
}
@@ -38,14 +40,14 @@
Set<Node> nodes = new HashSet<Node>();
nodes.addAll(Arrays.asList(process.getNodes()));
Set<Connection> connections = new HashSet<Connection>();
- processNodes(nodes, connections, processWrapper, resource);
+ processNodes(nodes, connections, processWrapper, project);
return processWrapper;
}
- private static void processNodes(Set<Node> nodes, Set<Connection> connections, ElementContainer container, IResource resource) {
+ private static void processNodes(Set<Node> nodes, Set<Connection> connections, ElementContainer container, IJavaProject project) {
Map<Node, NodeWrapper> nodeWrappers = new HashMap<Node, NodeWrapper>();
for (Node node: nodes) {
- NodeWrapper nodeWrapper = getNodeWrapper(node, resource);
+ NodeWrapper nodeWrapper = getNodeWrapper(node, project);
nodeWrapper.setNode(node);
nodeWrapper.setParent(container);
container.localAddElement(nodeWrapper);
@@ -74,7 +76,7 @@
}
}
- private static NodeWrapper getNodeWrapper(Node node, IResource resource) {
+ private static NodeWrapper getNodeWrapper(Node node, IJavaProject project) {
if (node instanceof StartNode) {
return new StartNodeWrapper();
} else if (node instanceof EndNode) {
@@ -100,11 +102,13 @@
Work work = ((WorkItemNode) node).getWork();
if (work != null && work.getName() != null) {
WorkDefinition workDefinition =
- WorkItemDefinitions.getWorkDefinitions(resource)
+ WorkItemDefinitions.getWorkDefinitions(project)
.get(work.getName());
if (workDefinition == null) {
- throw new IllegalArgumentException(
- "Could not find work definition for work " + work.getName());
+ DroolsEclipsePlugin.log(
+ new IllegalArgumentException("Could not find work definition for work " + work.getName()));
+ workDefinition = new WorkDefinitionImpl();
+ ((WorkDefinitionImpl) workDefinition).setName(work.getName());
}
workItemWrapper.setWorkDefinition(workDefinition);
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -17,6 +17,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.workflow.core.node.RuleSetNode;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
@@ -53,12 +54,14 @@
return descriptors;
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
public Object getPropertyValue(Object id) {
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-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -23,6 +23,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.eclipse.flow.ruleflow.view.property.constraint.ConstraintsPropertyDescriptor;
import org.drools.workflow.core.Connection;
import org.drools.workflow.core.Constraint;
@@ -62,14 +63,11 @@
return (Split) getNode();
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return true;
- }
-
public IPropertyDescriptor[] getPropertyDescriptors() {
if (getParent() != null && (getSplit().getType() == Split.TYPE_XOR
|| getSplit().getType() == Split.TYPE_OR)) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/StartNodeWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/StartNodeWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/StartNodeWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -16,6 +16,7 @@
*/
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.workflow.core.node.StartNode;
/**
@@ -36,11 +37,12 @@
return (StartNode) getNode();
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
return false;
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -17,6 +17,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.workflow.core.node.SubProcessNode;
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
@@ -57,12 +58,14 @@
return descriptors;
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
public Object getPropertyValue(Object id) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/TimerWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/TimerWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/TimerWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -17,6 +17,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.process.core.timer.Timer;
import org.drools.workflow.core.node.TimerNode;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
@@ -62,12 +63,14 @@
return descriptors;
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
public Object getPropertyValue(Object id) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/WorkItemWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/WorkItemWrapper.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/WorkItemWrapper.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -21,6 +21,7 @@
import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
import org.drools.eclipse.flow.ruleflow.view.property.workitem.WorkItemParameterMappingPropertyDescriptor;
import org.drools.eclipse.flow.ruleflow.view.property.workitem.WorkItemResultMappingPropertyDescriptor;
import org.drools.process.core.ParameterDefinition;
@@ -121,12 +122,14 @@
return descriptors;
}
- public boolean acceptsIncomingConnection(ElementConnection connection) {
- return getIncomingConnections().isEmpty();
+ public boolean acceptsIncomingConnection(ElementConnection connection, ElementWrapper source) {
+ return super.acceptsIncomingConnection(connection, source)
+ && getIncomingConnections().isEmpty();
}
- public boolean acceptsOutgoingConnection(ElementConnection connection) {
- return getOutgoingConnections().isEmpty();
+ public boolean acceptsOutgoingConnection(ElementConnection connection, ElementWrapper target) {
+ return super.acceptsOutgoingConnection(connection, target)
+ && getOutgoingConnections().isEmpty();
}
public Object getPropertyValue(Object id) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -27,9 +27,7 @@
import org.drools.compiler.PackageBuilderConfiguration;
import org.drools.eclipse.DroolsEclipsePlugin;
-import org.drools.eclipse.DroolsPluginImages;
import org.drools.eclipse.WorkItemDefinitions;
-import org.drools.eclipse.builder.DroolsBuilder;
import org.drools.eclipse.flow.common.editor.GenericModelEditor;
import org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper;
import org.drools.eclipse.flow.ruleflow.core.RuleFlowWrapperBuilder;
@@ -54,10 +52,8 @@
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.requests.SimpleFactory;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -71,7 +67,7 @@
public class RuleFlowModelEditor extends GenericModelEditor {
protected EditPartFactory createEditPartFactory() {
- return new RuleFlowEditPartFactory(this);
+ return new RuleFlowEditPartFactory(getJavaProject());
}
protected PaletteRoot createPalette() {
@@ -99,15 +95,11 @@
}
private void refreshPalette(IFile file) {
- IProject project = getFile().getProject();
- if (project != null) {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
+ IJavaProject javaProject = getJavaProject();
+ if (javaProject != null) {
try {
- if (project.getNature("org.eclipse.jdt.core.javanature") != null) {
- IJavaProject javaProject = JavaCore.create(project);
- newLoader = ProjectClassLoader.getProjectClassLoader(javaProject);
- }
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader newLoader = ProjectClassLoader.getProjectClassLoader(javaProject);
try {
Thread.currentThread().setContextClassLoader(newLoader);
PaletteDrawer drawer = (PaletteDrawer) getPaletteRoot().getChildren().get(2);
@@ -233,7 +225,7 @@
if (process == null) {
setModel(createModel());
} else {
- setModel(RuleFlowWrapperBuilder.getProcessWrapper(process, getFile()));
+ setModel(RuleFlowWrapperBuilder.getProcessWrapper(process, getJavaProject()));
}
} catch (Throwable t) {
DroolsEclipsePlugin.log(t);
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -21,6 +21,7 @@
import org.drools.eclipse.DroolsEclipsePlugin;
import org.drools.eclipse.flow.common.editor.core.ElementConnectionFactory;
import org.drools.eclipse.flow.ruleflow.core.ActionWrapper;
+import org.drools.eclipse.flow.ruleflow.core.CompositeNodeWrapper;
import org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper;
import org.drools.eclipse.flow.ruleflow.core.ConnectionWrapperFactory;
import org.drools.eclipse.flow.ruleflow.core.EndNodeWrapper;
@@ -161,15 +162,15 @@
);
entries.add(combined);
-// combined = new CombinedTemplateCreationEntry(
-// "Composite Node",
-// "Create a new Composite Node",
-// CompositeNodeWrapper.class,
-// new SimpleFactory(CompositeNodeWrapper.class),
-// ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif")),
-// ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif"))
-// );
-// entries.add(combined);
+ combined = new CombinedTemplateCreationEntry(
+ "Composite Node",
+ "Create a new Composite Node",
+ CompositeNodeWrapper.class,
+ new SimpleFactory(CompositeNodeWrapper.class),
+ ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif")),
+ ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif"))
+ );
+ entries.add(combined);
drawer.addAll(entries);
return drawer;
Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/CompositeNodeEditPart.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/CompositeNodeEditPart.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/CompositeNodeEditPart.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -0,0 +1,60 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.editpart.ElementContainerEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementContainerFigure;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
+
+public class CompositeNodeEditPart extends ElementContainerEditPart {
+
+ protected IFigure createFigure() {
+ return new CompositeNodeFigure();
+ }
+
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ Point p = ((DropRequest) request).getLocation();
+ return ((CompositeNodeFigure) getFigure()).getOutgoingConnectionAnchorAt(p);
+ }
+
+ public static class CompositeNodeFigure extends ElementContainerFigure {
+
+ private List<ConnectionAnchor> outgoingConnectionAnchors = new ArrayList<ConnectionAnchor>();
+
+ public ConnectionAnchor getOutgoingConnectionAnchorAt(Point p) {
+ ConnectionAnchor closest = null;
+ long min = Long.MAX_VALUE;
+ for (ConnectionAnchor c: outgoingConnectionAnchors) {
+ Point p2 = c.getLocation(null);
+ long d = p.getDistance2(p2);
+ if (d < min) {
+ min = d;
+ closest = c;
+ }
+ }
+ return closest;
+ }
+
+ public void layoutConnectionAnchors() {
+// FixedConnectionAnchor c = (FixedConnectionAnchor) outgoingConnectionAnchors.get(0);
+// c.setOffsetV(getBounds().height);
+// c.setOffsetH(0);
+// c = (FixedConnectionAnchor) outgoingConnectionAnchors.get(1);
+// c.setOffsetV(getBounds().height);
+// c.setOffsetH(getBounds().width);
+ }
+
+ public void validate() {
+ if(isValid()) return;
+ layoutConnectionAnchors();
+ super.validate();
+ }
+
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -33,6 +33,7 @@
import org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
+import org.eclipse.jdt.core.IJavaProject;
/**
* Factory for RuleFlow EditParts.
@@ -41,10 +42,10 @@
*/
public class RuleFlowEditPartFactory implements EditPartFactory {
- private RuleFlowModelEditor editor;
+ private IJavaProject project;
- public RuleFlowEditPartFactory(RuleFlowModelEditor editor) {
- this.editor = editor;
+ public RuleFlowEditPartFactory(IJavaProject project) {
+ this.project = project;
}
public EditPart createEditPart(EditPart context, Object model) {
@@ -71,7 +72,7 @@
result = new ActionEditPart();
} else if (model instanceof WorkItemWrapper) {
result = new WorkItemEditPart();
- ((WorkItemEditPart) result).setEditor(editor);
+ ((WorkItemEditPart) result).setProject(project);
} else if (model instanceof TimerWrapper) {
result = new TimerEditPart();
} else if (model instanceof CompositeNodeWrapper) {
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/WorkItemEditPart.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/WorkItemEditPart.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/WorkItemEditPart.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -16,25 +16,30 @@
*/
import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
import org.drools.eclipse.DroolsEclipsePlugin;
import org.drools.eclipse.DroolsPluginImages;
-import org.drools.eclipse.builder.DroolsBuilder;
import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
import org.drools.eclipse.flow.common.editor.editpart.figure.AbstractElementFigure;
+import org.drools.eclipse.flow.common.editor.editpart.figure.FixedConnectionAnchor;
import org.drools.eclipse.flow.ruleflow.core.WorkItemWrapper;
import org.drools.eclipse.util.ProjectClassLoader;
import org.drools.process.core.WorkDefinition;
import org.drools.process.core.WorkDefinitionExtension;
import org.drools.process.core.WorkEditor;
import org.drools.workflow.core.node.WorkItemNode;
-import org.eclipse.core.resources.IProject;
+import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.RoundedRectangle;
import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.requests.DropRequest;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
@@ -62,15 +67,11 @@
Image image = DroolsPluginImages.getImage(icon);
WorkItemFigure figure = new WorkItemFigure();
if (image == null) {
- IProject project = getEditor().getFile().getProject();
- if (project != null) {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
+ IJavaProject javaProject = getProject();
+ if (javaProject != null) {
try {
- if (project.getNature("org.eclipse.jdt.core.javanature") != null) {
- IJavaProject javaProject = JavaCore.create(project);
- newLoader = ProjectClassLoader.getProjectClassLoader(javaProject);
- }
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader newLoader = ProjectClassLoader.getProjectClassLoader(javaProject);
try {
Thread.currentThread().setContextClassLoader(newLoader);
image = ImageDescriptor.createFromURL(
@@ -96,6 +97,11 @@
return getWorkItemWrapper().getWorkDefinition();
}
+ public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+ Point p = ((DropRequest) request).getLocation();
+ return ((WorkItemFigure) getFigure()).getOutgoingConnectionAnchorAt(p);
+ }
+
protected void doubleClicked() {
super.doubleClicked();
// open custom editor pane if one exists
@@ -109,15 +115,11 @@
}
private void openEditor(String editorClassName, WorkDefinition workDefinition) {
- IProject project = getEditor().getFile().getProject();
- if (project != null) {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
+ IJavaProject javaProject = getProject();
+ if (javaProject != null) {
try {
- if (project.getNature("org.eclipse.jdt.core.javanature") != null) {
- IJavaProject javaProject = JavaCore.create(project);
- newLoader = ProjectClassLoader.getProjectClassLoader(javaProject);
- }
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader newLoader = ProjectClassLoader.getProjectClassLoader(javaProject);
try {
Thread.currentThread().setContextClassLoader(newLoader);
Class<WorkEditor> editorClass = (Class<WorkEditor>) newLoader.loadClass(editorClassName);
@@ -140,7 +142,43 @@
public static class WorkItemFigure extends AbstractElementFigure {
private RoundedRectangle rectangle;
+ private ConnectionAnchor defaultConnectionAnchor;
+ private List<ConnectionAnchor> outgoingConnectionAnchors = new ArrayList<ConnectionAnchor>();
+ public WorkItemFigure() {
+ defaultConnectionAnchor = new ChopboxAnchor(this);
+// FixedConnectionAnchor c = new FixedConnectionAnchor(this);
+// outgoingConnectionAnchors.add(c);
+// c = new FixedConnectionAnchor(this);
+// outgoingConnectionAnchors.add(c);
+ }
+
+ public void layoutConnectionAnchors() {
+// FixedConnectionAnchor c = (FixedConnectionAnchor) outgoingConnectionAnchors.get(0);
+// c.setOffsetV(getBounds().height);
+// c.setOffsetH(0);
+// c = (FixedConnectionAnchor) outgoingConnectionAnchors.get(1);
+// c.setOffsetV(getBounds().height);
+// c.setOffsetH(getBounds().width);
+ }
+
+ public ConnectionAnchor getOutgoingConnectionAnchorAt(Point p) {
+ ConnectionAnchor closest = null;
+ long min = Long.MAX_VALUE;
+ for (ConnectionAnchor c: outgoingConnectionAnchors) {
+ Point p2 = c.getLocation(null);
+ long d = p.getDistance2(p2);
+ if (d < min) {
+ min = d;
+ closest = c;
+ }
+ }
+ if (min > 100) {
+ return defaultConnectionAnchor;
+ }
+ return closest;
+ }
+
protected void customizeFigure() {
rectangle = new RoundedRectangle();
rectangle.setCornerDimensions(new Dimension(25, 25));
@@ -160,5 +198,11 @@
rectangle.setLineWidth(b ? 3 : 1);
repaint();
}
+
+ public void validate() {
+ if(isValid()) return;
+ layoutConnectionAnchors();
+ super.validate();
+ }
}
}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -337,7 +337,7 @@
if ("eval(true)".equals(constraint.getConstraint())) {
alwaysTrue.setSelection(true);
} else {
- setConstraintText(constraint.getConstraint().toString());
+ setConstraintText(constraint.getConstraint() == null ? "" : constraint.getConstraint());
}
tabFolder.setVisible(!alwaysTrue.getSelection());
nameText.setText(constraint.getName() == null ? "" : constraint
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java 2008-05-08 12:06:02 UTC (rev 19903)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java 2008-05-08 12:06:21 UTC (rev 19904)
@@ -67,16 +67,16 @@
private IResourceChangeListener packageFileTracker = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = getRootDelta( event.getDelta() );
+ if (packageEditorInput != null) {
+ IResourceDelta delta = getRootDelta( event.getDelta() );
+
+ IPath p1 = delta.getFullPath();
+ IPath p2 = packageEditorInput.getFile().getFullPath();
+ if ( p1.equals( p2 ) ) {
+ reloadCompletionEngine();
+ }
+ } }
- IPath p1 = delta.getFullPath();
- IPath p2 = packageEditorInput.getFile().getFullPath();
- if ( p1.equals( p2 ) ) {
- reloadCompletionEngine();
- }
-
- }
-
};
public RuleEditor() {
More information about the jboss-svn-commits
mailing list