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:br.ufmg.dcc.tabuleta.actions.LoadConcernModelAction.java

License:Open Source License

/**
 * Loads the concern model stored in the file wrapped in this object.
 * @see IActionDelegate#run(IAction)// w  ww . j a  va  2s .  c o  m
 * @param pAction the action proxy that handles the presentation portion of the
  *   action
 */
public void run(IAction pAction) {
    if (aFile == null) {
        return;
    }
    boolean lProceed = shouldProceed();
    if (!lProceed) {
        return;
    }

    ProgressMonitorDialog lProgressDialog = new ProgressMonitorDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
    try {
        lProgressDialog.run(true, false, this);
    } catch (InvocationTargetException lException) {
        Throwable lCause = lException.getCause();
        if (lCause instanceof Exception) {
            ProblemManager.reportException((Exception) lCause);
        } else {
            ProblemManager.reportException(lException);
        }
    } catch (InterruptedException lException) {
        ProblemManager.reportException(lException);
    }
}

From source file:br.ufscar.sas.ui.handlers.UI.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    // get workbench window
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    // set selection service
    ISelectionService service = window.getSelectionService();
    // set structured selection
    IStructuredSelection structured = (IStructuredSelection) service.getSelection();
    //Progress Monitor
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
    //Reset Perspective
    window.getActivePage().resetPerspective();

    try {//from   www  .  ja v  a  2s  . c  o m
        dialog.run(true, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) {
                //Creates KDM instance
                int totalUnitsOfWork = IProgressMonitor.UNKNOWN;
                monitor.beginTask("Performing Reverse Engineering....", totalUnitsOfWork);
                // Call Reverse Engineering
                String javaProjectName = "";
                String projectName = null;
                if (structured != null) {
                    if (structured.getFirstElement() instanceof IJavaProject) {
                        IJavaProject jProject = (IJavaProject) structured.getFirstElement();
                        projectName = jProject.getElementName();
                    }
                }

                javaProjectName = projectName;
                CreateKDM ck = new CreateKDM();
                ck.createKDMFile(javaProjectName);
                monitor.done();
                try {
                    refreshProjects();
                } catch (CoreException e) {
                    e.printStackTrace();
                }
            }
        });

        //Show main View
        window.getActivePage().showView("MainView");
        IWorkbenchPage ip = window.getActivePage();
        IViewPart myView = ip.findView("org.eclipse.jdt.ui.SourceView");
        ip.hideView(myView);
        myView = ip.findView("org.eclipse.jdt.ui.JavadocView");
        ip.hideView(myView);
        myView = ip.findView("org.eclipse.ui.views.ProblemView");
        ip.hideView(myView);
        myView = ip.findView("org.eclipse.mylyn.tasks.ui.views.tasks");
        ip.hideView(myView);
        myView = ip.findView("org.eclipse.ui.views.ContentOutline");
        ip.hideView(myView);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:ca.mcgill.cs.swevo.ppa.ui.actions.PPAOnCuAction.java

License:Open Source License

public void run(IAction action) {
    if (icu == null) {
        return;/*from w ww  . ja  va2 s.c o  m*/
    }

    try {
        MessageConsole mConsole = new MessageConsole("PPA Console", null);
        final PrintStream printer = new PrintStream(mConsole.newMessageStream());
        IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
        manager.addConsoles(new IConsole[] { mConsole });
        manager.showConsoleView(mConsole);

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

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.beginTask("Visiting AST", 100);
                    ASTNode node = PPAUtil.getCU((IFile) icu.getResource(), new PPAOptions());
                    monitor.worked(50);
                    node.accept(new NameBindingVisitor(printer, monitor));
                    printer.close();
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    monitor.done();
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ca.mcgill.cs.swevo.ppa.ui.actions.PPAOnFileAction.java

License:Open Source License

public void run(IAction action) {
    if (file == null) {
        return;//from   www .  ja  va2  s. co  m
    }

    try {
        MessageConsole mConsole = new MessageConsole("PPA Console", null);
        final PrintStream printer = new PrintStream(mConsole.newMessageStream());
        IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
        manager.addConsoles(new IConsole[] { mConsole });
        manager.showConsoleView(mConsole);

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

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.beginTask("Visiting AST", 100);
                    CompilationUnit node = PPAUtil.getCU(file.getLocation().toFile(), new PPAOptions());
                    monitor.worked(50);
                    node.accept(new NameBindingVisitor(printer, monitor));
                    printer.close();
                    PPAUtil.cleanUp(node);
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    monitor.done();
                }
            }
        });

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ca.mcgill.cs.swevo.ppa.ui.actions.PPAOnSnippetAction.java

License:Open Source License

