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

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

Introduction

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

Prototype

@Override
    public int open() 

Source Link

Usage

From source file:org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor.java

License:Open Source License

public static IStatus execute(final IOperation operation) {
    final Display display = Display.getCurrent();
    Assert.isNotNull(display);// ww w. jav  a2  s .  c o m
    final Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    final ProgressMonitorDialog dlg = new ProgressMonitorDialog(parent);
    dlg.setOpenOnRun(false);

    display.timerExec(500, new Runnable() {
        @Override
        public void run() {
            Shell shell = dlg.getShell();
            if (shell != null && !shell.isDisposed()) {
                Shell activeShell = display.getActiveShell();
                if (activeShell == null || activeShell == parent) {
                    dlg.open();
                } else {
                    display.timerExec(500, this);
                }
            }
        }
    });
    final AtomicReference<IStatus> ref = new AtomicReference<IStatus>();
    try {
        dlg.run(true, true, new IRunnableWithProgress() {
            @Override
            public void run(IProgressMonitor monitor) {
                ref.set(operation.run(monitor));
            }
        });
    } catch (InvocationTargetException e) {
        ref.set(StatusHelper.getStatus(e.getTargetException()));
    } catch (InterruptedException e) {
        return Status.CANCEL_STATUS;
    }
    IStatus status = ref.get();
    if (!status.isOK() && status.getMessage().length() > 0) {
        ErrorDialog.openError(parent, operation.getName(), Messages.UiExecutor_errorRunningOperation, status);
        UIPlugin.getDefault().getLog().log(status);
    }
    return status;
}

From source file:org.eclipse.thym.ui.internal.engine.AvailableCordovaEnginesSection.java

License:Open Source License

private void handleSearch(final Composite parent) {
    DirectoryDialog directoryDialog = new DirectoryDialog(parent.getShell());
    directoryDialog.setMessage("Select the directory in which to search for hybrid mobile engines");
    directoryDialog.setText("Search for Hybrid Mobile Engines");

    String pathStr = directoryDialog.open();
    if (pathStr == null)
        return;/*from  w ww .  j  ava2  s .com*/

    final IPath path = new Path(pathStr);
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(parent.getShell());
    dialog.setBlockOnOpen(false);
    dialog.setCancelable(true);
    dialog.open();
    final EngineSearchListener listener = new EngineSearchListener() {

        @Override
        public void engineFound(HybridMobileEngine engine) {
            addPathToPreference(engine.getLocation());
            getEngineProvider().engineFound(engine);
        }
    };

    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            List<HybridMobileEngineLocator> locators = HybridCore.getEngineLocators();
            for (HybridMobileEngineLocator locator : locators) {
                locator.searchForRuntimes(path, listener, monitor);
            }
            parent.getDisplay().asyncExec(new Runnable() {

                @Override
                public void run() {
                    updateAvailableEngines();
                }
            });
        }
    };

    try {
        dialog.run(true, true, runnable);
    } catch (InvocationTargetException e) {
        if (e.getTargetException() != null) {
            if (e.getTargetException() instanceof CoreException) {
                StatusManager.handle((CoreException) e.getTargetException());
            } else {
                ErrorDialog.openError(parent.getShell(), "Local Engine Search Error", null,
                        new Status(IStatus.ERROR, HybridUI.PLUGIN_ID,
                                "Error when searching for local hybrid mobile engines",
                                e.getTargetException()));
            }
        }
    } catch (InterruptedException e) {
        HybridUI.log(IStatus.ERROR, "Search for Cordova Engines error", e);
    }
}

From source file:org.eclipse.ui.internal.activities.ws.WorkbenchActivitySupport.java

License:Open Source License

/**
 * Create a new instance of this class./*from w w  w.ja  va  2 s  .  c  o m*/
 */
