Search in sources :

Example 1 with ProcessExplorerView

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

the class MdwWorkbenchWindowAdvisor method postWindowOpen.

public void postWindowOpen() {
    IWorkbenchPage activePage = Activator.getActivePage();
    // check for updates
    // IHandlerService handlerService = (IHandlerService)
    // activePage.getWorkbenchWindow().getService(IHandlerService.class);
    // try
    // {
    // Object result =
    // handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", null);
    // System.out.println("result: " + result);
    // if (result != null)
    // System.out.println("result class: " + result.getClass().getName());
    // }
    // catch (Exception ex)
    // {
    // ex.printStackTrace();
    // }
    PluginMessages.log("MDW workbench startup...");
    if (activePage != null) {
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.tools");
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.dev");
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.designerClassic");
        activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
        activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
        activePage.hideActionSet("org.eclipse.ui.externaltools.ExternalToolsSet");
        activePage.showActionSet("org.eclipse.search.menu");
        // make sure the process explorer view is visible
        try {
            ProcessExplorerView processExplorerView = (ProcessExplorerView) activePage.showView("mdw.views.designer.processes");
            if (mdwHost != null && mdwPort != null) {
                final Shell shell = activePage.getActivePart().getSite().getShell();
                BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {

                    public void run() {
                        try {
                            discoveryException = null;
                            projectToImport = getWorkflowProject(mdwHost, mdwPort, mdwContextRoot);
                            if (projectToImport == null)
                                throw new DiscoveryException("Unable to discover workflow app at: " + mdwHost + ":" + mdwPort);
                        } catch (DiscoveryException ex) {
                            discoveryException = ex;
                        }
                    }
                });
                if (discoveryException != null)
                    throw discoveryException;
                WorkflowProject existing = WorkflowProjectManager.getInstance().getRemoteWorkflowProject(projectToImport.getName());
                if (existing != null)
                    WorkflowProjectManager.getInstance().deleteProject(existing);
                ProgressMonitorDialog progMonDlg = new ProgressMonitorDialog(shell);
                ProjectInflator projectInflator = new ProjectInflator(projectToImport, null);
                projectInflator.inflateRemoteProject(progMonDlg);
                ProjectImporter projectImporter = new ProjectImporter(projectToImport);
                projectImporter.doImport();
                processExplorerView.handleRefresh();
                // handle preselected entity
                if (preselectType != null && preselectType.trim().length() > 0 && preselectId != null && preselectId.trim().length() > 0) {
                    if (!preselectType.equals(PRESELECT_PROCESS_INSTANCE))
                        throw new UnsupportedOperationException("Unsupported preselect type: " + preselectType);
                    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {

                        public void run() {
                            // open the process instance
                            IWorkbenchPage page = MdwPlugin.getActivePage();
                            try {
                                WorkflowProcess instance = getProcessInstance(new Long(preselectId));
                                page.openEditor(instance, "mdw.editors.process");
                                page.showView("org.eclipse.ui.views.PropertySheet");
                            } catch (PartInitException ex) {
                                PluginMessages.uiError(ex, "Open Process Instance", projectToImport);
                            }
                        }
                    });
                }
            }
        } catch (Exception ex) {
            PluginMessages.uiError(ex, "Initialize Workspace");
        }
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) PartInitException(org.eclipse.ui.PartInitException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) ProjectImporter(com.centurylink.mdw.plugin.project.assembly.ProjectImporter) Shell(org.eclipse.swt.widgets.Shell) ProjectInflator(com.centurylink.mdw.plugin.project.assembly.ProjectInflator) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 2 with ProcessExplorerView

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

the class ImportPackageWizard method performFinish.

