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:com.dnw.plugin.preference.TextFieldEditor.java

License:Open Source License

/**
 * Creates a string field editor. Use the method <code>setTextLimit</code> to limit the text.
 * //from  w w  w .j  a va  2  s  .  c  o m
 * @author manbaum
 * @since Oct 26, 2014
 * @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 height the height of the text input field in lines, 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.
 */
public TextFieldEditor(String name, String labelText, int width, int height, int strategy, Composite parent) {
    init(name, labelText);
    widthInChars = width;
    heightInLines = height;
    setValidateStrategy(strategy);
    isValid = false;
    errorMessage = JFaceResources.getString("StringFieldEditor.errorMessage");//$NON-NLS-1$
    createControl(parent);
}

From source file:com.elphel.vdt.ui.dialogs.VDTErrorDialog.java

License:Open Source License

/**
 * Creates an error dialog. Note that the dialog will have no visual
 * representation (no widgets) until it is told to open.
 * <p>/*from   ww  w .j a v  a2  s.c o m*/
 * Normally one should use <code>openError</code> to create and open one
 * of these. This constructor is useful only if the error object being
 * displayed contains child items <it>and </it> you need to specify a mask
 * which will be used to filter the displaying of these children.
 * </p>
 * 
 * @param parentShell
 *            the shell under which to create this dialog
 * @param dialogTitle
 *            the title to use for this dialog, or <code>null</code> to
 *            indicate that the default title should be used
 * @param message
 *            the message to show in this dialog, or <code>null</code> to
 *            indicate that the error's message should be shown as the
 *            primary message
 * @param status
 *            the error to show to the user
 * @param displayMask
 *            the mask to use to filter the displaying of child items, as
 *            per <code>IStatus.matches</code>
 * @see org.eclipse.core.runtime.IStatus#matches(int)
 */
public VDTErrorDialog(Shell parentShell, String dialogTitle, IStatus status, int displayMask) {
    super(parentShell);

    if (dialogTitle != null)
        this.title = dialogTitle;
    else
        this.title = JFaceResources.getString("Problem_Occurred");

    this.message = status.getMessage();
    this.status = status;
    this.displayMask = displayMask;

    setShellStyle(getShellStyle() | SWT.RESIZE);
}

From source file:com.github.jennybrown8.wicketsourceopener.preferences.SecurePreferenceStore.java

License:GNU General Public License

@Override
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
    final Object[] finalListeners = getListeners();
    // Do we need to fire an event.
    if (finalListeners.length > 0 && (oldValue == null || !oldValue.equals(newValue))) {
        final PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue);
        for (int i = 0; i < finalListeners.length; ++i) {
            final IPropertyChangeListener l = (IPropertyChangeListener) finalListeners[i];
            SafeRunnable.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
                public void run() {
                    l.propertyChange(pe);
                }//  w  w w . jav  a2s  . co  m
            });
        }
    }
}

From source file:com.github.ko2ic.plugin.eclipse.taggen.core.ui.components.JavaSelectButton.java

License:Open Source License

public JavaSelectButton(Composite parent) {
    button = new Button(parent, SWT.PUSH);
    button.setText(JFaceResources.getString("openBrowse"));
}

From source file:com.google.dart.tools.ui.internal.text.dart.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.
 *///from   www.  j  a va2  s  . c om
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = DartToolsPlugin.getActiveWorkbenchShell();
        String title = DartTextMessages.ContentAssistProcessor_all_disabled_title;
        String message = DartTextMessages.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(
                DartTextMessages.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.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);
            }

            /*
             * @see com.google.dart.tools.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;
            }
        };
        int returnValue = dialog.open();
        if (restoreId == returnValue || settingsId == returnValue) {
            if (restoreId == returnValue) {
                IPreferenceStore store = DartToolsPlugin.getDefault().getPreferenceStore();
                store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
                store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            }
            if (settingsId == returnValue) {
                PreferencesUtil.createPreferenceDialogOn(shell,
                        "com.google.dart.tools.ui.internal.preferences.CodeAssistPreferenceAdvanced", null, //$NON-NLS-1$
                        null).open();
            }
            CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
            registry.reload();
            return true;
        }
    }
    return false;
}

From source file:com.google.dart.tools.ui.omni.BasePopupDialog.java

License:Open Source License

/**
 * Create the dialog's menu for the move and resize actions.
 * // www  . j a  va2s . c  o  m
 * @param parent The parent composite.
 */
private void createDialogMenu(Composite parent) {

    toolBar = new ToolBar(parent, SWT.FLAT);
    ToolItem viewMenuButton = new ToolItem(toolBar, SWT.PUSH, 0);

    GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(toolBar);
    viewMenuButton.setImage(JFaceResources.getImage(POPUP_IMG_MENU));
    viewMenuButton.setDisabledImage(JFaceResources.getImage(POPUP_IMG_MENU_DISABLED));
    viewMenuButton.setToolTipText(JFaceResources.getString("BasePopupDialog.menuTooltip")); //$NON-NLS-1$
    viewMenuButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            showDialogMenu();
        }
    });
    // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=177183
    toolBar.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            showDialogMenu();
        }
    });
}

From source file:com.google.gdt.eclipse.designer.actions.AbstractModuleAction.java

License:Open Source License

/**
 * Shows the {@link Throwable} to user./*from   w  w w.j  ava  2  s . c om*/
 */
