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:eu.esdihumboldt.hale.ui.util.dialog.StackTraceErrorDialog.java

License:Open Source License

/**
 * @see ErrorDialog#createDropDownList(Composite)
 *//*from  w ww .ja va2 s  . co m*/
@Override
protected List createDropDownList(Composite parent) {
    _list = super.createDropDownList(parent);
    _list.removeAll();

    // replace context menu
    _list.getMenu().dispose();
    Menu copyMenu = new Menu(_list);
    MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
    copyItem.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            copyToClipboard();
        }

        @Override
        public void widgetSelected(SelectionEvent e) {
            copyToClipboard();
        }
    });
    copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
    _list.setMenu(copyMenu);

    // convert stack trace to string
    String stackTrace = stackTraceToString(_status.getException());
    if (stackTrace != null) {
        // add stack trace to list
        stackTrace = stackTrace.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
        stackTrace = stackTrace.replaceAll("\t", "    "); //$NON-NLS-1$ //$NON-NLS-2$
        String[] lines = stackTrace.split("\n"); //$NON-NLS-1$
        for (String l : lines) {
            _list.add(l);
        }
    }

    return _list;
}

From source file:eu.transkribus.swt_canvas.util.ExceptionDetailsErrorDialog.java

License:Open Source License

/**
 * Create this dialog's drop-down list component.
 * //from w w  w. ja  v  a 2s . co  m
 * @param parent
 *            the parent composite
 * @return the drop-down list component
 */
protected Text createDropDownList(Composite parent) {
    // create the list
    text = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    // fill the list
    populateList(text);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
            | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL);
    //        data.heightHint = text.getItemHeight() * LIST_ITEM_COUNT;
    data.horizontalSpan = 2;
    text.setLayoutData(data);
    text.setFont(parent.getFont());
    Menu copyMenu = new Menu(text);
    MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
    copyItem.addSelectionListener(new SelectionListener() {
        /*
         * @see SelectionListener.widgetSelected (SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            copyToClipboard();
        }

        /*
         * @see SelectionListener.widgetDefaultSelected(SelectionEvent)
         */
        public void widgetDefaultSelected(SelectionEvent e) {
            copyToClipboard();
        }
    });
    copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
    text.setMenu(copyMenu);
    listCreated = true;
    return text;
}

From source file:ext.org.eclipse.jdt.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// www .j av  a  2  s. co  m
 */
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.eclipse.jdt.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.eclipse.jdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                        .open();
            fComputerRegistry.reload();
            return true;
        }
    }
    return false;
}

From source file:fr.inria.diverse.commons.eclipse.jface.preference.TextFieldEditor.java

License:Open Source License

/**
 * Creates a string field editor.//  w w w  .  j a  v a 2  s  .  c o  m
 * Use the method <code>setTextLimit</code> to limit the text.
 * 
 * @param name the name of the preference this field editor works on
 * @param labelText the label text of the field editor
 * @param width the width of the text input field in characters,
 *  or <code>UNLIMITED</code> for no limit
 * @param strategy either <code>VALIDATE_ON_KEY_STROKE</code> to perform
 *  on the fly checking (the default), or <code>VALIDATE_ON_FOCUS_LOST</code> to
 *  perform validation only after the text has been typed in
 * @param parent the parent of the field editor's control
 * @since 2.0
 */
public TextFieldEditor(String name, String labelText, int width, int strategy, Composite parent) {
    init(name, labelText);
    widthInChars = width;
    setValidateStrategy(strategy);
    isValid = false;
    errorMessage = JFaceResources.getString("StringFieldEditor.errorMessage");//$NON-NLS-1$
    createControl(parent);
}

From source file:gov.nasa.ensemble.common.ui.preferences.DirectoryFieldEditor.java

License:Open Source License

/**
  * Creates a directory field editor./*from   ww  w  .j a  v a  2s .  co 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 DirectoryFieldEditor(String name, String labelText, Composite parent) {
    init(name, labelText, parent);
    setErrorMessage(JFaceResources.getString("DirectoryFieldEditor.errorMessage"));//$NON-NLS-1$
    setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
    setValidateStrategy(VALIDATE_ON_FOCUS_LOST);
    createControl(parent);
}

From source file:gov.nasa.ensemble.common.ui.preferences.FileFieldEditor.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 parent the parent of the field editor's control
 */
public FileFieldEditor(String name, String labelText, boolean enforceAbsolute, Composite parent) {
    init(name, labelText, parent);
    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:gov.nasa.ensemble.common.ui.preferences.FileFieldEditor.java

License:Open Source License

@Override
protected boolean checkState() {

    String msg = null;/*from  ww  w  .  j ava 2  s .c  o m*/

    String path = getTextControl().getText();
    if (path != null) {
        path = path.trim();
    } else {
        path = "";//$NON-NLS-1$
    }
    if (path.length() == 0) {
        if (!isEmptyStringAllowed()) {
            msg = getErrorMessage();
        }
    } else {
        File file = new File(path);
        if (file.isFile()) {
            if (enforceAbsolute && !file.isAbsolute()) {
                msg = JFaceResources.getString("FileFieldEditor.errorMessage2");//$NON-NLS-1$
            }
        } else if (style == SWT.OPEN) {
            msg = getErrorMessage();
        } else if (file.exists() && !file.canWrite()) {
            msg = "Do not have the necessary permissions to write to this file, may be in use";
        }
    }

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

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

From source file:gov.nasa.ensemble.common.ui.preferences.LongFieldEditor.java

License:Open Source License

/**
 * Creates an long field editor./*  ww  w . j  a  v  a  2s. 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
 * @param textLimit the maximum number of characters in the text.
 */
public LongFieldEditor(String name, String labelText, Composite parent, int textLimit) {
    init(name, labelText);
    setTextLimit(textLimit);
    setEmptyStringAllowed(false);
    setErrorMessage(JFaceResources.getString("LongFieldEditor.errorMessage"));//$NON-NLS-1$
    createControl(parent);
}

From source file:gov.nasa.ensemble.common.ui.preferences.ProjectFieldEditor.java

License:Open Source License

/**
 * Creates a project field editor./*from  ww  w  . j  a va 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 ProjectFieldEditor(String name, String labelText, Composite parent) {
    init(name, labelText);
    setErrorMessage(JFaceResources.getString("ProjectFieldEditor.errorMessage"));//$NON-NLS-1$
    setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
    setValidateStrategy(VALIDATE_ON_KEY_STROKE);
    createControl(parent);
}

From source file:gov.nasa.ensemble.common.ui.preferences.time.ISO8601FieldEditor.java

License:Open Source License

/**
 * Creates an iso8601-format date/time field editor.
 * /*from w  ww  .ja v a2 s.co 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 ISO8601FieldEditor(String name, String labelText, Composite parent, int textLimit) {
    init(name, labelText);
    setEmptyStringAllowed(false);
    setErrorMessage(JFaceResources.getString("Use 2006-01-02T03:04:05 syntax."));
    createControl(parent);
}