/* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createMessageArea(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createMessageArea(Composite parent) {
    initializeDialogUnits(parent);

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

    int indent = convertWidthInCharsToPixels(3);

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

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

    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;
  }
Exemplo n.º 2
0
    @Override
    protected void createContents(Composite topControl) {
      this.topControl = topControl;

      icon =
          SWTFactoryUtil.createLabel(
              topControl, SWT.LEFT, "", GridDataFactory.swtDefaults().create());
      icon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_INFO));

      hintText =
          SWTFactoryUtil.createLink(
              topControl, SWT.LEFT, "", GridDataFactory.fillDefaults().grab(true, false).create());
    }
Exemplo n.º 3
0
    @Override
    protected void createContents(Composite parent) {
      super.createContents(parent);

      icon.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));

      hintText.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              openPreferencePage();
            }
          });
    }
  @Override
  protected void doCreatePreferences(Composite composite, int numColumns) {

    Group group =
        createGroup(
            numColumns, composite, CleanUpMessages.CodeFormatingTabPage_GroupName_Formatter);

    if (!isSaveAction()) {
      final CheckboxPreference format =
          createCheckboxPref(
              group,
              numColumns,
              CleanUpMessages.CodeFormatingTabPage_CheckboxName_FormatSourceCode,
              CleanUpConstants.FORMAT_SOURCE_CODE,
              CleanUpModifyDialog.FALSE_TRUE);
      registerPreference(format);
      format.addObserver(
          new Observer() {
            @Override
            public void update(Observable o, Object arg) {
              fPreview.setFormat(format.getChecked());
              fPreview.update();
            }
          });
    }

    final CheckboxPreference whiteSpace =
        createCheckboxPref(
            group,
            numColumns,
            CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_checkbox_text,
            CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES,
            CleanUpModifyDialog.FALSE_TRUE);
    intent(group);
    final RadioPreference allPref =
        createRadioPref(
            group,
            1,
            CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_all_radio,
            CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_ALL,
            CleanUpModifyDialog.FALSE_TRUE);
    final RadioPreference ignoreEmptyPref =
        createRadioPref(
            group,
            1,
            CleanUpMessages.CodeFormatingTabPage_RemoveTrailingWhitespace_ignoreEmpty_radio,
            CleanUpConstants.FORMAT_REMOVE_TRAILING_WHITESPACES_IGNORE_EMPTY,
            CleanUpModifyDialog.FALSE_TRUE);
    registerSlavePreference(whiteSpace, new RadioPreference[] {allPref, ignoreEmptyPref});

    final CheckboxPreference correctIndentation =
        createCheckboxPref(
            group,
            numColumns,
            CleanUpMessages.CodeFormatingTabPage_correctIndentation_checkbox_text,
            CleanUpConstants.FORMAT_CORRECT_INDENTATION,
            CleanUpModifyDialog.FALSE_TRUE);
    registerPreference(correctIndentation);
    correctIndentation.addObserver(
        new Observer() {
          @Override
          public void update(Observable o, Object arg) {
            fPreview.setCorrectIndentation(correctIndentation.getChecked());
            fPreview.update();
          }
        });

    if (!isSaveAction()) {
      createLabel(
              numColumns, group, CleanUpMessages.CodeFormatingTabPage_FormatterSettings_Description)
          .setFont(composite.getFont());

      Group importsGroup =
          createGroup(
              numColumns, composite, CleanUpMessages.CodeFormatingTabPage_Imports_GroupName);
      CheckboxPreference organizeImports =
          createCheckboxPref(
              importsGroup,
              numColumns,
              CleanUpMessages.CodeFormatingTabPage_OrganizeImports_CheckBoxLable,
              CleanUpConstants.ORGANIZE_IMPORTS,
              CleanUpModifyDialog.FALSE_TRUE);
      registerPreference(organizeImports);
      createLabel(
              numColumns,
              importsGroup,
              CleanUpMessages.CodeFormatingTabPage_OrganizeImportsSettings_Description)
          .setFont(composite.getFont());
    }

    Group sortMembersGroup =
        createGroup(
            numColumns, composite, CleanUpMessages.CodeFormatingTabPage_SortMembers_GroupName);

    final CheckboxPreference sortMembersPref =
        createCheckboxPref(
            sortMembersGroup,
            numColumns,
            CleanUpMessages.CodeFormatingTabPage_SortMembers_CheckBoxLabel,
            CleanUpConstants.SORT_MEMBERS,
            CleanUpModifyDialog.FALSE_TRUE);
    intent(sortMembersGroup);
    final RadioPreference sortAllPref =
        createRadioPref(
            sortMembersGroup,
            numColumns - 1,
            CleanUpMessages.CodeFormatingTabPage_SortMembersFields_CheckBoxLabel,
            CleanUpConstants.SORT_MEMBERS_ALL,
            CleanUpModifyDialog.FALSE_TRUE);
    intent(sortMembersGroup);
    final Button nullRadio = new Button(sortMembersGroup, SWT.RADIO);
    nullRadio.setText(CleanUpMessages.CodeFormatingTabPage_SortMembersExclusive_radio0);
    nullRadio.setLayoutData(createGridData(numColumns - 1, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
    nullRadio.setFont(composite.getFont());
    intent(sortMembersGroup);
    final Label warningImage = new Label(sortMembersGroup, SWT.LEFT | SWT.WRAP);
    warningImage.setImage(Dialog.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
    warningImage.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
    final Label warningLabel =
        createLabel(
            numColumns - 2,
            sortMembersGroup,
            CleanUpMessages.CodeFormatingTabPage_SortMembersSemanticChange_warning);

    registerSlavePreference(sortMembersPref, new RadioPreference[] {sortAllPref});
    sortMembersPref.addObserver(
        new Observer() {
          @Override
          public void update(Observable o, Object arg) {
            nullRadio.setEnabled(sortMembersPref.getChecked());

            boolean warningEnabled = sortMembersPref.getChecked() && sortAllPref.getChecked();
            warningImage.setEnabled(warningEnabled);
            warningLabel.setEnabled(warningEnabled);
          }
        });
    sortAllPref.addObserver(
        new Observer() {
          @Override
          public void update(Observable o, Object arg) {
            boolean warningEnabled = sortMembersPref.getChecked() && sortAllPref.getChecked();
            warningImage.setEnabled(warningEnabled);
            warningLabel.setEnabled(warningEnabled);
          }
        });
    nullRadio.setEnabled(sortMembersPref.getChecked());
    nullRadio.setSelection(
        CleanUpOptions.FALSE.equals(fValues.get(CleanUpConstants.SORT_MEMBERS_ALL)));
    boolean warningEnabled = sortMembersPref.getChecked() && sortAllPref.getChecked();
    warningImage.setEnabled(warningEnabled);
    warningLabel.setEnabled(warningEnabled);

    createLabel(
        numColumns, sortMembersGroup, CleanUpMessages.CodeFormatingTabPage_SortMembers_Description);
  }