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

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

Introduction

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

Prototype

public int open() 

Source Link

Document

Opens this window, creating it first if it has not yet been created.

Usage

From source file:com.siteview.mde.internal.runtime.registry.RegistryBrowser.java

License:Open Source License

private void makeActions() {
    fRefreshAction = new Action("refresh") { //$NON-NLS-1$
        public void run() {
            BusyIndicator.showWhile(fTreeViewer.getTree().getDisplay(), new Runnable() {
                public void run() {
                    refresh(fTreeViewer.getInput());
                }//from  ww w. ja va2  s . com
            });
        }
    };
    fRefreshAction.setText(MDERuntimeMessages.RegistryView_refresh_label);
    fRefreshAction.setToolTipText(MDERuntimeMessages.RegistryView_refresh_tooltip);
    fRefreshAction.setImageDescriptor(PDERuntimePluginImages.DESC_REFRESH);
    fRefreshAction.setDisabledImageDescriptor(PDERuntimePluginImages.DESC_REFRESH_DISABLED);

    fShowPluginsAction = new Action(MDERuntimeMessages.RegistryView_showRunning_label) {
        public void run() {
            if (fShowPluginsAction.isChecked()) {
                fTreeViewer.addFilter(fActiveFilter);
            } else {
                fTreeViewer.removeFilter(fActiveFilter);
            }
            updateTitle();
        }
    };
    fShowPluginsAction.setChecked(fMemento.getString(SHOW_RUNNING_PLUGINS).equals("true")); //$NON-NLS-1$

    fShowDisabledAction = new Action(MDERuntimeMessages.RegistryView_showDisabled_label) {
        public void run() {
            if (fShowDisabledAction.isChecked()) {
                fTreeViewer.addFilter(fDisabledFilter);
            } else {
                fTreeViewer.removeFilter(fDisabledFilter);
            }
            updateTitle();
        }
    };
    fShowDisabledAction.setChecked(fMemento.getString(SHOW_DISABLED_MODE).equals("true")); //$NON-NLS-1$

    fCopyAction = new Action(MDERuntimeMessages.RegistryBrowser_copy_label) {
        public void run() {
            ITreeSelection selection = (ITreeSelection) fFilteredTree.getViewer().getSelection();
            if (selection.isEmpty()) {
                return;
            }

            String textVersion = ((ILabelProvider) fTreeViewer.getLabelProvider())
                    .getText(selection.getFirstElement());
            if ((textVersion != null) && (textVersion.trim().length() > 0)) {
                // set the clipboard contents
                fClipboard.setContents(new Object[] { textVersion },
                        new Transfer[] { TextTransfer.getInstance() });
            }
        }
    };
    fCopyAction.setImageDescriptor(PDERuntimePluginImages.COPY_QNAME);

    fGroupByBundlesAction = new GroupByAction(MDERuntimeMessages.RegistryBrowser_Bundle, BUNDLES);
    int groupBy = getGroupBy();
    fGroupByBundlesAction.setChecked(groupBy == BUNDLES);
    fGroupByExtensionPointsAction = new GroupByAction(MDERuntimeMessages.RegistryBrowser_ExtensionPoint,
            EXTENSION_REGISTRY);
    fGroupByExtensionPointsAction.setChecked(groupBy == EXTENSION_REGISTRY);
    fGroupByServicesAction = new GroupByAction(MDERuntimeMessages.RegistryBrowser_Service, SERVICES);
    fGroupByServicesAction.setChecked(groupBy == SERVICES);

    fShowAdvancedOperationsAction = new Action(MDERuntimeMessages.RegistryView_showAdvanced_label) {
        public void run() { // do nothing
        }
    };
    fShowAdvancedOperationsAction.setChecked(fMemento.getString(SHOW_ADVANCED_MODE).equals("true")); //$NON-NLS-1$

    fStartAction = new Action(MDERuntimeMessages.RegistryView_startAction_label) {
        public void run() {
            try {
                List bundles = getSelectedBundles();
                for (Iterator it = bundles.iterator(); it.hasNext();) {
                    Bundle bundle = (Bundle) it.next();
                    bundle.start();
                }
            } catch (BundleException e) {
                PDERuntimePlugin.log(e);
            }
        }
    };

    fStopAction = new Action(MDERuntimeMessages.RegistryView_stopAction_label) {
        public void run() {
            try {
                List bundles = getSelectedBundles();
                for (Iterator it = bundles.iterator(); it.hasNext();) {
                    Bundle bundle = (Bundle) it.next();
                    bundle.stop();
                }
            } catch (BundleException e) {
                PDERuntimePlugin.log(e);
            }
        }
    };

    fEnableAction = new Action(MDERuntimeMessages.RegistryView_enableAction_label) {
        public void run() {
            List bundles = getSelectedBundles();
            for (Iterator it = bundles.iterator(); it.hasNext();) {
                Bundle bundle = (Bundle) it.next();
                bundle.enable();
            }
        }
    };

    fDisableAction = new Action(MDERuntimeMessages.RegistryView_disableAction_label) {
        public void run() {
            List bundles = getSelectedBundles();
            for (Iterator it = bundles.iterator(); it.hasNext();) {
                Bundle bundle = (Bundle) it.next();
                bundle.disable();
            }
        }
    };

    fDiagnoseAction = new Action(MDERuntimeMessages.RegistryView_diagnoseAction_label) {
        public void run() {
            List bundles = getSelectedBundles();
            for (Iterator it = bundles.iterator(); it.hasNext();) {
                Bundle bundle = (Bundle) it.next();
                MultiStatus problems = bundle.diagnose();

                Dialog dialog;
                if ((problems != null) && (problems.getChildren().length > 0)) {
                    dialog = new DiagnosticsDialog(getSite().getShell(),
                            MDERuntimeMessages.RegistryView_diag_dialog_title, null, problems, IStatus.WARNING);
                    dialog.open();
                } else {
                    MessageDialog.openInformation(getSite().getShell(),
                            MDERuntimeMessages.RegistryView_diag_dialog_title,
                            MDERuntimeMessages.RegistryView_no_unresolved_constraints);
                }

            }
        }
    };

    fCollapseAllAction = new Action("collapseAll") { //$NON-NLS-1$
        public void run() {
            fTreeViewer.collapseAll();
        }
    };
    fCollapseAllAction.setText(MDERuntimeMessages.RegistryView_collapseAll_label);
    fCollapseAllAction.setImageDescriptor(PDERuntimePluginImages.DESC_COLLAPSE_ALL);
    fCollapseAllAction.setToolTipText(MDERuntimeMessages.RegistryView_collapseAll_tooltip);
}

