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

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

Introduction

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

Prototype

@Override
    public void create() 

Source Link

Usage

From source file:com.bdaum.zoom.ui.internal.views.DataEntryView.java

License:Open Source License

protected void setDialogLocation(Dialog dialog) {
    dialog.create();
    Point location = dialog.getShell().getLocation();
    location.x -= 25;/*  ww w  .  ja  v  a  2  s  .c  o m*/
    location.y += 30;
    dialog.getShell().setLocation(location);
}

From source file:com.cloudbees.eclipse.dtp.internal.actions.ShowPasswordAction.java

License:Open Source License

@Override
public void run(IAction action) {
    if (action instanceof ObjectPluginAction) {
        ObjectPluginAction pluginAction = (ObjectPluginAction) action;
        ISelection selection = pluginAction.getSelection();

        if (selection instanceof IStructuredSelection) {
            IStructuredSelection structSelection = (IStructuredSelection) selection;
            Object element = structSelection.getFirstElement();

            if (element instanceof DatabaseInfo) {
                DatabaseInfo db = (DatabaseInfo) element;
                try {
                    final DatabaseInfo dbi = BeesSDK.getDatabaseInfo(db.getName(), true);
                    final String psw = dbi.getPassword();

                    Dialog pswd = new Dialog(Display.getCurrent().getActiveShell()) {

                        @Override
                        protected void configureShell(Shell newShell) {
                            super.configureShell(newShell);
                            newShell.setText("Password for database '" + dbi.getName() + "'");
                        }//from   w w  w.  j  a  va 2s  . c o  m

                        protected void createButtonsForButtonBar(Composite parent) {
                            createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
                        }

                        @Override
                        protected Control createDialogArea(Composite parent) {
                            Composite container = (Composite) super.createDialogArea(parent);
                            GridLayout layout = new GridLayout();
                            layout.numColumns = 2;
                            container.setLayout(layout);
                            GridData gridData = new GridData();
                            gridData.grabExcessHorizontalSpace = true;
                            gridData.horizontalAlignment = GridData.FILL;

                            Label dbLabel = new Label(container, SWT.NONE);
                            dbLabel.setText("Database: ");

                            Text dbNameText = new Text(container, SWT.BORDER);
                            dbNameText.setText(dbi.getName());
                            dbNameText.setLayoutData(gridData);
                            dbNameText.setEditable(false);
                            dbNameText.setEnabled(true);

                            Label pswLabel = new Label(container, SWT.NONE);
                            pswLabel.setText("Password: ");
                            gridData = new GridData();
                            gridData.grabExcessHorizontalSpace = true;
                            gridData.horizontalAlignment = GridData.FILL;
                            Text pswText = new Text(container, SWT.BORDER);
                            pswText.setText(psw);
                            pswText.setEditable(false);
                            pswText.setEnabled(true);
                            pswText.setLayoutData(gridData);

                            pswText.setFocus();
                            pswText.selectAll();
                            return container;
                        }
                    };
                    pswd.create();
                    pswd.open();

                    //MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Password for database '"+dbi.getName()+"'", "Database: "+dbi.getName()+"\nPassword: "+dbi.getPassword());
                } catch (Exception e) {
                    CloudBeesUIPlugin.showError("Failed to fetch database password!", e);
                }

            }
        }
    }
}

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);/*from  w w w.jav  a  2  s. c  o  m*/
    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 ww  w . ja v a 2  s .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:org.amanzi.awe.nem.ui.contributions.AbstractNetworkMenuContribution.java

License:Open Source License

/**
 * @param model/*from ww  w. j  a va  2 s  . c  o m*/
 * @param newType
 */
protected void openWizard(final INetworkModel model, final IDataElement root, final INodeType newType) {
    final IWizard wizard = getWizard(model, root, newType);
    final Dialog wizardDialog = createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), wizard);
    wizardDialog.create();
    wizardDialog.open();

}

From source file:org.amanzi.awe.nem.ui.handlers.CreateNetworkHandler.java

