Example usage for org.eclipse.jface.dialogs IDialogConstants OK_LABEL

List of usage examples for org.eclipse.jface.dialogs IDialogConstants OK_LABEL

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs IDialogConstants OK_LABEL.

Prototype

String OK_LABEL

To view the source code for org.eclipse.jface.dialogs IDialogConstants OK_LABEL.

Click Source Link

Document

The label for OK buttons.

Usage

From source file:com.google.dart.tools.ui.internal.dialogs.SortMembersMessageDialog.java

License:Open Source License

public SortMembersMessageDialog(Shell parentShell) {
    super(OPTIONAL_ID, parentShell, DialogsMessages.SortMembersMessageDialog_dialog_title, null, new String(),
            INFORMATION, new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0);

    setShellStyle(getShellStyle() | SWT.RESIZE);

    fDialogSettings = DartToolsPlugin.getDefault().getDialogSettings();

    boolean isSortAll = fDialogSettings.getBoolean(DIALOG_SETTINGS_SORT_ALL);

    fNotSortAllRadio = new SelectionButtonDialogField(SWT.RADIO);
    fNotSortAllRadio.setLabelText(DialogsMessages.SortMembersMessageDialog_do_not_sort_fields_label);
    fNotSortAllRadio.setSelection(!isSortAll);

    fSortAllRadio = new SelectionButtonDialogField(SWT.RADIO);
    fSortAllRadio.setLabelText(DialogsMessages.SortMembersMessageDialog_sort_all_label);
    fSortAllRadio.setSelection(isSortAll);
}

From source file:com.google.dart.tools.ui.internal.text.dart.CompletionProposalComputerRegistry.java

License:Open Source License

private void informUserModal(CompletionProposalComputerDescriptor descriptor, IStatus status) {
    String title = DartTextMessages.CompletionProposalComputerRegistry_error_dialog_title;
    CompletionProposalCategory category = descriptor.getCategory();
    IContributor culprit = descriptor.getContributor();
    Set affectedPlugins = getAffectedContributors(category, culprit);

    final String avoidHint;
    final String culpritName = culprit == null ? null : culprit.getName();
    if (affectedPlugins.isEmpty()) {
        avoidHint = Messages.format(DartTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHint,
                new Object[] { culpritName, category.getDisplayName() });
    } else {//from  w  w w  . ja va 2 s. c  o m
        avoidHint = Messages.format(
                DartTextMessages.CompletionProposalComputerRegistry_messageAvoidanceHintWithWarning,
                new Object[] { culpritName, category.getDisplayName(), toString(affectedPlugins) });
    }

    String message = status.getMessage();
    // inlined from MessageDialog.openError
    MessageDialog dialog = new MessageDialog(DartToolsPlugin.getActiveWorkbenchShell(), title,
            null /* default image */, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL },
            0) {
        @Override
        protected Control createCustomArea(Composite parent) {
            Link link = new Link(parent, SWT.NONE);
            link.setText(avoidHint);
            link.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    PreferencesUtil.createPreferenceDialogOn(getShell(),
                            "com.google.dart.tools.ui.internal.preferences.CodeAssistPreferenceAdvanced", null, //$NON-NLS-1$
                            null).open();
                }
            });
            GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
            gridData.widthHint = this.getMinimumMessageWidth();
            link.setLayoutData(gridData);
            return link;
        }
    };
    dialog.open();
}

From source file:com.google.gapid.views.AboutDialog.java

License:Apache License

public static void showAbout(Shell shell, Theme theme) {
    new DialogBase(shell, theme) {
        @Override/*  ww  w.  j  av  a  2 s .  c o m*/
        public String getTitle() {
            return Messages.ABOUT_TITLE;
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite area = (Composite) super.createDialogArea(parent);

            Composite container = createComposite(area, centered(new RowLayout(SWT.VERTICAL)));
            container.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true));

            createLabel(container, "", theme.dialogLogo());
            Text title = createForegroundLabel(container, Messages.WINDOW_TITLE);
            title.setFont(theme.bigBoldFont());
            createForegroundLabel(container, "Version " + GAPID_VERSION);
            createForegroundLabel(container,
                    "Server: " + Info.getServerName() + ", Version: " + Info.getServerVersion());
            createForegroundLabel(container, Messages.ABOUT_COPY);

            return area;
        }

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

        public Text createForegroundLabel(Composite parent, String text) {
            Text label = createTextbox(parent, SWT.READ_ONLY, text);
            label.setBackground(parent.getBackground());

            // SWT will weirdly select the entire content of the first textbox. No thanks.
            label.setSelection(0, 0);
            return label;
        }
    }.open();
}

