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.eclipse.egit.ui.prefpages.configuration.GlobalConfigurationPageTest.java

License:Open Source License

@Test
public void testAddValue() throws Exception {
    config.setString(TESTSECTION, null, TESTNAME, "true");
    config.save();/*from w  w  w . jav a 2s. co  m*/
    getGitConfigurationPreferencePage();
    preferencePage.bot().tree(1).getTreeItem(TESTSECTION).getNode(TESTNAME).select();
    preferencePage.bot().textWithLabel(UIText.ConfigurationEditorComponent_ValueLabel).setText("second");
    bot.button(UIText.ConfigurationEditorComponent_AddButton).click();
    // press apply
    preferencePage.bot().button(JFaceResources.getString("apply")).click();
    config.load();
    List<String> values = Arrays.asList(config.getStringList(TESTSECTION, null, TESTNAME));
    assertEquals("Wrong number of values", 2, values.size());
    assertTrue(values.contains("true"));
    assertTrue(values.contains("second"));
    // add another value
    preferencePage.bot().tree(1).getTreeItem(TESTSECTION).getNode(TESTNAME + "[1]").select();
    preferencePage.bot().textWithLabel(UIText.ConfigurationEditorComponent_ValueLabel).setText("middle");
    bot.button(UIText.ConfigurationEditorComponent_AddButton).click();
    // close the editor
    preferencePage.bot().button(IDialogConstants.OK_LABEL).click();
    config.load();
    values = Arrays.asList(config.getStringList(TESTSECTION, null, TESTNAME));
    assertEquals("Wrong number of values", 3, values.size());
    assertTrue(values.contains("true"));
    assertEquals(1, values.indexOf("middle"));
    assertTrue(values.contains("second"));
}

From source file:org.eclipse.emf.ecp.edit.internal.swt.controls.TableControl.java

License:Open Source License

/**
 * This method shows a user confirmation dialog when the user attempts to delete a row in the table.
 *
 * @param deletionList the list of selected EObjects to delete
 *//*from   w  w  w.ja  v  a 2 s  .co m*/
protected void deleteRowUserConfirmDialog(final List<EObject> deletionList) {
    final MessageDialog dialog = new MessageDialog(tableViewer.getTable().getShell(),
            LocalizationServiceHelper.getString(getClass(), DepricatedControlMessageKeys.TableControl_Delete),
            null,
            LocalizationServiceHelper.getString(getClass(),
                    DepricatedControlMessageKeys.TableControl_DeleteAreYouSure),
            MessageDialog.CONFIRM, new String[] { JFaceResources.getString(IDialogLabelKeys.YES_LABEL_KEY),
                    JFaceResources.getString(IDialogLabelKeys.NO_LABEL_KEY) },
            0);

    new ECPDialogExecutor(dialog) {

        @Override
        public void handleResult(int codeResult) {
            if (codeResult == IDialogConstants.CANCEL_ID) {
                return;
            }

            deleteRows(deletionList);

            final List<?> containments = (List<?>) mainSetting.get(true);
            if (containments.size() < getTableReference().getUpperBound()) {
                addButton.setEnabled(true);
            }
            if (containments.size() <= getTableReference().getLowerBound()) {
                removeButton.setEnabled(false);
            }
        }
    }.execute();
}

From source file:org.eclipse.emf.ecp.internal.ui.dialogs.PropertiesDialog.java

License:Open Source License

@Override
protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.OK_ID, JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY), true);

    if (editable) {
        createButton(parent, IDialogConstants.CANCEL_ID,
                JFaceResources.getString(IDialogLabelKeys.CANCEL_LABEL_KEY), false);
    }/*  www.  ja v  a  2  s .  c o m*/
}

From source file:org.eclipse.emf.ecp.view.internal.editor.controls.EditableEReferenceLabelControlSWTRenderer.java

License:Open Source License

/**
 * Shows an error message dialog indicating a failed value link due to an exception.
 *
 * @param shell The parent {@link Shell} of the message dialog
 * @param ex The {@link Exception} causing the failure
 *//*from w  ww.ja  va  2  s  . c om*/
protected void showLinkValueFailedMessageDialog(Shell shell, final Exception ex) {
    final MessageDialog dialog = new MessageDialog(shell, "Link Value Failed", null, //$NON-NLS-1$
            "The value could not be linked due to an exception: " + ex.getMessage(), MessageDialog.ERROR, //$NON-NLS-1$
            new String[] { JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY) },
            0);

    new ECPDialogExecutor(dialog) {
        @Override
        public void handleResult(int codeResult) {
            // no op
        }
    }.execute();
}

From source file:org.eclipse.emf.ecp.view.spi.table.swt.TableControlSWTRenderer.java

License:Open Source License

/**
 * This method shows a user confirmation dialog when the user attempts to delete a row in the table.
 *
 * @param deletionList the list of selected EObjects to delete
 * @param eObject The containment reference {@link EObject}
 * @param structuralFeature The containment reference {@link EStructuralFeature}
 * @param addButton the add button/*w  w  w  .ja  va2s.  co  m*/
 * @param removeButton the remove button
 * @since 1.6
 */
