Example usage for org.eclipse.jface.resource JFaceResources getString

List of usage examples for org.eclipse.jface.resource JFaceResources getString

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getString.

Prototype

public static String getString(String key) 

Source Link

Document

Returns the resource object with the given key in JFace's resource bundle.

Usage

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
 *///from   w  ww. j a  v a  2 s .  c o  m
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;
}

From source file:org.eclipse.wst.sse.ui.internal.preferences.ui.TranslucencyPreferenceTab.java

License:Open Source License

public Control createContents(Composite tabFolder) {
    Composite composite = new Composite(tabFolder, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;//from w w  w.j  a  v  a 2  s . co m
    composite.setLayout(layout);

    String text = SSEUIMessages.TranslucencyPreferenceTab_1; //$NON-NLS-1$
    fTranslucencyScale = new IntegerFieldEditor(EditorPreferenceNames.READ_ONLY_FOREGROUND_SCALE, text,
            composite);

    fTranslucencyScale.setErrorMessage(JFaceResources.getString("StringFieldEditor.errorMessage"));//$NON-NLS-1$
    fTranslucencyScale.setPreferenceStore(getPreferenceStore());
    fTranslucencyScale.setPreferencePage(getMainPreferencePage());
    fTranslucencyScale.setTextLimit(Integer.toString(MAX_PERCENTAGE).length());
    fTranslucencyScale.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    fTranslucencyScale.setValidRange(0, MAX_PERCENTAGE);
    fTranslucencyScale.load();
    fTranslucencyScale.setPropertyChangeListener(validityChangeListener);

    //      PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PREFWEBX_READONLY_HELPID);
    return composite;
}

From source file:org.eclipse.wst.validation.ui.internal.dialog.FilterDialog.java

License:Open Source License

private void addButtons(Composite c) {
    Composite buttons = new Composite(c, SWT.TOP);
    GridData gd = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
    buttons.setLayoutData(gd);/*  ww w  .  j av  a 2  s .c o  m*/
    buttons.setLayout(new GridLayout(1, true));
    _addGroupInclude = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
    _addGroupInclude.setText(ValUIMessages.ButtonAddGroupInclude);
    _addGroupInclude.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    _addGroupInclude.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            addGroup(false);
        }

        public void widgetSelected(SelectionEvent e) {
            addGroup(false);
        }

    });

    _addGroupExclude = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
    _addGroupExclude.setText(ValUIMessages.ButtonAddGroupExclude);
    _addGroupExclude.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    _addGroupExclude.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            addGroup(true);
        }

        public void widgetSelected(SelectionEvent e) {
            addGroup(true);
        }

    });

    _addRule = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
    _addRule.setText(ValUIMessages.ButtonAddRule);
    _addRule.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    _addRule.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            doIt();
        }

        public void widgetSelected(SelectionEvent e) {
            doIt();
        }

        private void doIt() {
            NewFilterRule nfr = new NewFilterRule(_project);
            WizardDialog wd = new WizardDialog(_shell, nfr);
            wd.setBlockOnOpen(true);
            int rc = wd.open();
            if (rc == WizardDialog.CANCEL)
                return;

            FilterRule rule = nfr.getRule();
            if (rule != null) {
                FilterGroup newGroup = FilterGroup.addRule(_selectedGroup, rule);
                _validator.replaceFilterGroup(_selectedGroup, newGroup);
                _selectedGroup = newGroup;
                refresh();
            }
        }

    });

    _remove = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
    _remove.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    _remove.setText(ValUIMessages.ButtonRemove);
    _remove.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            remove();
        }

        public void widgetSelected(SelectionEvent e) {
            remove();
        }
    });

    Button restore = new Button(buttons, SWT.PUSH | SWT.FILL | SWT.CENTER);
    restore.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    String defaults = JFaceResources.getString("defaults"); //$NON-NLS-1$
    restore.setText(defaults);
    restore.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
            restoreDefaults();
        }

        public void widgetSelected(SelectionEvent e) {
            restoreDefaults();
        }
    });
}

From source file:org.eclipselab.eclipsesync.ui.storage.FileStoragePrefOptions.java

License:Open Source License

public void createOptions(final Composite control, ISyncStorage storage, IPreferenceStore prefStore) {
    store = prefStore;//w  w w  .ja va  2s  .c  o m
    GridLayout layout = new GridLayout();
    layout.horizontalSpacing = 8;
    layout.numColumns = 3;
    control.setLayout(layout);
    Label directoryLabel = new Label(control, SWT.NONE);
    directoryLabel.setText(Messages.PreferencePage_ChooseDirectory);
    directoryLabel.setData(STATE, Boolean.TRUE);
    GridData griddata = new GridData(GridData.FILL_HORIZONTAL);
    directoryText = new Text(control, SWT.BORDER);
    directoryText.setLayoutData(griddata);
    directoryText.setData(STATE, Boolean.TRUE);
    fileStoragePath = prefStore.getString(PreferenceConstants.FileStoragePath);
    directoryText.setText(fileStoragePath);
    if (!fileStoragePath.equals("")) { //$NON-NLS-1$
        ((FileStorage) storage).setStorageLocation(new File(fileStoragePath));
    }
    Button directoryChoose = new Button(control, SWT.PUSH);
    directoryChoose.setData(STATE, Boolean.TRUE);
    directoryChoose.setText(JFaceResources.getString("openBrowse")); //$NON-NLS-1$
    directoryChoose.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            DirectoryDialog directoryDialog = new DirectoryDialog(control.getShell());
            if (!fileStoragePath.equals("")) //$NON-NLS-1$
                directoryDialog.setFilterPath(fileStoragePath);
            String userChosen = directoryDialog.open();
            if (userChosen != null) {
                directoryText.setText(userChosen);
            }
        }
    });
}

