Search in sources :

Example 41 with WorkflowProcess

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

the class WorkflowElementActionHandler method runFromPage.

public void runFromPage(WorkflowElement element) {
    if (element instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) element;
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        WebApp webapp = WebApp.TaskManager;
        if (element.getProject().checkRequiredVersion(5, 5) && !processVersion.isCompatibilityRendering())
            webapp = WebApp.MdwHub;
        WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(element.getProject(), webapp);
        String urlPath = "/start.jsf?process=" + processVersion.getName();
        if (webapp.equals(WebApp.MdwHub)) {
            urlPath = urlPath + "&processVersion=" + processVersion.getVersion();
        }
        launchAction.launch(element.getProject(), urlPath);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WebApp(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebApp)

Example 42 with WorkflowProcess

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

the class WorkflowElementActionHandler method syncOpenEditors.

public void syncOpenEditors(final WorkflowProject project) {
    final WorkflowProjectManager projectMgr = WorkflowProjectManager.getInstance();
    final List<ProcessEditor> processEditors = getOpenProcessEditors(project);
    final List<IEditorPart> assetEditors = getOpenAssetEditors(project);
    if (!processEditors.isEmpty() || !assetEditors.isEmpty()) {
        // sync open editors
        IRunnableWithProgress loader = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Loading " + project.getLabel(), 100);
                monitor.worked(25);
                // sync process editors
                for (ProcessEditor ed : processEditors) {
                    WorkflowProcess pv = ed.getProcess();
                    pv.setProject(projectMgr.getWorkflowProject(pv.getProject().getName()));
                    if (pv.getPackage() != null && !pv.getPackage().isDefaultPackage()) {
                        WorkflowPackage pkg = pv.getProject().getPackage(pv.getPackage().getName());
                        WorkflowProcess oldPv = pkg.getProcess(pv.getName());
                        if (oldPv != null)
                            pkg.removeProcess(oldPv);
                        pkg.addProcess(pv);
                        pv.setPackage(pkg);
                    }
                }
                monitor.worked(50);
                // sync asset editors
                Map<IFile, AssetWorkbenchListener> assetListeners = WorkflowAssetFactory.getWorkbenchListeners();
                for (IEditorPart assetEd : assetEditors) {
                    FileEditorInput fileInput = (FileEditorInput) assetEd.getEditorInput();
                    AssetWorkbenchListener wbListener = assetListeners.get(fileInput.getFile());
                    if (wbListener != null) {
                        WorkflowAsset asset = wbListener.getAsset();
                        WorkflowProject wfProj = projectMgr.getWorkflowProject(asset.getProject().getName());
                        WorkflowAsset oldAsset = wfProj.getAsset(asset.getName(), asset.getLanguage(), asset.getVersion());
                        if (asset.getPackage() != null && !asset.getPackage().isDefaultPackage()) {
                            WorkflowPackage pkg = wfProj.getPackage(asset.getPackage().getName());
                            if (pkg != null) {
                                pkg.removeAsset(oldAsset);
                                pkg.addAsset(asset);
                                asset.setPackage(pkg);
                            } else {
                                asset.setPackage(wfProj.getDefaultPackage());
                            }
                        } else {
                            asset.setPackage(wfProj.getDefaultPackage());
                        }
                        asset.addElementChangeListener(wfProj);
                        if (oldAsset != null)
                            WorkflowAssetFactory.deRegisterAsset(oldAsset);
                        WorkflowAssetFactory.registerAsset(asset);
                        assetEd.addPropertyListener(asset.new AssetEditorPropertyListener(assetEd));
                        WorkflowAssetFactory.registerWorkbenchListener(fileInput.getFile(), wbListener);
                    }
                }
                monitor.worked(25);
                monitor.done();
            }
        };
        ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(Display.getCurrent().getActiveShell());
        try {
            progMonDlg.run(true, false, loader);
        } catch (Exception ex) {
            PluginMessages.uiError(ex, "Sync Open Editors", project);
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) AssetWorkbenchListener(com.centurylink.mdw.plugin.designer.model.WorkflowAsset.AssetWorkbenchListener) IFile(org.eclipse.core.resources.IFile) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProjectManager(com.centurylink.mdw.plugin.project.WorkflowProjectManager) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor)

Example 43 with WorkflowProcess

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

the class WorkflowElementActionHandler method importAttributes.

