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.jboss.tools.common.model.ui.dialog.MessageAndCheckboxDialog.java

License:Open Source License

static String[] createButtonLabels(Properties p) {
    String[] buttons = (String[]) p.get(BUTTONS);
    if (buttons == null)
        return new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL };
    String[] bs = new String[buttons.length];
    for (int i = 0; i < bs.length; i++) {
        bs[i] = JFaceResources.getString(buttons[i]);
        if (bs[i] == null)
            bs[i] = buttons[i];// w ww  . jav  a  2s.  co  m
    }
    return bs;
}

From source file:org.jboss.tools.forge.ui.internal.ext.dialog.ForgeProgressMonitorPart.java

License:Open Source License

/**
 * Creates the progress monitor's UI parts and layouts them according to the
 * given layout. If the layout is <code>null</code> the part's default
 * layout is used./*from  w  w w.j  av  a2s  .c o m*/
 * 
 * @param layout
 *            The layout for the receiver.
 * @param progressIndicatorHeight
 *            The suggested height of the indicator
 */
@Override
protected void initialize(Layout layout, int progressIndicatorHeight) {
    if (layout == null) {
        GridLayout l = new GridLayout();
        l.marginWidth = 0;
        l.marginHeight = 0;
        layout = l;
    }
    int numColumns = 2;
    setLayout(layout);

    if (layout instanceof GridLayout)
        ((GridLayout) layout).numColumns = numColumns;

    fLabel = new Label(this, SWT.LEFT);
    fLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 1));

    if (progressIndicatorHeight == SWT.DEFAULT) {
        GC gc = new GC(fLabel);
        FontMetrics fm = gc.getFontMetrics();
        gc.dispose();
        progressIndicatorHeight = fm.getHeight();
    }

    fProgressIndicator = new ProgressIndicator(this);
    GridData gd = new GridData();
    gd.horizontalAlignment = GridData.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = false;
    gd.verticalAlignment = GridData.CENTER;
    gd.heightHint = progressIndicatorHeight;
    fProgressIndicator.setLayoutData(gd);

    fToolBar = new ToolBar(this, SWT.FLAT);

    gd = new GridData();
    gd.grabExcessHorizontalSpace = false;
    gd.grabExcessVerticalSpace = false;
    gd.verticalAlignment = GridData.CENTER;
    fToolBar.setLayoutData(gd);
    fStopButton = new ToolItem(fToolBar, SWT.PUSH);
    // It would have been nice to use the fCancelListener, but that
    // listener operates on the fCancelComponent which must be a control.
    fStopButton.addListener(SWT.Selection, new CancelListener());
    final Image stopImage = ImageDescriptor.createFromFile(ForgeProgressMonitorPart.class, "images/stop.gif") //$NON-NLS-1$
            .createImage(getDisplay());
    final Cursor arrowCursor = new Cursor(this.getDisplay(), SWT.CURSOR_ARROW);
    fToolBar.setCursor(arrowCursor);
    fStopButton.setImage(stopImage);
    fStopButton.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            stopImage.dispose();
            arrowCursor.dispose();
        }
    });
    fStopButton.setEnabled(false);
    fStopButton.setToolTipText(JFaceResources.getString("ProgressMonitorPart.cancelToolTip")); //$NON-NLS-1$
}

From source file:org.jboss.tools.modeshape.rest.preferences.IgnoredResourcesEditor.java

License:Open Source License

/**
 * Creates a push button.//from w ww .j  a v  a 2  s  .c  om
 * 
 * @param parent the parent control
 * @param key the resource name used to supply the button's label text
 * @return the button (never <code>null</code>)
 */
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);
    return button;
}

From source file:org.jcryptool.core.logging.dialogs.ExceptionDetailsErrorDialog.java

License:Open Source License

/**
 * Create this dialog's drop-down list component.
 * /*from w ww  . ja  v a  2s  .c  o  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:org.kalypso.simulation.ui.ant.GetFileTask.java

License:Open Source License

private Shell findShell(final Display display) {
    final String shellTitle = JFaceResources.getString("ProgressMonitorDialog.title");

    final Shell[] shells = display.getShells();
    // HACK: we are looking for a progress monitor here...
    // Hopefully thing work also for the next eclipse versions...
    for (final Shell shell : shells) {
        if (shell.getText().equals(shellTitle))
            return shell;
    }/*from  w ww.  ja  v  a  2 s  .  co  m*/

    return shells[0];
}