public WorkbenchActivitySupport() {
    triggerPointManager = new TriggerPointManager();
    IExtensionTracker tracker = PlatformUI.getWorkbench().getExtensionTracker();
    tracker.registerHandler(this,
            ExtensionTracker.createExtensionPointFilter(getActivitySupportExtensionPoint()));
    mutableActivityManager = new MutableActivityManager(getTriggerPointAdvisor());
    proxyActivityManager = new ProxyActivityManager(mutableActivityManager);
    mutableActivityManager.addActivityManagerListener(new IActivityManagerListener() {

        private Set lastEnabled = new HashSet(mutableActivityManager.getEnabledActivityIds());

        /* (non-Javadoc)
         * @see org.eclipse.ui.activities.IActivityManagerListener#activityManagerChanged(org.eclipse.ui.activities.ActivityManagerEvent)
         */
        public void activityManagerChanged(ActivityManagerEvent activityManagerEvent) {
            Set activityIds = mutableActivityManager.getEnabledActivityIds();
            // only update the windows if we've not processed this new enablement state already.
            if (!activityIds.equals(lastEnabled)) {
                lastEnabled = new HashSet(activityIds);

                // abort if the workbench isn't running
                if (!PlatformUI.isWorkbenchRunning()) {
                    return;
                }

                // refresh the managers on all windows.
                final IWorkbench workbench = PlatformUI.getWorkbench();
                IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
                for (int i = 0; i < windows.length; i++) {
                    if (windows[i] instanceof WorkbenchWindow) {
                        final WorkbenchWindow window = (WorkbenchWindow) windows[i];

                        final ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());

                        final IRunnableWithProgress runnable = new IRunnableWithProgress() {

                            /**
                             * When this operation should open a dialog
                             */
                            private long openTime;

                            /**
                             * Whether the dialog has been opened yet.
                             */
                            private boolean dialogOpened = false;

                            /* (non-Javadoc)
                             * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
                             */
                            public void run(IProgressMonitor monitor) {

                                openTime = System.currentTimeMillis()
                                        + workbench.getProgressService().getLongOperationTime();

                                //two work units - updating the window bars, and updating view bars
                                monitor.beginTask(ActivityMessages.ManagerTask, 2);

                                monitor.subTask(ActivityMessages.ManagerWindowSubTask);

                                //update window managers...
                                updateWindowBars(window);
                                monitor.worked(1);

                                monitor.subTask(ActivityMessages.ManagerViewsSubTask);
                                // update all of the (realized) views in all of the pages
                                IWorkbenchPage[] pages = window.getPages();
                                for (int j = 0; j < pages.length; j++) {
                                    IWorkbenchPage page = pages[j];
                                    IViewReference[] refs = page.getViewReferences();
                                    for (int k = 0; k < refs.length; k++) {
                                        IViewPart part = refs[k].getView(false);
                                        if (part != null) {
                                            updateViewBars(part);
                                        }
                                    }
                                }
                                monitor.worked(1);

                                monitor.done();
                            }

                            /**
                             * Update the managers on the given given view.
                             * 
                             * @param part the view to update
                             */
                            private void updateViewBars(IViewPart part) {
                                IViewSite viewSite = part.getViewSite();
                                // check for badly behaving or badly initialized views
                                if (viewSite == null) {
                                    return;
                                }
                                IActionBars bars = viewSite.getActionBars();
                                IContributionManager manager = bars.getMenuManager();
                                if (manager != null) {
                                    updateManager(manager);
                                }
                                manager = bars.getToolBarManager();
                                if (manager != null) {
                                    updateManager(manager);
                                }
                                manager = bars.getStatusLineManager();
                                if (manager != null) {
                                    updateManager(manager);
                                }
                            }

                            /**
                             * Update the managers on the given window.
                             * 
                             * @param window the window to update
                             */
                            private void updateWindowBars(final WorkbenchWindow window) {
                                IContributionManager manager = window.getMenuBarManager();
                                if (manager != null) {
                                    updateManager(manager);
                                }
                                manager = window.getCoolBarManager2();
                                if (manager != null) {
                                    updateManager(manager);
                                }
                                manager = window.getToolBarManager2();
                                if (manager != null) {
                                    updateManager(manager);
                                }
                                manager = window.getStatusLineManager();
                                if (manager != null) {
                                    updateManager(manager);
                                }
                            }

                            /**
                             * Update the given manager in the UI thread.
                             * This may also open the progress dialog if 
                             * the operation is taking too long.
                             * 
                             * @param manager the manager to update
                             */
                            private void updateManager(final IContributionManager manager) {
                                if (!dialogOpened && System.currentTimeMillis() > openTime) {
                                    dialog.open();
                                    dialogOpened = true;
                                }

                                manager.update(true);
                            }
                        };

                        // don't open the dialog by default - that'll be
                        // handled by the runnable if we take too long
                        dialog.setOpenOnRun(false);
                        // run this in the UI thread
                        workbench.getDisplay().asyncExec(new Runnable() {

                            /* (non-Javadoc)
                             * @see java.lang.Runnable#run()
                             */
                            public void run() {
                                BusyIndicator.showWhile(workbench.getDisplay(), new Runnable() {

                                    /* (non-Javadoc)
                                     * @see java.lang.Runnable#run()
                                     */
                                    public void run() {
                                        try {
                                            dialog.run(false, false, runnable);
                                        } catch (InvocationTargetException e) {
                                            log(e);
                                        } catch (InterruptedException e) {
                                            log(e);
                                        }
                                    }
                                });
                            }
                        });
                    }
                }
            }
        }

        /**
         * Logs an error message to the workbench log.
         * 
         * @param e the exception to log
         */
        private void log(Exception e) {
            StatusUtil.newStatus(IStatus.ERROR, "Could not update contribution managers", e); //$NON-NLS-1$ 
        }
    });
}

