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

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

Introduction

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

Prototype

int CLIENT_ID

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

Click Source Link

Document

Starting button id reserved for use by clients of JFace (value 1024).

Usage

From source file:org.fusesource.ide.jvmmonitor.internal.ui.properties.mbean.InvokeDialog.java

License:Open Source License

/**
 * Validates the specified text./* w  ww  .  ja  v  a 2s .  c o  m*/
 */
void validate() {
    boolean enableButton = true;
    for (Entry<MBeanParameterInfo, Control> entry : controls.entrySet()) {
        Control control = entry.getValue();
        if (!(control instanceof Text)) {
            continue;
        }

        String type = entry.getKey().getType();
        String text = ((Text) control).getText();
        if (!validateNumber(type, text)) {
            enableButton = false;
            break;
        }
    }
    Button invokeButton = getButton(IDialogConstants.CLIENT_ID);
    if (invokeButton != null) {
        invokeButton.setEnabled(enableButton);
    }
}

From source file:org.marketcetera.photon.ui.LoginDialog.java

License:Open Source License

protected void createButtonsForButtonBar(Composite parent) {
    Button removeCurrentUser = createButton(parent, IDialogConstants.CLIENT_ID, MENU_CLEAR_LABEL.getText(),
            false);/*from w ww.  j av  a 2  s. c  o  m*/
    removeCurrentUser.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            savedDetails.remove(userIdText.getText());
            initializeUsers(""); //$NON-NLS-1$
        }
    });
    createButton(parent, IDialogConstants.OK_ID, MENU_LOGIN_LABEL.getText(), true);
    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}

From source file:org.pentaho.ui.xul.swt.tags.SwtPromptBox.java

License:Open Source License

@Override
protected void notifyListeners(Integer code) {
    XulDialogCallback.Status status = XulDialogCallback.Status.CANCEL;

    switch (code) {
    case IDialogConstants.OK_ID:
        status = XulDialogCallback.Status.ACCEPT;
        break;/*from w  w  w  .java2 s . com*/
    case IDialogConstants.CANCEL_ID:
        status = XulDialogCallback.Status.CANCEL;
        break;
    case IDialogConstants.CLIENT_ID + 1:
        status = XulDialogCallback.Status.ONEXTRA1;
        break;
    case IDialogConstants.CLIENT_ID + 2:
        status = XulDialogCallback.Status.ONEXTRA2;
        break;
    }

    for (XulDialogCallback<String> callback : callbacks) {
        callback.onClose(SwtPromptBox.this, status, dlg.getValue());
    }
}

From source file:org.python.pydev.editor.DialogNotifier.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    // create OK and Cancel buttons by default
    Button button = createButton(parent, IDialogConstants.OK_ID, " Show later ", true);
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            doClose();/*from  www  .  ja  v  a  2  s . c  o m*/
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }

    });

    button = createButton(parent, IDialogConstants.CLIENT_ID, " Read it ", true);
    button.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            doClose();
            IPreferenceStore preferenceStore = PydevPrefs.getPreferenceStore();
            preferenceStore.setValue(PydevShowBrowserMessage.PYDEV_FUNDING_SHOWN, true);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }

    });
}

From source file:org.python.pydev.shared_interactive_console.console.ui.internal.ScriptConsoleHistorySelector.java

License:Open Source License

/**
 * Selects a list of strings from a list of strings
 * /*from  w  w w. ja v a 2s.  c om*/
 * @param history the history that may be selected for execution
 * @return null if none was selected or a list of strings with the commands to be executed
 */