From source file:org.locationtech.udig.catalog.RemotePreferenceStore.java

License:Open Source License

public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
    // Do we need to fire an event.
    if ((oldValue == null || !oldValue.equals(newValue))) {
        final PropertyChangeEvent pe = new PropertyChangeEvent(this, name, oldValue, newValue);
        for (final IPropertyChangeListener l : listeners) {
            SafeRunnable.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
                public void run() {
                    l.propertyChange(pe);
                }//  ww  w .  j  a v a 2 s. c  om
            });
        }
    }
}

From source file:org.mailster.gui.prefs.ConfigurationDialog.java

License:Open Source License

/**
 * The preference dialog implementation of this <code>Dialog</code>
 * framework method sends <code>performOk</code> to all pages of the
 * preference dialog, then calls <code>handleSave</code> on this dialog to
 * save any state, and then calls <code>close</code> to close this dialog.
 *///from w w w.j a  v a 2 s .  c om
protected void okPressed() {
    SafeRunnable.run(new SafeRunnable() {
        private boolean errorOccurred;

        /**
         * @see org.eclipse.core.runtime.ISafeRunnable#run()
         */
        public void run() {
            // getButton(IDialogConstants.OK_ID).setEnabled(false);
            errorOccurred = false;
            boolean hasFailedOK = false;
            try {
                PreferenceManager preferenceManager = getPreferenceManager();
                // Notify all the pages and give them a chance to abort
                Iterator<?> nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator();
                while (nodes.hasNext()) {
                    IPreferenceNode node = (IPreferenceNode) nodes.next();
                    IPreferencePage page = node.getPage();
                    if (page != null) {
                        if (!page.performOk()) {
                            hasFailedOK = true;
                            return;
                        }
                    }
                }
            } catch (Exception e) {
                handleException(e);
            } finally {
                // Don't bother closing if the OK failed
                if (hasFailedOK) {
                    return;
                }
                if (!errorOccurred) {
                    // Give subclasses the choice to save the state of the
                    // preference pages.
                    handleSave();
                }

                close();
            }
        }

        /**
         * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
         */
        public void handleException(Throwable e) {
            errorOccurred = true;
            Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e));

            clearLastSelectedNode();
            String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$
            MessageDialog.openError(getShell(), JFaceResources.getString("Error"), message); //$NON-NLS-1$
        }
    });
}

From source file:org.mailster.gui.prefs.store.MailsterPrefStore.java

License:Open Source License

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  .  j  a va2 s .co  m
            });
        }
    }
}

From source file:org.mailster.gui.prefs.widgets.EnhancedDirectoryFieldEditor.java

License:Open Source License

/**
 * Creates a new <code>DirectoryFieldEditor</code>.
 * //  www  .ja  v a  2 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
 * @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
 */
public EnhancedDirectoryFieldEditor(String name, String labelText, Composite parent, int strategy) {
    init(name, labelText);
    setErrorMessage(JFaceResources.getString("DirectoryFieldEditor.errorMessage"));
    setChangeButtonText(JFaceResources.getString("openBrowse"));
    setValidateStrategy(strategy);
    createControl(parent);
}

From source file:org.mailster.gui.prefs.widgets.HostFieldEditor.java

License:Open Source License

/**
 * Checks whether the text input field contains a valid value or not.
 *
 * @return <code>true</code> if the field value is valid,
 *   and <code>false</code> if invalid
 *//*  w ww .  j  ava 2s .  co  m*/
protected boolean checkState() {
    boolean result = false;
    if (isEmptyStringAllowed())
        result = true;

    Text textField = getTextControl();

    if (textField == null)
        result = false;
    else {
        String txt = textField.getText();
        result = (txt.trim().length() > 0) || isEmptyStringAllowed();
    }

    // call hook for subclasses
    result = result && doCheckState();

    if (!result) {
        showErrorMessage(JFaceResources.getString("StringFieldEditor.errorMessage")); //$NON-NLS-1$
        showErrorMessage();
    }

    return result;
}