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

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

Introduction

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

Prototype

int CLOSE_ID

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

Click Source Link

Document

Button id for a "Close" button (value 12).

Usage

From source file:org.eclipse.sirius.common.ui.tools.api.dialog.SiriusMessageDialogWithToggle.java

License:Open Source License

/**
 * Attempt to find a standard JFace button id that matches the specified
 * button label. If no match can be found, use the default id provided.
 * /*  ww  w . j a  va  2s  .com*/
 * Overridden to investigate the provided buttons.
 * 
 * @param buttonLabel
 *            the button label whose id is sought
 * @param defaultId
 *            the id to use for the button if there is no standard id
 * @return the id for the specified button label
 */
// CHECKSTYLE:OFF
private int mapButtonLabelToButtonID(String buttonLabel, int defaultId) {
    // CHECKSTYLE:OON
    // Not pretty but does the job...
    if (IDialogConstants.OK_LABEL.equals(buttonLabel)) {
        return IDialogConstants.OK_ID;
    }

    if (IDialogConstants.YES_LABEL.equals(buttonLabel)) {
        return IDialogConstants.YES_ID;
    }

    if (IDialogConstants.NO_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NO_ID;
    }

    if (IDialogConstants.CANCEL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.CANCEL_ID;
    }

    if (IDialogConstants.YES_TO_ALL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.YES_TO_ALL_ID;
    }

    if (IDialogConstants.SKIP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.SKIP_ID;
    }

    if (IDialogConstants.STOP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.STOP_ID;
    }

    if (IDialogConstants.ABORT_LABEL.equals(buttonLabel)) {
        return IDialogConstants.ABORT_ID;
    }

    if (IDialogConstants.RETRY_LABEL.equals(buttonLabel)) {
        return IDialogConstants.RETRY_ID;
    }

    if (IDialogConstants.IGNORE_LABEL.equals(buttonLabel)) {
        return IDialogConstants.IGNORE_ID;
    }

    if (IDialogConstants.PROCEED_LABEL.equals(buttonLabel)) {
        return IDialogConstants.PROCEED_ID;
    }

    if (IDialogConstants.OPEN_LABEL.equals(buttonLabel)) {
        return IDialogConstants.OPEN_ID;
    }

    if (IDialogConstants.CLOSE_LABEL.equals(buttonLabel)) {
        return IDialogConstants.CLOSE_ID;
    }

    if (IDialogConstants.BACK_LABEL.equals(buttonLabel)) {
        return IDialogConstants.BACK_ID;
    }

    if (IDialogConstants.NEXT_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NEXT_ID;
    }

    if (IDialogConstants.FINISH_LABEL.equals(buttonLabel)) {
        return IDialogConstants.FINISH_ID;
    }

    if (IDialogConstants.HELP_LABEL.equals(buttonLabel)) {
        return IDialogConstants.HELP_ID;
    }

    if (IDialogConstants.NO_TO_ALL_LABEL.equals(buttonLabel)) {
        return IDialogConstants.NO_TO_ALL_ID;
    }

    if (IDialogConstants.SHOW_DETAILS_LABEL.equals(buttonLabel)) {
        return IDialogConstants.DETAILS_ID;
    }

    if (IDialogConstants.HIDE_DETAILS_LABEL.equals(buttonLabel)) {
        return IDialogConstants.DETAILS_ID;
    }

    for (String providedButton : buttonsMap.keySet()) {
        if (providedButton.equals(buttonLabel)) {
            return buttonsMap.get(providedButton);
        }
    }

    // No XXX_LABEL in IDialogConstants for these. Unlikely
    // they would be used in a message dialog though.
    // public int SELECT_ALL_ID = 18;
    // public int DESELECT_ALL_ID = 19;
    // public int SELECT_TYPES_ID = 20;

    return defaultId;
}

From source file:org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog.java

License:Open Source License

@Override
protected void buttonPressed(int buttonId) {
    switch (buttonId) {
    case SEARCH_ID:
        searchButtonPressed();/*  w  w w .  ja  va 2  s .c om*/
        break;
    case IDialogConstants.CLOSE_ID:
        closePressed();
        break;
    default:
        super.buttonPressed(buttonId);
    }
}

From source file:org.eclipse.tcf.te.ui.search.TreeViewerSearchDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, SEARCH_ID, Messages.TreeViewerSearchDialog_BtnSearchText, true);
    createButton(parent, IDialogConstants.CLOSE_ID, Messages.TreeViewerSearchDialog_BtnCloseText, false);
    fSearchable.restoreValues(getDialogSettings());
    updateButtonState();// www .  jav  a  2  s. co  m
}

From source file:org.eclipse.ui.internal.about.InstallationDialog.java

License:Open Source License

