use of com.centurylink.mdw.plugin.designer.model.ActivityImpl 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.ActivityImpl 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.ActivityImpl in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method findActivityImplementors.
/**
* Returns the activity implementors events belonging to a package version.
*/
public List<ActivityImpl> findActivityImplementors(WorkflowPackage aPackage) {
List<ActivityImpl> impls = new ArrayList<>();
List<ActivityImplementorVO> implVOs = getDataAccess().getActivityImplementors(false);
for (ActivityImplementorVO implVO : implVOs) {
if ((aPackage.isDefaultPackage() && !isPackaged(implVO)) || (!aPackage.isDefaultPackage() && aPackage.getPackageVO().containsActivityImpl(implVO.getImplementorClassName()))) {
ActivityImpl activityImpl = activityImpls.get(implVO.getImplementorClassName());
if (activityImpl == null) {
activityImpl = new ActivityImpl(implVO, aPackage);
activityImpl.addElementChangeListener(this);
activityImpls.put(implVO.getImplementorClassName(), activityImpl);
}
if (!impls.contains(activityImpl))
impls.add(activityImpl);
}
}
Collections.sort(impls);
return impls;
}
use of com.centurylink.mdw.plugin.designer.model.ActivityImpl in project mdw-designer by CenturyLinkCloud.
the class ToolboxViewActionGroup method enableToolbarActions.
public void enableToolbarActions(boolean enabled) {
sortAction.setEnabled(enabled);
refreshAction.setEnabled(enabled);
ActivityImpl impl = view.getSelection();
saveAction.setEnabled(enabled && view.isDirty() && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
deleteAction.setEnabled(enabled && view.isSelection() && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
newAction.setEnabled(enabled && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
filterAction.setEnabled(enabled);
discoverAction.setEnabled(enabled && impl != null && impl.isUserAuthorized(UserRoleVO.ASSET_DESIGN));
}
use of com.centurylink.mdw.plugin.designer.model.ActivityImpl in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerContentProvider method handleElementChange.
private void handleElementChange(ElementChangeEvent ece) {
if (ece.getChangeType().equals(ChangeType.ELEMENT_CREATE)) {
Object parent = getParent(ece.getElement());
if (parent == null) {
treeViewer.refresh(true);
ece.getElement().addElementChangeListener(this);
} else {
if (parent instanceof WorkflowPackage) {
try {
((WorkflowPackage) parent).getFolder().refreshLocal(IResource.DEPTH_ONE, null);
} catch (Exception ex) {
PluginMessages.log(ex);
}
}
treeViewer.refresh(parent, true);
}
treeViewer.expandToLevel(ece.getElement(), 0);
treeViewer.setSelection(ece.getElement());
} else if (ece.getChangeType().equals(ChangeType.ELEMENT_DELETE)) {
Object parent = getParent(ece.getElement());
if (parent != null) {
if (ece.getElement() instanceof ActivityImpl)
// impl can be associated with
treeViewer.refresh();
else
// multiple packages
treeViewer.refresh(parent, true);
} else {
// must be a workflowProject
ece.getElement().removeElementChangeListener(this);
treeViewer.refresh();
}
} else if (ece.getChangeType().equals(ChangeType.RENAME)) {
treeViewer.refresh(ece.getElement(), true);
treeViewer.getControl().forceFocus();
} else if (ece.getChangeType().equals(ChangeType.VERSION_CHANGE)) {
treeViewer.refresh(ece.getElement(), true);
if (ece.getElement() instanceof WorkflowPackage)
treeViewer.refresh(ece.getElement().getProject().getArchivedUserVisiblePackagesFolder(), true);
} else if (ece.getChangeType().equals(ChangeType.LABEL_CHANGE)) {
treeViewer.update(ece.getElement(), null);
} else if (ece.getChangeType().equals(ChangeType.SETTINGS_CHANGE)) {
// only applies for workflow projects
if (ece.getElement() instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) ece.getElement();
if (ece.getNewValue() instanceof JdbcDataSource) {
treeViewer.collapseToLevel(workflowProject, TreeViewer.ALL_LEVELS);
treeViewer.refresh(workflowProject, true);
} else if (ece.getNewValue() == null) {
// general refresh
treeViewer.refresh(workflowProject, true);
}
} else {
treeViewer.refresh(ece.getElement(), true);
}
} else if (ece.getChangeType().equals(ChangeType.STATUS_CHANGE)) {
treeViewer.update(ece.getElement(), null);
if (ece.getElement() instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) ece.getElement();
Object testResults;
if (testCase.isLegacy())
testResults = testCase.getLegacyExpectedResults();
else
testResults = testCase.getExpectedResults();
if (testResults != null)
treeViewer.refresh(testResults, true);
}
}
}
Aggregations