public void importAttributes(String attributePrefix, WorkflowElement element) {
    if (element instanceof WorkflowPackage || element instanceof WorkflowProcess) {
        ImportAttributesWizard importAttributesWizard = new ImportAttributesWizard();
        importAttributesWizard.init(getWorkbench(), element);
        importAttributesWizard.setPrefix(attributePrefix);
        new WizardDialog(getShell(), importAttributesWizard).open();
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ImportAttributesWizard(com.centurylink.mdw.plugin.designer.wizards.ImportAttributesWizard) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 44 with WorkflowProcess

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

the class WorkflowElementActionHandler method rename.

public void rename(WorkflowElement element) {
    RenameDialog renameDialog = new RenameDialog(getShell(), element);
    renameDialog.setTitle("Rename " + element.getTitle());
    if (element instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) element;
        String lbl = "'" + processVersion.getLabel() + "'";
        IEditorPart editor = findOpenEditor(processVersion);
        if (editor != null) {
            String message = lbl + " is currently open in an editor.\nPlease save and close before renaming.";
            MessageDialog.openError(getShell(), "Process Explorer", message);
            return;
        }
        if (processVersion.getLockingUser() != null && !processVersion.isLockedToUser()) {
            String message = lbl + " is currently locked to " + processVersion.getLockingUser() + ", so it cannot be renamed";
            MessageDialog.openError(getShell(), "Process Explorer", message);
            return;
        }
    } else if (element instanceof WorkflowAsset) {
        WorkflowAsset asset = (WorkflowAsset) element;
        if (asset.getFileEditor() != null) {
            IEditorPart assetEditor = findOpenEditor(asset.getFileEditor().getEditorInput());
            if (assetEditor != null) {
                String message = "'" + asset.getName() + "' is currently open in an editor.\nPlease save and close before renaming.";
                MessageDialog.openError(getShell(), "Process Explorer", message);
                return;
            }
        }
    } else if (element instanceof WorkflowProject) {
        WorkflowProject workflowProject = (WorkflowProject) element;
        if (!workflowProject.isRemote()) {
            if (workflowProject.isCloudProject())
                MessageDialog.openWarning(getShell(), "Cloud Project", "Please rename the underlying Java Project in Package Explorer and then refresh the Process Explorer view.");
            return;
        }
    }
    int result = renameDialog.open();
    if (result == Dialog.OK) {
        String newName = renameDialog.getNewName();
        if (element instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) element;
            if (!workflowProject.isRemote())
                return;
            WorkflowProjectManager.renameRemoteProject(workflowProject, newName);
            workflowProject.fireElementChangeEvent(ChangeType.RENAME, null);
        } else {
            WorkflowProject workflowProject = element.getProject();
            DesignerProxy designerProxy = workflowProject.getDesignerProxy();
            if (element instanceof WorkflowProcess) {
                WorkflowProcess processVersion = (WorkflowProcess) element;
                designerProxy.renameProcess(processVersion, newName);
            } else if (element instanceof WorkflowPackage) {
                WorkflowPackage packageVersion = (WorkflowPackage) element;
                designerProxy.renamePackage(packageVersion, newName);
            } else if (element instanceof WorkflowAsset) {
                WorkflowAsset asset = (WorkflowAsset) element;
                designerProxy.renameWorkflowAsset(asset, newName);
            }
            element.fireElementChangeEvent(ChangeType.RENAME, element.getName());
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) RenameDialog(com.centurylink.mdw.plugin.designer.dialogs.RenameDialog) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 45 with WorkflowProcess

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

the class WorkflowElementActionHandler method run.

public void run(Object element) {
    if (element instanceof WorkflowProcess) {
        WorkflowProcess processVersion = (WorkflowProcess) element;
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        if (MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_WEB_BASED_PROCESS_LAUNCH)) {
            // web-based process launch
            try {
                IViewPart viewPart = getPage().showView("mdw.views.designer.process.launch");
                if (viewPart != null) {
                    ProcessLaunchView launchView = (ProcessLaunchView) viewPart;
                    launchView.setProcess(processVersion);
                }
            } catch (PartInitException ex) {
                PluginMessages.log(ex);
            }
        } else {
            if (editorPart == null) {
                // process must be open
                open((WorkflowElement) element);
            }
            ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut();
            launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.RUN_MODE);
        }
    } else if (element instanceof Activity) {
        Activity activity = (Activity) element;
        WorkflowProcess processVersion = activity.getProcess();
        IEditorPart editorPart = findOpenEditor(processVersion);
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.RUN_MODE);
    } else if (element instanceof ExternalEvent) {
        ExternalEvent externalEvent = (ExternalEvent) element;
        ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut();
        launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.RUN_MODE);
    } else if (element instanceof Template) {
        Template template = (Template) element;
        IEditorPart editorPart = template.getFileEditor();
        if (editorPart != null && editorPart.isDirty()) {
            if (MessageDialog.openQuestion(getShell(), "Run Template", "Save template '" + template.getName() + "' before running?"))
                editorPart.doSave(new NullProgressMonitor());
        }
        template.openFile(new NullProgressMonitor());
        new TemplateRunDialog(getShell(), template).open();
    } else if (element instanceof Page) {
        Page page = (Page) element;
        IEditorPart editorPart = page.getFileEditor();
        if (editorPart != null) {
            if (editorPart.isDirty()) {
                if (MessageDialog.openQuestion(getShell(), "Run Page", "Save page '" + page.getName() + "' before running?"))
                    editorPart.doSave(new NullProgressMonitor());
            }
        }
        page.run();
    } else if (element instanceof WorkflowProject || element instanceof ServerSettings) {
        ServerSettings serverSettings;
        if (element instanceof WorkflowProject) {
            WorkflowProject workflowProject = (WorkflowProject) element;
            if (workflowProject.isRemote())
                throw new IllegalArgumentException("Cannot run server for remote projects.");
            serverSettings = workflowProject.getServerSettings();
        } else {
            serverSettings = (ServerSettings) element;
        }
        if (ServerRunner.isServerRunning()) {
            String question = "A server may be running already.  Shut down the currently-running server?";
            MessageDialog dlg = new MessageDialog(getShell(), "Server Running", null, question, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Shutdown", "Ignore", "Cancel" }, 0);
            int res = dlg.open();
            if (res == 0)
                new ServerRunner(serverSettings, getShell().getDisplay()).stop();
            else if (res == 2)
                return;
        }
        if (serverSettings.getHome() == null && element instanceof WorkflowProject) {
            final IProject project = serverSettings.getProject().isCloudProject() ? serverSettings.getProject().getSourceProject() : serverSettings.getProject().getEarProject();
            @SuppressWarnings("restriction") org.eclipse.ui.internal.dialogs.PropertyDialog dialog = org.eclipse.ui.internal.dialogs.PropertyDialog.createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", project);
            if (dialog != null)
                dialog.open();
        } else {
            IPreferenceStore prefStore = MdwPlugin.getDefault().getPreferenceStore();
            if (element instanceof WorkflowProject)
                prefStore.setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT, ((WorkflowProject) element).getName());
            else
                prefStore.setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName());
            ServerRunner runner = new ServerRunner(serverSettings, getShell().getDisplay());
            if (serverSettings.getProject() != null)
                runner.setJavaProject(serverSettings.getProject().getJavaProject());
            runner.start();
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IViewPart(org.eclipse.ui.IViewPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExternalEventLaunchShortcut(com.centurylink.mdw.plugin.launch.ExternalEventLaunchShortcut) AdapterActivity(com.centurylink.mdw.plugin.designer.model.Activity.AdapterActivity) EvaluatorActivity(com.centurylink.mdw.plugin.designer.model.Activity.EvaluatorActivity) StartActivity(com.centurylink.mdw.plugin.designer.model.Activity.StartActivity) Activity(com.centurylink.mdw.plugin.designer.model.Activity) ActivityLaunchShortcut(com.centurylink.mdw.plugin.launch.ActivityLaunchShortcut) TemplateRunDialog(com.centurylink.mdw.plugin.designer.dialogs.TemplateRunDialog) SearchResultsPage(com.centurylink.mdw.plugin.search.SearchResultsPage) Page(com.centurylink.mdw.plugin.designer.model.Page) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) Template(com.centurylink.mdw.plugin.designer.model.Template) TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) ProcessLaunchShortcut(com.centurylink.mdw.plugin.launch.ProcessLaunchShortcut) ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) PartInitException(org.eclipse.ui.PartInitException) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) ServerRunner(com.centurylink.mdw.plugin.server.ServerRunner) ProcessLaunchView(com.centurylink.mdw.plugin.designer.views.ProcessLaunchView) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)85 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)28 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)21 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)21 PartInitException (org.eclipse.ui.PartInitException)20 ArrayList (java.util.ArrayList)17 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)12 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)11 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)11 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)10 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)9 IEditorPart (org.eclipse.ui.IEditorPart)9 ProcessEditor (com.centurylink.mdw.plugin.designer.editors.ProcessEditor)8 IFile (org.eclipse.core.resources.IFile)8 CoreException (org.eclipse.core.runtime.CoreException)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 IOException (java.io.IOException)7 ValidationException (com.centurylink.mdw.designer.utils.ValidationException)6 Activity (com.centurylink.mdw.plugin.designer.model.Activity)6