use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset 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.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class TaskTemplateEditor method createPages.
@Override
protected void createPages() {
pages = new HashMap<>();
try {
WorkflowAsset pageletAsset = taskTemplate.getPagelet();
if (!pageletAsset.isLoaded())
pageletAsset.load();
String pageletXml = pageletAsset.getContent();
propertyEditors = new PropertyEditorList(taskTemplate, pageletXml);
// general section
addPage((String) null);
int pageCount = 1;
for (String section : propertyEditors.getSections()) {
addPage(section);
pageCount++;
}
addPage(textEditor, getEditorInput());
setPageText(pageCount, "Source");
pages.put("Source", textEditor);
firePropertyChange(PROP_TITLE);
taskTemplate.addElementChangeListener(this);
taskTemplate.addDirtyStateListener(this);
} catch (PartInitException ex) {
PluginMessages.uiError(getSite().getShell(), ex, "Task Template", taskTemplate.getProject());
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class RenameDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
String message = "";
final WorkflowProcess processVersion;
Composite composite = (Composite) super.createDialogArea(parent);
if (toRename instanceof WorkflowProcess) {
processVersion = (WorkflowProcess) toRename;
if (processVersion.hasDescendantProcessVersions())
message = "Renaming all process versions.";
else
message = "Renamed process will be version 1.";
message += "\nCalling processes must be updated manually.";
} else {
processVersion = null;
}
composite.getShell().setText(title);
new Label(composite, SWT.NONE).setText("New Name:");
newNameTextField = new Text(composite, SWT.BORDER | SWT.SINGLE);
GridData gd = new GridData(SWT.LEFT);
gd.widthHint = 200;
newNameTextField.setLayoutData(gd);
newNameTextField.setText(toRename.getName());
newNameTextField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String name = newNameTextField.getText().trim();
if (name.length() == 0) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
return;
}
String error = null;
if (toRename instanceof WorkflowProcess && workflowProject.getDataAccess().processNameExists(processVersion.getPackage().getPackageVO(), name))
error = "Process name already exists:\n'" + name + "'";
else if (toRename instanceof WorkflowPackage) {
WorkflowPackage packageVersion = (WorkflowPackage) toRename;
if (workflowProject.packageNameExists(name)) {
error = "Package name already exists:\n'" + name + "'";
} else {
boolean containsJavaOrGroovy = false;
for (WorkflowAsset asset : packageVersion.getAssets()) {
if (RuleSetVO.GROOVY.equals(asset.getLanguage()) || RuleSetVO.JAVA.equals(asset.getLanguage())) {
containsJavaOrGroovy = true;
break;
}
}
if (containsJavaOrGroovy && !"true".equals(System.getProperty("mdw.allow.nonstandard.naming"))) {
String goodPkgName = JavaNaming.getValidPackageName(name);
if (!goodPkgName.equals(name))
error = "Packages with Java or Groovy assets must comply with Java package naming restrictions.";
}
}
}
if (error != null) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
WarningTray tray = getWarningTray();
tray.setMessage(error);
tray.open();
} else {
newName = name;
getWarningTray().close();
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
}
});
new Label(composite, SWT.NONE).setText(message);
return composite;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class PluginMessages method uiList.
public static int uiList(Shell shell, String message, String title, List<?> items, final List<?> flaggedItems) {
ListDialog listDialog = new ListDialog(shell);
listDialog.setAddCancelButton(true);
listDialog.setContentProvider(new ArrayContentProvider());
int width = 0;
if (!items.isEmpty() && items.get(0) instanceof WorkflowElement) {
// calculate dialog width
for (Object item : items) {
WorkflowElement element = (WorkflowElement) item;
String label = (element instanceof WorkflowAsset && element.getProject().checkRequiredVersion(5, 5) && flaggedItems == null) ? element.getLabelWithPackage() : element.getLabel();
if (flaggedItems != null && flaggedItems.contains(item))
label += " *";
if (label.length() > width)
width = label.length();
}
listDialog.setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
return ((WorkflowElement) element).getIconImage();
}
@Override
public String getText(Object element) {
String flag = flaggedItems != null && flaggedItems.contains(element) ? " *" : "";
if (element instanceof WorkflowAsset && ((WorkflowAsset) element).getProject().checkRequiredVersion(5, 5) && flaggedItems == null)
return ((WorkflowAsset) element).getLabelWithPackage() + flag;
else
return ((WorkflowElement) element).getLabel() + flag;
}
});
} else {
for (Object item : items) {
if (item.toString().length() > width)
width = item.toString().length();
}
listDialog.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return element.toString();
}
});
}
listDialog.setInput(items);
listDialog.setTitle(title);
listDialog.setMessage(message);
if (width != 0)
listDialog.setWidthInChars(width + 2);
return listDialog.open();
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ProjectConfigurator method loadJavaLibraries.
public void loadJavaLibraries(IProgressMonitor monitor) {
// locally save all the Java libraries
for (WorkflowAsset asset : project.getTopLevelWorkflowAssets()) {
if (asset instanceof JavaSource) {
if (!asset.isLoaded())
asset.load();
try {
IFolder folder = asset.getTempFolder();
if (!folder.exists())
PluginUtil.createFoldersAsNeeded(project.getSourceProject(), folder, monitor);
IFile tempFile = asset.getTempFile(folder);
if (tempFile.exists())
new TempFileRemover(folder, tempFile).remove(monitor);
tempFile.create(new ByteArrayInputStream(asset.getFileContent()), true, monitor);
PluginMessages.log("Created Java lib file: " + tempFile.getFullPath().toString());
} catch (CoreException ex) {
PluginMessages.uiError(ex, "Load Java Libraries", project);
}
}
}
}
Aggregations