public void run(IAction action) {
    if (file == null) {
        return;/*  w w w .j a v  a  2s. c  om*/
    }

    try {
        MessageConsole mConsole = new MessageConsole("PPA Console", null);
        final PrintStream printer = new PrintStream(mConsole.newMessageStream());
        IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
        manager.addConsoles(new IConsole[] { mConsole });
        manager.showConsoleView(mConsole);
        final boolean isTypeBody = action.getId().equals("ca.mcgill.cs.swevo.ppa.ui.performPPAOnTypeSnippet");
        ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
        dialog.run(true, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.beginTask("Visiting AST", 100);
                    CompilationUnit node = (CompilationUnit) PPAUtil.getSnippet(file.getLocation().toFile(),
                            new PPAOptions(), isTypeBody);
                    monitor.worked(50);
                    node.accept(new NameBindingVisitor(printer, monitor));
                    printer.close();
                    PPAUtil.cleanUpSnippet();
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    monitor.done();
                }
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:ca.mcgill.cs.swevo.qualyzer.wizards.NewProjectWizard.java

License:Open Source License

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

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
    dialog.setOpenOnRun(true);
    dialog.create();
    dialog.getShell().setText(Messages.getString("wizards.NewProjectWizard.projectCreationStatus")); //$NON-NLS-1$
    try {
        dialog.run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                QualyzerActivator.getDefault().setCreatingProject(true);
                monitor.beginTask(Messages.getString("wizards.NewProjectWizard.creatingNewProject"), //$NON-NLS-1$
                        WORK);
                monitor.worked(1);
                monitor.worked(1);
                Project project = Facade.getInstance().createProject(fOne.getProjectName(),
                        fOne.getInvestigatorNickname(), fOne.getInvestigatorFullname(), fOne.getInstitution());
                monitor.worked(2);

                fProject = ResourcesPlugin.getWorkspace().getRoot().getProject(project.getFolderName());
                monitor.worked(1);
                monitor.done();
                QualyzerActivator.getDefault().setCreatingProject(false);
            }
        });
    } catch (InvocationTargetException e) {

    } catch (InterruptedException e) {

    } catch (QualyzerException e) {
        MessageDialog.openError(getShell(), Messages.getString("wizard.NewProjectWizard.projectError"), //$NON-NLS-1$
                e.getMessage());
        return false;
    }

    return fProject != null && fProject.exists();
}

From source file:ca.mt.wb.devtools.tx.InheritanceView.java

License:unlicense.org

/**
 * Creates the menu and toolbar actions.
 *///w  ww.  jav a 2  s  . c o  m
private void makeActions() {

    addNodeAction = new Action() {
        public void run() {
            try {
                SelectionDialog dialog = JavaUI.createTypeDialog(getSite().getShell(),
                        new ProgressMonitorDialog(getSite().getShell()), SearchEngine.createWorkspaceScope(),
                        IJavaElementSearchConstants.CONSIDER_ALL_TYPES, true);
                dialog.setTitle("Add type(s)...");
                dialog.setMessage("Type(s) to add?");
                if (dialog.open() == IDialogConstants.CANCEL_ID) {
                    return;
                }
                Object[] types = dialog.getResult();
                if (types == null || types.length == 0) {
                    return;
                }
                for (int i = 0; i < types.length; i++) {
                    addType((IType) types[i]);
                }
            } catch (JavaModelException e) {
                /* do nothing */
            }
        }
    };

    addNodeAction.setText("Add Type");
    addNodeAction.setToolTipText("Add a new class or interface");
    addNodeAction.setImageDescriptor(getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_ADD));

    expandElementAction = new Action() {
        public void run() {
            for (IType t : getSelectedTypes()) {
                addSubTypes(t);
            }
        }
    };
    expandElementAction.setText("Add Subtypes");
    expandElementAction.setToolTipText("Add subtypes of selected element");
    expandElementAction.setImageDescriptor(getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_ADD));

    // create the action that deletes the selected node
    deleteNodeAction = new Action() {
        public void run() {
            // ISelection = viewer.getSelection();
            ComparisonModel model = ((ComparisonModel) viewer.getInput()).copy();
            boolean modified = false;
            for (IType t : getSelectedTypes()) {
                if (model.remove(t)) {
                    modified = true;
                }
            }
            if (modified) {
                viewer.setInput(model);
            }
            setEnabled(false);
        }
    };
    deleteNodeAction.setEnabled(false);
    deleteNodeAction.setText("Delete Node");
    deleteNodeAction.setToolTipText("Delete the selected node");
    deleteNodeAction.setImageDescriptor(getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_DELETE));
    deleteNodeAction.setDisabledImageDescriptor(
            getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_DELETE_DISABLED));

    clearAction = new Action() {
        public void run() {
            viewer.setInput(new ComparisonModel());
            // viewer.refresh();
        }
    };
    clearAction.setText("Clear");
    clearAction.setToolTipText("Remove all elements");
    clearAction.setImageDescriptor(getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_CLEAR));
    clearAction.setDisabledImageDescriptor(
            getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_CLEAR_DISABLED));

    openInEditorAction = new Action() {
        public void run() {
            openInEditor(getSelectedTypes().get(0));
        }
    };

    layoutActions = new ArrayList<IAction>();
    layoutActions
            .add(createLayoutAction("Spring", new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING)));
    layoutActions
            .add(createLayoutAction("Radial", new RadialLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING)));
    layoutActions.add(createLayoutAction("Directed",
            new DirectedGraphLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING)));
    layoutActions
            .add(createLayoutAction("Tree", new TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING)));
    layoutActions.add(createLayoutAction("Horizontal Tree",
            new HorizontalTreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING)));

}

