/** Update the UI based on the values presently stored in the keys. */
 @Override
 protected void updateControls() {
   if (fAptEnabledField != null) {
     boolean aptEnabled = Boolean.valueOf(getValue(KEY_APTENABLED)).booleanValue();
     fAptEnabledField.setSelection(aptEnabled);
   }
   boolean reconcileEnabled = Boolean.valueOf(getValue(KEY_RECONCILEENABLED)).booleanValue();
   fReconcileEnabledField.setSelection(reconcileEnabled);
   String str = getValue(KEY_GENSRCDIR);
   fGenSrcDirField.setText(str == null ? "" : str); // $NON-NLS-1$
 }
  /** Update the values stored in the keys based on the UI. */
  protected final void updateModel(DialogField field) {

    if (fAptEnabledField != null && field == fAptEnabledField) {
      String newVal = String.valueOf(fAptEnabledField.isSelected());
      setValue(KEY_APTENABLED, newVal);
    } else if (field == fGenSrcDirField) {
      String newVal = fGenSrcDirField.getText();
      setValue(KEY_GENSRCDIR, newVal);
    } else if (field == fReconcileEnabledField) {
      String newVal = String.valueOf(fReconcileEnabledField.isSelected());
      setValue(KEY_RECONCILEENABLED, newVal);
    }
    validateSettings(null, null, null); // params are ignored
  }
  public AptConfigurationBlock(
      IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container) {
    super(context, project, getAllKeys(), container);

    fJProj = JavaCore.create(project);

    UpdateAdapter adapter = new UpdateAdapter();

    if (fJProj != null) {
      fAptEnabledField = new SelectionButtonDialogField(SWT.CHECK);
      fAptEnabledField.setDialogFieldListener(adapter);
      fAptEnabledField.setLabelText(Messages.AptConfigurationBlock_enable);
    } else {
      fAptEnabledField = null;
    }

    fReconcileEnabledField = new SelectionButtonDialogField(SWT.CHECK);
    fReconcileEnabledField.setDialogFieldListener(adapter);
    fReconcileEnabledField.setLabelText(Messages.AptConfigurationBlock_enableReconcileProcessing);

    fGenSrcDirField = new StringDialogField();
    fGenSrcDirField.setDialogFieldListener(adapter);
    fGenSrcDirField.setLabelText(Messages.AptConfigurationBlock_generatedSrcDir);

    String[] buttons =
        new String[] {
          Messages.AptConfigurationBlock_add,
          Messages.AptConfigurationBlock_edit,
          Messages.AptConfigurationBlock_remove
        };
    ProcessorOptionsAdapter optionsAdapter = new ProcessorOptionsAdapter();
    fProcessorOptionsField =
        new ListDialogField<>(optionsAdapter, buttons, new ProcessorOptionsLabelProvider());
    fProcessorOptionsField.setDialogFieldListener(optionsAdapter);
    fProcessorOptionsField.setRemoveButtonIndex(IDX_REMOVE);
    String[] columnHeaders =
        new String[] {Messages.AptConfigurationBlock_key, Messages.AptConfigurationBlock_value};
    fProcessorOptionsField.setTableColumns(
        new ListDialogField.ColumnsDescription(columnHeaders, true));
    fProcessorOptionsField.setViewerComparator(new ProcessorOptionSorter());
    fProcessorOptionsField.setLabelText(Messages.AptConfigurationBlock_options);

    updateControls();

    if (fProcessorOptionsField.getSize() > 0) {
      fProcessorOptionsField.selectFirstElement();
    } else {
      fProcessorOptionsField.enableButton(IDX_EDIT, false);
    }
  }
    public Control createControl(Composite composite) {
      final int numColumns = 3;

      final Group group = new Group(composite, SWT.NONE);
      group.setLayout(initGridLayout(new GridLayout(numColumns, false), true));
      group.setText("Contents");

      fWorkspaceRadio.doFillIntoGrid(group, numColumns);
      fExternalRadio.doFillIntoGrid(group, numColumns);
      fLocation.doFillIntoGrid(group, numColumns);
      LayoutUtil.setHorizontalGrabbing(fLocation.getTextControl(null));

      return group;
    }
 /** Bugzilla 136498: when project-specific settings are enabled, force APT to be enabled. */
 @Override
 public void useProjectSpecificSettings(boolean enable) {
   super.useProjectSpecificSettings(enable);
   if (enable ^ fPerProjSettingsEnabled) {
     fAptEnabledField.setSelection(enable);
     fPerProjSettingsEnabled = enable;
   }
 }
  @Override
  protected Control createContents(Composite parent) {
    setShell(parent.getShell());

    fPixelConverter = new PixelConverter(parent);
    int indent = fPixelConverter.convertWidthInCharsToPixels(4);

    fBlockControl = new Composite(parent, SWT.NONE);
    fBlockControl.setFont(parent.getFont());

    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 0;

    fBlockControl.setLayout(layout);

    DialogField[] fields =
        fAptEnabledField != null
            ? new DialogField[] {
              fAptEnabledField, fReconcileEnabledField, fGenSrcDirField, fProcessorOptionsField,
            }
            : new DialogField[] {
              fReconcileEnabledField, fGenSrcDirField, fProcessorOptionsField,
            };
    LayoutUtil.doDefaultLayout(fBlockControl, fields, true, SWT.DEFAULT, SWT.DEFAULT);
    LayoutUtil.setHorizontalGrabbing(fProcessorOptionsField.getListControl(null));

    GridData reconcileGD =
        (GridData) fReconcileEnabledField.getSelectionButton(parent).getLayoutData();
    reconcileGD.horizontalIndent = indent;
    fReconcileEnabledField.getSelectionButton(parent).setLayoutData(reconcileGD);

    Label description = new Label(fBlockControl, SWT.WRAP);
    description.setText(Messages.AptConfigurationBlock_classpathAddedAutomaticallyNote);
    GridData gdLabel = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    gdLabel.horizontalSpan = 2;
    gdLabel.widthHint = fPixelConverter.convertWidthInCharsToPixels(60);
    description.setLayoutData(gdLabel);

    Dialog.applyDialogFont(fBlockControl);

    validateSettings(null, null, null);

    return fBlockControl;
  }
 public void setLocation(IPath path) {
   fWorkspaceRadio.setSelection(path == null);
   if (path != null) {
     fLocation.setText(path.toOSString());
   } else {
     fLocation.setText(getDefaultPath(fNameGroup.getName()));
   }
   fireEvent();
 }
  /* (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;
  }
  @Override
  protected void saveSettings() {
    List<ProcessorOption> elements;
    boolean isProjSpecificDisabled = (fJProj != null) && !fBlockControl.isEnabled();
    if (isProjSpecificDisabled) {
      // We're in a project properties pane but the entire configuration
      // block control is disabled.  That means the per-project settings checkbox
      // is unchecked.  To save that state, we'll clear the proc options map.
      elements = Collections.<ProcessorOption>emptyList();
    } else {
      elements = getListElements();
    }
    saveProcessorOptions(elements);
    super.saveSettings();
    if (null != fAptProject) {
      if (isProjSpecificDisabled) { // compare against workspace defaults
        if (!fOriginalGenSrcDir.equals(AptConfig.getGenSrcDir(null))) {
          fAptProject.preferenceChanged(AptPreferenceConstants.APT_GENSRCDIR);
        }
        if (fOriginalAptEnabled != AptConfig.isEnabled(null)) {
          // make JDT "processingEnabled" setting track APT "enabled" setting.
          setJDTProcessAnnotationsSetting(fAptEnabledField.isSelected());

          fAptProject.preferenceChanged(AptPreferenceConstants.APT_ENABLED);
        }
        if (fOriginalReconcileEnabled != AptConfig.shouldProcessDuringReconcile(null)) {
          fAptProject.preferenceChanged(AptPreferenceConstants.APT_RECONCILEENABLED);
        }
      } else { // compare against current settings
        if (!fOriginalGenSrcDir.equals(fGenSrcDirField.getText()))
          fAptProject.preferenceChanged(AptPreferenceConstants.APT_GENSRCDIR);
        boolean isAptEnabled = fAptEnabledField.isSelected();
        if (fOriginalAptEnabled != isAptEnabled) {
          // make JDT "processingEnabled" setting track APT "enabled" setting.
          setJDTProcessAnnotationsSetting(isAptEnabled);

          fAptProject.preferenceChanged(AptPreferenceConstants.APT_ENABLED);
        }
        if (fOriginalReconcileEnabled != fReconcileEnabledField.isSelected())
          fAptProject.preferenceChanged(AptPreferenceConstants.APT_RECONCILEENABLED);
      }
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener
  * #dialogFieldChanged(org.eclipse.jdt.
  * internal.ui.wizards.dialogfields.DialogField)
  */
 public void dialogFieldChanged(DialogField field) {
   if (field == fWorkspaceRadio) {
     final boolean checked = fWorkspaceRadio.isSelected();
     if (checked) {
       fPreviousExternalLocation = fLocation.getText();
       fLocation.setText(getDefaultPath(fNameGroup.getName()));
     } else {
       fLocation.setText(fPreviousExternalLocation);
     }
   }
   fireEvent();
 }
 /*
  * At workspace level, don't ask for a rebuild.
  */
 @Override
 protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
   if (workspaceSettings) return null;
   // if the only thing that changed was the reconcile setting, return null: a rebuild is not
   // necessary
   if (fOriginalGenSrcDir.equals(fGenSrcDirField.getText())) {
     if (fOriginalAptEnabled == fAptEnabledField.isSelected()) {
       if (!procOptionsChanged()) {
         return null;
       }
     }
   }
   return super.getFullBuildDialogStrings(workspaceSettings);
 }
  public SortMembersMessageDialog(Shell parentShell) {
    super(
        OPTIONAL_ID,
        parentShell,
        DialogsMessages.SortMembersMessageDialog_dialog_title,
        null,
        new String(),
        INFORMATION,
        new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL},
        0);

    fDialogSettings = JavaPlugin.getDefault().getDialogSettings();

    boolean isSortAll = fDialogSettings.getBoolean(DIALOG_SETTINGS_SORT_ALL);

    fNotSortAllRadio = new SelectionButtonDialogField(SWT.RADIO);
    fNotSortAllRadio.setLabelText(
        DialogsMessages.SortMembersMessageDialog_do_not_sort_fields_label);
    fNotSortAllRadio.setSelection(!isSortAll);

    fSortAllRadio = new SelectionButtonDialogField(SWT.RADIO);
    fSortAllRadio.setLabelText(DialogsMessages.SortMembersMessageDialog_sort_all_label);
    fSortAllRadio.setSelection(isSortAll);
  }
    public LocationGroup() {
      fWorkspaceRadio = new SelectionButtonDialogField(SWT.RADIO);
      fWorkspaceRadio.setDialogFieldListener(this);
      fWorkspaceRadio.setLabelText("Use &default location");

      fExternalRadio = new SelectionButtonDialogField(SWT.RADIO);
      fExternalRadio.setLabelText("Use &external location");

      fLocation = new StringButtonDialogField(this);
      fLocation.setDialogFieldListener(this);
      fLocation.setLabelText(
          NewWizardMessages.NewJavaProjectWizardPageOne_LocationGroup_locationLabel_desc);
      fLocation.setButtonLabel(
          NewWizardMessages.NewJavaProjectWizardPageOne_LocationGroup_browseButton_desc);

      fExternalRadio.attachDialogField(fLocation);

      fWorkspaceRadio.setSelection(true);
      fExternalRadio.setSelection(false);

      fPreviousExternalLocation = ""; // $NON-NLS-1$
    }
 public boolean isNotSortingFieldsEnabled() {
   return fNotSortAllRadio.isSelected();
 }
 /* (non-Javadoc)
  * @see org.eclipse.jface.dialogs.Dialog#close()
  */
 @Override
 public boolean close() {
   fDialogSettings.put(DIALOG_SETTINGS_SORT_ALL, fSortAllRadio.isSelected());
   return super.close();
 }
 public boolean isWorkspaceRadioSelected() {
   return fWorkspaceRadio.isSelected();
 }