Search in sources :

Example 16 with MdwProgressMonitorDialog

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

the class SearchPage method search.

public boolean search(List<WorkflowProject> scopedProjects) {
    try {
        SearchQuery searchQuery = createSearchQuery();
        ProgressMonitorDialog context = new MdwProgressMonitorDialog(getShell());
        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);
        return true;
    } catch (OperationCanceledException ex) {
        setMessage("Search cancelled", IMessageProvider.INFORMATION);
        return false;
    } catch (Exception ex) {
        PluginMessages.uiError(ex, getEntityTitle() + " Search");
        return false;
    }
}
Also used : 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) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException)

Example 17 with MdwProgressMonitorDialog

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

the class WorkflowElementActionHandler method remoteImportVcs.

public void remoteImportVcs(final WorkflowProject workflowProject) {
    VcsRepository repo = workflowProject.getMdwVcsRepository();
    String msg = "Pull latest assets into " + workflowProject.getName() + " from Git branch: " + repo.getBranch() + "?";
    boolean proceed = MessageDialog.openConfirm(getShell(), "Import from VCS", msg);
    if (proceed) {
        ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(getShell());
        try {
            pmDialog.run(true, false, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask("Importing remote project from Git...", IProgressMonitor.UNKNOWN);
                    monitor.worked(20);
                    try {
                        workflowProject.getDesignerProxy().remoteImportVcs();
                    } catch (Exception ex) {
                        PluginMessages.log(ex);
                        throw new InvocationTargetException(ex);
                    }
                }
            });
        } catch (Exception ex) {
            PluginMessages.uiError(getShell(), ex, "Import From VCS", workflowProject);
        }
    }
}
Also used : 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) VcsRepository(com.centurylink.mdw.plugin.project.model.VcsRepository) InvocationTargetException(java.lang.reflect.InvocationTargetException) 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)

Example 18 with MdwProgressMonitorDialog

use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog 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 19 with MdwProgressMonitorDialog

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

the class ProjectUpdater method updateWithDialog.

/**
 * Download the file into the local folder in the specified project.
 */
public void updateWithDialog() {
    Shell shell = MdwPlugin.getShell();
    try {
        ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(shell);
        pmDialog.run(true, true, this);
    } catch (InvocationTargetException ex) {
        PluginMessages.uiError(shell, ex, "MDW Update", workflowProject);
    } catch (InterruptedException ex) {
        PluginMessages.log(ex);
        MessageDialog.openError(shell, "MDW Update", "Update cancelled");
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 20 with MdwProgressMonitorDialog

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

the class ToolboxWrapper method searchReferences.

private void searchReferences(ActivityImpl activityImpl) {
    List<WorkflowProject> projects = new ArrayList<>();
    projects.add(getProject());
    Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
    ProcessSearchQuery searchQuery = new ProcessSearchQuery(projects, SearchQuery.SearchType.CONTAINING_ENTITY, "*", true, shell);
    searchQuery.setContainedEntityId(activityImpl.getId());
    searchQuery.setContainedEntityName(activityImpl.getImplClassName());
    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 usages cancelled.");
    } catch (Exception ex) {
        PluginMessages.uiError(shell, ex, "Search for Usages", 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) ProcessSearchQuery(com.centurylink.mdw.plugin.search.ProcessSearchQuery) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

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