private void tabSelected(TabItem item) {
    if (item.getData() instanceof IConfigurationElement) {
        final IConfigurationElement element = (IConfigurationElement) item.getData();

        Composite pageComposite = (Composite) item.getControl();
        try {//from  w ww. j a  va 2 s. c  o  m
            final InstallationPage page = (InstallationPage) element
                    .createExecutableExtension(IWorkbenchRegistryConstants.ATT_CLASS);
            page.createControl(pageComposite);
            // new controls created since the dialog font was applied, so
            // apply again.
            Dialog.applyDialogFont(pageComposite);
            page.setPageContainer(this);
            // Must be done before creating the buttons because the control
            // button creation methods
            // use this map.
            pageToId.put(page, element.getAttribute(IWorkbenchRegistryConstants.ATT_ID));
            createButtons(page);
            item.setData(page);
            item.addDisposeListener(new DisposeListener() {

                public void widgetDisposed(DisposeEvent e) {
                    page.dispose();
                }
            });
            pageComposite.layout(true, true);

        } catch (CoreException e1) {
            Label label = new Label(pageComposite, SWT.NONE);
            label.setText(e1.getMessage());
            item.setData(null);
        }

    }
    String id = (String) item.getData(ID);
    rememberSelectedTab(id);
    buttonManager.update(id);
    Button button = createButton(buttonManager.getParent(), IDialogConstants.CLOSE_ID,
            IDialogConstants.CLOSE_LABEL, true);
    GridData gd = (GridData) button.getLayoutData();
    gd.horizontalAlignment = SWT.BEGINNING;
    gd.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH) / 2;
    // Layout the button bar's parent and all of its children.  We must
    // cascade through all children because the buttons have changed and
    // because tray dialog inserts an extra composite in the button bar
    // hierarchy.
    getButtonBar().getParent().layout(true, true);

}

From source file:org.eclipse.ui.internal.about.InstallationDialog.java

License:Open Source License

protected void buttonPressed(int buttonId) {
    if (IDialogConstants.CLOSE_ID == buttonId) {
        okPressed();
    }
}

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

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    parent.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Button button = createButton(parent, BROWSE_ERROR_LOG_BUTTON,
            WorkbenchMessages.AboutSystemDialog_browseErrorLogName, false);
    String filename = Platform.getLogFileLocation().toOSString();
    button.setEnabled(new File(filename).exists());

    createButton(parent, COPY_TO_CLIPBOARD_BUTTON, WorkbenchMessages.AboutSystemDialog_copyToClipboardName,
            false);//from  www .  ja va 2 s.  c  om

    new Label(parent, SWT.NONE).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout layout = (GridLayout) parent.getLayout();
    layout.numColumns++;
    layout.makeColumnsEqualWidth = false;

    createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
}

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

License:Open Source License

protected void buttonPressed(int buttonId) {
    switch (buttonId) {
    case IDialogConstants.CLOSE_ID:
        close();//from w w  w. j a  v a 2s  .co  m
        break;
    case BROWSE_ERROR_LOG_BUTTON:
        openErrorLogBrowser();
        break;
    case COPY_TO_CLIPBOARD_BUTTON:
        runCopyToClipboard();
        break;
    }
    super.buttonPressed(buttonId);
}

From source file:org.eclipse.wb.internal.core.editor.actions.errors.ErrorsDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, CONTACT_SUPPORT_ID, Messages.ErrorsDialog_supportButton, false);
    createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true);
}

From source file:org.eclipse.wst.jsdt.internal.ui.text.java.ContentAssistProcessor.java

License:Open Source License

/**
 * Informs the user about the fact that there are no enabled categories in the default content
 * assist set and shows a link to the preferences.
 * // w w  w . ja v  a 2s  .co m
 * 
 */
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = JavaScriptPlugin.getActiveWorkbenchShell();
        String title = JavaTextMessages.ContentAssistProcessor_all_disabled_title;
        String message = JavaTextMessages.ContentAssistProcessor_all_disabled_message;
        // see PreferencePage#createControl for the 'defaults' label
        final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
        final String linkMessage = Messages.format(
                JavaTextMessages.ContentAssistProcessor_all_disabled_preference_link,
                LegacyActionTools.removeMnemonics(restoreButtonLabel));
        final int restoreId = IDialogConstants.CLIENT_ID + 10;
        final int settingsId = IDialogConstants.CLIENT_ID + 11;
        final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY,
                shell, title, null /* default image */, message, MessageDialog.WARNING,
                new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
            /*
             * @see org.eclipse.wst.jsdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            protected Control createCustomArea(Composite composite) {
                // wrap link and checkbox in one composite without space
                Composite parent = new Composite(composite, SWT.NONE);
                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                parent.setLayout(layout);

                Composite linkComposite = new Composite(parent, SWT.NONE);
                layout = new GridLayout();
                layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
                layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
                linkComposite.setLayout(layout);

                Link link = new Link(linkComposite, SWT.NONE);
                link.setText(linkMessage);
                link.addSelectionListener(new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent e) {
                        setReturnCode(settingsId);
                        close();
                    }
                });
                GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
                gridData.widthHint = this.getMinimumMessageWidth();
                link.setLayoutData(gridData);

                // create checkbox and "don't show this message" prompt
                super.createCustomArea(parent);

                return parent;
            }

            /*
             * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
             */
            protected void createButtonsForButtonBar(Composite parent) {
                Button[] buttons = new Button[2];
                buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
                buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL,
                        true);
                setButtons(buttons);
            }
        };
        int returnValue = dialog.open();
        if (restoreId == returnValue || settingsId == returnValue) {
            if (restoreId == returnValue) {
                IPreferenceStore store = JavaScriptPlugin.getDefault().getPreferenceStore();
                store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
                store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            }
            if (settingsId == returnValue)
                PreferencesUtil
                        .createPreferenceDialogOn(shell,
                                "org.eclipse.wst.jsdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                        .open();
            CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
            registry.reload();
            return true;
        }
    }
    return false;
}