From source file:org.eclipse.ui.internal.dialogs.WorkbenchEditorsDialog.java

License:Open Source License

/**
 * Saves the specified editors/*from   w  w  w .  ja  v a2s. c o m*/
 */
private void saveItems(TableItem items[]) {
    if (items.length == 0) {
        return;
    }
    ProgressMonitorDialog pmd = new ProgressMonitorJobsDialog(getShell());
    pmd.open();
    for (int i = 0; i < items.length; i++) {
        Adapter editor = (Adapter) items[i].getData();
        editor.save(pmd.getProgressMonitor());
        updateItem(items[i], editor);
    }
    pmd.close();
    updateItems();
}

From source file:org.eclipse.wst.server.ui.internal.RuntimePreferencePage.java

License:Open Source License

/**
 * Create the preference options./*from   ww w.  j av  a2s.  c o  m*/
 *
 * @param parent org.eclipse.swt.widgets.Composite
 * @return org.eclipse.swt.widgets.Control
 */
protected Control createContents(Composite parent) {
    initializeDialogUnits(parent);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ContextIds.PREF_GENERAL);

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(4);
    layout.verticalSpacing = convertVerticalDLUsToPixels(3);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 2;
    composite.setLayout(layout);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    composite.setLayoutData(data);

    Label label = new Label(composite, SWT.WRAP);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    label.setLayoutData(data);
    label.setText(Messages.preferenceRuntimesDescription);

    label = new Label(composite, SWT.WRAP);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    data.horizontalSpan = 2;
    data.verticalIndent = 5;
    label.setLayoutData(data);
    label.setText(Messages.preferenceRuntimesTable);

    runtimeComp = new RuntimeComposite(composite, SWT.NONE, new RuntimeComposite.RuntimeSelectionListener() {
        public void runtimeSelected(IRuntime runtime) {
            if (runtime == null) {
                edit.setEnabled(false);
                remove.setEnabled(false);
                pathLabel.setText("");
            } else {
                IStatus status = runtime.validate(new NullProgressMonitor());
                if (status != null && status.getSeverity() == IStatus.ERROR) {
                    Color c = pathLabel.getDisplay().getSystemColor(SWT.COLOR_RED);
                    pathLabel.setForeground(c);
                    pathLabel.setText(status.getMessage());
                } else if (runtime.getLocation() != null) {
                    pathLabel.setForeground(edit.getForeground());
                    pathLabel.setText(runtime.getLocation() + "");
                } else
                    pathLabel.setText("");

                if (runtime.isReadOnly()) {
                    edit.setEnabled(false);
                    remove.setEnabled(false);
                } else {
                    if (runtime.getRuntimeType() != null)
                        edit.setEnabled(ServerUIPlugin.hasWizardFragment(runtime.getRuntimeType().getId()));
                    else
                        edit.setEnabled(false);
                    remove.setEnabled(true);
                }
            }
        }
    });
    runtimeComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

    Composite buttonComp = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(3);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.numColumns = 1;
    buttonComp.setLayout(layout);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
    buttonComp.setLayoutData(data);

    Button add = SWTUtil.createButton(buttonComp, Messages.add);
    final RuntimeComposite runtimeComp2 = runtimeComp;
    add.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (showWizard(null) == Window.CANCEL)
                return;
            runtimeComp2.refresh();
        }
    });

    edit = SWTUtil.createButton(buttonComp, Messages.edit);
    edit.setEnabled(false);
    edit.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            IRuntime runtime = runtimeComp2.getSelectedRuntime();
            if (runtime != null) {
                IRuntimeWorkingCopy runtimeWorkingCopy = runtime.createWorkingCopy();
                if (showWizard(runtimeWorkingCopy) != Window.CANCEL) {
                    try {
                        runtimeComp2.refresh(runtime);
                    } catch (Exception ex) {
                        // ignore
                    }
                }
            }
        }
    });

    remove = SWTUtil.createButton(buttonComp, Messages.remove);
    remove.setEnabled(false);
    remove.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            IRuntime runtime = runtimeComp.getSelectedRuntime();
            if (removeRuntime(runtime))
                runtimeComp2.remove(runtime);
        }
    });

    Button search = SWTUtil.createButton(buttonComp, Messages.search);
    data = (GridData) search.getLayoutData();
    data.verticalIndent = 9;
    search.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            try {
                // select a target directory for the search
                DirectoryDialog directoryDialog = new DirectoryDialog(getShell());
                directoryDialog.setMessage(Messages.dialogRuntimeSearchMessage);
                directoryDialog.setText(Messages.dialogRuntimeSearchTitle);

                String pathStr = directoryDialog.open();
                if (pathStr == null)
                    return;

                final IPath path = new Path(pathStr);

                final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
                dialog.setBlockOnOpen(false);
                dialog.setCancelable(true);
                dialog.open();
                final IProgressMonitor monitor = dialog.getProgressMonitor();
                final IRuntimeLocator[] locators = ServerPlugin.getRuntimeLocators();
                monitor.beginTask(Messages.dialogRuntimeSearchProgress, 100 * locators.length + 10);
                final List<IRuntimeWorkingCopy> list = new ArrayList<IRuntimeWorkingCopy>();

                final IRuntimeLocator.IRuntimeSearchListener listener = new IRuntimeLocator.IRuntimeSearchListener() {
                    public void runtimeFound(final IRuntimeWorkingCopy runtime) {
                        dialog.getShell().getDisplay().syncExec(new Runnable() {
                            public void run() {
                                monitor.subTask(runtime.getName());
                            }
                        });
                        list.add(runtime);
                    }
                };

                IRunnableWithProgress runnable = new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor2) {
                        int size = locators.length;
                        for (int i = 0; i < size; i++) {
                            if (!monitor2.isCanceled())
                                try {
                                    locators[i].searchForRuntimes(path, listener, monitor2);
                                } catch (CoreException ce) {
                                    if (Trace.WARNING) {
                                        Trace.trace(Trace.STRING_WARNING,
                                                "Error locating runtimes: " + locators[i].getId(), ce);
                                    }
                                }
                        }
                        if (Trace.INFO) {
                            Trace.trace(Trace.STRING_INFO, "Done search");
                        }
                    }
                };
                dialog.run(true, true, runnable);

                if (Trace.FINER) {
                    Trace.trace(Trace.STRING_FINER, "Found runtimes: " + list.size());
                }

                if (!monitor.isCanceled()) {
                    if (list.isEmpty()) {
                        EclipseUtil.openError(getShell(), Messages.infoNoRuntimesFound);
                        return;
                    }
                    monitor.worked(5);
                    if (Trace.FINER) {
                        Trace.trace(Trace.STRING_FINER, "Removing duplicates");
                    }
                    List<IRuntime> good = new ArrayList<IRuntime>();
                    Iterator iterator2 = list.iterator();
                    while (iterator2.hasNext()) {
                        boolean dup = false;
                        IRuntime wc = (IRuntime) iterator2.next();

                        IRuntime[] runtimes = ServerCore.getRuntimes();
                        if (runtimes != null) {
                            int size = runtimes.length;
                            for (int i = 0; i < size; i++) {
                                if (runtimes[i].getLocation() != null
                                        && runtimes[i].getLocation().equals(wc.getLocation()))
                                    dup = true;
                            }
                        }
                        if (!dup)
                            good.add(wc);
                    }
                    monitor.worked(5);

                    if (Trace.FINER) {
                        Trace.trace(Trace.STRING_FINER, "Adding runtimes: " + good.size());
                    }
                    Iterator iterator = good.iterator();
                    while (iterator.hasNext()) {
                        IRuntimeWorkingCopy wc = (IRuntimeWorkingCopy) iterator.next();
                        wc.save(false, monitor);
                    }
                    monitor.done();
                }
                dialog.close();
            } catch (Exception ex) {
                if (Trace.SEVERE) {
                    Trace.trace(Trace.STRING_SEVERE, "Error finding runtimes", ex);
                }
            }
            runtimeComp2.refresh();
        }
    });

    Button columnsButton = SWTUtil.createButton(buttonComp, Messages.actionColumns);
    data = (GridData) columnsButton.getLayoutData();
    final RuntimePreferencePage thisClass = this;
    columnsButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            ConfigureColumns.forTable(runtimeComp.getTable(), thisClass);
        }
    });

    pathLabel = new Label(parent, SWT.NONE);
    pathLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Dialog.applyDialogFont(composite);

    return composite;
}