From source file:com.google.gapid.views.ActivityPickerDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button ok = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);

    ok.setEnabled(false);//from  w w  w .  j a va2 s  .  com
    tree.getTree().addListener(SWT.Selection, e -> ok.setEnabled(selected != null));
}

From source file:com.google.gapid.views.ErrorDialog.java

License:Apache License

public static void showErrorDialog(Shell shell, String text, String detailString) {
    new IconAndMessageDialog(shell) {
        private Group details;

        @Override//from w  w  w  . j  a v a2s.c om
        protected void configureShell(Shell newShell) {
            super.configureShell(newShell);
            newShell.setText("Error");
        }

        @Override
        protected boolean isResizable() {
            return true;
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite container = (Composite) super.createDialogArea(parent);
            ((GridLayout) container.getLayout()).numColumns = 2;
            createMessageArea(container);

            String msg = String.format(Messages.ERROR_MESSAGE, text);
            withLayoutData(createTextbox(container, SWT.WRAP | SWT.READ_ONLY, msg),
                    withSizeHints(new GridData(SWT.FILL, SWT.CENTER, true, false), getWidthHint(), SWT.DEFAULT))
                            .setBackground(container.getBackground());

            if (detailString != null) {
                ExpandBar bar = withLayoutData(new ExpandBar(container, SWT.NONE),
                        withSpans(new GridData(SWT.FILL, SWT.TOP, true, false), 2, 1));
                new ExpandItem(bar, SWT.NONE, 0).setText("Details...");

                bar.addListener(SWT.Expand, e -> {
                    createDetails(container);
                    Point curr = getShell().getSize();
                    Point want = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
                    if (want.y > curr.y) {
                        getShell().setSize(
                                new Point(curr.x, curr.y + Math.min(MAX_DETAILS_SIZE, want.y - curr.y)));
                    } else {
                        details.requestLayout();
                    }
                });

                bar.addListener(SWT.Collapse, e -> {
                    Point curr = getShell().getSize();
                    if (details != null) {
                        details.dispose();
                        details = null;
                    }
                    Point want = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
                    if (want.y < curr.y) {
                        getShell().setSize(new Point(curr.x, want.y));
                    }
                });
            }

            return container;
        }

        private int getWidthHint() {
            return convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        }

        private void createDetails(Composite container) {
            details = createGroup(container, "");
            GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(details);
            Composite inner = createComposite(details, new GridLayout(1, false));
            withLayoutData(createTextbox(inner, DETAILS_STYLE, detailString),
                    new GridData(SWT.FILL, SWT.FILL, true, true));
            withLayoutData(createLink(inner, "<a>File a bug</a> on GitHub", e -> {
                Program.launch(getFileBugUrl());
            }), new GridData(SWT.RIGHT, SWT.BOTTOM, false, false));
            withLayoutData(createLink(inner, "<a>Show logs</a> directory", e -> {
                AboutDialog.showLogDir();
            }), new GridData(SWT.RIGHT, SWT.BOTTOM, false, false));
        }

        private String getFileBugUrl() {
            Escaper esc = UrlEscapers.urlFormParameterEscaper();
            return String.format(FILE_BUG_URL, esc.escape(text), esc.escape(Messages.BUG_BODY));
        }

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

        @Override
        protected Image getImage() {
            return getErrorImage();
        }
    }.open();
}

From source file:com.google.gapid.views.Licenses.java

License:Apache License

