Example usage for org.eclipse.jface.resource JFaceResources getStrings

List of usage examples for org.eclipse.jface.resource JFaceResources getStrings

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getStrings.

Prototype

public static String[] getStrings(String[] keys) 

Source Link

Document

Returns a list of string values corresponding to the given list of keys.

Usage

From source file:io.usethesource.impulse.preferences.PreferencesUtilities.java

License:Open Source License

public Control[] createDefaultAndApplyButtons(Composite parent, final PreferencesTab buttonHolder) {
    Composite buttonBar = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 0;// w  w  w .j a  v  a  2  s  .co m
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.makeColumnsEqualWidth = false;
    buttonBar.setLayout(layout);

    GridData bbgd = new GridData(SWT.END);
    buttonBar.setLayoutData(bbgd);

    //contributeButtons(buttonBar);
    boolean createDefaultAndApplyButton = true;
    if (createDefaultAndApplyButton) {
        layout.numColumns = layout.numColumns + 2;
        String[] labels = JFaceResources.getStrings(new String[] { "defaults", "apply" }); //$NON-NLS-2$//$NON-NLS-1$
        //int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
        Button defaultsButton = new Button(buttonBar, SWT.PUSH);
        defaultsButton.setText(labels[0]);
        Dialog.applyDialogFont(defaultsButton);
        //GridData 
        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        defaultsButton.setLayoutData(data);
        defaultsButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                buttonHolder.performDefaults();
            }
        });

        Button applyButton = new Button(buttonBar, SWT.PUSH);
        applyButton.setText(labels[1]);
        Dialog.applyDialogFont(applyButton);
        data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        applyButton.setLayoutData(data);
        applyButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                buttonHolder.performApply();
            }
        });
        //applyButton.setEnabled(true);      //isValid());
        Dialog.applyDialogFont(buttonBar);
    } else {
        /* Check if there are any other buttons on the button bar.
         * If not, throw away the button bar composite.  Otherwise
         * there is an unusually large button bar.
         */
        if (buttonBar.getChildren().length < 1)
            buttonBar.dispose();
    }
    return buttonBar.getChildren();
}

From source file:net.sourceforge.eclipsetrader.core.ui.PluginPreferencePage.java

License:Open Source License

/**
 * The <code>PreferencePage</code> implementation of this 
 * <code>IDialogPage</code> method creates a description label
 * and button bar for the page. It calls <code>createContents</code>
 * to create the custom contents of the page.
 * <p>/*  w  ww  .j  a  va 2s.c  om*/
 * If a subclass that overrides this method creates a <code>Composite</code>
 * that has a layout with default margins (for example, a <code>GridLayout</code>)
 * it is expected to set the margins of this <code>Layout</code> to 0 pixels.
 */
public void createControl(Composite parent) {

    GridData gd;
    Composite content = new Composite(parent, SWT.NONE);
    setControl(content);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    content.setLayout(layout);
    //Apply the font on creation for backward compatibility
    applyDialogFont(content);

    // initialize the dialog units
    initializeDialogUnits(content);

    descriptionLabel = createDescriptionLabel(content);
    if (descriptionLabel != null) {
        descriptionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }

    body = createContents(content);
    if (body != null)
        // null is not a valid return value but support graceful failure
        body.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite buttonBar = new Composite(content, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.makeColumnsEqualWidth = false;
    buttonBar.setLayout(layout);

    gd = new GridData(GridData.HORIZONTAL_ALIGN_END);

    buttonBar.setLayoutData(gd);

    contributeButtons(buttonBar);

    if (createDefaultAndApplyButton) {
        layout.numColumns = layout.numColumns + 2;
        String[] labels = JFaceResources.getStrings(new String[] { "defaults", "apply" }); //$NON-NLS-2$//$NON-NLS-1$
        int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
        defaultsButton = new Button(buttonBar, SWT.PUSH);
        defaultsButton.setText(labels[0]);
        Dialog.applyDialogFont(defaultsButton);
        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        Point minButtonSize = defaultsButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        data.widthHint = Math.max(widthHint, minButtonSize.x);
        defaultsButton.setLayoutData(data);
        defaultsButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                performDefaults();
            }
        });

        applyButton = new Button(buttonBar, SWT.PUSH);
        applyButton.setText(labels[1]);
        Dialog.applyDialogFont(applyButton);
        data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        minButtonSize = applyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        data.widthHint = Math.max(widthHint, minButtonSize.x);
        applyButton.setLayoutData(data);
        applyButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                performApply();
            }
        });
        applyButton.setEnabled(isValid());
        applyDialogFont(buttonBar);
    } else {
        /* Check if there are any other buttons on the button bar.
         * If not, throw away the button bar composite.  Otherwise
         * there is an unusually large button bar.
         */
        if (buttonBar.getChildren().length < 1)
            buttonBar.dispose();
    }
}

