Example usage for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog

List of usage examples for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs ProgressMonitorDialog ProgressMonitorDialog.

Prototype

public ProgressMonitorDialog(Shell parent) 

Source Link

Document

Creates a progress monitor dialog under the given shell.

Usage

From source file:com.arc.embeddedcdt.launch.LaunchShortcut.java

License:Open Source License

/**
 * Method searchAndLaunch.//from   w  w w.  j  av  a 2s .  c o m
 * @param objects
 * @param mode
 */
private void searchAndLaunch(final Object[] elements, String mode) {
    if (elements != null && elements.length > 0) {
        IBinary bin = null;
        if (elements.length == 1 && elements[0] instanceof IBinary) {
            bin = (IBinary) elements[0];
        } else {
            final List results = new ArrayList();
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            IRunnableWithProgress runnable = new IRunnableWithProgress() {
                public void run(IProgressMonitor pm) throws InterruptedException {
                    int nElements = elements.length;
                    pm.beginTask("Looking for executables", nElements); //$NON-NLS-1$
                    try {
                        IProgressMonitor sub = new SubProgressMonitor(pm, 1);
                        for (int i = 0; i < nElements; i++) {
                            if (elements[i] instanceof IAdaptable) {
                                IResource r = (IResource) ((IAdaptable) elements[i])
                                        .getAdapter(IResource.class);
                                if (r != null) {
                                    ICProject cproject = CoreModel.getDefault().create(r.getProject());
                                    if (cproject != null) {
                                        try {
                                            IBinary[] bins = cproject.getBinaryContainer().getBinaries();

                                            for (int j = 0; j < bins.length; j++) {
                                                if (bins[j].isExecutable()) {
                                                    results.add(bins[j]);
                                                }
                                            }
                                        } catch (CModelException e) {
                                        }
                                    }
                                }
                            }
                            if (pm.isCanceled()) {
                                throw new InterruptedException();
                            }
                            sub.done();
                        }
                    } finally {
                        pm.done();
                    }
                }
            };
            try {
                dialog.run(true, true, runnable);
            } catch (InterruptedException e) {
                return;
            } catch (InvocationTargetException e) {
                MessageDialog.openError(getShell(),
                        LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$
                        e.getMessage());
                return;
            }
            int count = results.size();
            if (count == 0) {
                MessageDialog.openError(getShell(),
                        LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$
                        LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_binaries")); //$NON-NLS-1$
            } else if (count > 1) {
                bin = chooseBinary(results, mode);
            } else {
                bin = (IBinary) results.get(0);
            }
        }
        if (bin != null) {
            launch(bin, mode);
        }
    } else {
        MessageDialog.openError(getShell(),
                LaunchMessages.getString("CApplicationLaunchShortcut.Application_Launcher"), //$NON-NLS-1$
                LaunchMessages.getString("CApplicationLaunchShortcut.Launch_failed_no_project_selected")); //$NON-NLS-1$
    }
}

From source file:com.archimatetool.jasperreports.ExportJasperReportsWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    fPage1.saveSettings();/*from   w  ww .j  a v a  2 s.  c  o  m*/

    fMainTemplateFile = fPage2.getMainTemplateFile();

    // Check this exists
    if (fMainTemplateFile == null || !fMainTemplateFile.exists()) {
        MessageDialog.openError(getShell(), Messages.ExportJasperReportsWizard_1,
                Messages.ExportJasperReportsWizard_2);
        return false;
    }

    fExportFolder = fPage1.getExportFolder();
    fExportFileName = fPage1.getExportFilename();
    fReportTitle = fPage1.getReportTitle();
    fIsPDF = fPage1.isExportPDF();
    fIsHTML = fPage1.isExportHTML();
    fIsDOCX = fPage1.isExportDOCX();
    fIsPPT = fPage1.isExportPPT();
    fIsODT = fPage1.isExportODT();
    fIsRTF = fPage1.isExportRTF();

    // Check valid dir and file name
    try {
        File file = new File(fExportFolder, fExportFileName);
        file.getCanonicalPath();
        fExportFolder.mkdirs();
    } catch (Exception ex) {
        MessageDialog.openError(getShell(), Messages.ExportJasperReportsWizard_3,
                Messages.ExportJasperReportsWizard_4);
        return false;
    }

    Display.getCurrent().asyncExec(new Runnable() {
        @Override
        public void run() {
            ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
            try {
                dialog.run(false, true, new IRunnableWithProgress() {
                    @Override
                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        try {
                            export(monitor);
                        } catch (Exception ex) {
                            ex.printStackTrace();
                            MessageDialog.openError(getShell(), Messages.ExportJasperReportsWizard_5,
                                    ex.getMessage());
                        } finally {
                            monitor.done();
                        }
                    }
                });
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    return true;
}

From source file:com.architexa.diagrams.relo.jdt.actions.OpenForBrowsingAction.java

License:Open Source License

public static void openReloViz(IWorkbenchWindow activeWorkbenchWindow, final List<?> selList,
        final Map<IDocument, IDocument> lToRDocMap, final Map<IDocument, String> lToPathMap,
        final StringBuffer docBuff, final IPath wkspcPath, final RunWithObjectParam runWithEditor) {
    try {/*from   ww w.j  av  a2s . c o m*/
        ReloView view = (ReloView) activeWorkbenchWindow.getActivePage().findView(ReloView.viewId);
        final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        if (view != null) {
            // Check why support for Relo View is being added here
            // view is always null here?

            // make sure the view is shown
            activeWorkbenchWindow.getActivePage().activate(view);

            ReloController rc = view.getReloController();
            CreateCommand createCmd = new CreateCommand(rc, selList);
            CompoundCommand cc = new CompoundCommand("Show Included Relationships");
            cc.add(createCmd);
            ((ReloDoc) rc.getRootArtifact()).showIncludedRelationships(cc, createCmd.getAddedAFs());

            if (!ResourceQueue.isEmpty())
                rc.addUnbuiltWarning();
            rc.execute(cc);
            return;
        }

        new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()).run(true,
                false, new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor)
                            throws InvocationTargetException, InterruptedException {
                        monitor.beginTask("Creating Class Diagram...", IProgressMonitor.UNKNOWN);

                        PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

                            public void run() {
                                try {
                                    ReloEditor reloEditor = null;
                                    RSEMultiPageEditor mpe = null;
                                    RSEShareableDiagramEditorInput edInput = null;
                                    if (lToRDocMap == null || lToPathMap == null) {
                                        edInput = new ListEditorInput(new ArrayList<Object>(),
                                                new ClassStrucBrowseModel());
                                    } else {
                                        edInput = new ListEditorInput(new ArrayList<Object>(),
                                                new ClassStrucBrowseModel(), lToRDocMap, lToPathMap, docBuff);
                                    }

                                    // The exploration server uses this to dynamically get the repo for a diagram from a code element
                                    if (wkspcPath != null) {
                                        edInput.wkspcPath = wkspcPath;
                                        //                             ((ListEditorInput)edInput).browseModel.setRepo(StoreUtil.getStoreRepository(wkspcPath));
                                    }

                                    mpe = (RSEMultiPageEditor) page.openEditor(edInput,
                                            RSEMultiPageEditor.editorId);
                                    if (runWithEditor != null)
                                        runWithEditor.run(mpe);

                                    reloEditor = (ReloEditor) mpe.getRseEditor();

                                    ReloController rc = reloEditor.getReloController();

                                    CreateCommand createCmd = new CreateCommand(reloEditor.getReloController(),
                                            selList);

                                    CompoundCommand cc = new CompoundCommand("Show Included Relationships");
                                    cc.add(createCmd);
                                    ((ReloDoc) rc.getRootArtifact()).showIncludedRelationships(cc,
                                            createCmd.getAddedAFs());

                                    if (!ResourceQueue.isEmpty())
                                        rc.addUnbuiltWarning();

                                    rc.execute(cc);
                                } catch (PartInitException e) {
                                    logger.error("Unexpected Exception.", e);
                                }
                            }
                        });
                    }
                });
    } catch (Throwable e) {
        logger.error("Unexepected exception while opening relo visualization", e);
    }
}