From source file:com.siteview.mde.internal.ui.nls.InternationalizeWizardOpenOperation.java

License:Open Source License

public int run(final Shell parent, final String dialogTitle) throws InterruptedException {
    Assert.isNotNull(dialogTitle);//w  ww.  jav  a 2  s  . com
    final IJobManager manager = Job.getJobManager();
    final int[] result = new int[1];
    final InterruptedException[] canceled = new InterruptedException[1];

    Runnable r = new Runnable() {
        public void run() {
            try {
                manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null);

                Dialog dialog = new WizardDialog(parent, fWizard);
                dialog.create();

                IWizardContainer wizardContainer = (IWizardContainer) dialog;
                if (wizardContainer.getCurrentPage() == null) {
                    //Close the dialog if there are no pages
                    result[0] = Window.CANCEL;
                } else {
                    //Open the wizard dialog
                    result[0] = dialog.open();
                }

            } catch (OperationCanceledException e) {
                canceled[0] = new InterruptedException(e.getMessage());
            } finally {
                manager.endRule(ResourcesPlugin.getWorkspace().getRoot());
            }
        }
    };
    BusyIndicator.showWhile(parent.getDisplay(), r);
    if (canceled[0] != null)
        throw canceled[0];
    return result[0];
}

From source file:com.siteview.mde.internal.ui.search.dependencies.ShowResultsAction.java

License:Open Source License

public void run() {
    if (fUnusedImports.length == 0) {
        MessageDialog.openInformation(MDEPlugin.getActiveWorkbenchShell(),
                MDEUIMessages.UnusedDependencies_title, MDEUIMessages.UnusedDependencies_notFound);
    } else {/*from  w w  w  .j av a2s .c o m*/
        Dialog dialog;
        if (fReadOnly) {
            // Launched from Dependencies View, show information dialog
            dialog = getUnusedDependeciesInfoDialog();
        } else {
            dialog = new UnusedImportsDialog(MDEPlugin.getActiveWorkbenchShell(), fModel, fUnusedImports);
            dialog.create();
        }
        dialog.getShell().setText(MDEUIMessages.UnusedDependencies_title);
        dialog.open();
    }
}

From source file:com.windowtester.eclipse.ui.views.OpenWTPreferencesPageAction.java

License:Open Source License

public void doRun() {
    Dialog dialog = org.eclipse.ui.dialogs.PreferencesUtil.createPreferenceDialogOn(getShell(),
            "com.windowtester.swt.runtime.preferences.GeneralPreferencePage", null, null);
    if (dialog != null)
        dialog.open();
}

From source file:de.innot.avreclipse.ui.editors.MCUReadActionPart.java

License:Open Source License

/**
 * Load the Bytes from the currently attached MCU.
 *///from  ww w.  ja va 2s .  c  o m