@Override
public boolean performFinish() {
    final List<WorkflowPackage> importedPackages = new ArrayList<>();
    final List<java.io.File> includes = new ArrayList<>();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                WorkflowProject wfp = topFolder.getProject();
                DesignerProxy designerProxy = wfp.getDesignerProxy();
                java.io.File assetDir = wfp.getAssetDir();
                java.io.File zipFile = null;
                java.io.File tempDir = wfp.getTempDir();
                monitor.beginTask("Import Packages", 100 * importPackageSelectPage.getSelectedPackages().size());
                monitor.subTask("Importing selected packages...");
                monitor.worked(10);
                StringBuilder sb = new StringBuilder();
                ProgressMonitor progressMonitor = new SwtProgressMonitor(new SubProgressMonitor(monitor, 100));
                for (File pkgFile : importPackageSelectPage.getSelectedPackages()) {
                    if (pkgFile.getContent() == null) {
                        // discovered
                        if (pkgFile.getUrl() != null) {
                            // assets
                            HttpHelper httpHelper = new HttpHelper(pkgFile.getUrl());
                            httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
                            httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
                            pkgFile.setContent(httpHelper.get());
                        } else if (mavenDiscovery)
                            importFromMaven(pkgFile.getName(), wfp, includes, monitor);
                        else {
                            getPackageNames(pkgFile.getName(), sb);
                        }
                    }
                    String pkgFileContent = pkgFile.getContent();
                    if (pkgFileContent != null) {
                        Importer importer = new Importer(designerProxy.getPluginDataAccess(), wfp.isFilePersist() && wfp.isRemote() ? null : getShell());
                        WorkflowPackage importedPackage = importer.importPackage(wfp, pkgFileContent, progressMonitor);
                        if (// canceled
                        importedPackage == null) {
                            progressMonitor.done();
                            break;
                        } else {
                            if (upgradeAssets) {
                                progressMonitor.subTask("Upgrading activity implementors and other assets...");
                                designerProxy.upgradeAssets(importedPackage);
                            }
                            if (// file system eclipse
                            wfp.isFilePersist())
                                // sync
                                wfp.getSourceProject().refreshLocal(2, null);
                            // TODO refresh Archive in case existing package
                            // was
                            // moved there
                            importedPackages.add(importedPackage);
                            includes.add(new java.io.File(assetDir + "/" + importedPackage.getName().replace('.', '/')));
                        }
                        progressMonitor.done();
                    }
                }
                if (sb.length() > 0) {
                    String url = wfp.getServiceUrl() + "/Services/Assets";
                    Map<String, String> hdrs = new HashMap<>();
                    hdrs.put("Content-Type", "application/json");
                    hdrs.put("request-query-string", "discoveryUrl=" + discoveryUrl + "&discoveryType=distributed");
                    DesignerHttpHelper httpHelper = new DesignerHttpHelper(new URL(url), wfp.getUser().getJwtToken());
                    httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
                    httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
                    httpHelper.setHeaders(hdrs);
                    httpHelper.put("{packages: [" + sb.toString() + "]}");
                }
                if (zipFormat) {
                    zipFile = importFile;
                    if (!wfp.isRemote())
                        unzipToLocal(wfp, zipFile, tempDir, assetDir, importedPackages, progressMonitor);
                }
                if (!includes.isEmpty()) {
                    if (!tempDir.exists() && !tempDir.mkdirs()) {
                        throw new IOException("Unable to create temp directory: " + tempDir);
                    }
                    zipFile = new java.io.File(tempDir + "/packages" + StringHelper.filenameDateToString(new Date()) + ".zip");
                    ZipHelper.zipWith(assetDir, zipFile, includes);
                }
                if (zipFile != null && wfp.isRemote() && wfp.isFilePersist()) {
                    uploadToRemoteServer(wfp, zipFile);
                    if (!zipFile.delete())
                        PluginMessages.log("Unable to delete the file " + zipFile.getPath());
                    progressMonitor.done();
                }
                wfp.getDesignerProxy().getCacheRefresh().doRefresh(true);
            } catch (ActionCancelledException ex) {
                throw new OperationCanceledException();
            } catch (Exception ex) {
                PluginMessages.log(ex);
                throw new InvocationTargetException(ex);
            }
        }
    };
    try {
        boolean confirmed = true;
        if (topFolder.getProject().checkRequiredVersion(6, 0, 13) && topFolder.getProject().isRemote())
            confirmed = MessageDialog.openConfirm(getShell(), "Confirm Import", "This import will impact the remote environment. Are you sure you want to import?");
        if (confirmed) {
            getContainer().run(true, true, op);
            if (!importedPackages.isEmpty())
                DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), importedPackages.get(0));
            IWorkbenchPage page = MdwPlugin.getActivePage();
            ProcessExplorerView processExplorer = (ProcessExplorerView) page.findView(ProcessExplorerView.VIEW_ID);
            if (processExplorer != null) {
                processExplorer.handleRefresh();
                processExplorer.expand(topFolder);
            }
        }
        return true;
    } catch (InterruptedException ex) {
        MessageDialog.openInformation(getShell(), "Import Package", "Import Cancelled");
        return true;
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Import Package", importPackagePage.getProject());
        return false;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) HashMap(java.util.HashMap) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) DesignerHttpHelper(com.centurylink.mdw.designer.utils.DesignerHttpHelper) URL(java.net.URL) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) Importer(com.centurylink.mdw.plugin.designer.Importer) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IOException(java.io.IOException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) Date(java.util.Date) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) JSONException(org.json.JSONException) GeneralSecurityException(java.security.GeneralSecurityException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitor(com.centurylink.mdw.common.utilities.timer.ProgressMonitor) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ActionCancelledException(com.centurylink.mdw.common.utilities.timer.ActionCancelledException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) File(com.centurylink.mdw.plugin.designer.model.File) HttpHelper(com.centurylink.mdw.common.utilities.HttpHelper) DesignerHttpHelper(com.centurylink.mdw.designer.utils.DesignerHttpHelper)

Example 3 with ProcessExplorerView

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

the class DesignerPerspective method showPerspectiveAndSelectProjectPreferences.

public static void showPerspectiveAndSelectProjectPreferences(IWorkbenchWindow activeWindow, WorkflowProject project) {
    try {
        IWorkbenchPage page = showPerspective(activeWindow);
        ProcessExplorerView processExplorer = (ProcessExplorerView) page.findView(ProcessExplorerView.VIEW_ID);
        if (processExplorer != null) {
            processExplorer.setFocus();
            processExplorer.select(project);
            PropertySheet propSheet = (PropertySheet) page.showView(PROPERTY_SHEET);
            if (propSheet != null) {
                TabbedPropertySheetPage tabbedPage = (TabbedPropertySheetPage) propSheet.getCurrentPage();
                if (tabbedPage != null)
                    tabbedPage.setSelectedTab("mdw.properties.tabs.preferences");
            }
        }
    } catch (WorkbenchException ex) {
        PluginMessages.uiError(activeWindow.getShell(), ex, "Project Preferences", project);
    }
}
Also used : PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) TabbedPropertySheetPage(com.centurylink.mdw.plugin.designer.properties.TabbedPropertySheetPage) WorkbenchException(org.eclipse.ui.WorkbenchException)

