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:net.sf.jasperreports.eclipse.ui.util.ExceptionDetailsErrorDialog.java

License:Open Source License

/**
 * Create this dialog's drop-down list component.
 * /*  ww  w  .j av  a  2s  .  c om*/
 * @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 = 100;
    // 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:net.sf.kerner.utils.rcp.DoubleFieldEditor.java

License:Open Source License

private static String getMessage_notDouble() {
    final String message = JFaceResources.getString("IntegerFieldEditor.errorMessage"); //$NON-NLS-1$
    return replaceInteger_withDouble(message);
}

From source file:net.sourceforge.eclipseccase.ui.preferences.ClearCasePreferenceStore.java

License:Open Source License

public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {

    // efficiently handle case of 0 listeners
    if (listeners.isEmpty())
        // no one interested
        return;/*  w w w.j  av a  2  s  .com*/

    // important: create intermediate array to protect against
    // listeners
    // being added/removed during the notification
    final Object[] list = listeners.getListeners();
    final PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
    SafeRunner.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$

        public void run() {
            for (int i = 0; i < list.length; i++) {
                ((IPropertyChangeListener) list[i]).propertyChange(event);
            }
        }
    });

}

From source file:net.sourceforge.eclipsetrader.core.db.PersistentPreferenceStore.java

License:Open Source License

public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
    final Object[] finalListeners = this.listeners.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);
                }/*from w  w w  .  j ava 2s .c  o m*/
            });
        }
    }
}

From source file:net.sourceforge.eclipsetrader.trading.wizards.accounts.AccountSettingsDialog.java

License:Open Source License

protected void okPressed() {
    SafeRunnable.run(new SafeRunnable() {
        private boolean errorOccurred;

        /* (non-Javadoc)
         * @see org.eclipse.core.runtime.ISafeRunnable#run()
         *///from   ww  w  .  j ava 2 s .c  o  m
        public void run() {
            getButton(IDialogConstants.OK_ID).setEnabled(false);
            errorOccurred = false;
            boolean hasFailedOK = false;
            try {
                // Notify all the pages and give them a chance to abort
                Iterator nodes = getPreferenceManager().getElements(PreferenceManager.PRE_ORDER).iterator();
                while (nodes.hasNext()) {
                    IPreferenceNode node = (IPreferenceNode) nodes.next();
                    IPreferencePage page = node.getPage();
                    if (page != null && page.getControl() != 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();
            }
        }

        /* (non-Javadoc)
         * @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));

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

        }
    });
}

From source file:net.sourceforge.texlipse.properties.BuilderConfigDialog.java

License:Open Source License

/**
 * Creates the executable browsing component.
 * @param composite parent component// w  w  w .ja  v  a  2 s .  c  o  m
 */
private void addFileBrowser(Composite composite) {

    Label fileLabel = new Label(composite, SWT.LEFT);
    fileLabel.setText(TexlipsePlugin.getResourceString("preferenceBuilderCommandLabel"));
    fileLabel.setToolTipText(TexlipsePlugin.getResourceString("preferenceBuilderCommandTooltip"));
    fileLabel.setLayoutData(new GridData());

    Composite browser = new Composite(composite, SWT.NONE);
    browser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout bgl = new GridLayout();
    bgl.numColumns = 2;
    browser.setLayout(bgl);

    fileField = new Text(browser, SWT.SINGLE | SWT.BORDER);
    fileField.setText(builder.getProgramPath());
    fileField.setToolTipText(TexlipsePlugin.getResourceString("preferenceBuilderCommandTooltip"));
    fileField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fileField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            checkFile(fileField.getText());
        }
    });

    Button browseButton = new Button(browser, SWT.PUSH);
    browseButton.setText(JFaceResources.getString("openBrowse"));
    browseButton.setLayoutData(new GridData());
    browseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            FileDialog dialog = new FileDialog(getShell());
            if (lastPath != null) {
                if (lastPath.exists()) {
                    dialog.setFilterPath(lastPath.getAbsolutePath());
                }
            } else {
                lastPath = new File(fileField.getText());
                while (lastPath != null && !lastPath.isDirectory()) {
                    lastPath = lastPath.getParentFile();
                }
                if (lastPath != null && lastPath.exists()) {
                    dialog.setFilterPath(lastPath.getAbsolutePath());
                }
            }

            String dir = dialog.open();
            if (dir != null) {
                lastPath = new File(dir.trim());
                if (lastPath.exists()) {
                    fileField.setText(lastPath.getAbsolutePath());
                } else {
                    lastPath = null;
                }
                checkFile(fileField.getText());
            }

        }
    });
}

