Search in sources :

Example 1 with MdwProgressMonitorDialog

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

the class WorkflowElementActionHandler method findCallers.

public void findCallers(WorkflowElement element) {
    WorkflowProcess processVersion = (WorkflowProcess) element;
    List<WorkflowProject> projects = new ArrayList<WorkflowProject>();
    projects.add(processVersion.getProject());
    Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
    ProcessSearchQuery searchQuery = new ProcessSearchQuery(projects, SearchQuery.SearchType.INVOKING_ENTITY, "*", true, shell);
    searchQuery.setInvokedEntityId(processVersion.getId());
    try {
        ProgressMonitorDialog context = new MdwProgressMonitorDialog(shell);
        NewSearchUI.runQueryInForeground(context, searchQuery);
        // this shouldn't be necessary according to the Eclipse API docs
        NewSearchUI.activateSearchResultView();
        ISearchResultViewPart part = NewSearchUI.getSearchResultView();
        part.updateLabel();
        SearchResultsPage page = (SearchResultsPage) part.getActivePage();
        page.setSearchQuery(searchQuery);
        page.setInput(searchQuery.getSearchResult(), null);
    } catch (OperationCanceledException ex) {
        MessageDialog.openInformation(shell, "Search Cancelled", "Search for callers cancelled.");
    } catch (Exception ex) {
        PluginMessages.uiError(shell, ex, "Search for Callers", processVersion.getProject());
    }
}
Also used : SearchResultsPage(com.centurylink.mdw.plugin.search.SearchResultsPage) Shell(org.eclipse.swt.widgets.Shell) ISearchResultViewPart(org.eclipse.search.ui.ISearchResultViewPart) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessSearchQuery(com.centurylink.mdw.plugin.search.ProcessSearchQuery) 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)

Example 2 with MdwProgressMonitorDialog

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

the class Template method runWith.

public void runWith(final String inputPath, final String outputLocation, final String velocityPropFile, final String velocityToolboxFile) {
    try {
        VelocityEngine engine = new VelocityEngine();
        Properties vProps = new Properties();
        if (velocityPropFile != null && velocityPropFile.length() > 0)
            vProps.load(new FileInputStream(velocityPropFile));
        String loadPath = vProps.getProperty("file.resource.loader.path");
        String tempFolder = getTempFolder().getLocation().toString();
        if (loadPath == null)
            loadPath = tempFolder;
        else
            loadPath += "," + tempFolder;
        vProps.setProperty("file.resource.loader.path", loadPath);
        engine.init(vProps);
        final VelocityContext velocityContext = getVelocityContext(velocityToolboxFile);
        final org.apache.velocity.Template velocityTemplate = engine.getTemplate(getTempFileName());
        final java.io.File input = new java.io.File(inputPath);
        if (input.isDirectory()) {
            ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(MdwPlugin.getActiveWorkbenchWindow().getShell());
            pmDialog.run(true, false, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    java.io.File[] inputFiles = input.listFiles();
                    monitor.beginTask("Creating output files", inputFiles.length);
                    for (java.io.File inputFile : inputFiles) {
                        if (!inputFile.isDirectory()) {
                            String outputFile = outputLocation + "/" + getOutputFileName(inputFile.getName());
                            monitor.subTask(inputFile.getName());
                            InputStream inputStream = null;
                            try {
                                inputStream = new FileInputStream(inputFile);
                                processInput(inputStream, outputLocation, outputFile, velocityContext, velocityTemplate);
                            } catch (Exception ex) {
                                throw new InvocationTargetException(ex, "Problem applying input:\n'" + inputFile.getName() + "'");
                            } finally {
                                if (inputStream != null) {
                                    try {
                                        inputStream.close();
                                    } catch (Exception ex) {
                                    }
                                }
                            }
                        }
                        monitor.worked(1);
                    }
                }
            });
        } else {
            int sepIdx = inputPath.lastIndexOf(System.getProperty("file.separator"));
            String inputFileName = sepIdx == -1 ? inputPath : inputPath.substring(sepIdx + 1);
            String outputFile = outputLocation + "/" + getOutputFileName(inputFileName);
            processInput(new FileInputStream(inputPath), outputLocation, outputFile, velocityContext, velocityTemplate);
            final IWorkbenchPage page = MdwPlugin.getActivePage();
            if (page != null) {
                IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(outputFile));
                IDE.openEditorOnFileStore(page, fileStore);
            }
        }
    } catch (InvocationTargetException ex) {
        PluginMessages.log(ex);
        String message = ex.getMessage() + ":\n\nCause:\n---------\n" + PluginMessages.getRootCause(ex);
        PluginMessages.uiError(message, "Run Template", getProject());
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Run Template", getProject());
    }
}
Also used : Path(org.eclipse.core.runtime.Path) VelocityEngine(org.apache.velocity.app.VelocityEngine) VelocityContext(org.apache.velocity.VelocityContext) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 3 with MdwProgressMonitorDialog

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