Example 4 with ProcessExplorerView

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

the class AssetSearchQuery method openExternalEvent.

private void openExternalEvent(ExternalEvent eventHandler) {
    try {
        IWorkbenchPage page = MdwPlugin.getActivePage();
        ProcessExplorerView processExplorer = (ProcessExplorerView) page.findView(ProcessExplorerView.VIEW_ID);
        if (processExplorer != null) {
            processExplorer.setFocus();
            processExplorer.select(eventHandler);
            page.showView("org.eclipse.ui.views.PropertySheet");
        }
    } catch (WorkbenchException ex) {
        PluginMessages.uiError(MdwPlugin.getShell(), ex, "Event Handler", eventHandler.getProject());
    }
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) WorkbenchException(org.eclipse.ui.WorkbenchException)

Aggregations

ProcessExplorerView (com.centurylink.mdw.plugin.designer.views.ProcessExplorerView)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 WorkbenchException (org.eclipse.ui.WorkbenchException)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 HttpHelper (com.centurylink.mdw.common.utilities.HttpHelper)1 ActionCancelledException (com.centurylink.mdw.common.utilities.timer.ActionCancelledException)1 ProgressMonitor (com.centurylink.mdw.common.utilities.timer.ProgressMonitor)1 DesignerHttpHelper (com.centurylink.mdw.designer.utils.DesignerHttpHelper)1 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)1 DiscoveryException (com.centurylink.mdw.plugin.designer.DiscoveryException)1 Importer (com.centurylink.mdw.plugin.designer.Importer)1 SwtProgressMonitor (com.centurylink.mdw.plugin.designer.SwtProgressMonitor)1 File (com.centurylink.mdw.plugin.designer.model.File)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 TabbedPropertySheetPage (com.centurylink.mdw.plugin.designer.properties.TabbedPropertySheetPage)1 ProjectImporter (com.centurylink.mdw.plugin.project.assembly.ProjectImporter)1 ProjectInflator (com.centurylink.mdw.plugin.project.assembly.ProjectInflator)1 IOException (java.io.IOException)1