From source file:org.eclipselabs.jar2uml.ui.FilesFieldEditor.java

License:Open Source License

/**
 * Creates a file field editor.// w w w  .  j  a  v  a2s. com
 * 
 * @param name the name of the preference this field editor works on
 * @param labelText the label text of the field editor
 * @param enforceAbsolute <code>true</code> if the file path
 *  must be absolute, and <code>false</code> otherwise
 * @param parent the parent of the field editor's control
 */
public FilesFieldEditor(String name, String labelText, boolean enforceAbsolute, Composite parent) {
    init(name, labelText);
    this.enforceAbsolute = enforceAbsolute;
    setErrorMessage(JFaceResources.getString("FileFieldEditor.errorMessage"));//$NON-NLS-1$
    setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
    setValidateStrategy(VALIDATE_ON_FOCUS_LOST);
    createControl(parent);
}

From source file:org.eclipselabs.jar2uml.ui.FilesFieldEditor.java

License:Open Source License

protected boolean checkState() {

    String msg = null;//from ww w. j ava2  s .  c  om

    String path = getTextControl().getText();
    if (path != null) {
        path = path.trim();
    } else {
        path = "";//$NON-NLS-1$
    }
    if (path.length() == 0) {
        if (!isEmptyStringAllowed()) {
            msg = getErrorMessage();
        }
    } else {
        StringTokenizer files = new StringTokenizer(path, ";");
        while (files.hasMoreTokens()) {
            File file = new File(files.nextToken());
            if (file.isFile()) {
                if (enforceAbsolute && !file.isAbsolute()) {
                    msg = JFaceResources.getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$
                }
            } else {
                msg = getErrorMessage();
            }
        }
    }

    if (msg != null) { // error
        showErrorMessage(msg);
        return false;
    }

    // OK!
    clearErrorMessage();
    return true;
}

From source file:org.erlide.ui.prefs.OtpDirectoryFieldEditor.java

License:Open Source License

public OtpDirectoryFieldEditor(final String name, final String label, final Composite parent) {
    init(name, label);//  www .ja v a2s.  c  o m
    setErrorMessage("\"Erlang Home\" location isn't an Erlang root directory");
    setChangeButtonText(JFaceResources.getString("openBrowse")); //$NON-NLS-1$
    setValidateStrategy(VALIDATE_ON_KEY_STROKE);
    // setValidateStrategy(VALIDATE_ON_FOCUS_LOST);
    createControl(parent);
}

From source file:org.evolizer.changedistiller.preferences.DoubleFieldEditor.java

License:Apache License

/**
 * Creates a double field editor.//  w ww  . j  av  a  2s  .c om
 * 
 * @param name
 *            the name of the preference this field editor works on
 * @param labelText
 *            the label text of the field editor
 * @param parent
 *            the parent of the field editor's control
 * @param textLimit
 *            the maximum number of characters in the text.
 */
public DoubleFieldEditor(String name, String labelText, Composite parent, int textLimit) {
    init(name, labelText);
    setTextLimit(textLimit);
    setEmptyStringAllowed(false);
    setErrorMessage(JFaceResources.getString("IntegerFieldEditor.errorMessage")); //$NON-NLS-1$
    createControl(parent);
}

From source file:org.globaltester.preferences.ValidateDirectoryFieldEditor.java

License:Open Source License

/**
 * Creates a directory field editor./*w  w w  . java  2 s. c  o  m*/
 * 
 * @param name the name of the preference this field editor works on
 * @param labelText the label text of the field editor
 * @param parent the parent of the field editor's control
 */
public ValidateDirectoryFieldEditor(String name, String labelText, Composite parent) {
    init(name, labelText);
    setErrorMessage(JFaceResources.getString("Use a valid directory!"));//$NON-NLS-1$
    setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
    setValidateStrategy(VALIDATE_ON_KEY_STROKE);
    createControl(parent);
}

From source file:org.globaltester.preferences.ValidateFileFieldEditor.java

License:Open Source License

/**
 * Creates a file field editor./* www . j  av a 2  s.c  o m*/
 * 
 * @param name the name of the preference this field editor works on
 * @param labelText the label text of the field editor
 * @param enforceAbsolute <code>true</code> if the file path
 *  must be absolute, and <code>false</code> otherwise
 * @param validationStrategy either {@link StringButtonFieldEditor#VALIDATE_ON_KEY_STROKE}
 *  to perform on the fly checking, or {@link StringButtonFieldEditor#VALIDATE_ON_FOCUS_LOST}
 *  (the default) to perform validation only after the text has been typed in
 * @param parent the parent of the field editor's control.
 * @since 3.4
 * @see StringButtonFieldEditor#VALIDATE_ON_KEY_STROKE
 * @see StringButtonFieldEditor#VALIDATE_ON_FOCUS_LOST
 */
public ValidateFileFieldEditor(String name, String labelText, boolean enforceAbsolute, int validationStrategy,
        Composite parent) {
    init(name, labelText);
    this.enforceAbsolute = enforceAbsolute;
    setErrorMessage("Use a valid file!");//$NON-NLS-1$
    setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
    setValidateStrategy(validationStrategy);
    createControl(parent);
}