the class DesignerRunner method run.

public RunnerResult run(boolean forked) {
    result = new RunnerResult();
    Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
    ProgressMonitorDialog progressMonitorDialog = new MdwProgressMonitorDialog(shell);
    try {
        // this is absolutely needed
        shell.setFocus();
        progressMonitorDialog.run(forked, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask(progressMessage, IProgressMonitor.UNKNOWN);
                try {
                    perform();
                    result.setStatus(RunnerStatus.SUCCESS);
                } catch (Exception ex) {
                    result.setStatus(RunnerStatus.FAILURE);
                    throw new InvocationTargetException(ex);
                }
            }
        });
        return result;
    } catch (Exception ex) {
        int messageLevel = PluginMessages.isDataIntegrityException(ex) ? PluginMessages.DATA_INTEGRITY_MESSAGE : PluginMessages.ERROR_MESSAGE;
        PluginMessages.uiMessage(shell, ex, errorMessage, workflowProject, messageLevel);
        if (ex.getCause() instanceof ValidationException) {
            if (DesignerProxy.INCOMPATIBLE_INSTANCES.equals(ex.getCause().getMessage()) || (ex.getCause().getMessage() != null && ex.getCause().getMessage().contains(DesignerProxy.ALREADY_EXISTS)))
                result.setStatus(RunnerStatus.DISALLOW);
            else
                result.setStatus(RunnerStatus.INVALID);
        }
        return result;
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) XmlException(org.apache.xmlbeans.XmlException) ValidationException(com.centurylink.mdw.designer.utils.ValidationException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 4 with MdwProgressMonitorDialog

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

the class WebUpdateAction method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(final IAction action) {
    IProject webProject = null;
    WorkflowProject workflowProject = null;
    try {
        if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() instanceof IProject) {
            webProject = (IProject) ((IStructuredSelection) selection).getFirstElement();
            workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(webProject);
        }
        if (workflowProject == null) {
            MessageDialog.openError(shell, "MDW Update", "Selection must be a Workflow Web project.\n(Try refreshing Process Explorer view.)");
            return;
        }
        ProjectUpdater updater = new ProjectUpdater(workflowProject, MdwPlugin.getSettings());
        if (action.getId().equals("mdw.workflow.updateFrameworkWebJars")) {
            updater.updateWebProjectJars(null);
        } else if (action.getId().equals("mdw.workflow.associateWebAppSourceCode")) {
            ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(shell);
            final WorkflowProject wfProject = workflowProject;
            pmDialog.run(true, false, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask("Setting Java source attachment locations", 100);
                    monitor.worked(20);
                    ProjectConfigurator configurator = new ProjectConfigurator(wfProject, MdwPlugin.getSettings());
                    try {
                        configurator.createWebProjectSourceCodeAssociations(shell, monitor);
                    } catch (CoreException ex) {
                        PluginMessages.log(ex);
                    }
                }
            });
        }
    } catch (Exception ex) {
        PluginMessages.log(ex);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProjectConfigurator(com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator) CoreException(org.eclipse.core.runtime.CoreException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 5 with MdwProgressMonitorDialog

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

the class ToolboxWrapper method refresh.

/**
 * Reloads from the database.
 */
public void refresh() {
    try {
        IRunnableWithProgress loader = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                ProgressMonitor progressMonitor = new SwtProgressMonitor(monitor);
                progressMonitor.start("Loading Activity Implementors for " + getProject().getLabel());
                progressMonitor.progress(25);
                getProject().reloadActivityImplementors();
                progressMonitor.done();
            }
        };
        ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(Display.getCurrent().getActiveShell());
        progMonDlg.run(true, false, loader);
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Refresh Implementors", getProject());
    }
    update();
    clearDirty();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProgressMonitor(com.centurylink.mdw.common.utilities.timer.ProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)22 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)22 InvocationTargetException (java.lang.reflect.InvocationTargetException)21 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)16 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)16 CoreException (org.eclipse.core.runtime.CoreException)9 IOException (java.io.IOException)8 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)6 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)6 Shell (org.eclipse.swt.widgets.Shell)6 IProject (org.eclipse.core.resources.IProject)4 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)3 ExtensionModuleException (com.centurylink.mdw.plugin.project.extensions.ExtensionModuleException)3 ConnectException (java.net.ConnectException)3 ArrayList (java.util.ArrayList)3 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)3 ProgressMonitor (com.centurylink.mdw.common.utilities.timer.ProgressMonitor)2 SwtProgressMonitor (com.centurylink.mdw.plugin.designer.SwtProgressMonitor)2 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)2 ProjectConfigurator (com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator)2