From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.BaseStylePreferencePage.java

License:Open Source License

public void createControl(Composite parent) {

    GridData gd;//from   ww  w. j  a  v a2 s .c  o  m
    Composite content = new Composite(parent, SWT.NONE);
    setControl(content);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    content.setLayout(layout);
    // Apply the font on creation for backward compatibility
    applyDialogFont(content);

    // initialize the dialog units
    initializeDialogUnits(content);

    descriptionLabel = createDescriptionLabel(content);
    if (descriptionLabel != null) {
        descriptionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }

    body = createContents(content);
    if (body != null) {
        // null is not a valid return value but support graceful failure
        body.setLayoutData(new GridData(GridData.FILL_BOTH));
    }

    Composite buttonBar = new Composite(content, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.makeColumnsEqualWidth = false;
    buttonBar.setLayout(layout);

    gd = new GridData(GridData.HORIZONTAL_ALIGN_END);

    buttonBar.setLayoutData(gd);

    contributeButtons(buttonBar);

    if (createDefaultButton) {
        layout.numColumns = layout.numColumns + 1;
        String[] labels = JFaceResources.getStrings(new String[] { "defaults", "apply" }); //$NON-NLS-2$//$NON-NLS-1$
        int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
        defaultsButton = new Button(buttonBar, SWT.PUSH);
        defaultsButton.setText(labels[0]);
        Dialog.applyDialogFont(defaultsButton);
        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        Point minButtonSize = defaultsButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        data.widthHint = Math.max(widthHint, minButtonSize.x);
        defaultsButton.setLayoutData(data);
        defaultsButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                performDefaults();
            }
        });

        applyDialogFont(buttonBar);
    } else {
        /*
         * Check if there are any other buttons on the button bar. If not,
         * throw away the button bar composite. Otherwise there is an
         * unusually large button bar.
         */
        if (buttonBar.getChildren().length < 1) {
            buttonBar.dispose();
        }
    }
}

From source file:org.eclipse.edt.ide.rui.visualeditor.internal.util.Mnemonics.java

License:Open Source License

/**
 * Set if the mnemonics are for a preference page
 * Preference pages already have a few buttons with mnemonics set by Eclipse
 * We have to make sure we do not use the ones they use
 *//*from  w ww. j a va2s.  c o m*/
public Mnemonics setOnPreferencePage(boolean page) {
    if (page) {
        String[] labels = JFaceResources.getStrings(new String[] { "defaults", "apply" }); //$NON-NLS-1$ //$NON-NLS-2$
        String used = getMnemonicsFromStrings(labels).toUpperCase();
        makeUsed(used);
    }
    return this;
}

From source file:org.eclipse.imp.preferences.PreferencesUtilities.java

License:Open Source License

public Control[] createDefaultAndApplyButtons(Composite parent, final PreferencesTab buttonHolder) {
    Composite buttonBar = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 0;/*from   w w w .ja v  a  2s.  com*/
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.makeColumnsEqualWidth = false;
    buttonBar.setLayout(layout);

    GridData bbgd = new GridData(SWT.END);
    buttonBar.setLayoutData(bbgd);

    //contributeButtons(buttonBar);
    boolean createDefaultAndApplyButton = true;
    if (createDefaultAndApplyButton) {
        layout.numColumns = layout.numColumns + 2;
        String[] labels = JFaceResources.getStrings(new String[] { "defaults", "apply" }); //$NON-NLS-2$//$NON-NLS-1$
        //int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
        Button defaultsButton = new Button(buttonBar, SWT.PUSH);
        defaultsButton.setText(labels[0]);
        Dialog.applyDialogFont(defaultsButton);
        //GridData 
        GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        Point minButtonSize = defaultsButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        //data.widthHint = Math.max(widthHint, minButtonSize.x);
        defaultsButton.setLayoutData(data);
        defaultsButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                buttonHolder.performDefaults();
            }
        });

        Button applyButton = new Button(buttonBar, SWT.PUSH);
        applyButton.setText(labels[1]);
        Dialog.applyDialogFont(applyButton);
        data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
        minButtonSize = applyButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
        //data.widthHint = Math.max(widthHint, minButtonSize.x);
        applyButton.setLayoutData(data);
        applyButton.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                buttonHolder.performApply();
            }
        });
        //applyButton.setEnabled(true);      //isValid());
        Dialog.applyDialogFont(buttonBar);
    } else {
        /* Check if there are any other buttons on the button bar.
         * If not, throw away the button bar composite.  Otherwise
         * there is an unusually large button bar.
         */
        if (buttonBar.getChildren().length < 1)
            buttonBar.dispose();
    }
    return buttonBar.getChildren();
}