Search in sources :

Example 31 with WorkflowAsset

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

the class ProcessExplorerActionGroup method createImportActionGroup.

private ActionGroup createImportActionGroup() {
    importMenu = new MenuManager("Import", MdwPlugin.getImageDescriptor("icons/import.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import");
    return new ActionGroup() {

        @Override
        public void fillContextMenu(IMenuManager menu) {
            importMenu.removeAll();
            IStructuredSelection selection = getSelection();
            WorkflowElement element = (WorkflowElement) selection.getFirstElement();
            if (!importMenuApplies(selection))
                return;
            if (importProjectApplies())
                importMenu.add(importProjectAction);
            if (importPackageApplies(selection))
                importMenu.add(importPackageAction);
            if (importVcsApplies(selection))
                importMenu.add(importVcsAction);
            if (importProcessApplies(selection)) {
                if (element instanceof WorkflowProcess) {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.process.version");
                    importProcessAction.setText("New Process Version...");
                } else {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.process");
                    importProcessAction.setText(PROCESS_DOT);
                }
                importMenu.add(importProcessAction);
            }
            if (importWorkflowAssetApplies(selection)) {
                if (element instanceof WorkflowAsset) {
                    WorkflowAsset asset = (WorkflowAsset) element;
                    // menu item text and icon are dynamic
                    importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.asset.version");
                    importWorkflowAssetAction.setText("New " + asset.getTitle() + " Version...");
                    importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICONS + asset.getIcon()));
                } else {
                    importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.asset");
                    importWorkflowAssetAction.setText("Asset...");
                    importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICON_DOC_GIF));
                }
                importMenu.add(importWorkflowAssetAction);
            }
            if (importAttributesApplies(selection)) {
                List<IAction> importAttrsActions = getImportAttributeActions(selection);
                if (!importAttrsActions.isEmpty()) {
                    MenuManager attributesMenu = new MenuManager("Attributes", MdwPlugin.getImageDescriptor("icons/attribute.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import.attributes");
                    attributesMenu.removeAll();
                    for (IAction action : importAttrsActions) attributesMenu.add(action);
                    importMenu.add(attributesMenu);
                }
            }
            if (importTaskTemplateApplies(selection))
                importMenu.add(importTaskTemplateAction);
            importMenu.add(new Separator(OTHER));
            IWorkbenchAction otherAction = ActionFactory.IMPORT.create(getViewSite().getWorkbenchWindow());
            otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.other");
            otherAction.setText(OTHER_DOT);
            importMenu.add(otherAction);
        }
    };
}
Also used : IAction(org.eclipse.jface.action.IAction) ActionGroup(org.eclipse.ui.actions.ActionGroup) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) MdwMenuManager(com.centurylink.mdw.plugin.actions.MdwMenuManager) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) Separator(org.eclipse.jface.action.Separator)

Example 32 with WorkflowAsset

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

the class ProcessExplorerDragSource method isDragAllowed.

private boolean isDragAllowed(Object selectedElement) {
    boolean dragArchived = MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_ALLOW_DELETE_ARCHIVED_PROCESSES);
    if (selectedElement instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) selectedElement;
        IEditorPart editor = findOpenEditor(processVersion);
        if (editor != null) {
            String message = "'" + processVersion.getLabel() + "' is currently open in an editor.\nPlease save and close before dragging.";
            MessageDialog.openError(MdwPlugin.getShell(), "Process Explorer", message);
            return false;
        }
        return dragArchived || !processVersion.isArchived();
    } else if (selectedElement instanceof ExternalEvent) {
        ExternalEvent externalEvent = (ExternalEvent) selectedElement;
        return dragArchived || !externalEvent.isArchived();
    } else if (selectedElement instanceof ActivityImpl) {
        ActivityImpl activityImpl = (ActivityImpl) selectedElement;
        return dragArchived || !activityImpl.isArchived();
    } else if (selectedElement instanceof WorkflowAsset) {
        WorkflowAsset asset = (WorkflowAsset) selectedElement;
        IEditorPart tempFileEditor = asset.getFileEditor();
        if (tempFileEditor != null && findOpenEditor(tempFileEditor.getEditorInput()) != null) {
            String message = "'" + asset.getLabel() + "' is currently open in an editor.\nPlease save and close before dragging.";
            MessageDialog.openError(MdwPlugin.getShell(), "Process Explorer", message);
            return false;
        }
        return dragArchived || !asset.isArchived();
    }
    return false;
}
Also used : ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 33 with WorkflowAsset

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

the class ProcessExplorerDragSource method dragSetData.

@Override
public void dragSetData(DragSourceEvent event) {
    if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
        IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
        List<?> elements = selection.toList();
        StringBuilder data = new StringBuilder();
        for (int i = 0; i < elements.size(); i++) {
            Object element = elements.get(i);
            if (element instanceof WorkflowProcess || element instanceof ExternalEvent || element instanceof ActivityImpl || element instanceof WorkflowAsset) {
                data.append(element.toString());
                if (i < elements.size() - 1)
                    data.append("#");
            }
        }
        event.data = data.toString();
    }
}
Also used : ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 34 with WorkflowAsset

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

the class ExportAssetWizard method performImportExport.

void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ActionCancelledException {
    WorkflowAsset asset = getAsset();
    if (!asset.isLoaded())
        asset.load();
    progressMonitor.progress(20);
    byte[] bytes = asset.isBinary() ? asset.getDecodedContent() : asset.getContent().getBytes();
    writeFile(getPage().getFilePath(), bytes);
    progressMonitor.progress(5);
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

Example 35 with WorkflowAsset

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

the class ImportAssetWizard method postRunUpdates.

@Override
protected void postRunUpdates() {
    WorkflowAsset asset = getPage().getAsset();
    asset.addElementChangeListener(asset.getProject());
    asset.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, asset);
    if (!asset.isLockedToUser())
        asset.fireElementChangeEvent(ChangeType.PROPERTIES_CHANGE, null);
    WorkflowAssetFactory.registerAsset(asset);
}
Also used : WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset)

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