From source file:org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.java

License:Open Source License

/**
 * <p>Informs the user about the fact that there are no enabled categories in the default content
 * assist set and shows a link to the preferences.</p>
 *
 * @return  <code>true</code> if the default should be restored
 *///  w w  w .  ja  v  a  2s  . com
private boolean informUserAboutEmptyDefaultCategory() {
    /*If warn about empty default category and there are associated properties for this
     * processors content type and those properties have an associated properties page then
     * display warning message to user.
     */
    ICompletionProposalCategoriesConfigurationReader properties = CompletionProposoalCatigoriesConfigurationRegistry
            .getDefault().getReadableConfiguration(this.fContentTypeID);
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)
            && properties instanceof ICompletionProposalCategoriesConfigurationWriter
            && ((ICompletionProposalCategoriesConfigurationWriter) properties).hasAssociatedPropertiesPage()) {

        ICompletionProposalCategoriesConfigurationWriter propertiesExtension = (ICompletionProposalCategoriesConfigurationWriter) properties;

        final Shell shell = SSEUIPlugin.getActiveWorkbenchShell();
        String title = SSEUIMessages.ContentAssist_all_disabled_title;
        String message = SSEUIMessages.ContentAssist_all_disabled_message;
        // see PreferencePage#createControl for the 'defaults' label
        final String restoreButtonLabel = JFaceResources.getString("defaults"); //$NON-NLS-1$
        final String linkMessage = NLS.bind(SSEUIMessages.ContentAssist_all_disabled_preference_link,
                LegacyActionTools.removeMnemonics(restoreButtonLabel));
        final int restoreId = IDialogConstants.CLIENT_ID + 10;
        final int settingsId = IDialogConstants.CLIENT_ID + 11;
        final OptionalMessageDialog dialog = new OptionalMessageDialog(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY,
                shell, title, null /* default image */, message, MessageDialog.WARNING,
                new String[] { restoreButtonLabel, IDialogConstants.CLOSE_LABEL }, 1) {
            /*
             * @see org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            protected Control createCustomArea(Composite composite) {
                // wrap link and checkbox in one composite without space
                Composite parent = new Composite(composite, SWT.NONE);
                GridLayout layout = new GridLayout();
                layout.marginHeight = 0;
                layout.marginWidth = 0;
                layout.verticalSpacing = 0;
                parent.setLayout(layout);

                Composite linkComposite = new Composite(parent, SWT.NONE);
                layout = new GridLayout();
                layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
                layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
                linkComposite.setLayout(layout);

                Link link = new Link(linkComposite, SWT.NONE);
                link.setText(linkMessage);
                link.addSelectionListener(new SelectionAdapter() {
                    public void widgetSelected(SelectionEvent e) {
                        setReturnCode(settingsId);
                        close();
                    }
                });
                GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
                gridData.widthHint = this.getMinimumMessageWidth();
                link.setLayoutData(gridData);

                // create checkbox and "don't show this message" prompt
                super.createCustomArea(parent);

                return parent;
            }

            /*
             * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
             */
            protected void createButtonsForButtonBar(Composite parent) {
                Button[] buttons = new Button[2];
                buttons[0] = createButton(parent, restoreId, restoreButtonLabel, false);
                buttons[1] = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL,
                        true);
                setButtons(buttons);
            }
        };
        int returnValue = dialog.open();

        //based on user actions either reset defaults or open preference dialog
        if (restoreId == returnValue || settingsId == returnValue) {
            if (restoreId == returnValue) {
                propertiesExtension.loadDefaults();
                propertiesExtension.saveConfiguration();
            }
            if (settingsId == returnValue) {
                PreferencesUtil
                        .createPreferenceDialogOn(shell, propertiesExtension.getPropertiesPageID(), null, null)
                        .open();
            }

            return true;
        }
    }
    return false;
}