From source file:net.sourceforge.texlipse.properties.BuilderSettingsPreferencePage.java

License:Open Source License

/**
 * @param contents parent component/*  w w w . j av  a 2 s  . c o  m*/
 */
private void addTexInstallDir(Composite contents) {

    Composite parent = new Composite(contents, SWT.NULL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    parent.setLayout(layout);
    GridData pgd = new GridData(GridData.FILL_HORIZONTAL);
    pgd.horizontalSpan = 2;
    parent.setLayoutData(pgd);

    TexlipsePreferencePage.addLabelField(3,
            TexlipsePlugin.getResourceString("preferenceBuilderTexDirDescription"), parent);

    Label label = new Label(parent, SWT.LEFT);
    label.setText(TexlipsePlugin.getResourceString("preferenceBuilderTexDirLabel"));
    label.setLayoutData(new GridData());

    texDirField = new Text(parent, SWT.SINGLE | SWT.BORDER);
    texDirField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    texDirField.setText("");
    WorkbenchHelp.setHelp(texDirField, TexlipseHelpIds.BUILDER_TEX_DIR);

    Button button = new Button(parent, SWT.PUSH);
    button.setText(JFaceResources.getString("openBrowse"));
    button.setLayoutData(new GridData());
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            DirectoryDialog dialog = new DirectoryDialog(getShell());
            if (lastPath != null) {
                if (lastPath.exists())
                    dialog.setFilterPath(lastPath.getAbsolutePath());
            }

            String dir = dialog.open();
            if (dir != null) {
                lastPath = new File(dir.trim());
                if (lastPath.exists()) {
                    texDirField.setText(lastPath.getAbsolutePath());
                } else {
                    lastPath = null;
                }
            }
        }
    });
}

From source file:net.sourceforge.texlipse.viewer.TexLaunchConfigurationTab.java

License:Open Source License

/**
 * Creates the top level control for this launch configuration
 * tab under the given parent composite.  This method is called once on
 * tab creation, after <code>setLaunchConfigurationDialog</code>
 * is called.//from www  . ja v a  2  s.c  om
 * <p>
 * Implementors are responsible for ensuring that
 * the created control can be accessed via <code>getControl</code>
 * </p>
 *
 * @param parent the parent composite
 */
public void createControl(Composite parent) {

    Composite composite = new Composite(parent, SWT.FILL);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    createVerticalSpacer(composite, 3);

    Label choiceLabel = new Label(composite, SWT.LEFT);
    choiceLabel.setText(TexlipsePlugin.getResourceString("launchTabChoiceLabel"));
    choiceLabel.setToolTipText(TexlipsePlugin.getResourceString("launchTabChoiceTooltip"));
    choiceLabel.setLayoutData(new GridData());

    choiceCombo = new Combo(composite, SWT.DROP_DOWN);
    choiceCombo.setToolTipText(TexlipsePlugin.getResourceString("launchTabChoiceTooltip"));
    GridData cgd = new GridData();
    cgd.horizontalSpan = 2;
    choiceCombo.setLayoutData(cgd);
    String[] viewers = registry.getViewerList();
    choiceCombo.setItems(viewers);
    choiceCombo.select(registry.getActiveViewerIndex(viewers));
    choiceCombo.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updateFields(choiceCombo.getSelectionIndex());
        }
    });

    createVerticalSpacer(composite, 3);

    Label commandLabel = new Label(composite, SWT.LEFT);
    commandLabel.setText(TexlipsePlugin.getResourceString("launchTabCommandLabel"));
    commandLabel.setToolTipText(TexlipsePlugin.getResourceString("launchTabCommandTooltip"));
    commandLabel.setLayoutData(new GridData());

    commandField = new Text(composite, SWT.SINGLE | SWT.WRAP | SWT.BORDER);
    commandField.setToolTipText(TexlipsePlugin.getResourceString("launchTabCommandTooltip"));
    commandField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    commandField.addFocusListener(new FocusAdapter() {
        public void focusLost(FocusEvent e) {
            File f = new File(commandField.getText());
            if (!f.exists()) {
                setErrorMessage(TexlipsePlugin.getResourceString("launchTabCommandError"));
            }
        }
    });
    commandField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updateLaunchConfigurationDialog();
        }
    });

    commandBrowserButton = new Button(composite, SWT.PUSH);
    commandBrowserButton.setText(JFaceResources.getString("openChange"));
    commandBrowserButton.setToolTipText(TexlipsePlugin.getResourceString("launchTabCommandTooltip"));
    commandBrowserButton.setLayoutData(new GridData());
    commandBrowserButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(commandBrowserButton.getShell(), SWT.OPEN);
            String file = dialog.open();
            if (file != null && file.length() > 0) {
                File f = new File(file);
                if (f.exists()) {
                    commandField.setText(file);
                }
            }
        }
    });

    createVerticalSpacer(composite, 3);

    Label argumentLabel = new Label(composite, SWT.LEFT);
    argumentLabel.setText(TexlipsePlugin.getResourceString("launchTabArgumentsLabel"));
    argumentLabel.setToolTipText(TexlipsePlugin.getResourceString("launchTabArgumentsTooltip"));
    argumentLabel.setLayoutData(new GridData());

    argumentField = new Text(composite, SWT.SINGLE | SWT.WRAP | SWT.BORDER);
    argumentField.setToolTipText(TexlipsePlugin.getResourceString("launchTabArgumentsTooltip"));
    argumentField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
    argumentField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            updateLaunchConfigurationDialog();
        }
    });

    addDDEGroups(composite);

    setControl(composite);
}