private void readFuseBytesFromDevice(final ProgrammerConfig progcfg) {

    // Set the form busy. It is restored from the job.
    getManagedForm().getForm().setBusy(true);

    // The Job that does the actual loading.
    Job readJob = new Job("Reading Fuse Bytes") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {

            final ScrolledForm form = getManagedForm().getForm();

            try {
                monitor.beginTask("Starting AVRDude", 100);

                // Read the values from the attached programmer.
                final ByteValues newvalues = readByteValues(progcfg, new SubProgressMonitor(monitor, 95));

                // update
                if (form.isDisposed()) {
                    return Status.CANCEL_STATUS;
                }
                form.getDisplay().syncExec(new Runnable() {
                    // Run in the UI thread in case we have to open a MCU mismatch dialog.
                    public void run() {
                        ByteValues current = getByteValues();
                        boolean forceMCU = false;

                        // Check if the mcus are compatible
                        String projectmcu = getByteValues().getMCUId();
                        String newmcu = newvalues.getMCUId();

                        if (current.isCompatibleWith(newmcu)) {
                            // Compatible MCUs
                            // Change the MCU type anyway to be consistent
                            forceMCU = true;
                        } else {
                            // No, they are not compatible. Ask the user what to do
                            // "Convert", "Change" or "Cancel"
                            Dialog dialog = new FileMCUMismatchDialog(form.getShell(), newmcu, projectmcu,
                                    current.getType());
                            int choice = dialog.open();
                            switch (choice) {
                            case FileMCUMismatchDialog.CANCEL:
                                return;
                            case FileMCUMismatchDialog.CHANGE:
                                // Change project ByteValues to the new MCU and then copy
                                // the values
                                forceMCU = true;
                                break;
                            case FileMCUMismatchDialog.CONVERT:
                                // Change the new ByteValues to our MCU and then copy
                                // the values
                                forceMCU = false;
                                break;
                            }
                        }
                        current.setValues(newvalues, forceMCU);
                        markDirty();
                        notifyForm();
                    }
                });
                monitor.worked(5);
            } catch (AVRDudeException ade) {
                // Show an Error message and exit
                if (!form.isDisposed()) {
                    UIJob messagejob = new AVRDudeErrorDialogJob(form.getDisplay(), ade, progcfg.getId());
                    messagejob.setPriority(Job.INTERACTIVE);
                    messagejob.schedule();
                    try {
                        messagejob.join(); // block until the dialog is closed.
                    } catch (InterruptedException e) {
                        // Don't care if the dialog is interrupted from outside.
                    }
                }
            } catch (SWTException swte) {
                // The display has been disposed, so the user is not
                // interested in the results from this job
                return Status.CANCEL_STATUS;
            } finally {
                monitor.done();
                // remove the busy cursor
                if (!form.isDisposed()) {
                    form.getDisplay().syncExec(new Runnable() {
                        public void run() {
                            form.setBusy(false);
                        }
                    });
                }
            }

            return Status.OK_STATUS;
        }
    };

    // now set the Job properties and start it
    readJob.setRule(new AVRDudeSchedulingRule(progcfg));
    readJob.setPriority(Job.SHORT);
    readJob.setUser(true);
    readJob.schedule();
}

From source file:de.innot.avreclipse.ui.propertypages.AbstractTabAVRDudeBytes.java

License:Open Source License

/**
 * Load the Bytes from the currently attached MCU.
 * <p>// w w  w  . j a  va 2  s  .c o  m
 * This method will start a new Job to load the values and return immediately.
 * </p>
 */