From source file:com.architexa.diagrams.relo.jdt.parts.CodeUnitEditPart.java

License:Open Source License

@Override
public void buildContextMenu(IMenuManager menu) {
    super.buildContextMenu(menu);

    // Don't need javadoc and Open/Find menu entries if this is a palette frag
    if (!(this.getModel() instanceof UserCreatedFragment)) {

        // javadoc actions:

        IAction action = new AddJavaDocAction(this);
        if (!((AddJavaDocAction) action).canRun((ArtifactFragment) getModel()))
            action.setEnabled(false);/*w  w  w. j  ava2s  . co m*/
        menu.appendToGroup(RSEContextMenuProvider.GROUP_RSE_TOOLS, action);

        action = new EditJavaDocDialogAction(this, this.getRepo());
        menu.appendToGroup(RSEContextMenuProvider.GROUP_RSE_TOOLS, action);
        //Disable if cannot run
        if (!((EditJavaDocDialogAction) action).canRun((ArtifactFragment) getModel()))
            action.setEnabled(false);

        // Put Open in Java Editor if jdt element
        // or Find in Workspace if not jdt element

        // JDT Wkspace Element: Open in a java editor
        action = new Action(JDTUISupport.getOpenInJavaEditorActionString(),
                JDTUISupport.getOpenInJavaEditorActionIcon()) {
            @Override
            public void run() {
                CodeUnitEditPart cuep = CodeUnitEditPart.this;
                JDTUISupport.openInEditor(cuep.getCU(), cuep.getRepo());
            }
        };

        // Otherwise: open the search dialog
        if (!RJCore.isJDTWksp(getArtFrag().getArt().elementRes)) {
            action = new Action("Find in Workspace", Activator.getImageDescriptor("icons/jcu_obj.gif")) {
                @Override
                public void run() {
                    try {
                        ISearchQuery query = DefaultTextSearchQueryProvider.getPreferred()
                                .createQuery(getArtFrag().getArt().queryName(getRepo()));
                        InternalSearchUI searchUI = InternalSearchUI.getInstance();
                        searchUI.addQuery(query);
                        searchUI.runSearchInForeground(
                                new ProgressMonitorDialog(Display.getCurrent().getActiveShell()), query,
                                searchUI.getSearchView());
                    } catch (CoreException e) {
                        logger.error("Error parsing name for search", e);
                        e.printStackTrace();
                    }
                }
            };
        }
        menu.appendToGroup(RSEContextMenuProvider.GROUP_RSE_EDITORS, action);
    }

    if (!(this instanceof ClassEditPart))
        return;
    final ClassEditPart cep = (ClassEditPart) this;
    List<ArtifactEditPart> epList = new ArrayList<ArtifactEditPart>();
    epList.add(cep);
    addColorAction(menu, epList);

}