From source file:org.eclipse.zest.examples.cloudio.application.actions.LoadFileAction.java

License:Open Source License

@Override
public void run(IAction action) {
    FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);

    dialog.setText("Select text file...");
    String sourceFile = dialog.open();
    if (sourceFile == null)
        return;/*w  ww  .  ja  v a  2s. c om*/
    ProgressMonitorDialog pd = new ProgressMonitorDialog(getShell());
    try {
        List<Type> types = TypeCollector.getData(new File(sourceFile), "UTF-8");
        pd.setBlockOnOpen(false);
        pd.open();
        pd.getProgressMonitor().beginTask("Generating cloud...", 200);
        TagCloudViewer viewer = getViewer();
        viewer.setInput(types, pd.getProgressMonitor());
        viewer.getCloud().layoutCloud(pd.getProgressMonitor(), false);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        pd.close();
    }
}

From source file:org.eclipse.zest.examples.cloudio.application.ui.TagCloudViewPart.java

License:Open Source License

private void createSideTab(SashForm form) {
    Composite parent = new Composite(form, SWT.NONE);
    parent.setLayout(new GridLayout());
    parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    options = new CloudOptionsComposite(parent, SWT.NONE, viewer) {

        protected Group addLayoutButtons(Composite parent) {
            Group buttons = super.addLayoutButtons(parent);

            Label l = new Label(buttons, SWT.NONE);
            l.setText("X Axis Variation");
            final Combo xAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            xAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            xAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" });
            xAxis.select(2);/*ww w . j av  a2  s  .c o  m*/
            xAxis.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String item = xAxis.getItem(xAxis.getSelectionIndex());
                    layouter.setOption(DefaultLayouter.X_AXIS_VARIATION, Integer.parseInt(item));

                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });

            l = new Label(buttons, SWT.NONE);
            l.setText("Y Axis Variation");
            final Combo yAxis = new Combo(buttons, SWT.DROP_DOWN | SWT.READ_ONLY);
            yAxis.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
            yAxis.setItems(new String[] { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" });
            yAxis.select(1);
            yAxis.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    String item = yAxis.getItem(yAxis.getSelectionIndex());
                    layouter.setOption(DefaultLayouter.Y_AXIS_VARIATION, Integer.parseInt(item));
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });

            Button run = new Button(buttons, SWT.NONE);
            run.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            run.setText("Re-Position");
            run.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(
                            viewer.getControl().getShell());
                    dialog.setBlockOnOpen(false);
                    dialog.open();
                    dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 100);
                    viewer.reset(dialog.getProgressMonitor(), false);
                    dialog.close();
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            Button layout = new Button(buttons, SWT.NONE);
            layout.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
            layout.setText("Re-Layout");
            layout.addSelectionListener(new SelectionListener() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    ProgressMonitorDialog dialog = new ProgressMonitorDialog(viewer.getControl().getShell());
                    dialog.setBlockOnOpen(false);
                    dialog.open();
                    dialog.getProgressMonitor().beginTask("Layouting tag cloud...", 200);
                    viewer.setInput(viewer.getInput(), dialog.getProgressMonitor());
                    viewer.reset(dialog.getProgressMonitor(), false);
                    dialog.close();
                }

                @Override
                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            return buttons;
        };

    };
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    options.setLayoutData(gd);
}