From source file:ca.uvic.cs.tagsea.research.UserIDDialog.java

License:Open Source License

@Override
protected void okPressed() {
    ProgressMonitorDialog progress = new ProgressMonitorDialog(this.getParentShell());
    GetIDWithProgress getID = new GetIDWithProgress(composite.getFirstName(), composite.getLastName(),
            composite.getEmail(), composite.isAnonymous(), composite.getJob(), composite.getCompanySize(),
            composite.getCompany());//from  w  w w .  j  av a  2s  .c  om
    try {
        progress.run(false, true, getID);
    } catch (InvocationTargetException ex) {
        Exception e = (Exception) ex.getCause();
        if (e instanceof NoRouteToHostException || e instanceof UnknownHostException) {
            MessageDialog.openError(null, "Error Communicating", "There was an error getting a new user id. \n"
                    + "No network connection.  Please try again later");
        } else {
            MessageDialog.openError(null, "Error Communicating", "There was an error getting a new user id: \n"
                    + e.getClass().getCanonicalName() + e.getMessage());
            TagSEAPlugin.log("", e);
        }
        return;
    } catch (InterruptedException e) {
    }
    if (getID.success()) {
        composite.setIDText(getID.getUID());
        this.id = getID.getUID();
        finish.setEnabled(true);
        cancel.setEnabled(false);
        okay.setEnabled(false);
    } else {
        setReturnCode(ERROR);
    }
}

From source file:ca.uwaterloo.gp.fmp.presentation.FmpEditor.java

License:Open Source License

/**
 * This is for implementing {@link IEditorPart} and simply saves the model file.
 * <!-- begin-user-doc -->//  www  .ja  v  a 2  s.  c o m
 * <!-- end-user-doc -->
 * @generated
 */
public void doSave(IProgressMonitor progressMonitor) {
    // Do the work within an operation because this is a long running activity that modifies the workbench.
    //
    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
        // This is the method that gets invoked when the operation runs.
        //
        public void execute(IProgressMonitor monitor) {
            try {
                // Save the resource to the file system.
                //
                Resource savedResource = (Resource) editingDomain.getResourceSet().getResources().get(0);
                savedResources.add(savedResource);
                savedResource.save(Collections.EMPTY_MAP);
            } catch (Exception exception) {
                fmpEditPlugin.INSTANCE.log(exception);
            }
        }
    };

    try {
        // This runs the options, and shows progress.
        //
        new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);

        // Refresh the necessary state.
        //
        ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
        firePropertyChange(IEditorPart.PROP_DIRTY);
    } catch (Exception exception) {
        // Something went wrong that shouldn't.
        //
        fmpEditPlugin.INSTANCE.log(exception);
    }
}

From source file:carisma.modeltype.bpmn2.extension.presentation.ExtensionEditor.java

License:Open Source License

/**
 * This is for implementing {@link IEditorPart} and simply saves the model file.
 * <!-- begin-user-doc -->/*from  w w w.jav a  2 s  . c o  m*/
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void doSave(IProgressMonitor progressMonitor) {
    // Save only resources that have actually changed.
    //
    final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
    saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);

    // Do the work within an operation because this is a long running activity that modifies the workbench.
    //
    WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
        // This is the method that gets invoked when the operation runs.
        //
        @Override
        public void execute(IProgressMonitor monitor) {
            // Save the resources to the file system.
            //
            boolean first = true;
            for (Resource resource : ExtensionEditor.this.editingDomain.getResourceSet().getResources()) {
                if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
                        && !ExtensionEditor.this.editingDomain.isReadOnly(resource)) {
                    try {
                        long timeStamp = resource.getTimeStamp();
                        resource.save(saveOptions);
                        if (resource.getTimeStamp() != timeStamp) {
                            ExtensionEditor.this.savedResources.add(resource);
                        }
                    } catch (Exception exception) {
                        ExtensionEditor.this.resourceToDiagnosticMap.put(resource,
                                analyzeResourceProblems(resource, exception));
                    }
                    first = false;
                }
            }
        }
    };

    this.updateProblemIndication = false;
    try {
        // This runs the options, and shows progress.
        //
        new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);

        // Refresh the necessary state.
        //
        ((BasicCommandStack) this.editingDomain.getCommandStack()).saveIsDone();
        firePropertyChange(IEditorPart.PROP_DIRTY);
    } catch (Exception exception) {
        // Something went wrong that shouldn't.
        //
        ExtensionEditorPlugin.INSTANCE.log(exception);
    }
    this.updateProblemIndication = true;
    updateProblemIndication();
}