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.buglabs.dragonfly.ui.wizards.bugProject.OSGiServiceBindingPage.java

License:Open Source License

/**
 * Opens the selector dialog that lets us choose service properties for
 * filtering/*from w  w w .  j  av a2 s.c o m*/
 * 
 */
private void openServicePropertySelectorDialog(Shell shell, String selectedService,
        boolean clearCheckedOnCancel) {
    /* TODO - Make sure this works, this is for 1.5 SDK, R1.4.3 of BUG */
    if (servicePropertyOptionsMap.containsKey(selectedService)
            && servicePropertyOptionsMap.get(selectedService) != null
            && servicePropertyOptionsMap.get(selectedService).size() > 0) {
        Dialog d = new ServicePropertySelectorDialog(shell, selectedService,
                (List<ServicePropertyHelper>) servicePropertyOptionsMap.get(selectedService), pinfo);
        if (d.open() == Dialog.CANCEL && clearCheckedOnCancel) {
            dependencyViewer.setChecked(selectedService, false);
        }
    }

}

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 v  a  2  s.  c  om*/

                        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.ebmwebsourcing.petals.services.sa.wizards.PetalsSaNewWizardPage.java

License:Open Source License

@Override
public void createControl(Composite parent) {

    // Add a tool tip to display in case of problem
    this.helpTooltip = new FixedShellTooltip(getShell(), true, 90) {
        @Override/*from   w  w  w .  j  a  v a  2  s.c  o  m*/
        public void populateTooltip(Composite parent) {

            parent.setLayout(new GridLayout());
            parent.setLayoutData(new GridData(GridData.FILL_BOTH));
            parent.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));

            StringBuilder sb = new StringBuilder();
            sb.append("<form><p><b>What does this error mean?</b></p><p>");
            sb.append("This wizard will generate, among other things, Maven artifacts.<br />");
            sb.append("Unfortunately, there is a problem with the <A>the Petals Maven preferences</A>.</p>");
            sb.append("<p>Please, make them correct.</p></form>");

            FormText formText = new FormText(parent, SWT.WRAP | SWT.NO_FOCUS);
            formText.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
            formText.setText(sb.toString(), true, false);
            formText.addHyperlinkListener(new HyperlinkAdapter() {

                @Override
                public void linkActivated(HyperlinkEvent e) {
                    try {
                        Dialog dlg = PreferencesUtil.createPreferenceDialogOn(new Shell(),
                                "com.ebmwebsourcing.petals.services.prefs.maven", null, null);

                        if (dlg.open() == Window.OK)
                            validate();

                    } catch (Exception e1) {
                        PetalsServicesPlugin.log(e1, IStatus.ERROR);
                    }
                }
            });
        }
    };

    this.helpTooltip.hide();

    // Basic fields
    Composite container = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).extendedMargins(15, 15, 20, 0).spacing(15, 5)
            .applyTo(container);
    container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    SwtFactory.createLabel(container, "Name:",
            "The service assembly name to put into the jbi.xml and pom.xml files");
    TextWithButtonComposite twc = new TextWithButtonComposite(container);
    twc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    twc.getText().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    final List<IProject> suProjects = new ArrayList<IProject>();
    for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
        if (ServiceProjectRelationUtils.isSuProject(p))
            suProjects.add(p);
    }

    twc.getButton().setText("Name Helper...");
    if (suProjects.isEmpty()) {
        twc.getButton().setEnabled(false);
        twc.getButton().setToolTipText("No Service Unit project was found in the workspace");
    } else {
        twc.getButton().setToolTipText("Generate the SA name from a SU name");
    }

    twc.getButton().addSelectionListener(new DefaultSelectionListener() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            ListDialog dlg = new ListDialog(getShell());
            dlg.setContentProvider(new ArrayContentProvider());
            dlg.setLabelProvider(new WorkbenchLabelProvider());
            dlg.setInput(suProjects);
            if (dlg.open() != Window.OK)
                return;

            String suName = ((IProject) dlg.getResult()[0]).getName();
            String saName = JbiUtils.createSaName(suName);
            PetalsSaNewWizardPage.this.nameText.setText(saName);
        }
    });

    this.nameText = twc.getText();
    this.nameText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {

            String aid = PetalsSaNewWizardPage.this.artifactIdText.getText();
            String n = PetalsSaNewWizardPage.this.nameText.getText();

            if (aid.trim().length() != 0 && !n.startsWith(aid))
                validate();
            else
                PetalsSaNewWizardPage.this.artifactIdText.setText(n);
        }
    });

    ModifyListener validationListener = new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            validate();
        }
    };

    SwtFactory.createLabel(container, "Artifact ID:",
            "The service assembly description to put into the jbi.xml and pom.xml files");
    this.artifactIdText = SwtFactory.createSimpleTextField(container, true);
    this.artifactIdText.addModifyListener(validationListener);

    new Label(container, SWT.NONE).setText("Group ID:");
    this.groupIdText = SwtFactory.createSimpleTextField(container, true);
    this.groupIdText.setText(this.groupId);
    this.groupIdText.addModifyListener(validationListener);

    new Label(container, SWT.NONE).setText("Version:");
    this.versionText = SwtFactory.createSimpleTextField(container, true);
    this.versionText.setText(this.version);
    this.versionText.addModifyListener(validationListener);

    new Label(container, SWT.NONE).setText("Description:");
    this.descriptionText = SwtFactory.createSimpleTextField(container, true);
    this.descriptionText.addModifyListener(validationListener);

    // Project location
    final Button useDefaultLocButton = new Button(container, SWT.CHECK);
    useDefaultLocButton.setText("Create the project in the default location");
    GridDataFactory.swtDefaults().indent(0, 17).span(2, 1).applyTo(useDefaultLocButton);

    Composite locContainer = new Composite(container, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).applyTo(locContainer);
    GridDataFactory.swtDefaults().span(2, 1).applyTo(locContainer);

    final Label locLabel = new Label(locContainer, SWT.NONE);
    locLabel.setText("Project location:");

    final TextWithButtonComposite twbc = SwtFactory.createDirectoryBrowser(locContainer);
    this.projectLocationText = twbc.getText();
    this.projectLocationText.setText(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
    this.projectLocationText.addModifyListener(validationListener);

    useDefaultLocButton.setSelection(this.isAtDefaultLocation);
    useDefaultLocButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {

            PetalsSaNewWizardPage.this.isAtDefaultLocation = useDefaultLocButton.getSelection();

            boolean use = !PetalsSaNewWizardPage.this.isAtDefaultLocation;
            locLabel.setEnabled(use);
            PetalsSaNewWizardPage.this.projectLocationText.setEnabled(use);
            twbc.getButton().setEnabled(use);
            PetalsSaNewWizardPage.this.projectLocationText.setFocus();
        }
    });

    // Last steps in the UI definition
    useDefaultLocButton.notifyListeners(SWT.Selection, new Event());
    setControl(container);
    validate();

    String msg = getErrorMessage();
    setErrorMessage(null);
    setMessage(msg, INFORMATION);

    this.nameText.setFocus();
}

