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:ar.com.tadp.xml.rinzo.core.preferences.IntegerFieldEditor.java

License:Open Source License

public IntegerFieldEditor(String name, String labelText, Composite parent, int textLimit) {
    minValidValue = 0;//ww w . jav a2 s.  c o m
    maxValidValue = 0x7fffffff;
    init(name, labelText);
    setTextLimit(textLimit);
    setEmptyStringAllowed(false);
    setErrorMessage(JFaceResources.getString("IntegerFieldEditor.errorMessage"));
    createControl(parent);
}

From source file:ar.com.tadp.xml.rinzo.core.preferences.IntegerFieldEditor.java

License:Open Source License

public IntegerFieldEditor(String name, String labelText, int width, int textLimit, Composite parent) {
    super(name, labelText, width, parent);
    minValidValue = 0;//from w  w  w.j  a  v a 2  s  .c  o  m
    maxValidValue = 0x7fffffff;
    setTextLimit(textLimit);
    setEmptyStringAllowed(false);
    setErrorMessage(JFaceResources.getString("IntegerFieldEditor.errorMessage"));
}

From source file:at.nucle.e4.plugin.preferences.core.internal.context.PreferenceScopeContext.java

License:Open Source License

@Override
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
    // important: create intermediate array to protect against listeners
    // being added/removed during the notification
    final Object[] list = getListeners();
    if (list.length == 0) {
        return;//  w ww.j  a va2  s.com
    }
    final PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
    for (int i = 0; i < list.length; i++) {
        final IPropertyChangeListener listener = (IPropertyChangeListener) list[i];
        SafeRunner.run(new SafeRunnable(JFaceResources.getString("PreferenceScopeContext.changeError")) { //$NON-NLS-1$

            @Override
            public void run() {
                listener.propertyChange(event);
            }
        });
    }
}

From source file:au.edu.unimelb.plantcell.core.DoubleFieldEditor.java

License:Open Source License

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

From source file:au.gov.ga.earthsci.common.ui.preferences.LazyPreferenceDialog.java

License:Apache License

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

        /*/*from   w w  w  .  ja  v  a2 s. c  om*/
         * (non-Javadoc)
         * 
         * @see org.eclipse.core.runtime.ISafeRunnable#run()
         */
        @Override
        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 && pagesWithCreatedControls.contains(page)) {
                        if (!page.performOk()) {
                            hasFailedOK = true;
                            return;
                        }
                    }
                }
            } catch (Exception e) {
                handleException(e);
            } finally {
                //Don't bother closing if the OK failed
                if (hasFailedOK) {
                    setReturnCode(FAILED);
                    getButton(IDialogConstants.OK_ID).setEnabled(true);
                    return;
                }

                if (!errorOccurred) {
                    //Give subclasses the choice to save the state of the
                    //preference pages.
                    handleSave();
                }
                setReturnCode(OK);
                close();
            }
        }

        /*
         * (non-Javadoc)
         * 
         * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable)
         */
        @Override
        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$

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

        }
    });

    if (getReturnCode() == FAILED) {
        return;
    }

    if (workingCopyManager != null) {
        try {
            workingCopyManager.applyChanges();
        } catch (BackingStoreException e) {
            String msg = e.getMessage();
            if (msg == null) {
                msg = WorkbenchMessages.FilteredPreferenceDialog_PreferenceSaveFailed;
            }
            StatusUtil.handleStatus(WorkbenchMessages.PreferencesExportDialog_ErrorDialogTitle + ": " + msg, e, //$NON-NLS-1$
                    StatusManager.SHOW, getShell());
        }
    }

    // Run the update jobs
    Iterator<Job> updateIterator = updateJobs.iterator();
    while (updateIterator.hasNext()) {
        updateIterator.next().schedule();
    }
}

From source file:au.gov.ga.earthsci.core.preferences.ScopedPreferenceStore.java

License:Open Source License

@Override
public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
    // important: create intermediate array to protect against listeners
    // being added/removed during the notification
    final Object[] list = getListeners();
    if (list.length == 0) {
        return;//from www.  j  av  a 2s .c o m
    }
    final PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
    for (int i = 0; i < list.length; i++) {
        final IPropertyChangeListener listener = (IPropertyChangeListener) list[i];
        SafeRunner.run(new SafeRunnable(JFaceResources.getString("PreferenceStore.changeError")) { //$NON-NLS-1$
            @Override
            public void run() {
                listener.propertyChange(event);
            }
        });
    }
}

From source file:aurora.ide.helpers.StatusDialog.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  .  j a v a2s  .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. The error
 * dialog will only be displayed if there is at least one child status
 * matching the mask.
 * </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 StatusDialog(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;
}

From source file:chuck.terran.admin.ui.jface.LineSelector.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>.
 *
 * @param parent/*  w  w  w.  ja  v  a2  s  .c om*/
 *            The parent of the button.
 */
public LineSelector(Composite parent) {
    fButton = new Button(parent, SWT.PUSH);
    fFGColor = fButton.getDisplay().getSystemColor(SWT.COLOR_BLACK);
    fBGColor = fButton.getDisplay().getSystemColor(SWT.COLOR_WHITE);
    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() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            open();
        }
    });
    fButton.addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent event) {
            if (fImage != null) {
                fImage.dispose();
                fImage = null;
            }
        }
    });
    fButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
        @Override
        public void getName(AccessibleEvent e) {
            e.result = JFaceResources.getString("LineSelector.Name"); //$NON-NLS-1$
        }
    });
}

From source file:cn.ieclipse.adt.ext.wizards.EditComponentWizardPage.java

License:Apache License

