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

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

Introduction

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

Prototype

String DLG_IMG_MESSAGE_WARNING

To view the source code for org.eclipse.jface.dialogs Dialog DLG_IMG_MESSAGE_WARNING.

Click Source Link

Document

Image registry key for info message image (value "dialog_messasge_warning_image").

Usage

From source file:org.kalypso.contribs.eclipse.jface.wizard.view.WizardView.java

License:Open Source License

/**
 * Sets the message for this dialog with an indication of what type of message it is.
 * <p>//from  www .j  ava  2 s.co  m
 * The valid message types are one of <code>NONE</code>,<code>INFORMATION</code>,<code>WARNING</code>, or
 * <code>ERROR</code>.
 * </p>
 * <p>
 * Note that for backward compatibility, a message of type <code>ERROR</code> is different than an error message (set
 * using <code>setErrorMessage</code>). An error message overrides the current message until the error message is
 * cleared. This method replaces the current message and does not affect the error message.
 * </p>
 *
 * @param newMessage
 *          the message, or <code>null</code> to clear the message
 * @param newType
 *          the message type
 * @since 2.0
 */
public void setMessage(final String newMessage, final int newType) {
    Image newImage = null;
    if (newMessage != null) {
        switch (newType) {
        case IMessageProvider.NONE:
            break;
        case IMessageProvider.INFORMATION:
            newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
            break;
        case IMessageProvider.WARNING:
            newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
            break;
        case IMessageProvider.ERROR:
            newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
            break;
        }
    }
    showMessage(newMessage, newImage);
}

From source file:org.mailster.gui.prefs.widgets.DialogMessageArea.java

License:Open Source License

/**
 * Show the new message in the message text and update the image. Base the
 * background color on whether or not there are errors.
 * //  ww  w.  ja  v  a 2s .co  m
 * @param newMessage The new value for the message
 * @param newType One of the IMessageProvider constants. If newType is
 *            IMessageProvider.NONE show the title.
 * @see org.eclipse.jface.dialogs.IMessageProvider
 */
public void updateText(String newMessage, int newType) {
    Image newImage = null;
    switch (newType) {
    case IMessageProvider.NONE:
        if (newMessage == null) {
            this.restoreTitle();
        } else {
            this.showTitle(newMessage, null);
        }
        return;
    case IMessageProvider.INFORMATION:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
        break;
    case IMessageProvider.WARNING:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
        break;
    case IMessageProvider.ERROR:
        newImage = JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
        break;
    }

    this.messageComposite.setVisible(true);
    this.titleLabel.setVisible(false);
    // Any more updates required?
    // If the message text equals the tooltip (i.e. non-shortened text is
    // the same)
    // and shortened text is the same (i.e. not a resize)
    // and the image is the same then nothing to do
    String shortText = Dialog.shortenText(newMessage, messageText);
    if (newMessage.equals(messageText.getToolTipText()) && newImage == messageImageLabel.getImage()
            && shortText.equals(messageText.getText())) {
        return;
    }
    this.messageImageLabel.setImage(newImage);
    this.messageText.setText(Dialog.shortenText(newMessage, messageText));
    this.messageText.setToolTipText(newMessage);
    this.lastMessageText = newMessage;
}

From source file:org.seasar.s2junit4plugin.wizard.NewS2JUnit4TestCaseWizardPageOne.java

License:Apache License

/**
 * Creates the controls for the JUnit 4 toggle control. Expects a <code>GridLayout</code> with 
 * at least 3 columns.// w w  w.j ava  2  s .  com
 * 
 * @param composite the parent composite
 * @param nColumns number of columns to span
 * 
 * @since 3.2
 */
protected void createBuildPathConfigureControls(Composite composite, int nColumns) {
    Composite inner = new Composite(composite, SWT.NONE);
    inner.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, nColumns, 1));
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    inner.setLayout(layout);

    fImage = new Label(inner, SWT.NONE);
    fImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
    fImage.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false, 1, 1));

    fLink = new Link(inner, SWT.WRAP);
    fLink.setText("\n\n"); //$NON-NLS-1$
    fLink.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            performBuildpathConfiguration(e.text);
        }
    });
    GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, true, false, 1, 1);
    gd.widthHint = convertWidthInCharsToPixels(60);
    fLink.setLayoutData(gd);
    updateBuildPathMessage();
}