From source file:com.eclipsesource.jshint.ui.internal.preferences.ui.PathPatternDialog_Test.java

License:Open Source License

private static void openNonBlocking(Dialog dialog) {
    dialog.setBlockOnOpen(false);
    dialog.open();
}

From source file:com.helio.boomer.rap.handler.ChangeLogHandler.java

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Dialog dialog = new ChangeLogDialog(HandlerUtil.getActiveShell(event));
    dialog.open();
    return null;/*from  w w w .  java  2 s  . c om*/
}

From source file:com.helio.boomer.rap.handler.LicenseBoomerHandler.java

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Dialog dialog = new LicenseDialog(HandlerUtil.getActiveShell(event));
    dialog.open();

    return null;/*from   w  ww.j a v a  2 s  .co  m*/
}

From source file:com.hydra.project.myplugin_nebula.xviewer.customize.CustomizeManager.java

License:Open Source License

public void handleTableCustomization() {
    Dialog dialog = xViewerFactory.getCustomizeDialog(xViewer);
    if (dialog != null) {
        dialog.open();
    }/*from   ww  w .  j a  v a 2 s .c  o m*/
}

From source file:com.microsoft.azureexplorer.actions.ManageSubscriptionsAction.java

License:Open Source License

@Override
public void actionPerformed(NodeActionEvent e) {
    Dialog subscriptionsDialog = new ManageSubscriptionDialog(new Shell(), true, false);
    subscriptionsDialog.open();
    azureServiceModule.load();/*from   w w w.  jav a 2 s .co  m*/
}

From source file:com.microsoft.azureexplorer.forms.createvm.SubscriptionStep.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    GridLayout gridLayout = new GridLayout(3, false);
    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalAlignment = GridData.BEGINNING;
    Composite container = new Composite(parent, 0);
    container.setLayout(gridLayout);/*from w  w w . ja  va2 s . c o  m*/
    container.setLayoutData(gridData);

    wizard.configStepList(container, 0);

    createSubscriptionCombo(container);

    this.buttonLogin = new Button(container, SWT.PUSH);
    this.buttonLogin.setImage(Activator.getImageDescriptor("icons/settings.png").createImage());
    gridData = new GridData();
    gridData.horizontalIndent = 5;
    gridData.widthHint = 50;
    gridData.heightHint = 40;
    gridData.verticalAlignment = GridData.BEGINNING;
    buttonLogin.setLayoutData(gridData);
    buttonLogin.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Dialog subscriptionsDialog = new ManageSubscriptionDialog(new Shell(), true, false);
            subscriptionsDialog.open();
            loadSubscriptions();
        }
    });

    this.setControl(container);
}

From source file:com.microsoft.tfs.client.common.ui.framework.helper.UIHelpers.java

License:Open Source License

public static int openOnUIThread(final Dialog dialog) {
    final AtomicInteger dialogStatus = new AtomicInteger();

    runOnUIThread(false, new Runnable() {
        @Override//from   w  w w.  j a va  2s  .  c o  m
        public void run() {
            dialogStatus.set(dialog.open());
        }
    });

    return dialogStatus.get();
}