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.talend.librariesmanager.ui.dialogs.ExternalModulesInstallDialog.java

License:Open Source License

private ToolBar createHelpImageButton(Composite parent, Image image) {
    ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
    ((GridLayout) parent.getLayout()).numColumns++;
    toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    toolBar.setCursor(cursor);/*from   w  w w. ja v a  2s .c om*/
    toolBar.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            cursor.dispose();
        }
    });
    ToolItem item = new ToolItem(toolBar, SWT.NONE);
    item.setImage(image);
    item.setToolTipText(JFaceResources.getString("helpToolTip")); //$NON-NLS-1$
    item.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            helpPressed();
        }
    });
    return toolBar;
}

From source file:org.talend.repository.ui.dialog.ProjectSettingsPreferenceDialog.java

License:Open Source License

protected void saveCurrentSettings() {
    SafeRunnable.run(new SafeRunnable() {

        private boolean errorOccurred;

        @Override//from   w w w.  j a v  a 2s.  c o m
        public void run() {
            errorOccurred = false;
            boolean hasFailedOK = false;
            try {
                Iterator nodes = getPreferenceManager().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 {

                if (hasFailedOK) {
                    setReturnCode(FAILED);
                    return;
                }

                if (!errorOccurred) {

                    handleSave();
                }
                setReturnCode(OK);
            }
        }

        @Override
        public void handleException(Throwable e) {
            errorOccurred = true;

            Policy.getLog().log(new Status(IStatus.ERROR, Policy.JFACE, 0, e.toString(), e));

            clearSelectedNode();
            String message = JFaceResources.getString("SafeRunnable.errorMessage"); //$NON-NLS-1$

            Policy.getStatusHandler().show(new Status(IStatus.ERROR, Policy.JFACE, message, e),
                    JFaceResources.getString("Error")); //$NON-NLS-1$ 

        }
    });
}

From source file:org.talend.repository.ui.wizards.ConfigExternalLib.TableField.java

License:Open Source License

/**
 * Helper method to create a push button.
 * /*from   w  w  w  . j  av a  2 s .co  m*/
 * @param parent 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 | GridData.VERTICAL_ALIGN_BEGINNING);
    int widthHint = IDialogConstants.BUTTON_WIDTH;
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    button.addSelectionListener(getSelectionListener());
    return button;
}

From source file:org.wso2.developerstudio.eclipse.errorreporter.ui.dialogs.ErrorNotificationDialog.java

License:Open Source License

/**
 * This method contains the logic to create the contents in the Error Report
 * text area//from   w  ww .  j a va  2s  . com
 * 
 * @param parent
 */

@Override
protected List createDropDownList(Composite parent) {
    // create the list
    list = new List(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    // fill the list {
    try {
        addReportInfo(list, errorMessage);
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
            | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL);
    data.heightHint = 150;
    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() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            copyToClipboard();
        }

        @Override
        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.yakindu.sct.ui.editor.propertysheets.AbstractEditorPropertySection.java

License:Open Source License

protected void createHelpWidget(final Composite parent, final Control control, String helpId) {
    final ImageHyperlink helpWidget = toolkit.createImageHyperlink(parent, SWT.CENTER);
    Image defaultImage = PlatformUI.getWorkbench().getSharedImages()
            .getImage(ISharedImages.IMG_LCL_LINKTO_HELP);
    helpWidget.setImage(defaultImage);// w  ww.j ava2 s . co  m
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(helpWidget);
    helpWidget.setToolTipText(JFaceResources.getString(IDialogLabelKeys.HELP_LABEL_KEY));
    helpWidget.addMouseListener(new MouseAdapter() {
        public void mouseDown(MouseEvent e) {
            control.setFocus();
            PlatformUI.getWorkbench().getHelpSystem().displayDynamicHelp();
        }
    });
    GridDataFactory.fillDefaults().applyTo(helpWidget);
    helpWidget.setEnabled(true);
    setHelpContext(control, helpId);
}

From source file:raptor.pref.fields.ListEditor.java

License:Open Source License

/**
 * Helper method to create a push button.
 * //from  w w  w . jav a2s.co m
 * @param parent
 *            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, String keyOverride) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(key != null ? JFaceResources.getString(key) : keyOverride);
    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;
}

From source file:tern.eclipse.ide.server.nodejs.internal.ui.preferences.FileComboFieldEditor.java

License:Open Source License

public FileComboFieldEditor(String name, String labelText, boolean enforceAbsolute, int validationStrategy,
        String[] items, Composite parent) {
    super(items);

    this.extensions = null;

    this.filterPath = null;

    this.enforceAbsolute = false;

    init(name, labelText);/*from ww  w  .j  ava2  s.  co  m*/
    this.enforceAbsolute = enforceAbsolute;
    setErrorMessage(JFaceResources.getString("FileFieldEditor.errorMessage"));
    setChangeButtonText(JFaceResources.getString("openBrowse"));
    setValidateStrategy(validationStrategy);
    createControl(parent);
}

From source file:tern.eclipse.ide.server.nodejs.internal.ui.preferences.FileComboFieldEditor.java

License:Open Source License

protected boolean checkState() {
    String msg = null;/*from w w  w  .jav  a 2 s.  c  om*/

    String path = getTextControl().getText();
    if (path != null)
        path = path.trim();
    else {
        path = "";
    }
    if (path.length() == 0) {
        if (!(isEmptyStringAllowed()))
            msg = getErrorMessage();
    } else {
        if (!path.equals("node")) {
            File file = new File(path);
            if (file.isFile()) {
                if ((this.enforceAbsolute) && (!(file.isAbsolute())))
                    msg = JFaceResources.getString("FileFieldEditor.errorMessage2");
            } else {
                msg = getErrorMessage();
            }
        }
    }

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

    if (doCheckState()) {
        clearErrorMessage();
        return true;
    }
    msg = getErrorMessage();
    if (msg != null) {
        showErrorMessage(msg);
    }
    return false;
}

From source file:tern.eclipse.ide.server.nodejs.internal.ui.preferences.StringButtonComboFieldEditor.java

License:Open Source License

protected Button getChangeControl(Composite parent) {
    if (this.changeButton == null) {
        this.changeButton = new Button(parent, 8);
        if (this.changeButtonText == null) {
            this.changeButtonText = JFaceResources.getString("openChange");
        }//from w w w . j  av a  2 s  .  c  om
        this.changeButton.setText(this.changeButtonText);
        this.changeButton.setFont(parent.getFont());
        this.changeButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent evt) {
                String newValue = StringButtonComboFieldEditor.this.changePressed();
                if (newValue != null)
                    StringButtonComboFieldEditor.this.setStringValue(newValue);
            }
        });
        this.changeButton.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent event) {
                StringButtonComboFieldEditor.this.changeButton = null;
            }
        });
    } else {
        checkParent(this.changeButton, parent);
    }
    return this.changeButton;
}

From source file:tern.eclipse.ide.server.nodejs.internal.ui.preferences.StringComboFieldEditor.java

License:Open Source License

public StringComboFieldEditor(String name, String labelText, int width, int strategy, String[] items,
        Composite parent) {//from   ww  w.  ja  va  2s .com
    this.widthInChars = UNLIMITED;

    this.textLimit = UNLIMITED;

    this.emptyStringAllowed = true;

    this.validateStrategy = 0;

    init(name, labelText);
    this.widthInChars = width;
    setValidateStrategy(strategy);
    this.isValid = false;
    this.errorMessage = JFaceResources.getString("StringComboFieldEditor.errorMessage");
    this.items = items;
    createControl(parent);
}