public static void showException(final Throwable exception) {
    // log
    DesignerPlugin.log(exception);
    // show
    {
        final Throwable rootCause = DesignerExceptionUtils.getDesignerCause(exception);
        final Status status = new Status(IStatus.ERROR, DesignerPlugin.getDefault().toString(), IStatus.ERROR,
                "Parse error or internal Designer error.", rootCause);
        ErrorDialog dialog = new ErrorDialog(DesignerPlugin.getShell(), "Exception happened",
                "Designer error occurred.\nSelect Details>> for more information.\nSee the Error Log for more information.",
                status, IStatus.ERROR) {
            private Clipboard clipboard;

            @Override
            protected org.eclipse.swt.widgets.List createDropDownList(Composite parent) {
                final org.eclipse.swt.widgets.List list = super.createDropDownList(parent);
                list.removeAll();
                // populate list using custom PrintWriter
                list.add("Plug-in Provider: Google");
                list.add("Plug-in Name: " + BrandingUtils.getBranding().getProductName());
                list.add("Plug-in ID: org.eclipse");
                //list.add("Plug-in Version: " + String.valueOf(product.getVersion()));
                list.add("");
                final PrintWriter printWriter = new PrintWriter(new Writer() {
                    @Override
                    public void write(char[] cbuf, int off, int len) throws IOException {
                        if (len != 2 && !(cbuf[0] == '\r' || cbuf[0] == '\n')) {
                            list.add(StringUtils.replace(new String(cbuf, off, len), "\t", "    "));
                        }
                    }

                    @Override
                    public void flush() throws IOException {
                    }

                    @Override
                    public void close() throws IOException {
                    }
                });
                if (rootCause != null) {
                    rootCause.printStackTrace(printWriter);
                    list.add("");
                    list.add("Full stack trace (to see full context):");
                }
                exception.printStackTrace(printWriter);
                // print config
                list.add("");
                // install own context menu
                Menu menu = list.getMenu();
                menu.dispose();
                Menu copyMenu = new Menu(list);
                MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
                copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
                copyItem.addSelectionListener(new SelectionListener() {
                    public void widgetSelected(SelectionEvent e) {
                        copyList(list);
                    }

                    public void widgetDefaultSelected(SelectionEvent e) {
                        copyList(list);
                    }
                });
                list.setMenu(copyMenu);
                return list;
            }

            private void copyList(org.eclipse.swt.widgets.List list) {
                if (clipboard != null) {
                    clipboard.dispose();
                }
                StringBuffer statusBuffer = new StringBuffer();
                for (int i = 0; i < list.getItemCount(); ++i) {
                    statusBuffer.append(list.getItem(i));
                    statusBuffer.append("\r\n");
                }
                clipboard = new Clipboard(list.getDisplay());
                clipboard.setContents(new Object[] { statusBuffer.toString() },
                        new Transfer[] { TextTransfer.getInstance() });
            }

            @Override
            public boolean close() {
                if (clipboard != null) {
                    clipboard.dispose();
                }
                return super.close();
            }
        };
        dialog.open();
    }
}

From source file:com.hangum.tadpole.commons.exception.dialog.ExceptionDetailsErrorDialog.java

License:Open Source License

/**
 * Creates an error dialog. Note that the dialog will have no visual
 * representation (no widgets) until it is told to open.
 * <p>//from ww  w  .ja  va 2s .  c  om
 * Normally one should use <code>openError</code> to create and open one
 * of these. This constructor is useful only if the error object being
 * displayed contains child items <it>and </it> you need to specify a mask
 * which will be used to filter the displaying of these children.
 * </p>
 * 
 * @param parentShell
 *            the shell under which to create this dialog
 * @param dialogTitle
 *            the title to use for this dialog, or <code>null</code> to
 *            indicate that the default title should be used
 * @param message
 *            the message to show in this dialog, or <code>null</code> to
 *            indicate that the error's message should be shown as the
 *            primary message
 * @param status
 *            the error to show to the user
 * @param displayMask
 *            the mask to use to filter the displaying of child items, as
 *            per <code>IStatus.matches</code>
 * @see org.eclipse.core.runtime.IStatus#matches(int)
 */
public ExceptionDetailsErrorDialog(Shell parentShell, String dialogTitle, String message, IStatus status,
        int displayMask) {
    super(parentShell);
    this.title = dialogTitle == null ? JFaceResources.getString("Problem_Occurred") : //$NON-NLS-1$
            dialogTitle;
    this.message = message == null ? status.getMessage()
            : JFaceResources.format("Reason", new Object[] { message, status.getMessage() }); //$NON-NLS-1$
    this.status = status;
    this.displayMask = displayMask;
    setShellStyle(getShellStyle() | SWT.RESIZE);
}

From source file:com.ivenix.debug.core.preferences.LabelFakeFieldEditor.java

License:Open Source License

/**
 * Creates a label fake field editor.//  ww  w  .  jav a2  s  .c  o  m
 * 
 * @param value
 *            the content of the label field
 * @param labelText
 *            the label text of the field editor
 * @param parent
 *            the parent of the field editor's control
 * @since 2.0
 */
public LabelFakeFieldEditor(String value, String labelText, Composite parent) {

    init("no_name", labelText);
    labelValue = value;
    errorMessage = JFaceResources.getString("StringFieldEditor.errorMessage");//$NON-NLS-1$
    createControl(parent);
}

From source file:com.ixenit.membersort.preferences.editor.ListEditor.java

License:Apache License

/**
 * Helper method to create a push button.
 *
 * @param parent//from w  w  w  . j  av  a  2s.com
 *        the parent control
 * @param key
 *        the resource name used to supply the button's label text
 * @return Button
 */
private Button _createPushButton(Composite parent, String key) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(JFaceResources.getString(key));
    button.setFont(parent.getFont());
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    button.addSelectionListener(_getSelectionListener());
    return button;
}