From source file:org.springframework.ide.eclipse.wizard.ui.BeanChildDialog.java

License:Open Source License

protected void updateMessage() {
    String message = getMessage();
    if (message != null) {
        if (BeanWizard.getIgnoreError()) {
            messageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
        } else {//w ww . j a va  2s .c o m
            messageLabel.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR));
        }
        messageLabel.setText(message);
    } else {
        messageLabel.setImage(null);
        messageLabel.setText(getDefaultMessage());
    }

    messageLabel.redraw();

}

From source file:org.summer.sdt.internal.ui.dialogs.SortMembersMessageDialog.java

License:Open Source License

@Override
protected Control createMessageArea(Composite parent) {
    initializeDialogUnits(parent);/* w w w  .ja v  a2s .  com*/

    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));

    createLinkControl(messageComposite);

    fNotSortAllRadio.doFillIntoGrid(messageComposite, 1);
    LayoutUtil.setHorizontalIndent(fNotSortAllRadio.getSelectionButton(null));

    fSortAllRadio.doFillIntoGrid(messageComposite, 1);
    LayoutUtil.setHorizontalIndent(fSortAllRadio.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);
    final Label imageLabel1 = new Label(warningComposite, SWT.LEFT | SWT.WRAP);
    imageLabel1.setImage(image);
    imageLabel1.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 1, 1));

    final Label label = new Label(warningComposite, SWT.WRAP);
    label.setText(DialogsMessages.SortMembersMessageDialog_sort_warning_label);
    GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false, 1, 1);
    gridData.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
    label.setLayoutData(gridData);
    label.setFont(warningComposite.getFont());

    fNotSortAllRadio.setDialogFieldListener(new IDialogFieldListener() {
        public void dialogFieldChanged(DialogField field) {
            imageLabel1.setEnabled(!fNotSortAllRadio.isSelected());
            label.setEnabled(!fNotSortAllRadio.isSelected());
        }
    });
    imageLabel1.setEnabled(!fNotSortAllRadio.isSelected());
    label.setEnabled(!fNotSortAllRadio.isSelected());

    return messageComposite;
}

From source file:org.summer.sdt.internal.ui.preferences.ComplianceConfigurationBlock.java

License:Open Source License