From source file:org.eclipsercp.e4.texteditor.handlers.SaveHandler.java

License:Open Source License

@Execute
public void execute(IEclipseContext context, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
        @Named(IServiceConstants.ACTIVE_PART) final MContribution contribution)
        throws InvocationTargetException, InterruptedException {
    final IEclipseContext pmContext = context.createChild();

    ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
    dialog.open();
    dialog.run(true, true, new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            pmContext.set(IProgressMonitor.class.getName(), monitor);
            if (contribution != null) {
                //Object clientObject = 
                contribution.getObject();
                //               ContextInjectionFactory.invoke(clientObject, Persist.class, //$NON-NLS-1$
                //                     pmContext, null);
            }/*from   w w  w .  j ava  2  s  .  co m*/
        }
    });

    pmContext.dispose();
}

From source file:org.elbe.relations.internal.actions.IndexerAction.java

License:Open Source License

private void indexWithFeedback() {
    final IEclipseContext lContext = context.createChild();
    final IndexJob lJob = new IndexJob(lContext, dataService, log);
    final ProgressMonitorDialog lDialog = new ProgressMonitorJobsDialog(shell);
    lDialog.open();
    try {/*from ww w.  j a  va  2  s  .co  m*/
        lDialog.run(true, true, lJob);
        statusLine.showStatusLineMessage(RelationsMessages.getString("IndexerAction.job.feedback", //$NON-NLS-1$
                new Object[] { lJob.getIndexed() }));
    } catch (final InvocationTargetException exc) {
        log.error(exc, exc.getMessage());
    } catch (final InterruptedException exc) {
        statusLine.showStatusLineMessage(RelationsMessages.getString("action.indexer.status.cancelled")); //$NON-NLS-1$
        log.error(exc, exc.getMessage());
    } finally {
        lContext.dispose();
    }

}

