Search in sources :

Example 76 with WorkflowPackage

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);
}
Also used : IWorkbenchListener(org.eclipse.ui.IWorkbenchListener) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) TaskTemplateDocument(com.centurylink.mdw.task.TaskTemplateDocument) IFile(org.eclipse.core.resources.IFile) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) PartInitException(org.eclipse.ui.PartInitException) IWorkbenchPartReference(org.eclipse.ui.IWorkbenchPartReference) WorkflowSelectionProvider(com.centurylink.mdw.plugin.designer.WorkflowSelectionProvider) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) JSONException(org.json.JSONException) PartInitException(org.eclipse.ui.PartInitException) IPartListener2(org.eclipse.ui.IPartListener2) IWorkbench(org.eclipse.ui.IWorkbench) JSONObject(org.json.JSONObject) FileEditorInput(org.eclipse.ui.part.FileEditorInput) TaskVO(com.centurylink.mdw.model.value.task.TaskVO)

Example 77 with WorkflowPackage

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;
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) Text(org.eclipse.swt.widgets.Text) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 78 with WorkflowPackage

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();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Composite(org.eclipse.swt.widgets.Composite) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList)

Example 79 with WorkflowPackage

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);
}
Also used : CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) GridData(org.eclipse.swt.layout.GridData) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 80 with WorkflowPackage

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()));
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Combo(org.eclipse.swt.widgets.Combo)

Aggregations

WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)85 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)31 ArrayList (java.util.ArrayList)27 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)17 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 GridData (org.eclipse.swt.layout.GridData)11 CoreException (org.eclipse.core.runtime.CoreException)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)8 List (java.util.List)8 Label (org.eclipse.swt.widgets.Label)8 JSONException (org.json.JSONException)8 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)7 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)7 Folder (com.centurylink.mdw.plugin.designer.model.Folder)7 IOException (java.io.IOException)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7