From source file:com.architexa.diagrams.relo.parts.ArtifactEditPart.java

License:Open Source License

public Action getRelAction(final String text, final DirectedRel rel, final Predicate filter) {
    return new Action(text) {
        @Override//  w  w w.  j  a  va2 s  .c o  m
        public void run() {
            final CompoundCommand actionCmd = new CompoundCommand();

            final IRunnableWithProgress op = new IRunnableWithProgress() {
                public void run(final IProgressMonitor monitor)
                        throws InvocationTargetException, InterruptedException {
                    monitor.beginTask(text, IProgressMonitor.UNKNOWN);
                    Display.getDefault().asyncExec(new Runnable() {
                        public void run() {
                            ArtifactEditPart.this.showAllDirectRelation(actionCmd, rel, filter);
                            if (actionCmd.size() > 0)
                                ArtifactEditPart.this.execute(actionCmd);
                        }
                    });
                }
            };
            try {
                new ProgressMonitorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell())
                        .run(true, false, op);
            } catch (InvocationTargetException e) {
                logger.error(e.getMessage());
            } catch (InterruptedException e) {
                logger.error(e.getMessage());
            }
        }
    };
}

From source file:com.aspose.barcode.maven.AsposeMavenProjectWizard.java

License:Open Source License

@Override
public boolean performFinish() {
    AsposeMavenProjectSupport asposeMavenProjectSupport = new AsposeMavenProjectSupport(
            wizardPage.getProjectName(), wizardPage.getLocationURI(), wizardPage.getPackageName(),
            wizardPage.isDownloadExamplesChecked(), wizardPage.getVersion(), wizardPage.getGroupId());
    try {/*from  ww w.j a va  2  s.  com*/
        new ProgressMonitorDialog(this.getShell()).run(true, false, asposeMavenProjectSupport);
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:com.aspose.barcode.maven.examples.AsposeExampleWizard.java

License:Open Source License

@Override
public boolean performFinish() {

    String selectedProjectPath = wizardPage.getSelectedProjectPath();
    String exampleCategory = wizardPage.getSelectedExampleCategory();
    IProject project = wizardPage.getIProject();

    AsposeExampleSupport asposeExampleSupport = new AsposeExampleSupport(selectedProjectPath, exampleCategory,
            project);//from   w  ww  .ja va 2 s. c  o  m
    try {
        new ProgressMonitorDialog(this.getShell()).run(true, false, asposeExampleSupport);
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }

    return true;
}

From source file:com.aspose.barcode.maven.examples.AsposeExampleWizardPage.java

License:Open Source License

private void downloadExamplesRepo() {
    // download code examples with status progress
    try {//  w  w w. j ava  2  s. c  o m
        new ProgressMonitorDialog(this.getShell()).run(true, false, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Downloading latest example categories...", IProgressMonitor.UNKNOWN);

                AsposeMavenProjectManager.initialize(null);
                AsposeJavaAPI component = AsposeBarCodeJavaAPI
                        .initialize(AsposeMavenProjectManager.getInstance());
                component.checkAndUpdateRepo();

                monitor.done();
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.aspose.cells.maven.examples.AsposeExampleWizardPage.java

License:Open Source License

private void downloadExamplesRepo() {
    // download code examples with status progress
    try {/* ww w  .  j av a2s.com*/
        new ProgressMonitorDialog(this.getShell()).run(true, false, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Downloading latest example categories...", IProgressMonitor.UNKNOWN);

                AsposeMavenProjectManager.initialize(null);
                AsposeJavaAPI component = AsposeCellsJavaAPI
                        .initialize(AsposeMavenProjectManager.getInstance());
                component.checkAndUpdateRepo();

                monitor.done();
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:com.aspose.eclipse.maven.wizard.AsposeMavenNewProjectWizard.java

License:Open Source License

/**
 * //from   www .  j a v a  2 s.c  o  m
 */
@Override
public boolean performFinish() {

    final Model model = getModel();
    // final String projectName = importConfiguration.getProjectName(model);
    final String projectName = model.getName();
    IStatus nameStatus = importConfiguration.validateProjectName(model);
    if (!nameStatus.isOK()) {
        MessageDialog.openError(getShell(), NLS.bind(Messages.wizardProjectJobFailed, projectName),
                nameStatus.getMessage());
        return false;
    }

    if (!AsposeMavenManager.isInternetConnected()) {
        MessageDialog.openError(getShell(),
                NLS.bind(AsposeConstants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, projectName),
                AsposeConstants.MAVEN_INTERNET_CONNECTION_REQUIRED_MESSAGE);

        return false;
    }

    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    final IPath location;
    if (!_pageTwo.useDefaults()) {

        location = _pageTwo.getLocationPath();
    } else
        location = null;

    final IWorkspaceRoot root = workspace.getRoot();
    final IProject project = importConfiguration.getProject(root, model);

    final IPath pomFile;

    if (location == null || root.getLocation().equals(location)) {
        pomFile = root.getLocation().append(project.getName()).append(IMavenConstants.POM_FILE_NAME);

    } else {
        pomFile = location.append(IMavenConstants.POM_FILE_NAME);

    }

    if (pomFile.toFile().exists()) {
        MessageDialog.openError(getShell(), NLS.bind(Messages.wizardProjectJobFailed, projectName),
                Messages.wizardProjectErrorPomAlreadyExists);
        return false;
    }

    final AbstractCreateMavenProjectJob job;
    final String[] folders = _pageOne.getFolders();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);

    try {
        dialog.run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) {
                monitor.beginTask("Retrieving Aspose Maven Dependencies ...",
                        AsposeMavenProject.getApiList().size());

                AsposeMavenManager.retrieveAsposeMavenDependencies(monitor);

            }
        });
    } catch (InvocationTargetException | InterruptedException e2) {
        // TODO Auto-generated catch block
        e2.printStackTrace();
    }

    job = new AbstractCreateMavenProjectJob(NLS.bind(Messages.wizardProjectJobCreatingProject, projectName),
            workingSets) {
        @Override
        protected List<IProject> doCreateMavenProjects(IProgressMonitor monitor) throws CoreException {
            MavenPlugin.getProjectConfigurationManager().createSimpleProject(project, location, model, folders, //
                    importConfiguration, monitor);

            try {
                Document pomDocument = AsposeMavenManager.getXmlDocument(pomFile.toString());

                // Get the root element
                Node projectNode = pomDocument.getFirstChild();
                // Adding Aspose Cloud Maven Repository configuration
                // setting here
                AsposeMavenManager.addAsposeMavenRepositoryConfiguration(pomDocument, projectNode);

                // Adding Dependencies here
                Element dependenciesTag = pomDocument.createElement("dependencies");
                projectNode.appendChild(dependenciesTag);

                for (Metadata dependency : AsposeMavenManager.getAsposeProjectMavenDependencies()) {

                    AsposeMavenManager.addAsposeMavenDependency(pomDocument, dependenciesTag, dependency);

                }

                AsposeMavenManager.updatePOM(pomDocument, monitor, project);

            } catch (ParserConfigurationException | SAXException | IOException
                    | TransformerConfigurationException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (TransformerException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return Arrays.asList(project);
        }
    };
    job.addJobChangeListener(new JobChangeAdapter() {
        public void done(IJobChangeEvent event) {
            final IStatus result = event.getResult();
            if (!result.isOK()) {
                Display.getDefault().asyncExec(new Runnable() {
                    public void run() {
                        MessageDialog.openError(getShell(), //
                                NLS.bind(Messages.wizardProjectJobFailed, projectName), result.getMessage());
                    }
                });
            }

            MappingDiscoveryJob discoveryJob = new MappingDiscoveryJob(job.getCreatedProjects());
            discoveryJob.schedule();

        }
    });

    job.setRule(MavenPlugin.getProjectConfigurationManager().getRule());
    job.schedule();

    return true;
}