From source file:org.elbe.relations.internal.actions.PrintAction.java

License:Open Source License

@Override
public void execute() {
    final PrintOutWizard lWizard = ContextInjectionFactory.make(PrintOutWizard.class, context);
    final WizardDialog lDialog = new WizardDialog(shell, lWizard);
    if (lDialog.open() == Window.OK) {
        if (lWizard.isInitNew()) {
            if (!printOutManager.initNew(lWizard.getPrintOutFileName(), lWizard.getPrintOutPlugin())) {
                return;
            }/*w  w  w .j av a  2s.  c o  m*/
        } else {
            if (!printOutManager.initFurther(lWizard.getPrintOutFileName())) {
                return;
            }
        }
        printOutManager.setContentScope(lWizard.getPrintOutScope());
        printOutManager.setPrintOutReferences(lWizard.getPrintOutReferences());

        final PrintJob lJob = new PrintJob(printOutManager, browserManager.getSelectedModel());
        final ProgressMonitorDialog lMonitor = new ProgressMonitorJobsDialog(shell);
        lMonitor.open();
        try {
            lMonitor.run(true, true, lJob);
        } catch (final InvocationTargetException exc) {
            log.error(exc, exc.getMessage());
        } catch (final InterruptedException exc) {
            log.error(exc, exc.getMessage());
        } finally {
            lMonitor.close();
        }
    }
}