From source file:net.sourceforge.texlipse.viewer.ViewerConfigDialog.java

License:Open Source License

/**
 * Creates the executable browsing component.
 * @param composite parent component//from  ww w.j a  va  2  s. c  o m
 */
private void addFileBrowser(Composite composite) {

    Label fileLabel = new Label(composite, SWT.LEFT);
    fileLabel.setText(TexlipsePlugin.getResourceString("preferenceViewerCommandLabel"));
    fileLabel.setToolTipText(TexlipsePlugin.getResourceString("preferenceViewerCommandTooltip"));
    fileLabel.setLayoutData(new GridData());

    Composite browser = new Composite(composite, SWT.NONE);
    browser.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridLayout bgl = new GridLayout();
    bgl.numColumns = 2;
    browser.setLayout(bgl);

    fileField = new Text(browser, SWT.SINGLE | SWT.BORDER);
    fileField.setText(registry.getCommand());
    fileField.setToolTipText(TexlipsePlugin.getResourceString("preferenceViewerCommandTooltip"));
    fileField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    fileField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            validateFields();
        }
    });

    Button browseButton = new Button(browser, SWT.PUSH);
    browseButton.setText(JFaceResources.getString("openBrowse"));
    browseButton.setLayoutData(new GridData());
    browseButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {

            FileDialog dialog = new FileDialog(getShell());
            if (lastPath != null) {
                if (lastPath.exists()) {
                    dialog.setFilterPath(lastPath.getAbsolutePath());
                }
            } else {
                lastPath = new File(fileField.getText());
                while (lastPath != null && !lastPath.isDirectory()) {
                    lastPath = lastPath.getParentFile();
                }
                if (lastPath != null && lastPath.exists()) {
                    dialog.setFilterPath(lastPath.getAbsolutePath());
                }
            }

            String dir = dialog.open();
            if (dir != null) {
                lastPath = new File(dir.trim());
                if (lastPath.exists()) {
                    fileField.setText(lastPath.getAbsolutePath());
                    registry.setCommand(fileField.getText());
                } else {
                    lastPath = null;
                }
            }

        }
    });
}

From source file:net.tourbook.common.font.FontFieldEditorExtended.java

License:Open Source License

/**
 * Creates a font field editor with an optional preview area.
 * /*from   ww  w  . j av 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 previewAreaText
 *            the text used for the preview window. If it is <code>null</code> there will be no
 *            preview area,
 * @param parent
 *            the parent of the field editor's control
 */
public FontFieldEditorExtended(final String name, final String labelText, final String previewAreaText,
        final Composite parent) {
    init(name, labelText);

    _previewAreaText = previewAreaText;
    _buttonText = JFaceResources.getString("openChange"); //$NON-NLS-1$

    createControl(parent);
}