Example usage for org.eclipse.jface.dialogs Dialog getImage

List of usage examples for org.eclipse.jface.dialogs Dialog getImage

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog getImage.

Prototype

public static Image getImage(String key) 

Source Link

Document

Returns the standard dialog image with the given key.

Usage

From source file:org.summer.sdt.internal.ui.refactoring.reorg.RenameTypeWizardSimilarElementsOptionsDialog.java

License:Open Source License

@Override
protected Control createMessageArea(Composite parent) {
    initializeDialogUnits(parent);//from   ww w .ja v  a2  s .c om

    Composite messageComposite = new Composite(parent, SWT.NONE);
    messageComposite.setFont(parent.getFont());
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    messageComposite.setLayout(layout);
    messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    Label infoLabel = new Label(messageComposite, SWT.WRAP);
    infoLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_select_strategy);
    GridData gd = new GridData(GridData.FILL, GridData.CENTER, true, false);
    gd.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    infoLabel.setLayoutData(gd);
    infoLabel.setFont(parent.getFont());

    fExactStrategyRadio = new SelectionButtonDialogField(SWT.RADIO);
    fExactStrategyRadio
            .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_1);
    fExactStrategyRadio.doFillIntoGrid(messageComposite, 1);
    fExactStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EXACT);
    LayoutUtil.setHorizontalIndent(fExactStrategyRadio.getSelectionButton(null));

    fEmbeddedStrategyRadio = new SelectionButtonDialogField(SWT.RADIO);
    fEmbeddedStrategyRadio
            .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_2);
    fEmbeddedStrategyRadio.doFillIntoGrid(messageComposite, 1);
    fEmbeddedStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_EMBEDDED);
    LayoutUtil.setHorizontalIndent(fEmbeddedStrategyRadio.getSelectionButton(null));

    fSuffixStrategyRadio = new SelectionButtonDialogField(SWT.RADIO);
    fSuffixStrategyRadio
            .setLabelText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_strategy_3);
    fSuffixStrategyRadio.doFillIntoGrid(messageComposite, 1);
    fSuffixStrategyRadio.setSelection(fSelectedStrategy == RenamingNameSuggestor.STRATEGY_SUFFIX);
    LayoutUtil.setHorizontalIndent(fSuffixStrategyRadio.getSelectionButton(null));

    final Composite warningComposite = new Composite(messageComposite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    warningComposite.setLayout(layout);
    warningComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
    warningComposite.setFont(messageComposite.getFont());

    Image image = Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
    fWarningImageLabel = new Label(warningComposite, SWT.LEFT | SWT.WRAP);
    fWarningImageLabel.setImage(image);
    fWarningImageLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));

    fWarningLabel = new Label(warningComposite, SWT.WRAP);
    fWarningLabel.setText(RefactoringMessages.RenameTypeWizardSimilarElementsOptionsDialog_warning_short_names);
    GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1);
    gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    fWarningLabel.setLayoutData(gridData);
    fWarningLabel.setFont(warningComposite.getFont());

    fExactStrategyRadio.setDialogFieldListener(new IDialogFieldListener() {

        public void dialogFieldChanged(DialogField field) {
            updateLabel();
            fSelectedStrategy = RenamingNameSuggestor.STRATEGY_EXACT;
        }
    });

    fEmbeddedStrategyRadio.setDialogFieldListener(new IDialogFieldListener() {

        public void dialogFieldChanged(DialogField field) {
            updateLabel();
            fSelectedStrategy = RenamingNameSuggestor.STRATEGY_EMBEDDED;
        }
    });

    fSuffixStrategyRadio.setDialogFieldListener(new IDialogFieldListener() {

        public void dialogFieldChanged(DialogField field) {
            updateLabel();
            fSelectedStrategy = RenamingNameSuggestor.STRATEGY_SUFFIX;
        }
    });

    updateLabel();

    return messageComposite;
}

From source file:org.tigris.subversion.subclipse.ui.properties.SVNRepositoryPropertiesPage.java

License:Open Source License