protected void deleteRowUserConfirmDialog(final List<EObject> deletionList, final EObject eObject,
        final EStructuralFeature structuralFeature, final Button addButton, final Button removeButton) {
    final MessageDialog dialog = new MessageDialog(addButton.getShell(),
            LocalizationServiceHelper.getString(TableControlSWTRenderer.class, MessageKeys.TableControl_Delete),
            null,
            LocalizationServiceHelper.getString(TableControlSWTRenderer.class,
                    MessageKeys.TableControl_DeleteAreYouSure),
            MessageDialog.CONFIRM, new String[] { JFaceResources.getString(IDialogLabelKeys.YES_LABEL_KEY),
                    JFaceResources.getString(IDialogLabelKeys.NO_LABEL_KEY) },
            0);

    new ECPDialogExecutor(dialog) {

        @Override
        public void handleResult(int codeResult) {
            if (codeResult == IDialogConstants.CANCEL_ID || codeResult == SWT.DEFAULT) { // SWT.DEFAULT is return by closing a message dialog
                return;
            }

            deleteRows(deletionList, eObject, structuralFeature);

            final List<?> containments = (List<?>) eObject.eGet(structuralFeature, true);
            if (containments.size() < structuralFeature.getUpperBound()) {
                addButton.setEnabled(true);
            }
            if (containments.size() <= structuralFeature.getLowerBound()) {
                removeButton.setEnabled(false);
            }
        }
    }.execute();
}

From source file:org.eclipse.epf.common.serviceability.ErrorDialogNoReason.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  w  w  . j a v  a  2s.  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.
 * </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 ErrorDialogNoReason(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() : message;
    this.status = status;
    this.displayMask = displayMask;
    setShellStyle(getShellStyle() | SWT.RESIZE);
}

From source file:org.eclipse.epf.common.serviceability.ErrorDialogNoReason.java

License:Open Source License

/**
 * Create this dialog's drop-down list component.
 * //from   ww w .jav a2 s . com
 * @param parent
 *            the parent composite
 * @return the drop-down list component
 */
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
    populateList(list);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL
            | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL);
    data.heightHint = list.getItemHeight() * 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.equinox.internal.p2.ui.admin.dialogs.IUImplementationGroup.java

License:Open Source License

private void createCopyMenu(final List list) {
    Menu copyMenu = new Menu(list);
    MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
    copyItem.addSelectionListener(new SelectionListener() {
        /*/*  ww w.  j  a va  2 s . co m*/
         * @see SelectionListener.widgetSelected (SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            copySelectionsToClipboard(list);
        }

        /*
         * @see SelectionListener.widgetDefaultSelected(SelectionEvent)
         */
        public void widgetDefaultSelected(SelectionEvent e) {
            copySelectionsToClipboard(list);
        }
    });
    copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
    list.setMenu(copyMenu);
}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.CopyPopup.java

License:Open Source License

public CopyPopup(ICopyable copyable, final Control control) {
    this.copySource = copyable;
    this.control = control;
    Menu copyMenu = new Menu(control);
    MenuItem copyItem = new MenuItem(copyMenu, SWT.NONE);
    copyItem.addSelectionListener(new SelectionListener() {
        /*//from w  ww .j a  va 2  s.c om
         * @see SelectionListener.widgetSelected (SelectionEvent)
         */
        public void widgetSelected(SelectionEvent e) {
            copySource.copyToClipboard(control);
        }

        /*
         * @see SelectionListener.widgetDefaultSelected(SelectionEvent)
         */
        public void widgetDefaultSelected(SelectionEvent e) {
            copySource.copyToClipboard(control);
        }
    });
    copyItem.setText(JFaceResources.getString("copy")); //$NON-NLS-1$
    control.setMenu(copyMenu);
}

From source file:org.eclipse.gmf.internal.codegen.popup.actions.DiagnosticsDialog.java

License:Open Source License

/**
 * Creates an diagnostic dialog. Note that the dialog will have no visual
 * representation (no widgets) until it is told to open.
 * <p>/*from   ww  w  . j  av  a  2s  .co m*/
 * 
 * @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 dialogMessage
 *            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 diagnostic
 *            the diagnostic grouping all errors to be shown to the user
 * @param dialogButtonLabels array of labels for buttons to create in the dialog button bar
 * @param dialogButtonIDs array of IDs for buttons to create in the dialog button bar
 * @param defaultDialogButtonIndex the index of the default button
 */
public DiagnosticsDialog(Shell parentShell, String dialogTitle, String dialogMessage, Diagnostic diagnostic,
        String[] dialogButtonLabels, int[] dialogButtonIDs, int defaultDialogButtonIndex) {
    super(parentShell);

    if (diagnostic == null) {
        throw new IllegalArgumentException("Null diagnostic"); //$NON-NLS-1$
    }

    this.title = (dialogTitle == null) ? JFaceResources.getString("Problem_Occurred") : dialogTitle; //$NON-NLS-1$
    this.message = (dialogMessage == null) ? diagnostic.getMessage()
            : JFaceResources.format("Reason", new Object[] { dialogMessage, diagnostic.getMessage() }); //$NON-NLS-1$;

    this.rootDiagnotic = diagnostic;
    this.shouldIncludeTopLevelErrorInDetails = true;

    assert dialogButtonIDs != null && dialogButtonLabels != null;
    assert dialogButtonIDs.length == dialogButtonLabels.length;
    assert defaultDialogButtonIndex >= 0 && defaultDialogButtonIndex < dialogButtonIDs.length;

    buttonIDs = dialogButtonIDs;
    buttonLabels = dialogButtonLabels;
    defaultButtonIndex = defaultDialogButtonIndex;

    setShellStyle(getShellStyle() | SWT.RESIZE);
}