use of com.centurylink.mdw.plugin.designer.model.Versionable.Increment in project mdw-designer by CenturyLinkCloud.
the class ProcessSaveDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.getShell().setText("Save Process");
String msg = "'" + process.getName() + "'";
if (respondingToClose)
msg += " has been modified. Save changes?";
new Label(composite, SWT.NONE).setText(msg);
// MDW3
String oldEmbedded = getProcess().getAttribute("process_old_embedded");
Group radioGroup = new Group(composite, SWT.NONE);
radioGroup.setText("Process Version to Save");
GridLayout gl = new GridLayout();
radioGroup.setLayout(gl);
GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
radioGroup.setLayoutData(gd);
overwriteButton = new Button(radioGroup, SWT.RADIO | SWT.LEFT);
if (oldEmbedded != null || !allowForceUpdate)
overwriteButton.setEnabled(false);
overwriteButton.setText("Overwrite current version: " + process.getVersionString());
overwriteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
versionButtonSelected(e);
}
});
newMinorButton = new Button(radioGroup, SWT.RADIO | SWT.LEFT);
newMinorButton.setText("Save as new minor version: " + process.getNewVersionString(false));
newMinorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
versionButtonSelected(e);
}
});
newMajorButton = new Button(radioGroup, SWT.RADIO | SWT.LEFT);
newMajorButton.setText("Save as new major version: " + process.getNewVersionString(true));
newMajorButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
versionButtonSelected(e);
}
});
if (oldEmbedded != null)
new Label(composite, SWT.NONE).setText("This process contains MDW 3.* subprocesses.\nYou must save it as a new version.");
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
String prefsIncrement = prefsStore.getString(PreferenceConstants.PREFS_PROCESS_SAVE_INCREMENT);
boolean rememberSelection = !prefsIncrement.isEmpty();
if (prefsIncrement.isEmpty())
prefsIncrement = Increment.Minor.toString();
Increment increment = Increment.valueOf(prefsIncrement);
if (increment == Increment.Overwrite)
overwriteButton.setSelection(true);
else if (increment == Increment.Major)
newMajorButton.setSelection(true);
else
newMinorButton.setSelection(true);
rememberSelectionCheckbox = new Button(composite, SWT.CHECK);
rememberSelectionCheckbox.setText("Remember this selection for future saves");
rememberSelectionCheckbox.setSelection(rememberSelection);
enforceValidationCheckbox = new Button(composite, SWT.CHECK);
enforceValidationCheckbox.setText("Enforce process validation rules");
enforceValidationCheckbox.setSelection(prefsStore.getBoolean(PreferenceConstants.PREFS_ENFORCE_PROCESS_VALIDATION_RULES));
if (process.getProject().isFilePersist()) {
boolean overwrite = overwriteButton.getSelection();
// override attributes
carryOverrideAttributesCheckbox = new Button(composite, SWT.CHECK);
carryOverrideAttributesCheckbox.setText("Carry forward override attributes");
boolean enabled = process.overrideAttributesApplied() && !overwrite;
boolean checked = overwrite ? true : process.overrideAttributesApplied();
enableCarryOverrideAttrs(enabled, checked);
carryOverrideAttributesCheckbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (carryOverrideAttributesCheckbox.getSelection()) {
WarningTray tray = getWarningTray();
if (tray.getMessage().startsWith("Any override attributes")) {
tray.close();
getButton(Dialog.OK).setText(respondingToClose ? "Save" : "OK");
}
}
}
});
} else {
keepLockedCheckbox = new Button(composite, SWT.CHECK);
keepLockedCheckbox.setText("Keep process locked after saving");
keepLockedCheckbox.setSelection(prefsStore.getBoolean(PreferenceConstants.PREFS_KEEP_PROCESSES_LOCKED_WHEN_SAVING));
}
return composite;
}
use of com.centurylink.mdw.plugin.designer.model.Versionable.Increment in project mdw-designer by CenturyLinkCloud.
the class TaskTemplateEditor method saveDialog.
private int saveDialog(boolean closeButton) {
VersionableSaveDialog saveDlg = new VersionableSaveDialog(getSite().getShell(), taskTemplate, closeButton);
int result = saveDlg.open();
if (result == VersionableSaveDialog.CANCEL)
return result;
try {
if (result == VersionableSaveDialog.CLOSE_WITHOUT_SAVE) {
// refresh from file
String content = new String(PluginUtil.readFile(taskTemplate.getFile()));
TaskVO taskVO;
if (content.trim().startsWith("{")) {
taskVO = new TaskVO(new JSONObject(content));
} else {
TaskTemplateDocument docx = TaskTemplateDocument.Factory.parse(content);
taskVO = new TaskVO(docx.getTaskTemplate());
}
taskVO.setName(taskTemplate.getName());
taskVO.setTaskId(taskTemplate.getId());
taskVO.setPackageName(taskTemplate.getPackage().getName());
taskTemplate.setTaskVO(taskVO);
taskTemplate.setDirty(false);
return result;
} else // save the template
{
// clean out units attrs
taskTemplate.removeAttribute("TaskSLA_UNITS");
taskTemplate.removeAttribute("ALERT_INTERVAL_UNITS");
Increment versionIncrement = saveDlg.getVersionIncrement();
String pkgMeta = taskTemplate.getPackage().getMetaContent();
if (pkgMeta != null && pkgMeta.trim().startsWith("{")) {
taskTemplate.setContent(taskTemplate.getTaskVO().getJson().toString(2));
} else {
TaskTemplateDocument doc = TaskTemplateDocument.Factory.newInstance();
doc.setTaskTemplate(taskTemplate.getTaskVO().toTemplate());
XmlOptions xmlOptions = new XmlOptions().setSaveAggressiveNamespaces();
xmlOptions.setSavePrettyPrint().setSavePrettyPrintIndent(2);
taskTemplate.setContent(doc.xmlText(xmlOptions));
}
taskTemplate.ensureFileWritable();
InputStream is = new ByteArrayInputStream(taskTemplate.getContent().getBytes());
taskTemplate.getAssetFile().setContents(is, true, true, new NullProgressMonitor());
if (versionIncrement != Increment.Overwrite) {
taskTemplate.setVersion(versionIncrement == Increment.Major ? taskTemplate.getNextMajorVersion() : taskTemplate.getNextMinorVersion());
taskTemplate.setRevisionComment(saveDlg.getVersionComment());
taskTemplate.getProject().getDesignerProxy().saveWorkflowAssetWithProgress(taskTemplate, false);
taskTemplate.fireElementChangeEvent(ChangeType.VERSION_CHANGE, taskTemplate.getVersion());
}
dirtyStateChanged(false);
if (!taskTemplate.getProject().isRemote())
taskTemplate.getProject().getDesignerProxy().getCacheRefresh().fireRefresh(false);
return result;
}
} catch (Exception ex) {
PluginMessages.uiError(getSite().getShell(), ex, "Save Task Template", taskTemplate.getProject());
return VersionableSaveDialog.CANCEL;
}
}
use of com.centurylink.mdw.plugin.designer.model.Versionable.Increment in project mdw-designer by CenturyLinkCloud.
the class ProcessSaveDialog method okPressed.
@Override
protected void okPressed() {
String warning = null;
if (overwriteButton.getSelection() && !getButton(Dialog.OK).getText().equals("Force Update") && !getButton(Dialog.OK).getText().equals("Force Save") && hasInstances()) {
warning = INSTANCES_MESSAGE + "\n\n" + "It is recommended that you increment the version when saving\n" + "rather than overwriting the existing version. Otherwise Designer\n" + "may not correctly display previous incompatible instances.\n\n" + "To update the existing version, click 'Force Update' to confirm.";
getButton(Dialog.OK).setText("Force Update");
} else if (!getButton(Dialog.OK).getText().equals("Force Save") && process.getProject().isProduction()) {
warning = "This process is for project '" + getProcess().getProject().getSourceProjectName() + "',\nwhich is flagged as a production environment.\n\nPlease click 'Force Save' to confirm.\n\nThis action will be audit logged.";
getButton(Dialog.OK).setText("Force Save");
} else if (MdwPlugin.getSettings().isWarnOverrideAttrsNotCarriedForward() && process.getProject().isFilePersist() && !overwriteButton.getSelection() && !carryOverrideAttributesCheckbox.getSelection() && !getButton(Dialog.OK).getText().equals("Save Anyway")) {
warning = "Any override attributes will not be carried forward";
if (!process.overrideAttributesApplied())
warning += "\n(server not running when process loaded).";
else
warning += ".";
getButton(Dialog.OK).setText("Save Anyway");
}
if (warning != null) {
WarningTray tray = getWarningTray();
tray.setMessage(warning);
tray.open();
return;
}
if (overwriteButton.getSelection()) {
if (getButton(Dialog.OK).getText().equals("Force Update"))
setReturnCode(FORCE_UPDATE);
else
setReturnCode(OVERWRITE);
} else {
if (newMinorButton.getSelection())
version = process.getNewVersion(false);
else if (newMajorButton.getSelection())
version = process.getNewVersion(true);
setReturnCode(NEW_VERSION);
}
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
if (rememberSelectionCheckbox.getSelection()) {
Increment increment = Increment.Minor;
if (newMajorButton.getSelection())
increment = Increment.Major;
else if (overwriteButton.getSelection())
increment = Increment.Overwrite;
prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_SAVE_INCREMENT, increment.toString());
} else {
prefsStore.setValue(PreferenceConstants.PREFS_PROCESS_SAVE_INCREMENT, "");
}
prefsStore.setValue(PreferenceConstants.PREFS_ENFORCE_PROCESS_VALIDATION_RULES, enforceValidationCheckbox.getSelection());
if (!process.getProject().isFilePersist())
prefsStore.setValue(PreferenceConstants.PREFS_KEEP_PROCESSES_LOCKED_WHEN_SAVING, keepLockedCheckbox.getSelection());
if (carryOverrideAttributesCheckbox != null)
prefsStore.setValue(PreferenceConstants.PREFS_CARRY_FORWARD_OVERRIDE_ATTRS, carryOverrideAttributesCheckbox.getSelection());
close();
}
Aggregations