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.ebayopensource.turmeric.eclipse.utils.ui.SOAErrorDialog.java

License:Open Source License

/**
 * create the details list.//from  w  ww  .  java  2s.  c o  m
 *
 * @param parent the parent
 * @return the list
 */
protected List createDetailsList(Composite parent) {
    // create the list
    messageList = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    // fill the list
    fillList(messageList, status, 0);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
            | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL);
    data.heightHint = messageList.getItemHeight() * RESERVE_LIST_ITEM_COUNT;
    data.horizontalSpan = 2;
    messageList.setLayoutData(data);
    messageList.setFont(parent.getFont());
    Menu copyMenu = new Menu(messageList);
    MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
    copyItem.addSelectionListener(new SelectionListener() {
        /*
         * @see SelectionListener.widgetSelected (SelectionEvent)
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
            copyDetailsToClipboard();
        }

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

From source file:org.eclipse.ajdt.internal.ui.ajde.AJDTErrorDialog.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>/*  w ww . ja  v  a 2  s .com*/
 * 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 AJDTErrorDialog(Shell parentShell, String dialogTitle, String shortMessage, String longMessage) {
    super(parentShell);
    this.title = dialogTitle == null ? JFaceResources.getString("Problem_Occurred") : //$NON-NLS-1$
            dialogTitle;
    this.message = shortMessage;
    this.longMessage = longMessage;
    setShellStyle(getShellStyle() | SWT.RESIZE);
}

From source file:org.eclipse.ajdt.internal.ui.ajde.AJDTErrorDialog.java

License:Open Source License

/**
 * Create this dialog's drop-down list component.
 * /*from w  ww  .  j  a v a  2s. c om*/
 * @param parent
 *            the parent composite
 * @return the drop-down list component
 */
protected Text createDropDownList(Composite parent) {
    // create the list
    list = new Text(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    list.setEditable(false);
    // fill the list
    populateList(list);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
            | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL);
    data.heightHint = list.getLineHeight() * LIST_ITEM_COUNT;
    data.horizontalSpan = 2;
    list.setLayoutData(data);
    list.setFont(parent.getFont());
    Menu copyMenu = new Menu(list);
    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$
    list.setMenu(copyMenu);
    listCreated = true;
    return list;
}

From source file:org.eclipse.ant.internal.ui.preferences.URLFieldEditor.java

License:Open Source License

public URLFieldEditor(String name, String labelText, Composite parent) {
    super(name, labelText, parent);
    setEmptyStringAllowed(false);//from w w w  . j  a  v  a  2s  .co m
    setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
    setErrorMessage(AntPreferencesMessages.URLFieldEditor_0);
}

From source file:org.eclipse.birt.report.designer.internal.ui.swt.custom.ColorSelector.java

License:Open Source License

/**
 * Create a new instance of the reciever and the button that it wrappers in
 * the supplied parent <code>Composite</code>.
 * /*w  ww  . ja  v a  2 s  . c om*/
 * @param parent
 *            The parent of the button.
 */
public ColorSelector(Composite parent) {
    fButton = new Button(parent, SWT.PUSH);
    fExtent = computeImageSize(parent);
    fImage = new Image(parent.getDisplay(), fExtent.x, fExtent.y);
    GC gc = new GC(fImage);
    gc.setBackground(fButton.getBackground());
    gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
    gc.dispose();
    fButton.setImage(fImage);
    fButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            open();
        }
    });
    fButton.addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent event) {
            if (fImage != null) {
                fImage.dispose();
                fImage = null;
            }
            if (fColor != null) {
                fColor.dispose();
                fColor = null;
            }
        }
    });
    fButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {

        /*
        * (non-Javadoc)
        * 
        * @see
        * org.eclipse.swt.accessibility.AccessibleAdapter#getName
        * (org.eclipse.swt.accessibility.AccessibleEvent)
        */
        public void getName(AccessibleEvent e) {
            e.result = JFaceResources.getString("ColorSelector.Name"); //$NON-NLS-1$
        }
    });
}

From source file:org.eclipse.birt.report.designer.ui.preferences.PreferenceWrapper.java

License:Open Source License

public void firePreferenceChangeEvent(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 PreferenceChangeEvent pe = new PreferenceChangeEvent(this, name, oldValue, newValue);
        for (int i = 0; i < finalListeners.length; ++i) {
            final IPreferenceChangeListener l = (IPreferenceChangeListener) finalListeners[i];
            SafeRunnable.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$

                public void run() {
                    l.preferenceChange(pe);
                }/*from  ww w .  j  a  v a 2 s .  co m*/
            });
        }
    }
}

From source file:org.eclipse.buckminster.jnlp.p2.ui.UiUtils.java

License:Open Source License

public static Button createPushButton(Composite parent, String key, SelectionListener listener) {
    Button button = new Button(parent, SWT.PUSH);
    if (key != null)
        button.setText(JFaceResources.getString(key));
    button.setFont(parent.getFont());// www.  j a v  a  2  s. com
    if (listener != null)
        button.addSelectionListener(listener);
    return button;
}

From source file:org.eclipse.buckminster.ui.UiUtils.java

License:Open Source License

public static Button createCheckButton(Composite parent, String key, boolean readOnly,
        SelectionListener listener) {/*from  ww w . j  a v  a2s  . c  o  m*/
    final Button button = new Button(parent, SWT.CHECK);
    if (key != null)
        button.setText(JFaceResources.getString(key));
    button.setFont(parent.getFont());
    if (listener != null)
        button.addSelectionListener(listener);

    if (readOnly)
        button.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                button.setSelection(!button.getSelection());
            }
        });
    return button;

}

From source file:org.eclipse.cdt.internal.ui.text.contentassist.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 w  w w.j  a va 2 s.  com
private boolean informUserAboutEmptyDefaultCategory() {
    if (OptionalMessageDialog.isDialogEnabled(PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY)) {
        final Shell shell = CUIPlugin.getActiveWorkbenchShell();
        String title = ContentAssistMessages.ContentAssistProcessor_all_disabled_title;
        String message = ContentAssistMessages.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(
                ContentAssistMessages.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.cdt.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 = CUIPlugin.getDefault().getPreferenceStore();
                store.setToDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER);
                store.setToDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
            }
            if (settingsId == returnValue)
                PreferencesUtil
                        .createPreferenceDialogOn(shell,
                                "org.eclipse.cdt.ui.preferences.CodeAssistPreferenceAdvanced", null, null) //$NON-NLS-1$
                        .open();
            CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
            registry.reload();
            return true;
        }
    }
    return false;
}

From source file:org.eclipse.cdt.managedbuilder.pkgconfig.preferences.LibDirFieldEditor.java

License:Open Source License

/**
 * Creates a lib dir editor./*from  w w  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 LibDirFieldEditor(String name, String labelText, Composite parent) {
    init(name, labelText);
    setErrorMessage(JFaceResources.getString("DirectoryFieldEditor.errorMessage"));//$NON-NLS-1$
    setChangeButtonText(JFaceResources.getString("openBrowse"));//$NON-NLS-1$
    setValidateStrategy(VALIDATE_ON_FOCUS_LOST);
    createControl(parent);
}