use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class TaskTemplateEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
setSite(site);
textEditor = new StructuredTextEditor() {
@Override
public boolean isEditable() {
return false;
}
@Override
public boolean isEditorInputModifiable() {
return false;
}
@Override
public boolean isEditorInputReadOnly() {
return true;
}
@Override
public boolean isDirty() {
return false;
}
};
textEditor.setEditorPart(this);
if (input instanceof FileEditorInput) {
setInput(input);
IFile file = ((FileEditorInput) input).getFile();
WorkflowProject project = WorkflowProjectManager.getInstance().getWorkflowProject(file.getProject());
// force initialization
project.getDesignerProxy();
WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
taskTemplate = (TaskTemplate) pkg.getTaskTemplate(file);
// refresh from file system to make sure we're in sync
try {
Long taskId = taskTemplate.getId();
int version = taskTemplate.getVersion();
file.refreshLocal(IResource.DEPTH_ZERO, null);
String content = new String(PluginUtil.readFile(file));
TaskVO taskVO;
if (content.trim().startsWith("{")) {
taskVO = new TaskVO(new JSONObject(content));
} else {
TaskTemplateDocument doc = TaskTemplateDocument.Factory.parse(content);
com.centurylink.mdw.task.TaskTemplate fileTemplate = doc.getTaskTemplate();
taskVO = new TaskVO(fileTemplate);
}
taskTemplate.setTaskVO(taskVO);
taskVO.setName(file.getName());
taskVO.setTaskId(taskId);
taskTemplate.setId(taskId);
taskTemplate.setVersion(version);
taskVO.setPackageName(pkg.getName());
} catch (Exception ex) {
throw new PartInitException(ex.getMessage(), ex);
}
} else {
throw new PartInitException("Invalid input: " + input);
}
selectionProvider = new WorkflowSelectionProvider(taskTemplate);
site.setSelectionProvider(selectionProvider);
setPartName(taskTemplate.getName());
addPageChangedListener(new IPageChangedListener() {
public void pageChanged(PageChangedEvent event) {
if (getSelectedPage() == pages.get("Variables")) {
reconcileVariables();
}
}
});
partListener = new IPartListener2() {
public void partOpened(IWorkbenchPartReference partRef) {
// do nothing
}
public void partActivated(IWorkbenchPartReference partRef) {
IWorkbenchPart part = partRef.getPart(false);
if (part == TaskTemplateEditor.this && getSelectedPage() == pages.get("Variables"))
reconcileVariables();
}
public void partBroughtToTop(IWorkbenchPartReference partRef) {
// do nothing
}
public void partDeactivated(IWorkbenchPartReference partRef) {
// do nothing
}
public void partClosed(IWorkbenchPartReference partRef) {
// do nothing
}
public void partVisible(IWorkbenchPartReference partRef) {
// do nothing
}
public void partHidden(IWorkbenchPartReference partRef) {
// do nothing
}
public void partInputChanged(IWorkbenchPartReference partRef) {
// do nothing
}
};
getSite().getPage().addPartListener(partListener);
workbenchListener = new IWorkbenchListener() {
public boolean preShutdown(IWorkbench workbench, boolean forced) {
return MdwPlugin.getActivePage().closeEditor(TaskTemplateEditor.this, true);
}
public void postShutdown(IWorkbench workbench) {
// do nothing
}
};
PlatformUI.getWorkbench().addWorkbenchListener(workbenchListener);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage 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.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class ToolboxFilterDialog method createSelectButtons.
private void createSelectButtons(Composite parent) {
Composite buttonComposite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 0;
layout.marginWidth = 0;
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
buttonComposite.setLayout(layout);
buttonComposite.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false));
Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, "Select All", false);
selectButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
suppressedImplementors = new ArrayList<>();
treeViewer.refresh();
}
});
Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, "Deselect All", false);
deselectButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
suppressedImplementors = new ArrayList<>();
for (WorkflowPackage pkg : workflowProject.getTopLevelUserVisiblePackages()) {
for (ActivityImpl impl : pkg.getActivityImpls()) {
if (!suppressedImplementors.contains(impl.getImplClassName()))
suppressedImplementors.add(impl.getImplClassName());
}
}
treeViewer.refresh();
}
});
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class ToolboxFilterDialog method createPackageTree.
private void createPackageTree(Composite parent) {
treeViewer = new CheckboxTreeViewer(parent, SWT.CHECK | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
treeViewer.setContentProvider(new ViewContentProvider());
treeViewer.setLabelProvider(new ViewLabelProvider());
treeViewer.setCheckStateProvider(new ViewCheckStateProvider());
treeViewer.setInput(workflowProject.getTopLevelUserVisiblePackages());
GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = 400;
treeViewer.getTree().setLayoutData(data);
treeViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
boolean checked = event.getChecked();
if (event.getElement() instanceof WorkflowPackage) {
WorkflowPackage pkg = (WorkflowPackage) event.getElement();
for (ActivityImpl impl : pkg.getActivityImpls()) {
if (checked)
suppressedImplementors.remove(impl.getImplClassName());
else if (!suppressedImplementors.contains(impl.getImplClassName()))
suppressedImplementors.add(impl.getImplClassName());
}
treeViewer.refresh();
} else if (event.getElement() instanceof ActivityImpl) {
ActivityImpl impl = (ActivityImpl) event.getElement();
if (checked)
suppressedImplementors.remove(impl.getImplClassName());
else if (!suppressedImplementors.contains(impl.getImplClassName()))
suppressedImplementors.add(impl.getImplClassName());
treeViewer.refresh();
}
}
});
ColumnViewerToolTipSupport.enableFor(treeViewer);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage in project mdw-designer by CenturyLinkCloud.
the class WizardPage method createWorkflowPackageControls.
protected void createWorkflowPackageControls(Composite parent, int ncol, final boolean handleFieldChanged) {
new Label(parent, SWT.NONE).setText("Workflow Package:");
workflowPackageCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = ncol - 1;
gd.widthHint = 200;
workflowPackageCombo.setLayoutData(gd);
workflowPackageCombo.removeAll();
if (getElement().getProject() != null) {
for (WorkflowPackage packageVersion : getElement().getProject().getTopLevelUserVisiblePackages()) workflowPackageCombo.add(packageVersion.getName());
}
workflowPackageCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setPackage(workflowPackageCombo.getText().trim());
if (handleFieldChanged)
handleFieldChanged();
}
});
if (getElement().getPackage() != null)
workflowPackageCombo.setText(getElement().getPackage().getName());
else
workflowPackageCombo.select(0);
getElement().setPackage(getElement().getProject().getTopLevelUserVisiblePackages().get(workflowPackageCombo.getSelectionIndex()));
}
Aggregations