Search in sources :

Example 1 with WorkflowProjectManager

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

the class WebToolsAction method populateMenu.

/**
 * populates the plugin action menu (the webtools icon) with its items
 */
public void populateMenu(Menu menu) {
    WorkflowProjectManager wfProjectMgr = WorkflowProjectManager.getInstance();
    List<WorkflowProject> workflowProjects = wfProjectMgr.getWorkflowProjects();
    if (workflowProjects.isEmpty()) {
        MenuItem item = new MenuItem(menu, SWT.NONE);
        item.setText("(No Projects)");
        item.setImage(MdwPlugin.getImageDescriptor("icons/wait.gif").createImage());
        item.setEnabled(false);
    } else {
        for (final WorkflowProject workflowProject : workflowProjects) {
            String projName = workflowProject.isFrameworkProject() ? "MDWFramework" : workflowProject.getName();
            // MDWWeb
            MenuItem item = new MenuItem(menu, SWT.NONE);
            final WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(workflowProject, WebApp.WebTools);
            item.setText(projName + " - " + launchAction.getLabel());
            item.setImage(launchAction.getIconImage());
            item.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    mostRecentWebToolsLaunchWorkflowProject = workflowProject;
                    launchAction.launch(workflowProject);
                }
            });
        }
    }
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) MenuItem(org.eclipse.swt.widgets.MenuItem) WorkflowProjectManager(com.centurylink.mdw.plugin.project.WorkflowProjectManager)

Example 2 with WorkflowProjectManager

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

the class MdwHubAction method populateMenu.

/**
 * populates the plugin action menu (the mdwhub icon) with its items
 */
public void populateMenu(Menu menu) {
    WorkflowProjectManager wfProjectMgr = WorkflowProjectManager.getInstance();
    List<WorkflowProject> workflowProjects = wfProjectMgr.getWorkflowProjects();
    if (workflowProjects.isEmpty()) {
        MenuItem item = new MenuItem(menu, SWT.NONE);
        item.setText("(No Projects)");
        item.setImage(MdwPlugin.getImageDescriptor("icons/wait.gif").createImage());
        item.setEnabled(false);
    } else {
        for (final WorkflowProject workflowProject : workflowProjects) {
            if (workflowProject.checkRequiredVersion(5, 5)) {
                String projName = workflowProject.isFrameworkProject() ? "MDWFramework" : workflowProject.getName();
                // MDWWeb
                MenuItem item = new MenuItem(menu, SWT.NONE);
                final WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(workflowProject, WebApp.MdwHub);
                item.setText(projName + " - " + launchAction.getLabel());
                item.setImage(launchAction.getIconImage());
                item.addSelectionListener(new SelectionAdapter() {

                    public void widgetSelected(SelectionEvent e) {
                        mostRecentHubWorkflowProject = workflowProject;
                        launchAction.launch(workflowProject);
                    }
                });
            }
        }
    }
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) MenuItem(org.eclipse.swt.widgets.MenuItem) WorkflowProjectManager(com.centurylink.mdw.plugin.project.WorkflowProjectManager)

Example 3 with WorkflowProjectManager

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

the class ProcessExplorerView method handleRefresh.

public void handleRefresh() {
    BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {

        public void run() {
            treeViewer.collapseAll();
            WorkflowProjectManager projectMgr = WorkflowProjectManager.getInstance();
            projectMgr.refresh();
            treeViewer.setInput(projectMgr.getWorkflowProjects());
        }
    });
    WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
    for (WorkflowProject project : WorkflowProjectManager.getInstance().getWorkflowProjects()) {
        if (!project.isFilePersist())
            actionHandler.syncOpenEditors(project);
    }
}
Also used : WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowProjectManager(com.centurylink.mdw.plugin.project.WorkflowProjectManager)

Example 4 with WorkflowProjectManager

use of com.centurylink.mdw.plugin.project.WorkflowProjectManager 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 5 with WorkflowProjectManager

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

the class RefreshCacheAction method populateMenu.

/**
 * populates the plugin action menu (the refr_cache icon) with its items
 */
public void populateMenu(Menu menu) {
    WorkflowProjectManager wfProjectMgr = WorkflowProjectManager.getInstance();
    List<WorkflowProject> workflowProjects = wfProjectMgr.getWorkflowProjects();
    if (workflowProjects.isEmpty()) {
        MenuItem item = new MenuItem(menu, SWT.NONE);
        item.setText("(No Projects)");
        item.setImage(MdwPlugin.getImageDescriptor("icons/wait.gif").createImage());
        item.setEnabled(false);
    } else {
        for (final WorkflowProject workflowProject : workflowProjects) {
            String projName = workflowProject.isFrameworkProject() ? "MDWFramework" : workflowProject.getSourceProjectName();
            MenuItem item = new MenuItem(menu, SWT.NONE);
            item.setText(projName + " Refresh");
            item.setImage(image);
            item.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent e) {
                    if (!workflowProject.isUserAuthorizedForSystemAdmin()) {
                        PluginMessages.uiMessage("You must be in the System Admin role to refresh the cache for this environment", "Not Authorized", PluginMessages.INFO_MESSAGE);
                    } else {
                        mostRecentCacheRefreshWorkflowProject = workflowProject;
                        workflowProject.getDesignerProxy().getCacheRefresh().doRefresh(false);
                    }
                }
            });
        }
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) MenuItem(org.eclipse.swt.widgets.MenuItem) WorkflowProjectManager(com.centurylink.mdw.plugin.project.WorkflowProjectManager)

Aggregations

WorkflowProjectManager (com.centurylink.mdw.plugin.project.WorkflowProjectManager)6 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)6 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)3 WorkflowElementActionHandler (com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler)1 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)1 ProcessEditor (com.centurylink.mdw.plugin.designer.editors.ProcessEditor)1 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)1 AssetWorkbenchListener (com.centurylink.mdw.plugin.designer.model.WorkflowAsset.AssetWorkbenchListener)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ConnectException (java.net.ConnectException)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1