public static void showLicensesDialog(Shell shell, Theme theme) {
    new DialogBase(shell, theme) {
        @Override/*  ww w. j av  a 2  s. co m*/
        public String getTitle() {
            return Messages.LICENSES;
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite area = (Composite) super.createDialogArea(parent);

            Browser browser;
            try {
                browser = new Browser(area, SWT.NONE);
            } catch (SWTError e) {
                // Failed to initialize the browser. Show it as a plain text widget.
                Text text = new Text(area,
                        SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
                text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                text.setText(readLicenses(false));
                return text;
            }

            GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
            data.widthHint = 600;
            data.heightHint = 400;
            browser.setLayoutData(data);
            browser.setText(readLicenses(true));
            browser.addLocationListener(new LocationAdapter() {
                @Override
                public void changing(LocationEvent event) {
                    if ("about:blank".equals(event.location)) {
                        browser.setText(readLicenses(true));
                    }
                }
            });

            return area;
        }

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

From source file:com.google.gapid.views.SettingsDialog.java

License:Apache License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
    createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
}

From source file:com.google.gapid.widgets.AboutDialog.java

License:Apache License

public static void showAbout(Shell shell, Theme theme) {
    new TitleAreaDialog(shell) {
        @Override/*from www . j  a v  a  2s .com*/
        public void create() {
            super.create();
            setTitle(Messages.ABOUT_TITLE);
        }

        @Override
        protected void configureShell(Shell newShell) {
            super.configureShell(newShell);
            newShell.setText(Messages.ABOUT_WINDOW_TITLE);
        }

        @Override
        protected Control createDialogArea(Composite parent) {
            Composite area = (Composite) super.createDialogArea(parent);
            area.setBackground(theme.aboutBackground());

            Composite container = createComposite(area, centered(new RowLayout(SWT.VERTICAL)));
            container.setLayoutData(new GridData(SWT.CENTER, SWT.FILL, true, true));

            container.setBackground(theme.aboutBackground());
            createLabel(container, "", theme.logoBig());
            Label title = createForegroundLabel(container, Messages.WINDOW_TITLE);
            title.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
            createForegroundLabel(container, "Version " + Version.GAPIC_VERSION);
            createForegroundLabel(container,
                    "Server: " + Info.getServerName() + ", Version: " + Info.getServerVersion());
            createForegroundLabel(container, Messages.ABOUT_DESCRIPTION);
            createForegroundLabel(container, Messages.ABOUT_COPY);

            return area;
        }

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

        public Label createForegroundLabel(Composite parent, String text) {
            Label label = createLabel(parent, text);
            label.setForeground(theme.aboutForeground());
            label.setBackground(theme.aboutBackground());
            return label;
        }

    }.open();
}

From source file:com.google.gapid.widgets.Licenses.java

License:Apache License

public static void showLicensesDialog(Shell shell) {
    new MessageDialog(shell, Messages.LICENSES, null, Messages.LICENSES, MessageDialog.INFORMATION, 0,
            IDialogConstants.OK_LABEL) {
        @Override/*  w  w w . ja  va  2  s  .c  om*/
        protected boolean isResizable() {
            return true;
        }

        @Override
        protected Control createCustomArea(Composite parent) {
            Browser browser;
            try {
                browser = new Browser(parent, SWT.NONE);
            } catch (SWTError e) {
                // Failed to initialize the browser. Show it as a plain text widget.
                Text text = new Text(parent,
                        SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
                text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                text.setText(readLicenses(false));
                return text;
            }

            GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
            data.widthHint = 600;
            data.heightHint = 400;
            browser.setLayoutData(data);
            browser.setText(readLicenses(true));
            browser.addLocationListener(new LocationAdapter() {
                @Override
                public void changing(LocationEvent event) {
                    if ("about:blank".equals(event.location)) {
                        browser.setText(readLicenses(true));
                    }
                }
            });
            return browser;
        }
    }.open();
}

From source file:com.google.gapid.widgets.TextViewer.java

License:Apache License

public static void showViewTextPopup(Shell shell, Widgets widgets, String title,
        ListenableFuture<String> text) {
    new MessageDialog(shell, Messages.VIEW_DETAILS, null, title, MessageDialog.INFORMATION, 0,
            IDialogConstants.OK_LABEL) {
        protected LoadablePanel<Text> loadable;

        @Override/*from  w w w.j a v a2s  . c  o m*/
        protected boolean isResizable() {
            return true;
        }

        @Override
        protected Control createCustomArea(Composite parent) {
            loadable = new LoadablePanel<Text>(parent, widgets, panel -> new Text(panel,
                    SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL));
            loadable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

            loadable.startLoading();
            Rpc.listen(text, new UiErrorCallback<String, String, String>(parent, LOG) {
                @Override
                protected ResultOrError<String, String> onRpcThread(Rpc.Result<String> result) {
                    try {
                        return success(result.get());
                    } catch (RpcException e) {
                        return error(e.getMessage());
                    } catch (ExecutionException e) {
                        return error(e.getCause().toString());
                    }
                }

                @Override
                protected void onUiThreadSuccess(String result) {
                    loadable.getContents().setText(result);
                    loadable.stopLoading();
                }

                @Override
                protected void onUiThreadError(String error) {
                    loadable.showMessage(MessageType.Error, error);
                }
            });
            return loadable;
        }

        @Override
        protected Point getInitialSize() {
            Point size = super.getInitialSize();
            size.y = Math.max(size.y, INITIAL_MIN_HEIGHT);
            return size;
        }
    }.open();
}