Search in sources :

Example 61 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class MdwListInputDialog method initialize.

protected void initialize() {
    setAddCancelButton(true);
    setContentProvider(new ArrayContentProvider());
    int width = 0;
    // calculate dialog width
    for (WorkflowElement element : elements) {
        if (element.getLabel().length() > width)
            width = element.getLabel().length();
    }
    if (width != 0)
        setWidthInChars(width + 2);
    setLabelProvider(new LabelProvider() {

        public Image getImage(Object element) {
            return ((WorkflowElement) element).getIconImage();
        }

        public String getText(Object element) {
            return ((WorkflowElement) element).getLabel();
        }
    });
    setInput(elements);
    setTitle(title);
    setMessage(message);
}
Also used : ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Image(org.eclipse.swt.graphics.Image) LabelProvider(org.eclipse.jface.viewers.LabelProvider) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 62 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement 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 63 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class ImportPackagePage method removeGitVersionedPackages.

/**
 * Not foolproof since it relies on asset XML naming convention. returns
 * emptyFolders to be pruned.
 */
private List<Folder> removeGitVersionedPackages(Folder folder) {
    List<Folder> emptyFolders = new ArrayList<>();
    Map<File, Folder> toRemove = new HashMap<>();
    for (WorkflowElement child : folder.getChildren()) {
        if (child instanceof Folder) {
            for (Folder emptyFolder : removeGitVersionedPackages((Folder) child)) {
                if (!emptyFolders.contains(emptyFolder))
                    emptyFolders.add(emptyFolder);
            }
        } else if (child instanceof File) {
            File file = (File) child;
            String pkgName = file.getName();
            if (file.getParent() instanceof Folder && pkgName.endsWith(".xml")) {
                pkgName = pkgName.substring(0, pkgName.length() - 3);
                int lastDash = pkgName.lastIndexOf('-');
                if (lastDash > 0) {
                    pkgName = pkgName.substring(0, lastDash);
                    for (WorkflowPackage gitPackage : getProject().getTopLevelPackages()) {
                        if (pkgName.equals(gitPackage.getName())) {
                            PluginMessages.log("Import excludes VCS package: " + pkgName);
                            toRemove.put(file, (Folder) file.getParent());
                        }
                    }
                }
            }
        }
    }
    if (!toRemove.isEmpty()) {
        getImportPackageWizard().getImportPackageSelectPage().setInfo("Some packages are not displayed since they exist in version control.");
        for (Map.Entry<File, Folder> file : toRemove.entrySet()) {
            Folder removeFrom = file.getValue();
            removeFrom.getChildren().remove(file.getKey());
            if (removeFrom.getChildren().isEmpty())
                emptyFolders.add(removeFrom);
        }
    }
    return emptyFolders;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Folder(com.centurylink.mdw.plugin.designer.model.Folder) File(com.centurylink.mdw.plugin.designer.model.File) Map(java.util.Map) HashMap(java.util.HashMap) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 64 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class NewPackageWizard method init.

public void init(IWorkbench workbench, IStructuredSelection selection) {
    setDefaultPageImageDescriptor(MdwPlugin.getImageDescriptor("icons/mdw_wiz.png"));
    setNeedsProgressMonitor(true);
    newPackagePage = new NewPackagePage();
    newPackage = new WorkflowPackage();
    if (selection != null && selection.getFirstElement() instanceof WorkflowProject) {
        WorkflowProject workflowProject = (WorkflowProject) selection.getFirstElement();
        newPackage.setProject(workflowProject);
    } else if (selection != null && selection.getFirstElement() instanceof WorkflowElement) {
        WorkflowProject workflowProject = ((WorkflowElement) selection.getFirstElement()).getProject();
        newPackage.setProject(workflowProject);
    } else {
        WorkflowProject workflowProject = WorkflowProjectManager.getInstance().findWorkflowProject(selection);
        if (workflowProject != null)
            newPackage.setProject(workflowProject);
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 65 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class WorkflowAssetWizard method init.

public void init(IWorkbench workbench, IStructuredSelection selection, WorkflowAsset asset) {
    setDefaultPageImageDescriptor(MdwPlugin.getImageDescriptor("icons/mdw_wiz.png"));
    setNeedsProgressMonitor(true);
    this.workflowAsset = asset;
    if (selection != null && selection.getFirstElement() instanceof WorkflowPackage) {
        WorkflowPackage packageVersion = (WorkflowPackage) selection.getFirstElement();
        workflowAsset.setPackage(packageVersion);
    } else if (selection != null && selection.getFirstElement() instanceof WorkflowProject) {
        WorkflowProject workflowProject = (WorkflowProject) selection.getFirstElement();
        if (workflowProject.isShowDefaultPackage())
            workflowAsset.setPackage(workflowProject.getDefaultPackage());
    } else if (selection != null && selection.getFirstElement() instanceof WorkflowElement) {
        WorkflowElement element = (WorkflowElement) selection.getFirstElement();
        workflowAsset.setPackage(element.getPackage());
    } else {
        WorkflowProject workflowProject = WorkflowProjectManager.getInstance().findWorkflowProject(selection);
        if (workflowProject != null)
            workflowAsset.setProject(workflowProject);
    }
    workflowAssetPage = new WorkflowAssetPage(workflowAsset);
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Aggregations

WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)65 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)25 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)25 IAction (org.eclipse.jface.action.IAction)22 Action (org.eclipse.jface.action.Action)21 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)21 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)19 ArrayList (java.util.ArrayList)17 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)14 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)11 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 IFile (org.eclipse.core.resources.IFile)8 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)7 Folder (com.centurylink.mdw.plugin.designer.model.Folder)7 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)7 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)7 PartInitException (org.eclipse.ui.PartInitException)7 AutomatedTestResults (com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)5 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)5