public static List<String> select(final ScriptConsoleHistory history) {

    //created the HistoryElementListSelectionDialog instead of using the ElementListSelectionDialog directly because:
    //1. No sorting should be enabled for choosing the history
    //2. The last element should be the one selected by default
    //3. The list should be below the commands
    //4. The up arrow should be the one used to get focus in the elements
    HistoryElementListSelectionDialog dialog = new HistoryElementListSelectionDialog(
            Display.getDefault().getActiveShell(), getLabelProvider()) {
        private static final int CLEAR_HISTORY_ID = IDialogConstants.CLIENT_ID + 1;

        @Override
        protected void createButtonsForButtonBar(Composite parent) {
            super.createButtonsForButtonBar(parent);
            createButton(parent, CLEAR_HISTORY_ID, "Clear History", false); //$NON-NLS-1$
        }

        @Override
        protected void buttonPressed(int buttonId) {
            if (buttonId == CLEAR_HISTORY_ID) {
                history.clear();

                // After deleting the history, close the dialog with a cancel return code
                cancelPressed();
            }
            super.buttonPressed(buttonId);
        }
    };

    dialog.setTitle("Command history");
    final List<String> selectFrom = history.getAsList();
    dialog.setElements(selectFrom.toArray(new String[0]));
    dialog.setEmptySelectionMessage("No command selected");
    dialog.setAllowDuplicates(true);
    dialog.setBlockOnOpen(true);
    dialog.setSize(100, 25); //in number of chars
    dialog.setMessage("Select command(s) to be executed");
    dialog.setMultipleSelection(true);

    if (dialog.open() == SelectionDialog.OK) {
        Object[] result = dialog.getResult();
        if (result != null) {
            ArrayList<String> list = new ArrayList<String>();
            for (Object o : result) {
                list.add(o.toString());
            }
            return list;
        }
    }
    return null;
}

From source file:org.rcpbook.hyperbola.ui.dialogs.LoginDialog.java

License:Open Source License

private Button createDeleteUserButton(Composite parent) {
    Button deleteUserButton = createButton(parent, IDialogConstants.CLIENT_ID, "&Delete User", false);
    deleteUserButton.addSelectionListener(new SelectionAdapter() {
        @Override//from   w ww. j a v a  2 s. co m
        public void widgetSelected(SelectionEvent e) {
            savedDetails.remove(userIdText.getText());
            initializeUsers("");
        }
    });

    return deleteUserButton;
}

From source file:org.rubypeople.rdt.internal.ui.text.ruby.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.
 * //ww w . ja  v a 2 s.  co m
 * @since 3.3
 */
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = RubyPlugin.getActiveWorkbenchShell();
        String title = RubyTextMessages.ContentAssistProcessor_all_disabled_title;
        String message = RubyTextMessages.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(
                RubyTextMessages.ContentAssistProcessor_all_disabled_preference_link,
                LegacyActionTools.removeMnemonics(restoreButtonLabel));
        final int restoreId = IDialogConstants.CLIENT_ID + 10;
        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) {
                        close();
                        PreferencesUtil.createPreferenceDialogOn(shell,
                                "org.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                                .open();
                    }
                });
                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);
            }
        };
        if (restoreId == dialog.open()) {
            IPreferenceStore store = RubyPlugin.getDefault().getPreferenceStore();
            store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
            store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
            registry.reload();
            return true;
        }
    }
    return false;
}

From source file:org.summer.sdt.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.
 *
 * @return  <code>true</code> if the default should be restored
 * @since 3.3/*from   www  .ja v  a 2 s.  c om*/
 */
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = JavaPlugin.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.summer.sdt.internal.ui.dialogs.OptionalMessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
             */
            @Override
            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() {
                    @Override
                    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)
             */
            @Override
            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 = JavaPlugin.getDefault().getPreferenceStore();
                store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
                store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            }
            if (settingsId == returnValue)
                PreferencesUtil
                        .createPreferenceDialogOn(shell,
                                "org.summer.sdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                        .open();
            fComputerRegistry.reload();
            return true;
        }
    }
    return false;
}

From source file:org.talend.designer.runtime.visualization.internal.ui.properties.cpu.actions.FindDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    findButton = createButton(parent, IDialogConstants.CLIENT_ID, Messages.findButtonLabel, true);
    findButton.addSelectionListener(new SelectionAdapter() {

        @Override/*  w ww  . j  a  va 2  s  .  c om*/
        public void widgetSelected(SelectionEvent e) {
            doFind();
        }
    });

    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, false);
}

From source file:org.talend.designer.runtime.visualization.internal.ui.properties.MBean.InvokeDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button invokeButton = createButton(parent, IDialogConstants.CLIENT_ID, Messages.invokeButtonLabel, true);
    invokeButton.addSelectionListener(new SelectionAdapter() {

        @Override/*from   w w  w .j a  va2  s .  c o m*/
        public void widgetSelected(SelectionEvent e) {
            invoke();
        }
    });

    createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CLOSE_LABEL, false);
}