use of com.centurylink.mdw.plugin.designer.DesignerRunner.RunnerResult in project mdw-designer by CenturyLinkCloud.
the class ProcessCanvasWrapper method forceUpdateProcess.
public RunnerResult forceUpdateProcess() {
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
boolean validate = prefsStore.getBoolean(PreferenceConstants.PREFS_ENFORCE_PROCESS_VALIDATION_RULES);
boolean keepLocked = prefsStore.getBoolean(PreferenceConstants.PREFS_KEEP_PROCESSES_LOCKED_WHEN_SAVING);
RunnerResult result = getDesignerProxy().forceUpdateProcessWithProgress(getProcess(), getFlowchartPage(), validate, keepLocked);
dirtyStateChanged(getFlowchartPage().getProcess().dirtyLevel > 0);
// so that we don't lose edits to previous canvas selections
setEditorFocus();
designerCanvasSelection = getProcess();
getSelectionProvider().setSelection(designerCanvasSelection);
getProcess().sync();
if (result.getStatus() == RunnerStatus.SUCCESS)
updateCanvasBackground();
return result;
}
use of com.centurylink.mdw.plugin.designer.DesignerRunner.RunnerResult in project mdw-designer by CenturyLinkCloud.
the class WorkflowAsset method resourceChanged.
/**
* Change listener so we'll know when the resource is changed in the
* workspace.
*/
public void resourceChanged(IResourceChangeEvent event) {
if (isForceExternalEditor())
return;
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
final IFile file = getAssetFile();
IResourceDelta rootDelta = event.getDelta();
IResourceDelta assetDelta = rootDelta.findMember(file.getFullPath());
if (assetDelta != null && assetDelta.getKind() == IResourceDelta.CHANGED && (assetDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
// the file has been changed
final Display display = Display.getCurrent();
if (display != null) {
display.syncExec(new Runnable() {
public void run() {
if (isRawEdit()) {
if (getProject().isReadOnly())
MessageDialog.openWarning(display.getActiveShell(), "Not Editable", "Your changes to " + getFile().getName() + " will be overwritten the next time project '" + getProject().getLabel() + "' is refreshed.");
} else {
if (!isUserAuthorized(UserRoleVO.ASSET_DESIGN)) {
MessageDialog.openWarning(display.getActiveShell(), "Can't Update " + getTitle(), "You're not authorized to update '" + getLabel() + "'\nin workflow project '" + getProject().getName() + "'.");
return;
} else if (!isLockedToUser()) {
MessageDialog.openWarning(display.getActiveShell(), "Can't Update " + getTitle(), "Resource '" + getLabel() + "' is not locked by you, so updates are not allowed.");
return;
}
}
if (isBinary())
encodeAndSetContent(PluginUtil.readFile(file));
else
setContent(new String(PluginUtil.readFile(file)));
Increment versionIncrement = Increment.Overwrite;
int previousVersion = getVersion();
String versionComment = null;
if (getProject().checkRequiredVersion(5, 0)) {
VersionableSaveDialog saveDialog = new VersionableSaveDialog(display.getActiveShell(), WorkflowAsset.this);
int res = saveDialog.open();
if (res == VersionableSaveDialog.CANCEL) {
if (isRawEdit()) {
String message = "Version for '" + WorkflowAsset.this.getName() + "' remains " + WorkflowAsset.this.getVersionLabel();
MessageDialog.openInformation(display.getActiveShell(), WorkflowAsset.this.getTitle() + " Overwrite", message);
return;
} else {
String message = "Database save for '" + WorkflowAsset.this.getName() + "' was canceled.\nTemp file changes were not persisted.";
MessageDialog.openWarning(display.getActiveShell(), WorkflowAsset.this.getTitle() + " Not Saved", message);
return;
}
}
versionIncrement = saveDialog.getVersionIncrement();
if (versionIncrement != Increment.Overwrite) {
setVersion(versionIncrement == Increment.Major ? getNextMajorVersion() : getNextMinorVersion());
versionComment = saveDialog.getVersionComment();
}
}
if (isRawEdit()) {
if (versionIncrement == Increment.Overwrite) {
// just fire cache refresh
if (!getProject().isRemote())
getProject().getDesignerProxy().getCacheRefresh().fireRefresh(RuleSetVO.JAVA.equals(getLanguage()));
} else {
setRevisionComment(versionComment);
getProject().getDesignerProxy().saveWorkflowAssetWithProgress(WorkflowAsset.this, false);
fireElementChangeEvent(ChangeType.VERSION_CHANGE, getVersion());
}
} else {
try {
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
boolean keepLocked = prefsStore.getBoolean(PreferenceConstants.PREFS_KEEP_RESOURCES_LOCKED_WHEN_SAVING);
if (versionIncrement != Increment.Overwrite) {
RuleSetVO prevVO = new RuleSetVO(WorkflowAsset.this.getRuleSetVO());
prevVO.setId(getId());
prevVO.setVersion(previousVersion);
setComment(versionComment);
if (!isInDefaultPackage()) {
getPackage().removeAsset(WorkflowAsset.this);
getProject().getUnpackagedWorkflowAssets().add(new WorkflowAsset(prevVO, getProject().getDefaultPackage()));
}
RunnerResult result = getProject().getDesignerProxy().createNewWorkflowAsset(WorkflowAsset.this, keepLocked);
if (result.getStatus() == RunnerStatus.SUCCESS) {
getRuleSetVO().setPrevVersion(prevVO);
fireElementChangeEvent(ChangeType.VERSION_CHANGE, getVersion());
} else if (result.getStatus() == RunnerStatus.DISALLOW) {
// deregister since save never
// happened
WorkflowAssetFactory.deRegisterAsset(WorkflowAsset.this);
}
} else {
getProject().getDesignerProxy().saveWorkflowAssetWithProgress(WorkflowAsset.this, keepLocked);
fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, null);
}
if (!keepLocked)
fireElementChangeEvent(ChangeType.PROPERTIES_CHANGE, null);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Save Definition Doc", getProject());
}
}
}
});
}
}
}
}
Aggregations