private void readFuseBytesFromDevice() {
    // Disable the Actions Menu. It is re-enabled by the load job when it finishes.
    fActionsToolBar.setEnabled(false);
    fLoadingLabel.setVisible(true);

    // The Job that does the actual loading.
    Job readJob = new Job("Reading Fuse Bytes") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {

            try {
                monitor.beginTask("Starting AVRDude", 100);

                final ByteValues bytevalues = getByteValues(fTargetProps, new SubProgressMonitor(monitor, 95));

                // and update the user interface
                if (!fActionsToolBar.isDisposed()) {
                    fActionsToolBar.getDisplay().syncExec(new Runnable() {
                        public void run() {
                            // Check if the mcus match
                            String projectmcu = fTargetProps.getParent().getMCUId();
                            String newmcu = bytevalues.getMCUId();
                            if (!bytevalues.isCompatibleWith(projectmcu)) {
                                // No, they don't match. Ask the user what to do
                                // "Convert to project MCU", "Accept anyway" or "Cancel"
                                Dialog dialog = new ProjectMCUMismatchDialog(fActionsToolBar.getShell(), newmcu,
                                        projectmcu, getType(), isPerConfig());
                                int choice = dialog.open();
                                switch (choice) {
                                case ProjectMCUMismatchDialog.CANCEL:
                                    return;
                                case ProjectMCUMismatchDialog.ACCEPT:
                                    // Accept the values including their MCUId.
                                    // Set the properties accordingly
                                    fBytes.setByteValues(bytevalues);
                                    break;
                                case ProjectMCUMismatchDialog.CONVERT:
                                    // Convert the values to the current project MCU
                                    ByteValues newvalues = convertFusesTo(projectmcu, bytevalues);
                                    fBytes.setByteValues(newvalues);
                                    break;
                                }
                            } else {
                                // MCUs are compatible.
                                fBytes.setByteValues(bytevalues);
                            }
                            updateData(fTargetProps);
                        }
                    });
                }
                monitor.worked(5);
            } catch (AVRDudeException ade) {
                // Show an Error message and exit
                if (!fActionsToolBar.isDisposed()) {
                    UIJob messagejob = new AVRDudeErrorDialogJob(fActionsToolBar.getDisplay(), ade,
                            fTargetProps.getProgrammerId());
                    messagejob.setPriority(Job.INTERACTIVE);
                    messagejob.schedule();
                    try {
                        messagejob.join(); // block until the dialog is closed.
                    } catch (InterruptedException e) {
                        // Don't care if the dialog is interrupted from outside.
                    }
                }
            } catch (SWTException swte) {
                // The display has been disposed, so the user is not
                // interested in the results from this job
                return Status.CANCEL_STATUS;
            } finally {
                monitor.done();
                // Enable the Load from MCU Button
                if (!fActionsToolBar.isDisposed()) {
                    fActionsToolBar.getDisplay().syncExec(new Runnable() {
                        public void run() {
                            // Re-Enable the Button
                            fActionsToolBar.setEnabled(true);
                            fLoadingLabel.setVisible(false);
                        }
                    });
                }
            }

            return Status.OK_STATUS;
        }
    };

    // now set the Job properties and start it
    readJob.setRule(new AVRDudeSchedulingRule(fTargetProps.getProgrammer()));
    readJob.setPriority(Job.SHORT);
    readJob.setUser(true);
    readJob.schedule();
}

From source file:de.instanttouch.ui.scaffolding.swt.presenter.SnakeListPresenter.java

License:Open Source License

protected void open(SnakeType type) {

    Dialog typeDialog = SnakeDialogRegistry.createForType(composite.getShell(), type, true, bValidate);
    if (typeDialog != null) {
        if (Dialog.OK == typeDialog.open()) {
            refresh();/*  w  w w  .ja  v  a2 s  .  co m*/
        }
    }

}

From source file:de.instanttouch.ui.scaffolding.swt.presenter.SnakeListPresenter.java

License:Open Source License

protected void add() {

    try {//from   ww  w  .j a v a  2s  . co m

        // create element
        if (list.getElementCreator() instanceof SnakeTypeSelectionCreator) {
            SnakeTypeSelectionCreator creator = (SnakeTypeSelectionCreator) list.getElementCreator();

            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            SnakeSelectTypeDialog selectDialog = new SnakeSelectTypeDialog(shell, creator,
                    "select element type");
            if (selectDialog.open() != Dialog.OK) {
                return;
            }
        }

        T type = list.newElement();
        type.setParent(list);

        SnakeType dialogType = type.getReference() == null ? type : type.getReference();

        // edit new element
        Dialog dialog = SnakeDialogRegistry.createForType(composite.getShell(), dialogType, allowOk, bValidate);
        if (dialog.open() == Dialog.OK) {
            list.add(type);
            refresh();
        } else {
            type.setParent(null);
        }

    } catch (Exception e) {
        SnakeExceptionHandler.handle(e);
    }
}

From source file:de.instanttouch.ui.scaffolding.swt.presenter.SnakeMapPresenter.java

License:Open Source License

protected int mapOpen(SnakeType type) {

    int ok = -1;//from  ww  w.j av  a  2 s  .  co m

    Dialog typeDialog = SnakeDialogRegistry.createForType(composite.getShell(), type, true, bValidate);
    if (typeDialog != null) {
        ok = typeDialog.open();
    }

    return ok;
}

From source file:de.instanttouch.ui.scaffolding.swt.viewer.lazy.SnakeLazyTablePresenter.java

License:Open Source License

protected void open(SnakeType type) {

    boolean bValidate = false;
    boolean bOk = false;
    Dialog typeDialog = SnakeDialogRegistry.createForType(composite.getShell(), type, bOk, bValidate);
    if (typeDialog != null) {
        if (Dialog.OK == typeDialog.open()) {
        }/*from  ww w  .j  ava 2  s  . co  m*/
    }

}