License:Open Source License

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    NetworkCreationWizard wizard = new NetworkCreationWizard();
    Dialog wizardDialog = createDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), wizard);
    wizardDialog.create();
    wizardDialog.open();/*from ww w.  j  av  a  2 s . co  m*/
    return null;
}

From source file:org.amanzi.neo.loader.ui.handler.LoaderWizardHandler.java

License:Open Source License

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    String wizardId = event.getParameter(LOADER_WIZARD_ID);
    if (wizardId != null) {
        ILoaderWizard<?> wizard = loaderContext.getLoaderWizard(wizardId);

        if (wizard != null) {
            IWorkbenchWindow window = getWorkbenchWindow(event);
            IWorkbench workbench = window.getWorkbench();

            wizard.init(workbench, null);

            Dialog wizardDialog = createDialog(window.getShell(), wizard);
            wizardDialog.create();
            wizardDialog.open();/* ww w  . j av a 2s . c om*/
        } else {
            throw new ExecutionException(
                    Messages.formatString(Messages.LoaderWizardHandler_NoWizardByIdError, wizardId));
        }
    } else {
        throw new ExecutionException(Messages.LoaderWizardHandler_NoWizardIdError);
    }

    return null;
}

From source file:org.eclipse.emf.search.ui.internal.replace.provisional.TextualModelSearchRefactoringOperation.java

License:Open Source License

/**
 * Opens the refactoring dialog for the refactoring wizard passed to the constructor. 
 * The method first checks the initial conditions of the refactoring. If the condition 
 * checking returns a status with a severity of {@link RefactoringStatus#FATAL} then
 * a message dialog is opened containing the corresponding status message. No wizard 
 * dialog is opened in this situation. If the condition checking passes then the 
 * refactoring dialog is opened. /*  w  ww .j a  v  a 2s . c o m*/
 * <p>
 * The methods ensures that the workspace lock is held while the condition checking, 
 * change creation and change execution is performed. Clients can't make any assumption
 * about the thread in which these steps are executed. However the framework ensures
 * that the workspace lock is transfered to the thread in which the execution of the
 * steps takes place. 
 * </p>
 * @param parent the parent shell for the dialog or <code>null</code> if the dialog
 *  is a top level dialog
 * @param dialogTitle the dialog title of the message box presenting the failed
 *  condition check (if any)
 *   
 * @return {@link #INITIAL_CONDITION_CHECKING_FAILED} if the initial condition checking
 *  failed and no wizard dialog was presented. Otherwise either {@link IDialogConstants#OK_ID}
 *  or {@link IDialogConstants#CANCEL_ID} is returned depending on whether the user
 *  has pressed the OK or cancel button on the wizard dialog.
 * 
 * @throws InterruptedException if the initial condition checking got canceled by
 *  the user.
 */
public int run(final Shell parent, final String dialogTitle) throws InterruptedException {
    Assert.isNotNull(dialogTitle);
    final Refactoring refactoring = fWizard.getRefactoring();
    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 {
                // we are getting the block dialog for free if we pass in null
                manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null);

                refactoring.setValidationContext(parent);
                fInitialConditions = checkInitialConditions(refactoring, parent, dialogTitle);
                if (fInitialConditions.hasFatalError()) {
                    String message = fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL);
                    MessageDialog.openInformation(parent, dialogTitle, message);
                    result[0] = INITIAL_CONDITION_CHECKING_FAILED;
                } else {
                    fWizard.setInitialConditionCheckingStatus(fInitialConditions);
                    Dialog dialog = new ModelSearchWizardDialog(parent, fWizard);
                    dialog.create();
                    IWizardContainer wizardContainer = (IWizardContainer) dialog;
                    if (wizardContainer.getCurrentPage() == null)
                        /*
                         * Don't show the dialog at all if there are no user
                         * input pages and change creation was cancelled.
                         */
                        result[0] = Window.CANCEL;
                    else
                        result[0] = dialog.open();
                }
            } catch (InterruptedException e) {
                canceled[0] = e;
            } catch (OperationCanceledException e) {
                canceled[0] = new InterruptedException(e.getMessage());
            } finally {
                manager.endRule(ResourcesPlugin.getWorkspace().getRoot());
                refactoring.setValidationContext(null);
            }
        }
    };
    BusyIndicator.showWhile(parent.getDisplay(), r);
    if (canceled[0] != null)
        throw canceled[0];
    return result[0];
}

