Search in sources :

Example 41 with WorkflowAsset

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;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) TreeComboCellEditor(com.centurylink.jface.viewers.TreeComboCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SelectionModifier(com.centurylink.jface.viewers.TreeComboCellEditor.SelectionModifier) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) TreeComboCellEditor(com.centurylink.jface.viewers.TreeComboCellEditor) List(java.util.List) ArrayList(java.util.ArrayList) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) HashMap(java.util.HashMap)

Example 42 with WorkflowAsset

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());
    }
}
Also used : PropertyEditorList(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) PartInitException(org.eclipse.ui.PartInitException)

Example 43 with WorkflowAsset

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;
}
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 44 with WorkflowAsset

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();
}
Also used : ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) Image(org.eclipse.swt.graphics.Image) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ListDialog(org.eclipse.ui.dialogs.ListDialog) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 45 with WorkflowAsset

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);
            }
        }
    }
}
Also used : TempFileRemover(com.centurylink.mdw.plugin.workspace.TempFileRemover) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) JavaSource(com.centurylink.mdw.plugin.designer.model.JavaSource) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)46 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)17 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)15 ArrayList (java.util.ArrayList)13 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)8 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)8 IFile (org.eclipse.core.resources.IFile)8 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)7 RuleSetVO (com.centurylink.mdw.model.value.attribute.RuleSetVO)6 File (java.io.File)6 IOException (java.io.IOException)6 CoreException (org.eclipse.core.runtime.CoreException)6 IEditorPart (org.eclipse.ui.IEditorPart)5 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)4 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)4 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)4 List (java.util.List)4 IFolder (org.eclipse.core.resources.IFolder)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 CodeTimer (com.centurylink.mdw.plugin.CodeTimer)3