private Composite createComplianceTabContent(Composite folder) {

    String[] values3456 = new String[] { VERSION_1_3, VERSION_1_4, VERSION_1_5, VERSION_1_6, VERSION_1_7,
            VERSION_1_8 };/*from  w ww .j  a v  a 2s .  c om*/
    String[] values3456Labels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_version13,
            PreferencesMessages.ComplianceConfigurationBlock_version14,
            PreferencesMessages.ComplianceConfigurationBlock_version15,
            PreferencesMessages.ComplianceConfigurationBlock_version16,
            PreferencesMessages.ComplianceConfigurationBlock_version17,
            PreferencesMessages.ComplianceConfigurationBlock_version18, };

    final ScrolledPageContent sc1 = new ScrolledPageContent(folder);
    Composite composite = sc1.getBody();
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    composite.setLayout(layout);

    fControlsComposite = new Composite(composite, SWT.NONE);
    fControlsComposite.setFont(composite.getFont());
    fControlsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));

    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 1;
    fControlsComposite.setLayout(layout);

    int nColumns = 3;

    layout = new GridLayout();
    layout.numColumns = nColumns;

    Group group = new Group(fControlsComposite, SWT.NONE);
    group.setFont(fControlsComposite.getFont());
    group.setText(PreferencesMessages.ComplianceConfigurationBlock_compliance_group_label);
    group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    group.setLayout(layout);

    String[] defaultUserValues = new String[] { DEFAULT_CONF, USER_CONF };

    Control[] otherChildren = group.getChildren();
    if (fProject != null) {
        String label = PreferencesMessages.ComplianceConfigurationBlock_compliance_follows_EE_label;
        int widthHint = fPixelConverter.convertWidthInCharsToPixels(40);
        addCheckBoxWithLink(group, label, INTR_COMPLIANCE_FOLLOWS_EE, defaultUserValues, 0, widthHint,
                new SelectionAdapter() {
                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        openBuildPathPropertyPage();
                    }
                });
    }

    Control[] allChildren = group.getChildren();
    fComplianceFollowsEEControls.addAll(Arrays.asList(allChildren));
    fComplianceFollowsEEControls.removeAll(Arrays.asList(otherChildren));
    otherChildren = allChildren;

    String label = PreferencesMessages.ComplianceConfigurationBlock_compiler_compliance_label;
    addComboBox(group, label, PREF_COMPLIANCE, values3456, values3456Labels, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_default_settings_label;
    addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, defaultUserValues, 0);

    allChildren = group.getChildren();
    fComplianceControls.addAll(Arrays.asList(allChildren));
    fComplianceControls.removeAll(Arrays.asList(otherChildren));
    otherChildren = allChildren;

    int indent = LayoutUtil.getIndent();

    String[] versions = new String[] { VERSION_CLDC_1_1, VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4,
            VERSION_1_5, VERSION_1_6, VERSION_1_7, VERSION_1_8 };
    String[] versionsLabels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_versionCLDC11,
            PreferencesMessages.ComplianceConfigurationBlock_version11,
            PreferencesMessages.ComplianceConfigurationBlock_version12,
            PreferencesMessages.ComplianceConfigurationBlock_version13,
            PreferencesMessages.ComplianceConfigurationBlock_version14,
            PreferencesMessages.ComplianceConfigurationBlock_version15,
            PreferencesMessages.ComplianceConfigurationBlock_version16,
            PreferencesMessages.ComplianceConfigurationBlock_version17,
            PreferencesMessages.ComplianceConfigurationBlock_version18 };

    boolean showJsr14 = ComplianceConfigurationBlock.VERSION_JSR14
            .equals(getValue(PREF_CODEGEN_TARGET_PLATFORM));
    if (showJsr14) {
        versions = append(versions, ComplianceConfigurationBlock.VERSION_JSR14);
        versionsLabels = append(versionsLabels, ComplianceConfigurationBlock.VERSION_JSR14);
    }

    label = PreferencesMessages.ComplianceConfigurationBlock_codegen_targetplatform_label;
    addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, versions, versionsLabels, indent);

    label = PreferencesMessages.ComplianceConfigurationBlock_source_compatibility_label;
    addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values3456, values3456Labels, indent);

    String[] errorWarningIgnore = new String[] { ERROR, WARNING, IGNORE };

    String[] errorWarningIgnoreLabels = new String[] { PreferencesMessages.ComplianceConfigurationBlock_error,
            PreferencesMessages.ComplianceConfigurationBlock_warning,
            PreferencesMessages.ComplianceConfigurationBlock_ignore };

    label = PreferencesMessages.ComplianceConfigurationBlock_pb_assert_as_identifier_label;
    addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels,
            indent);

    label = PreferencesMessages.ComplianceConfigurationBlock_pb_enum_as_identifier_label;
    addComboBox(group, label, PREF_PB_ENUM_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);

    allChildren = group.getChildren();
    fComplianceChildControls.addAll(Arrays.asList(allChildren));
    fComplianceChildControls.removeAll(Arrays.asList(otherChildren));

    layout = new GridLayout();
    layout.numColumns = nColumns;

    group = new Group(fControlsComposite, SWT.NONE);
    group.setFont(fControlsComposite.getFont());
    group.setText(PreferencesMessages.ComplianceConfigurationBlock_classfiles_group_label);
    group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    group.setLayout(layout);

    String[] generateValues = new String[] { GENERATE, DO_NOT_GENERATE };
    String[] enableDisableValues = new String[] { ENABLED, DISABLED };

    label = PreferencesMessages.ComplianceConfigurationBlock_variable_attr_label;
    addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_line_number_attr_label;
    addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_source_file_attr_label;
    addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_codegen_unused_local_label;
    addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_codegen_inline_jsr_bytecode_label;
    addCheckBox(group, label, PREF_CODEGEN_INLINE_JSR_BYTECODE, enableDisableValues, 0);

    label = PreferencesMessages.ComplianceConfigurationBlock_codegen_method_parameters_attr;
    addCheckBox(group, label, PREF_CODEGEN_METHOD_PARAMETERS_ATTR, generateValues, 0);

    Composite infoComposite = new Composite(fControlsComposite, SWT.NONE);
    infoComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    infoComposite.setLayout(new GridLayout(2, false));

    fJRE50InfoImage = new Label(infoComposite, SWT.NONE);
    fJRE50InfoImage.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
    GridData gd = new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false);
    fJRE50InfoImage.setLayoutData(gd);

    fJRE50InfoText = new Link(infoComposite, SWT.WRAP);
    fJRE50InfoText.setFont(composite.getFont());
    // set a text: not the real one, just for layouting
    fJRE50InfoText.setText(
            Messages.format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project,
                    new String[] { getVersionLabel(VERSION_1_3), getVersionLabel(VERSION_1_3) }));
    fJRE50InfoText.setVisible(false);
    fJRE50InfoText.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
            if ("1".equals(e.text)) { //$NON-NLS-1$
                openJREInstallPreferencePage(false);
            } else if ("2".equals(e.text)) { //$NON-NLS-1$
                openJREInstallPreferencePage(true);
            } else {
                openBuildPathPropertyPage();
            }
        }

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }
    });
    gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.widthHint = fPixelConverter.convertWidthInCharsToPixels(50);
    fJRE50InfoText.setLayoutData(gd);
    validateComplianceStatus();

    return sc1;
}

