use of com.centurylink.mdw.plugin.designer.model.Activity in project mdw-designer by CenturyLinkCloud.
the class ProcessCanvasWrapper method handleSelection.
private void handleSelection(MouseEvent mouseEvent) {
Graph lProcess = null;
if (isInstance())
lProcess = getProcessInstancePage().getProcess();
else
lProcess = getFlowchartPage().getProcess();
int mouseX = mouseEvent.getX();
int mouseY = mouseEvent.getY();
if (lProcess.zoom != 100) {
mouseX = mouseX * 100 / lProcess.zoom;
mouseY = mouseY * 100 / lProcess.zoom;
}
Object obj = null;
if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED) {
if (isInstance())
obj = getProcessInstancePage().canvas.objectAt(lProcess, mouseX, mouseY, getProcessInstancePage().canvas.getGraphics());
else
obj = getFlowchartPage().canvas.objectAt(lProcess, mouseX, mouseY, getFlowchartPage().canvas.getGraphics());
} else {
obj = lProcess.objectAt(mouseX, mouseY, isInstance() ? getProcessInstancePage().canvas.getGraphics() : getFlowchartPage().canvas.getGraphics());
}
if (obj != null) {
DesignerProxy designerProxy = getProcess().getProject().getDesignerProxy();
// create the appropriate DesignerCanvasSelection
if (obj instanceof Node) {
ActivityImpl actImpl = getProcess().getProject().getActivityImpl(((Node) obj).nodet.getImplementorClassName());
Activity activity = new Activity((Node) obj, getProcess(), actImpl);
if (isInstance()) {
activity.setProcessInstance(getProcess().getProcessInstance());
List<ActivityInstanceVO> activityInstances = getProcess().getProcessInstance().getActivityInstances(activity.getId());
if (activityInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
// try embedded subprocess instances
for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) activityInstances.addAll(embeddedSubProcessInstance.getActivityInstances(activity.getId()));
}
activity.setInstances(activityInstances);
if (activity.isManualTask()) {
activity.setTaskInstances(getProcess().getMainTaskInstances(activity.getId()));
activity.setSubTaskInstances(getProcess().getSubTaskInstances(activity.getId()));
}
if (activity.isSubProcessInvoke()) {
// TODO: load subprocess instances when process instance
// id loaded (like manual task instances above)
List<ProcessInstanceVO> subProcessInstances = designerProxy.getSubProcessInstances(getProcess(), activity);
if (subProcessInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) subProcessInstances.addAll(designerProxy.getSubProcessInstances(embeddedSubProcessInstance, activity));
}
activity.setSubProcessInstances(subProcessInstances);
}
} else {
if (activity.getLogicalId() == null)
activity.setLogicalId(lProcess.generateLogicalId("A"));
if (Node.ID_SEQUENCE.equals(getNodeIdType()) && activity.getSequenceId() == 0)
lProcess.assignSequenceIds();
}
designerCanvasSelection = activity;
} else if (obj instanceof Link) {
Transition transition = new Transition((Link) obj, getProcess());
if (isInstance())
transition.setInstances(getProcess().getProcessInstance().getTransitionInstances(transition.getId()));
designerCanvasSelection = transition;
} else if (obj instanceof SubGraph) {
EmbeddedSubProcess embeddedSubProcess = new EmbeddedSubProcess((SubGraph) obj, getProcess());
if (isInstance()) {
embeddedSubProcess.setSubProcessInstances(((SubGraph) obj).getInstances());
}
designerCanvasSelection = embeddedSubProcess;
} else if (obj instanceof TextNote) {
TextNote textNote = (TextNote) obj;
Note note = new Note(textNote, getProcess());
designerCanvasSelection = note;
} else {
designerCanvasSelection = getProcess();
}
} else {
designerCanvasSelection = getProcess();
}
designerCanvasSelection.addDirtyStateListener(this);
}
use of com.centurylink.mdw.plugin.designer.model.Activity in project mdw-designer by CenturyLinkCloud.
the class ArtifactResourceListener method resourceChanged.
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta rootDelta = event.getDelta();
IResourceDelta artifactDelta = rootDelta.findMember(tempFile.getFullPath());
if (artifactDelta != null && artifactDelta.getKind() == IResourceDelta.CHANGED && (artifactDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
// the file has been changed
final Display display = Display.getCurrent();
if (display != null) {
display.syncExec(new Runnable() {
public void run() {
byte[] newValue = PluginUtil.readFile(tempFile);
String attrVal = valueProvider.isBinary() ? encodeBase64(newValue) : new String(newValue);
if (getElement() instanceof Activity || getElement() instanceof WorkflowProcess) {
WorkflowProcess processVersion = null;
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
activity.setAttribute(valueProvider.getAttributeName(), attrVal);
processVersion = activity.getProcess();
} else {
processVersion = (WorkflowProcess) getElement();
processVersion.setAttribute(valueProvider.getAttributeName(), attrVal);
}
processVersion.fireDirtyStateChanged(true);
ProcessEditor processEditor = findProcessEditor(processVersion);
if (processEditor == null) {
try {
processEditor = openProcessEditor(processVersion);
IEditorPart tempFileEditor = findTempFileEditor(tempFile);
if (tempFileEditor != null)
processEditor.addActiveScriptEditor(tempFileEditor);
} catch (PartInitException ex) {
PluginMessages.uiError(display.getActiveShell(), ex, "Open Process", processVersion.getProject());
return;
}
}
processVersion = processEditor.getProcess();
if (processVersion.isReadOnly()) {
WorkflowProject workflowProject = getElement().getProject();
PluginMessages.uiMessage("Process for '" + getElement().getName() + "' in workflow project '" + workflowProject.getName() + "' is Read Only.", "Not Updated", workflowProject, PluginMessages.INFO_MESSAGE);
return;
}
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
// previously-opened process version
for (Node node : processEditor.getProcessCanvasWrapper().getFlowchartPage().getProcess().nodes) {
if (activity.getLogicalId() != null && activity.getLogicalId().equals(node.getAttribute("LOGICAL_ID"))) {
node.setAttribute(valueProvider.getAttributeName(), attrVal);
ActivityImpl actImpl = processVersion.getProject().getActivityImpl(node.nodet.getImplementorClassName());
element = new Activity(node, processVersion, actImpl);
}
}
activity.fireDirtyStateChanged(true);
}
processEditor.dirtyStateChanged(true);
valueProvider.afterTempFileSaved();
// process editor is open
String message = valueProvider.getArtifactTypeDescription() + " temporary file has been saved locally; however, you must still save the process for the changes to be persisted.";
String toggleMessage = "Don't show me this message again.";
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
String prefsKey = "Mdw" + valueProvider.getArtifactTypeDescription() + "SuppressSaveNag";
if (!prefsStore.getBoolean(prefsKey)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(display.getActiveShell(), "Artifact Save", message, toggleMessage, false, null, null);
prefsStore.setValue(prefsKey, dialog.getToggleState());
}
}
}
});
}
}
}
}
use of com.centurylink.mdw.plugin.designer.model.Activity in project mdw-designer by CenturyLinkCloud.
the class SubProcessMappingSection method select.
public boolean select(Object toTest) {
if (toTest == null || !(toTest instanceof Activity))
return false;
activity = (Activity) toTest;
if (!activity.isSubProcessInvoke())
return false;
if (activity.isForProcessInstance())
return false;
PropertyEditorList propEditorList = new PropertyEditorList(activity);
for (PropertyEditor propertyEditor : propEditorList) {
if (propertyEditor.getType().equals(MappingEditor.TYPE_MAPPING))
return true;
}
return false;
}
use of com.centurylink.mdw.plugin.designer.model.Activity in project mdw-designer by CenturyLinkCloud.
the class TaskVariablesSection method select.
@Override
public boolean select(Object toTest) {
if (toTest == null || !(toTest instanceof Activity))
return false;
Activity activity = (Activity) toTest;
if (!activity.isManualTask())
return false;
if (activity.isForProcessInstance())
return false;
PropertyEditorList propEditorList = new PropertyEditorList(activity);
for (PropertyEditor propertyEditor : propEditorList) {
// return true if any widgets specify Variables section
if (PropertyEditor.SECTION_VARIABLES.equals(propertyEditor.getSection()))
return true;
}
return false;
}
use of com.centurylink.mdw.plugin.designer.model.Activity in project mdw-designer by CenturyLinkCloud.
the class ExpressionSection method select.
/**
* For IFilter interface, determine which activities include this section in
* their Design properties tab page.
*/
public boolean select(Object toTest) {
if (toTest == null || !(toTest instanceof Activity))
return false;
activity = (Activity) toTest;
if (activity.isForProcessInstance())
return false;
if (activity.getActivityImpl().getAttrDescriptionXml() == null)
return false;
PropertyEditorList propEditorList = new PropertyEditorList(activity);
for (PropertyEditor propertyEditor : propEditorList) {
if (propertyEditor.getType().equals(PropertyEditor.TYPE_SCRIPT)) {
activity.setScriptLanguages(propertyEditor.getScriptLanguages());
return "EXPRESSION".equals(propertyEditor.getScriptType());
}
}
return false;
}
Aggregations