From source file:org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.java

License:Open Source License

/**
 * Opens the refactoring dialog for the refactoring wizard passed to the constructor.
 * The method first checks the initial conditions of the refactoring. If the condition
 * checking returns a status with a severity of {@link RefactoringStatus#FATAL} then
 * a message dialog is opened containing the corresponding status message. No wizard
 * dialog is opened in this situation. If the condition checking passes then the
 * refactoring dialog is opened./*w  w w  .  j a v  a2s  . co m*/
 * <p>
 * The methods ensures that the workspace lock is held while the condition checking,
 * change creation and change execution is performed. Clients can't make any assumption
 * about the thread in which these steps are executed. However the framework ensures
 * that the workspace lock is transfered to the thread in which the execution of the
 * steps takes place.
 * </p>
 * @param parent the parent shell for the dialog or <code>null</code> if the dialog
 *  is a top level dialog
 * @param dialogTitle the dialog title of the message box presenting the failed
 *  condition check (if any)
 * @param context the runnable context to use for conditions checking before the
 *  refactoring wizard dialog is visible. If <code>null</code>, the workbench window's
 *  progress service is used.  
 *
 * @return {@link #INITIAL_CONDITION_CHECKING_FAILED} if the initial condition checking
 *  failed and no wizard dialog was presented. Otherwise either {@link IDialogConstants#OK_ID}
 *  or {@link IDialogConstants#CANCEL_ID} is returned depending on whether the user
 *  has pressed the OK or cancel button on the wizard dialog.
 *
 * @throws InterruptedException if the initial condition checking got canceled by
 *  the user.
 *  
 * @since 3.5
 */
public int run(final Shell parent, final String dialogTitle, final IRunnableContext context)
        throws InterruptedException {
    Assert.isNotNull(dialogTitle);
    final Refactoring refactoring = fWizard.getRefactoring();
    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 {
                // we are getting the block dialog for free if we pass in null
                manager.beginRule(ResourcesPlugin.getWorkspace().getRoot(), null);

                refactoring.setValidationContext(parent);
                fInitialConditions = checkInitialConditions(refactoring, parent, dialogTitle, context);
                if (fInitialConditions.hasFatalError()) {
                    String message = fInitialConditions.getMessageMatchingSeverity(RefactoringStatus.FATAL);
                    MessageDialog.openError(parent, dialogTitle, message);
                    result[0] = INITIAL_CONDITION_CHECKING_FAILED;
                } else {
                    fWizard.setInitialConditionCheckingStatus(fInitialConditions);
                    Dialog dialog = RefactoringUI.createRefactoringWizardDialog(fWizard, parent);
                    dialog.create();
                    IWizardContainer wizardContainer = (IWizardContainer) dialog;
                    if (wizardContainer.getCurrentPage() == null)
                        /*
                         * Don't show the dialog at all if there are no user
                         * input pages and change creation was cancelled.
                         */
                        result[0] = Window.CANCEL;
                    else
                        result[0] = dialog.open();
                }
            } catch (InterruptedException e) {
                canceled[0] = e;
            } catch (OperationCanceledException e) {
                canceled[0] = new InterruptedException(e.getMessage());
            } finally {
                manager.endRule(ResourcesPlugin.getWorkspace().getRoot());
                refactoring.setValidationContext(null);
                RefactoringContext refactoringContext = fWizard.getRefactoringContext();
                if (refactoringContext != null)
                    refactoringContext.dispose();
            }
        }
    };
    BusyIndicator.showWhile(parent != null ? parent.getDisplay() : null, r);
    if (canceled[0] != null)
        throw canceled[0];
    return result[0];
}

From source file:org.eclipse.pde.internal.ui.search.dependencies.ShowResultsAction.java

License:Open Source License

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