From source file:org.summer.sdt.internal.ui.preferences.ComplianceConfigurationBlock.java

License:Open Source License

private void validateComplianceStatus() {
    if (fJRE50InfoText != null && !fJRE50InfoText.isDisposed()) {
        boolean isVisible = false;
        String compliance = getStoredValue(PREF_COMPLIANCE); // get actual value
        IVMInstall install = null;/*ww  w. j av  a 2s . c  o  m*/
        if (fProject != null) { // project specific settings: only test if a 50 JRE is installed
            try {
                install = JavaRuntime.getVMInstall(JavaCore.create(fProject));
            } catch (CoreException e) {
                JavaPlugin.log(e);
            }
        } else {
            install = JavaRuntime.getDefaultVMInstall();
        }
        if (install instanceof IVMInstall2) {
            String compilerCompliance = JavaModelUtil.getCompilerCompliance((IVMInstall2) install, compliance);
            if (!compilerCompliance.equals(compliance)) { // Discourage using compiler with version other than compliance
                String[] args = { getVersionLabel(compliance), getVersionLabel(compilerCompliance) };
                if (fProject == null) {
                    fJRE50InfoText.setText(Messages
                            .format(PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info, args));
                } else {
                    fJRE50InfoText.setText(Messages.format(
                            PreferencesMessages.ComplianceConfigurationBlock_jrecompliance_info_project, args));
                }
                isVisible = true;
            }
        }

        //         String source= getValue(PREF_SOURCE_COMPATIBILITY);
        //         if (VERSION_1_8.equals(source)) {
        //            fJRE50InfoText.setText("This is an implementation of an early-draft specification developed under the Java Community Process (JCP) and is made available for testing and evaluation purposes only. The code is not compatible with any specification of the JCP."); //$NON-NLS-1$
        //            isVisible= true;
        //         }

        fJRE50InfoText.setVisible(isVisible);
        fJRE50InfoImage.setImage(isVisible ? JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING) : null);
        fJRE50InfoImage.getParent().layout();
    }
}

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 . j a  va  2s.  co  m*/

    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();/*from   ww w.j av a2s .  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;
}