use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class Importer method importAttributes.
public void importAttributes(final WorkflowElement element, final String xml, final ProgressMonitor progressMonitor, String attrPrefix) throws DataAccessException, XmlException {
progressMonitor.subTask(PARSING_XML);
int schemaVersion = dataAccess.getSchemaVersion();
ProcessImporter importer = DataAccess.getProcessImporter(schemaVersion);
progressMonitor.progress(40);
progressMonitor.subTask("Saving attributes");
ProcessDefinitionDocument procdef = ProcessDefinitionDocument.Factory.parse(xml, Compatibility.namespaceOptions());
if (element instanceof WorkflowPackage && !((WorkflowPackage) element).getName().equals(procdef.getProcessDefinition().getPackageName()))
throw new DataAccessException("Expected package: " + ((WorkflowPackage) element).getName() + " in attributes XML but found: " + procdef.getProcessDefinition().getPackageName());
for (MDWProcess process : procdef.getProcessDefinition().getProcessList()) {
ProcessDefinitionDocument oneProcDef = ProcessDefinitionDocument.Factory.newInstance();
MDWProcessDefinition oneProc = oneProcDef.addNewProcessDefinition();
oneProc.getProcessList().add(process);
ProcessVO importedProc = importer.importProcess(oneProcDef.xmlText());
if (element instanceof WorkflowProcess && !((WorkflowProcess) element).getName().equals(importedProc.getProcessName()))
throw new DataAccessException("Expected process: " + ((WorkflowProcess) element).getName() + " in attributes XML but found: " + importedProc.getName());
ProcessVO proc = dataAccess.getLatestProcess(importedProc.getName());
if (proc == null)
throw new DataAccessException("Process not found: " + importedProc.getName());
Map<String, String> existAttrs = dataAccess.getDesignerDataAccess().getAttributes(OwnerType.PROCESS, proc.getId());
Map<String, String> importedAttrs = importedProc.getOverrideAttributes();
Map<String, String> setAttrs = new HashMap<>();
if (existAttrs != null) {
// retain existing attrs not related to this prefix
for (Map.Entry<String, String> attrs : existAttrs.entrySet()) {
if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
setAttrs.put(attrs.getKey(), attrs.getValue());
}
}
if (importedAttrs != null) {
for (Map.Entry<String, String> attrs : importedAttrs.entrySet()) {
if (!WorkAttributeConstant.isAttrNameFor(attrs.getKey(), attrPrefix))
throw new DataAccessException("Expected attribute prefix: " + attrPrefix + " in attributes XML but found attribute: " + attrs.getKey());
else
setAttrs.put(attrs.getKey(), attrs.getValue());
}
}
dataAccess.getDesignerDataAccess().setOverrideAttributes(attrPrefix, OwnerType.PROCESS, proc.getId(), setAttrs);
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class TableEditor method createTableViewer.
private TableViewer createTableViewer(Table table) {
TableViewer lTableViewer = new TableViewer(table);
lTableViewer.setUseHashlookup(true);
lTableViewer.setColumnProperties(columnProps);
if (!isReadOnly()) {
CellEditor[] cellEditors = new CellEditor[columnSpecs.size()];
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
CellEditor cellEditor = null;
if (!colSpec.hidden) {
if (colSpec.type.equals(TYPE_TEXT)) {
if (colSpec.style != 0)
cellEditor = new TextCellEditor(table, colSpec.style);
else
cellEditor = new TextCellEditor(table);
} else if (colSpec.type.equals(TYPE_CHECKBOX)) {
cellEditor = new CheckboxCellEditor(table);
} else if (colSpec.type.equals(TYPE_COMBO)) {
int style = SWT.None;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
cellEditor = new ComboBoxCellEditor(table, colSpec.options, style);
if (!colSpec.readOnly)
cellEditor.addListener(new EditableComboCellEditorListener((ComboBoxCellEditor) cellEditor, i));
} else if (colSpec.type.equals(WorkflowAssetEditor.TYPE_ASSET)) {
int style = SWT.None;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
cellEditor = new TreeComboCellEditor(table, style) {
@Override
protected void doSetValue(Object value) {
Object val = getValue();
if (val instanceof CTreeComboItem) {
CTreeComboItem selItem = (CTreeComboItem) getValue();
if (selItem != null) {
super.doSetValue(selItem.getText());
return;
}
}
if (value instanceof String) {
String strVal = (String) value;
if (strVal.indexOf('/') > -1) {
super.doSetValue(strVal.substring(strVal.indexOf('/') + 1));
return;
}
}
super.doSetValue(value);
}
};
((TreeComboCellEditor) cellEditor).setSelectionModifier(new SelectionModifier() {
public String modify(CTreeComboItem selection) {
if (selection.getParentItem() != null) {
WorkflowPackage pkg = getProject().getPackage(selection.getParentItem().getText());
if (pkg == null || pkg.isDefaultPackage())
return selection.getText();
else
return pkg.getName() + "/" + selection.getText();
} else {
// ignore packages
return null;
}
}
});
// populate the treecombo
if (colSpec.source.equals(PROCESS)) {
List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
for (WorkflowPackage pkg : packages) {
CTreeComboItem packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkg.getName());
packageItem.setText(pkg.getName());
packageItem.setImage(pkg.getIconImage());
for (WorkflowProcess process : pkg.getProcesses()) {
CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
processItem.setText(process.getLabel());
processItem.setImage(process.getIconImage());
}
}
} else {
List<WorkflowAsset> assets = getProject().getAssetList(Arrays.asList(colSpec.assetTypes));
Map<String, CTreeComboItem> packageItems = new HashMap<>();
for (WorkflowAsset asset : assets) {
String pkgName = asset.getPackage().getName();
CTreeComboItem packageItem = packageItems.get(pkgName);
if (packageItem == null) {
packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkgName);
packageItem.setImage(asset.getPackage().getIconImage());
packageItems.put(pkgName, packageItem);
}
CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
assetItem.setText(asset.getLabel());
assetItem.setImage(asset.getIconImage());
}
}
}
if (colSpec.listener != null && cellEditor != null)
cellEditor.addListener(colSpec.listener);
cellEditors[i] = cellEditor;
}
}
lTableViewer.setCellEditors(cellEditors);
lTableViewer.setCellModifier(cellModifier);
}
return lTableViewer;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class ProcessLockSection method elementChanged.
public void elementChanged(ElementChangeEvent ece) {
if (ece.getElement().equals(process)) {
if (ece.getChangeType().equals(ChangeType.PROPERTIES_CHANGE)) {
WorkflowProcess changedVersion = (WorkflowProcess) ece.getElement();
if (!lockUserPropertyEditor.getValue().equals(changedVersion.getLockingUser())) {
lockUserPropertyEditor.setValue(changedVersion.getLockingUser());
lockDatePropertyEditor.setValue(changedVersion.getLockedDate());
lockButtonPropertyEditor.setLabel(changedVersion.isLockedToUser() ? "Unlock" : "Lock");
}
notifyLabelChange();
}
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class ProcessVersionsSection method createContextMenu.
private Menu createContextMenu(Shell shell) {
Menu menu = new Menu(shell, SWT.POP_UP);
final StructuredSelection selection = (StructuredSelection) tableEditor.getTableViewer().getSelection();
if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowProcess) {
final WorkflowProcess processVer = (WorkflowProcess) selection.getFirstElement();
MenuItem openItem = new MenuItem(menu, SWT.PUSH);
openItem.setText("Open");
ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
openItem.setImage(openImageDesc.createImage());
openItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
openProcess(processVer);
}
});
}
// delete
if (!selection.isEmpty() && !process.getProject().isProduction() && process.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION) && (selection.size() == 1 && ((WorkflowProcess) selection.getFirstElement()).isLatest()) || MdwPlugin.getSettings().isAllowDeleteArchivedProcesses()) {
MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
deleteItem.setText("Delete...");
ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif");
deleteItem.setImage(deleteImageDesc.createImage());
deleteItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (selection.size() >= 1 && selection.getFirstElement() instanceof WorkflowProcess) {
WorkflowProcess[] processVers = new WorkflowProcess[selection.size()];
int idx = 0;
for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
processVers[idx] = (WorkflowProcess) iter.next();
idx++;
}
WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
actionHandler.delete(processVers);
boolean removedSelected = false;
for (WorkflowProcess pv : processVers) {
if (pv.equals(process))
removedSelected = true;
else
process.remove(pv);
}
if (removedSelected) {
WorkflowProcess sel = null;
for (WorkflowProcess toSel : process.getAllProcessVersions()) {
if (!toSel.equals(process)) {
sel = toSel;
break;
}
}
setSelection(sel);
} else {
// just force refresh
setSelection(process);
}
}
}
});
}
return menu;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowProcess in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementDeleteDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
composite.getShell().setText("Delete Workflow Elements");
boolean showIncludeInstances = false;
for (WorkflowElement workflowElement : elements) {
if (workflowElement instanceof WorkflowProcess) {
showIncludeInstances = true;
break;
}
}
if (showIncludeInstances) {
includeInstancesCheckbox = new Button(composite, SWT.CHECK | SWT.LEFT);
includeInstancesCheckbox.setText("Include instances if they exist");
}
return composite;
}
Aggregations