private void createAttrFiled(Composite parent, int nColumns, ComponentAttribute attr, ComponentElement ce,
        Element e) {/* w  w  w . j a  v a  2  s  .com*/
    Control control = null;
    int type = attr.getType();
    if (ComponentAttribute.TYPE_LIST == type) {
        ComboDialogField field = new ComboDialogField(SWT.BORDER);
        field.setDialogFieldListener(
                new TextDialogFieldAdapter(attr, parent.getShell(), project, e, treeViewer));
        field.setLabelText(attr.getShortName());
        String initText = attr.getValue();
        if (attr.getFormats() != null) {
            field.setItems(attr.getFormats());
        }
        if (initText != null && !"".equals(initText)) {
            field.selectItem(initText);
        }
        field.doFillIntoGrid(parent, nColumns);
        control = field.getComboControl(parent);
    } else if (ComponentAttribute.TYPE_MLIST == type || ComponentAttribute.TYPE_DRAWABLE == type
            || ComponentAttribute.TYPE_STYPE == type || ComponentAttribute.TYPE_STRING_REF == type) {

        StringButtonAdapter adapter = new StringButtonAdapter(attr, parent.getShell(), project, e, treeViewer);
        StringButtonDialogField field = new StringButtonDialogField(adapter);
        field.setLabelText(attr.getShortName());
        field.setButtonLabel(JFaceResources.getString("openBrowse"));
        field.setDialogFieldListener(adapter);
        field.doFillIntoGrid(parent, nColumns);
        int w = Dialog.convertWidthInCharsToPixels(fontMetrics, 50);
        LayoutUtil.setWidthHint(field.getTextControl(null), w);
        if (attr.getValue() != null) {
            field.setText(attr.getValue());
        }
        control = field.getTextControl(parent);
    } else if (ComponentAttribute.TYPE_STRING == type) {
        StringDialogField field = new StringDialogField();
        field.setLabelText(attr.getShortName());
        field.setDialogFieldListener(new StringButtonAdapter(attr, parent.getShell(), project, e, treeViewer));
        field.doFillIntoGrid(parent, nColumns);
        int w = Dialog.convertWidthInCharsToPixels(fontMetrics, 50);
        LayoutUtil.setWidthHint(field.getTextControl(null), w);

        control = field.getTextControl(parent);
        if (attr.getValue() != null) {
            field.setText(attr.getValue());
        }
        if (intentHelper != null) {
            if ("name".equals(attr.getShortName())) {
                if (ce.getName().equals("action")) {
                    AutoCompleteField acf = new AutoCompleteField(control, new TextContentAdapter(),
                            intentHelper.getActions().toArray(new String[] {}));
                } else if (ce.getName().equals("category")) {
                    AutoCompleteField acf = new AutoCompleteField(control, new TextContentAdapter(),
                            intentHelper.getCategories().toArray(new String[] {}));
                }
            } else if (attr.getShortName().toLowerCase().contains("permission")) {
                AutoCompleteField acf = new AutoCompleteField(control, new TextContentAdapter(),
                        intentHelper.getPermissions().toArray(new String[] {}));
            }
        }
    }
    if (control != null) {
        TipShell.enableFor(control, attr);
        TipShell.setNodeName(selectedNode.getNodeName());
    }
}

From source file:cn.ieclipse.aorm.eclipse.wizards.EditComponentWizardPage.java

License:Apache License

private void createAttrFiled(Composite parent, int nColumns, ComponentAttribute attr) {
    ////  w ww  . java2s .co m
    // GridData gridData = new GridData();
    // gridData.horizontalSpan = 1;
    // Label label = new Label(parent, SWT.NONE);
    // label.setText(attr.getName());
    // label.setLayoutData(gridData);
    //
    // gridData = new GridData();
    int type = attr.getType();
    if (ComponentAttribute.TYPE_LIST == type) {
        ComboDialogField field = new ComboDialogField(SWT.BORDER);
        field.setDialogFieldListener(new ComboAdapter(attr));
        field.setLabelText(attr.getShortName());
        if (attr.getFormats() != null) {
            field.setItems(attr.getFormats());
        }
        if (attr.getValue() != null && !"".equals(attr.getValue())) {
            System.out.println(attr.getName() + "init:" + attr.getValue());
            field.setText(attr.getValue());
        }
        field.doFillIntoGrid(parent, nColumns);
        // int w = Dialog.convertWidthInCharsToPixels(fontMetrics, 50);
        // LayoutUtil.setWidthHint(field.get, w);
    } else if (ComponentAttribute.TYPE_MLIST == type || ComponentAttribute.TYPE_DRAWABLE == type
            || ComponentAttribute.TYPE_STYPE == type || ComponentAttribute.TYPE_STRING_REF == type) {

        MyStringButtonDialogField field = new MyStringButtonDialogField(
                new StringButtonAdapter(attr, parent.getShell()));
        field.setLabelText(attr.getShortName());
        field.setButtonLabel(JFaceResources.getString("openBrowse"));
        field.doFillIntoGrid(parent, nColumns);
        int w = Dialog.convertWidthInCharsToPixels(fontMetrics, 50);
        LayoutUtil.setWidthHint(field.getTextControl(null), w);
        if (attr.getValue() != null) {
            field.setText(attr.getValue());
        }
    } else if (ComponentAttribute.TYPE_STRING == type) {
        StringDialogField field = new StringDialogField();
        field.setLabelText(attr.getShortName());
        field.setDialogFieldListener(new StringButtonAdapter(attr, parent.getShell()));
        field.doFillIntoGrid(parent, nColumns);
        if (attr.getValue() != null) {
            field.setText(attr.getValue());
        }
        if ("name".equals(attr.getShortName())) {

        }
    }

}