protected Control createContents(Composite parent) {
    initialize();//w  w  w .j a  v a 2s .co m

    GridLayout layout;
    Label label;
    GridData data;

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    layout = new GridLayout();
    layout.numColumns = 1;
    composite.setLayout(layout);

    Listener labelListener = new Listener() {
        public void handleEvent(Event event) {
            updateWidgetEnablements();
        }
    };

    // group for label
    Composite labelGroup = new Composite(composite, SWT.NONE);
    labelGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    layout.numColumns = 2;
    labelGroup.setLayout(layout);

    // use url as label
    useUrlLabelButton = new Button(labelGroup, SWT.RADIO);
    useUrlLabelButton.setText(Policy.bind("SVNRepositoryPropertiesPage.useRepositoryUrlAsLabel")); //$NON-NLS-1$
    useUrlLabelButton.addListener(SWT.Selection, labelListener);
    data = new GridData();
    data.horizontalSpan = 2;
    useUrlLabelButton.setLayoutData(data);

    // use custom label
    useCustomLabelButton = new Button(labelGroup, SWT.RADIO);
    useCustomLabelButton.setText(Policy.bind("SVNRepositoryPropertiesPage.useCustomLabel")); //$NON-NLS-1$
    useCustomLabelButton.addListener(SWT.Selection, labelListener);
    data = new GridData();
    useCustomLabelButton.setLayoutData(data);
    customLabelText = new Text(labelGroup, SWT.SINGLE | SWT.BORDER);
    customLabelText.addListener(SWT.Modify, labelListener);
    data = new GridData(GridData.FILL_HORIZONTAL);
    // data.widthHint = 200;
    customLabelText.setLayoutData(data);

    // empty label to separate
    label = new Label(composite, SWT.NONE);

    FocusListener focusListener = new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            ((Text) e.getSource()).selectAll();
        }

        public void focusLost(FocusEvent e) {
            ((Text) e.getSource()).setText(((Text) e.getSource()).getText());
        }
    };
    customLabelText.addFocusListener(focusListener);

    if (showCredentials) {
        // group for login and password
        Composite userPasswordGroup = new Composite(composite, SWT.NONE);
        userPasswordGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        layout = new GridLayout();
        layout.numColumns = 2;
        userPasswordGroup.setLayout(layout);

        // login
        label = new Label(userPasswordGroup, SWT.NONE);
        label.setText(Policy.bind("SVNRepositoryPropertiesPage.login")); //$NON-NLS-1$
        loginText = new Text(userPasswordGroup, SWT.SINGLE | SWT.BORDER);
        data = new GridData(GridData.FILL_HORIZONTAL);
        data.grabExcessHorizontalSpace = true;
        loginText.setLayoutData(data);
        loginText.addFocusListener(focusListener);

        // password
        label = new Label(userPasswordGroup, SWT.NONE);
        label.setText(Policy.bind("SVNRepositoryPropertiesPage.password")); //$NON-NLS-1$
        passwordText = new Text(userPasswordGroup, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
        data = new GridData(GridData.FILL_HORIZONTAL);
        data.grabExcessHorizontalSpace = true;
        passwordText.setLayoutData(data);
        passwordText.addListener(SWT.Modify, new Listener() {
            public void handleEvent(Event event) {
                passwordChanged = !passwordText.getText().equals(FAKE_PASSWORD);
            }
        });
        passwordText.addFocusListener(focusListener);
    }

    // empty label to separate
    label = new Label(composite, SWT.NONE);

    // group for repository root
    Composite repositoryRootGroup = new Composite(composite, SWT.NONE);
    repositoryRootGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    layout = new GridLayout();
    layout.numColumns = 3;
    repositoryRootGroup.setLayout(layout);

    // url of the repository 
    label = new Label(repositoryRootGroup, SWT.NONE);
    label.setText(Policy.bind("SVNRepositoryPropertiesPage.repositoryUrl")); //$NON-NLS-1$
    repositoryUrlText = new Text(repositoryRootGroup, SWT.SINGLE);
    repositoryUrlText.setText("");
    repositoryUrlText.setEditable(false);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    data.horizontalSpan = 2;
    repositoryUrlText.setLayoutData(data);

    // url of the repository root 
    label = new Label(repositoryRootGroup, SWT.NONE);
    label.setText(Policy.bind("SVNRepositoryPropertiesPage.repositoryRootUrl")); //$NON-NLS-1$
    repositoryRootText = new Text(repositoryRootGroup, SWT.SINGLE | SWT.BORDER);
    repositoryRootText.setEditable(false);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.grabExcessHorizontalSpace = true;
    repositoryRootText.setLayoutData(data);

    Button button = new Button(repositoryRootGroup, SWT.NONE);
    button.setText(Policy.bind("SVNRepositoryPropertiesPage.browseRootUrl")); //$NON-NLS-1$
    button.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            openChooseRootDialog();
        }
    });

    // warning for repository root
    Composite warningComposite = new Composite(composite, SWT.NONE);
    warningComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = 0;
    layout.marginHeight = 0;
    warningComposite.setLayout(layout);

    Label warningLabel = new Label(warningComposite, SWT.NONE);
    warningLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
    warningLabel.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
    Label warningText = new Label(warningComposite, SWT.WRAP);
    warningText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    warningText.setText(Policy.bind("SVNRepositoryPropertiesPage.rootUrlWarning")); //$NON-NLS-1$

    initializeValues();
    return composite;
}