org.eclipse.jdt.apt.ui_3.3.300.v20110305-1450

16:44:59.834 INFO  jd.cli.Main - Decompiling org.eclipse.jdt.apt.ui_3.3.300.v20110305-1450.jar
package org.eclipse.jdt.apt.ui.internal;

import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class AptUIPlugin
  extends AbstractUIPlugin
{
  private static AptUIPlugin plugin;
  public static final String PLUGIN_ID = "org.eclipse.jdt.apt.ui";
  public static final int STATUS_EXCEPTION = 1;
  public static final int INTERNAL_ERROR = 2;
  
  public AptUIPlugin()
  {
    plugin = this;
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    super.stop(context);
    plugin = null;
  }
  
  public static AptUIPlugin getDefault()
  {
    return plugin;
  }
  
  public static IWorkbenchWindow getActiveWorkbenchWindow()
  {
    return getDefault().getWorkbench().getActiveWorkbenchWindow();
  }
  
  public static Shell getActiveWorkbenchShell()
  {
    IWorkbenchWindow window = getActiveWorkbenchWindow();
    if (window != null) {
      return window.getShell();
    }
    return null;
  }
  
  public static ImageDescriptor getImageDescriptor(String path)
  {
    return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.jdt.apt.ui", path);
  }
  
  public static void log(IStatus status)
  {
    getDefault().getLog().log(status);
  }
  
  public static void log(Throwable e)
  {
    log(new Status(4, "org.eclipse.jdt.apt.ui", 1, Messages.AptUIPlugin_exceptionThrown, e));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.AptUIPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal;

import org.eclipse.osgi.util.NLS;

public class Messages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.jdt.apt.ui.messages";
  public static String AptUIPlugin_exceptionThrown;
  
  static
  {
    NLS.initializeMessages("org.eclipse.jdt.apt.ui.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;

class AdvancedFactoryPathOptionsDialog$FieldAdapter
  implements IDialogFieldListener
{
  private AdvancedFactoryPathOptionsDialog$FieldAdapter(AdvancedFactoryPathOptionsDialog paramAdvancedFactoryPathOptionsDialog) {}
  
  public void dialogFieldChanged(DialogField field) {}
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AdvancedFactoryPathOptionsDialog.FieldAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import java.io.IOException;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.jdt.apt.core.internal.util.FactoryContainer;
import org.eclipse.jdt.apt.core.internal.util.FactoryContainer.FactoryType;
import org.eclipse.jdt.apt.core.internal.util.FactoryPath.Attributes;
import org.eclipse.jdt.apt.ui.internal.util.ExceptionHandler;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.help.IWorkbenchHelpSystem;

public class AdvancedFactoryPathOptionsDialog
  extends Dialog
{
  private static final int LIST_WIDTH = 70;
  private static final int LIST_HEIGHT = 10;
  private final FactoryContainer _fc;
  private final FactoryPath.Attributes _attr;
  private SelectionButtonDialogField _batchModeField;
  private ListViewer _contentsField;
  
  public AdvancedFactoryPathOptionsDialog(Shell parent, FactoryContainer fc, FactoryPath.Attributes attr)
  {
    super(parent);
    setShellStyle(getShellStyle() | 0x10);
    _fc = fc;
    _attr = attr;
  }
  
  protected void configureShell(Shell shell)
  {
    super.configureShell(shell);
    shell.setText(Messages.AdvancedFactoryPathOptionsDialog_advancedOptions);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, "org.eclipse.jdt.apt.ui.advanced_factory_path_options_dialog_context");
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Composite dlgArea = (Composite)super.createDialogArea(parent);
    
    FieldAdapter adapter = new FieldAdapter(null);
    _batchModeField = new SelectionButtonDialogField(32);
    _batchModeField.setSelection(_attr.runInBatchMode());
    _batchModeField.setLabelText(Messages.AdvancedFactoryPathOptionsDialog_batchMode);
    _batchModeField.setDialogFieldListener(adapter);
    _batchModeField.doFillIntoGrid(dlgArea, 2);
    
    boolean isPlugin = _fc.getType() == FactoryContainer.FactoryType.PLUGIN;
    _batchModeField.setEnabled(!isPlugin);
    
    DialogField.createEmptySpace(dlgArea, 1);
    
    Label description = new Label(dlgArea, 64);
    description.setText(Messages.AdvancedFactoryPathOptionsDialog_label_processorsInThisContainer);
    GridData gdLabel = new GridData(256);
    horizontalSpan = 2;
    description.setLayoutData(gdLabel);
    
    _contentsField = new ListViewer(dlgArea, 2820);
    GridData data = new GridData(4, 4, true, true);
    heightHint = convertHeightInCharsToPixels(10);
    widthHint = convertWidthInCharsToPixels(70);
    _contentsField.getList().setLayoutData(data);
    _contentsField.getList().setFont(parent.getFont());
    try
    {
      for (Map.Entry<String, String> entry : _fc.getFactoryNames().entrySet())
      {
        String name = (String)entry.getKey();
        _contentsField.add(name);
      }
    }
    catch (IOException e)
    {
      String message = "Unable to load factory names from container [" + _fc.getId() + "]";
      ExceptionHandler.log(e, message);
    }
    _contentsField.setSelection(null, false);
    
    applyDialogFont(dlgArea);
    return dlgArea;
  }
  
  public FactoryPath.Attributes getResult()
  {
    boolean batchMode = _batchModeField.isSelected();
    return new FactoryPath.Attributes(_attr.isEnabled(), batchMode);
  }
  
  private class FieldAdapter
    implements IDialogFieldListener
  {
    private FieldAdapter() {}
    
    public void dialogFieldChanged(DialogField field) {}
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AdvancedFactoryPathOptionsDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

public class AptConfigurationBlock$ProcessorOption
{
  public String key;
  public String value;
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AptConfigurationBlock.ProcessorOption
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import java.util.Comparator;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;

class AptConfigurationBlock$ProcessorOptionSorter
  extends ViewerComparator
{
  public int compare(Viewer viewer, Object e1, Object e2)
  {
    return getComparator().compare(key, key);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AptConfigurationBlock.ProcessorOptionSorter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import java.util.List;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;

class AptConfigurationBlock$ProcessorOptionsAdapter
  implements IListAdapter<AptConfigurationBlock.ProcessorOption>, IDialogFieldListener
{
  private AptConfigurationBlock$ProcessorOptionsAdapter(AptConfigurationBlock paramAptConfigurationBlock) {}
  
  public void customButtonPressed(ListDialogField<AptConfigurationBlock.ProcessorOption> field, int index)
  {
    switch (index)
    {
    case 0: 
      AptConfigurationBlock.access$0(this$0, null);
      break;
    case 1: 
      tryToEdit(field);
    }
  }
  
  public void selectionChanged(ListDialogField<AptConfigurationBlock.ProcessorOption> field)
  {
    List<AptConfigurationBlock.ProcessorOption> selectedElements = field.getSelectedElements();
    field.enableButton(1, canEdit(field, selectedElements));
  }
  
  public void doubleClicked(ListDialogField<AptConfigurationBlock.ProcessorOption> field)
  {
    tryToEdit(field);
  }
  
  public void dialogFieldChanged(DialogField field)
  {
    this$0.updateModel(field);
  }
  
  private boolean canEdit(DialogField field, List<AptConfigurationBlock.ProcessorOption> selectedElements)
  {
    if (!field.isEnabled()) {
      return false;
    }
    return selectedElements.size() == 1;
  }
  
  private void tryToEdit(ListDialogField<AptConfigurationBlock.ProcessorOption> field)
  {
    List<AptConfigurationBlock.ProcessorOption> selection = AptConfigurationBlock.access$1(this$0);
    if (canEdit(field, selection)) {
      AptConfigurationBlock.access$0(this$0, (AptConfigurationBlock.ProcessorOption)selection.get(0));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AptConfigurationBlock.ProcessorOptionsAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;

class AptConfigurationBlock$ProcessorOptionsLabelProvider
  extends LabelProvider
  implements ITableLabelProvider
{
  private AptConfigurationBlock$ProcessorOptionsLabelProvider(AptConfigurationBlock paramAptConfigurationBlock) {}
  
  public Image getColumnImage(Object element, int columnIndex)
  {
    return null;
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    AptConfigurationBlock.ProcessorOption o = (AptConfigurationBlock.ProcessorOption)element;
    if (columnIndex == 0) {
      return key;
    }
    if (columnIndex == 1) {
      return value;
    }
    return "";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AptConfigurationBlock.ProcessorOptionsLabelProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.apt.core.internal.AptPlugin;
import org.eclipse.jdt.apt.core.internal.AptProject;
import org.eclipse.jdt.apt.core.util.AptConfig;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField.ColumnsDescription;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringDialogField;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.PixelConverter;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import org.osgi.service.prefs.BackingStoreException;

public class AptConfigurationBlock
  extends BaseConfigurationBlock
{
  private static final BaseConfigurationBlock.Key KEY_APTENABLED = getKey("org.eclipse.jdt.apt.core", "org.eclipse.jdt.apt.aptEnabled");
  private static final BaseConfigurationBlock.Key KEY_RECONCILEENABLED = getKey("org.eclipse.jdt.apt.core", "org.eclipse.jdt.apt.reconcileEnabled");
  private static final BaseConfigurationBlock.Key KEY_GENSRCDIR = getKey("org.eclipse.jdt.apt.core", "org.eclipse.jdt.apt.genSrcDir");
  private static final int IDX_ADD = 0;
  private static final int IDX_EDIT = 1;
  private static final int IDX_REMOVE = 2;
  private final IJavaProject fJProj;
  private SelectionButtonDialogField fAptEnabledField;
  private SelectionButtonDialogField fReconcileEnabledField;
  private StringDialogField fGenSrcDirField;
  private ListDialogField<ProcessorOption> fProcessorOptionsField;
  private PixelConverter fPixelConverter;
  private Composite fBlockControl;
  private Map<String, String> fOriginalProcOptions;
  private String fOriginalGenSrcDir;
  private boolean fOriginalAptEnabled;
  private boolean fOriginalReconcileEnabled;
  private boolean fPerProjSettingsEnabled;
  
  private static BaseConfigurationBlock.Key[] getAllKeys()
  {
    return new BaseConfigurationBlock.Key[] {
      KEY_APTENABLED, KEY_RECONCILEENABLED, KEY_GENSRCDIR };
  }
  
  private class ProcessorOptionsAdapter
    implements IListAdapter<AptConfigurationBlock.ProcessorOption>, IDialogFieldListener
  {
    private ProcessorOptionsAdapter() {}
    
    public void customButtonPressed(ListDialogField<AptConfigurationBlock.ProcessorOption> field, int index)
    {
      switch (index)
      {
      case 0: 
        AptConfigurationBlock.this.editOrAddProcessorOption(null);
        break;
      case 1: 
        tryToEdit(field);
      }
    }
    
    public void selectionChanged(ListDialogField<AptConfigurationBlock.ProcessorOption> field)
    {
      List<AptConfigurationBlock.ProcessorOption> selectedElements = field.getSelectedElements();
      field.enableButton(1, canEdit(field, selectedElements));
    }
    
    public void doubleClicked(ListDialogField<AptConfigurationBlock.ProcessorOption> field)
    {
      tryToEdit(field);
    }
    
    public void dialogFieldChanged(DialogField field)
    {
      updateModel(field);
    }
    
    private boolean canEdit(DialogField field, List<AptConfigurationBlock.ProcessorOption> selectedElements)
    {
      if (!field.isEnabled()) {
        return false;
      }
      return selectedElements.size() == 1;
    }
    
    private void tryToEdit(ListDialogField<AptConfigurationBlock.ProcessorOption> field)
    {
      List<AptConfigurationBlock.ProcessorOption> selection = AptConfigurationBlock.this.getListSelection();
      if (canEdit(field, selection)) {
        AptConfigurationBlock.this.editOrAddProcessorOption((AptConfigurationBlock.ProcessorOption)selection.get(0));
      }
    }
  }
  
  private static class ProcessorOptionSorter
    extends ViewerComparator
  {
    public int compare(Viewer viewer, Object e1, Object e2)
    {
      return getComparator().compare(key, key);
    }
  }
  
  private class ProcessorOptionsLabelProvider
    extends LabelProvider
    implements ITableLabelProvider
  {
    private ProcessorOptionsLabelProvider() {}
    
    public Image getColumnImage(Object element, int columnIndex)
    {
      return null;
    }
    
    public String getColumnText(Object element, int columnIndex)
    {
      AptConfigurationBlock.ProcessorOption o = (AptConfigurationBlock.ProcessorOption)element;
      if (columnIndex == 0) {
        return key;
      }
      if (columnIndex == 1) {
        return value;
      }
      return "";
    }
  }
  
  public AptConfigurationBlock(IStatusChangeListener context, IProject project, IWorkbenchPreferenceContainer container)
  {
    super(context, project, getAllKeys(), container);
    
    fJProj = JavaCore.create(project);
    
    BaseConfigurationBlock.UpdateAdapter adapter = new BaseConfigurationBlock.UpdateAdapter(this);
    if (fJProj != null)
    {
      fAptEnabledField = new SelectionButtonDialogField(32);
      fAptEnabledField.setDialogFieldListener(adapter);
      fAptEnabledField.setLabelText(Messages.AptConfigurationBlock_enable);
    }
    else
    {
      fAptEnabledField = null;
    }
    fReconcileEnabledField = new SelectionButtonDialogField(32);
    fReconcileEnabledField.setDialogFieldListener(adapter);
    fReconcileEnabledField.setLabelText(Messages.AptConfigurationBlock_enableReconcileProcessing);
    
    fGenSrcDirField = new StringDialogField();
    fGenSrcDirField.setDialogFieldListener(adapter);
    fGenSrcDirField.setLabelText(Messages.AptConfigurationBlock_generatedSrcDir);
    
    String[] buttons = {
      Messages.AptConfigurationBlock_add, 
      Messages.AptConfigurationBlock_edit, 
      Messages.AptConfigurationBlock_remove };
    
    ProcessorOptionsAdapter optionsAdapter = new ProcessorOptionsAdapter(null);
    fProcessorOptionsField = new ListDialogField(optionsAdapter, buttons, new ProcessorOptionsLabelProvider(null));
    fProcessorOptionsField.setDialogFieldListener(optionsAdapter);
    fProcessorOptionsField.setRemoveButtonIndex(2);
    String[] columnHeaders = {
      Messages.AptConfigurationBlock_key, 
      Messages.AptConfigurationBlock_value };
    
    fProcessorOptionsField.setTableColumns(new ListDialogField.ColumnsDescription(columnHeaders, true));
    fProcessorOptionsField.setViewerComparator(new ProcessorOptionSorter(null));
    fProcessorOptionsField.setLabelText(Messages.AptConfigurationBlock_options);
    
    updateControls();
    if (fProcessorOptionsField.getSize() > 0) {
      fProcessorOptionsField.selectFirstElement();
    } else {
      fProcessorOptionsField.enableButton(1, false);
    }
  }
  
  protected String[] getFullBuildDialogStrings(boolean workspaceSettings)
  {
    if (workspaceSettings) {
      return null;
    }
    if ((fOriginalGenSrcDir.equals(fGenSrcDirField.getText())) && 
      (fOriginalAptEnabled == fAptEnabledField.isSelected()) && 
      (!procOptionsChanged())) {
      return null;
    }
    return super.getFullBuildDialogStrings(workspaceSettings);
  }
  
  private List<ProcessorOption> getListElements()
  {
    return fProcessorOptionsField.getElements();
  }
  
  private List<ProcessorOption> getListSelection()
  {
    return fProcessorOptionsField.getSelectedElements();
  }
  
  private void editOrAddProcessorOption(ProcessorOption original)
  {
    ProcessorOptionInputDialog dialog = new ProcessorOptionInputDialog(getShell(), original, getListElements());
    if (dialog.open() == 0) {
      if (original != null) {
        fProcessorOptionsField.replaceElement(original, dialog.getResult());
      } else {
        fProcessorOptionsField.addElement(dialog.getResult());
      }
    }
  }
  
  protected Control createContents(Composite parent)
  {
    setShell(parent.getShell());
    
    fPixelConverter = new PixelConverter(parent);
    int indent = fPixelConverter.convertWidthInCharsToPixels(4);
    
    fBlockControl = new Composite(parent, 0);
    fBlockControl.setFont(parent.getFont());
    
    GridLayout layout = new GridLayout();
    numColumns = 2;
    marginWidth = 0;
    marginHeight = 0;
    
    fBlockControl.setLayout(layout);
    
    DialogField[] fields = 
    
      {
      fReconcileEnabledField, 
      fGenSrcDirField, fAptEnabledField != null ? new DialogField[] {fAptEnabledField, fReconcileEnabledField, fGenSrcDirField, fProcessorOptionsField } : 
      fProcessorOptionsField };
    
    LayoutUtil.doDefaultLayout(fBlockControl, fields, true, -1, -1);
    LayoutUtil.setHorizontalGrabbing(fProcessorOptionsField.getListControl(null));
    
    GridData reconcileGD = (GridData)fReconcileEnabledField.getSelectionButton(parent).getLayoutData();
    horizontalIndent = indent;
    fReconcileEnabledField.getSelectionButton(parent).setLayoutData(reconcileGD);
    
    Label description = new Label(fBlockControl, 64);
    description.setText(Messages.AptConfigurationBlock_classpathAddedAutomaticallyNote);
    GridData gdLabel = new GridData(256);
    horizontalSpan = 2;
    widthHint = fPixelConverter.convertWidthInCharsToPixels(60);
    description.setLayoutData(gdLabel);
    
    Dialog.applyDialogFont(fBlockControl);
    
    validateSettings(null, null, null);
    
    return fBlockControl;
  }
  
  protected void cacheOriginalValues()
  {
    super.cacheOriginalValues();
    fOriginalProcOptions = AptConfig.getRawProcessorOptions(fJProj);
    fOriginalGenSrcDir = AptConfig.getGenSrcDir(fJProj);
    fOriginalAptEnabled = AptConfig.isEnabled(fJProj);
    fOriginalReconcileEnabled = AptConfig.shouldProcessDuringReconcile(fJProj);
    fPerProjSettingsEnabled = hasProjectSpecificOptionsNoCache(fProject);
  }
  
  protected void initContents()
  {
    loadProcessorOptions(fJProj);
  }
  
  protected void saveSettings()
  {
    boolean isProjSpecificDisabled = (fJProj != null) && (!fBlockControl.isEnabled());
    List<ProcessorOption> elements;
    List<ProcessorOption> elements;
    if (isProjSpecificDisabled) {
      elements = Collections.emptyList();
    } else {
      elements = getListElements();
    }
    saveProcessorOptions(elements);
    super.saveSettings();
    if (fAptProject != null) {
      if (isProjSpecificDisabled)
      {
        if (!fOriginalGenSrcDir.equals(AptConfig.getGenSrcDir(null))) {
          fAptProject.preferenceChanged("org.eclipse.jdt.apt.genSrcDir");
        }
        if (fOriginalAptEnabled != AptConfig.isEnabled(null))
        {
          setJDTProcessAnnotationsSetting(fAptEnabledField.isSelected());
          
          fAptProject.preferenceChanged("org.eclipse.jdt.apt.aptEnabled");
        }
        if (fOriginalReconcileEnabled != AptConfig.shouldProcessDuringReconcile(null)) {
          fAptProject.preferenceChanged("org.eclipse.jdt.apt.reconcileEnabled");
        }
      }
      else
      {
        if (!fOriginalGenSrcDir.equals(fGenSrcDirField.getText())) {
          fAptProject.preferenceChanged("org.eclipse.jdt.apt.genSrcDir");
        }
        boolean isAptEnabled = fAptEnabledField.isSelected();
        if (fOriginalAptEnabled != isAptEnabled)
        {
          setJDTProcessAnnotationsSetting(isAptEnabled);
          
          fAptProject.preferenceChanged("org.eclipse.jdt.apt.aptEnabled");
        }
        if (fOriginalReconcileEnabled != fReconcileEnabledField.isSelected()) {
          fAptProject.preferenceChanged("org.eclipse.jdt.apt.reconcileEnabled");
        }
      }
    }
  }
  
  private void setJDTProcessAnnotationsSetting(boolean enable)
  {
    IScopeContext context = fJProj != null ? 
      new ProjectScope(fJProj.getProject()) : InstanceScope.INSTANCE;
    IEclipsePreferences node = context.getNode("org.eclipse.jdt.core");
    String value = enable ? "enabled" : "disabled";
    node.put("org.eclipse.jdt.core.compiler.processAnnotations", value);
    try
    {
      node.flush();
    }
    catch (BackingStoreException e)
    {
      AptPlugin.log(e, "Failed to save preference: org.eclipse.jdt.core.compiler.processAnnotations");
    }
  }
  
  private boolean procOptionsChanged()
  {
    Map<String, String> savedProcOptions = new HashMap(fOriginalProcOptions);
    for (ProcessorOption o : getListElements())
    {
      String savedVal = (String)savedProcOptions.get(key);
      if ((savedVal != null) && (savedVal.equals(value))) {
        savedProcOptions.remove(key);
      } else {
        return true;
      }
    }
    if (!savedProcOptions.isEmpty()) {
      return true;
    }
    return false;
  }
  
  protected boolean settingsChanged(IScopeContext currContext)
  {
    if (procOptionsChanged()) {
      return true;
    }
    return super.settingsChanged(currContext);
  }
  
  protected void validateSettings(BaseConfigurationBlock.Key changedKey, String oldValue, String newValue)
  {
    IStatus status = null;
    
    status = validateGenSrcDir();
    if (status.getSeverity() == 0) {
      status = validateProcessorOptions();
    }
    fContext.statusChanged(status);
  }
  
  private IStatus validateGenSrcDir()
  {
    String dirName = fGenSrcDirField.getText();
    if (!AptConfig.validateGenSrcDir(fJProj, dirName)) {
      return new StatusInfo(4, Messages.AptConfigurationBlock_genSrcDirMustBeValidRelativePath);
    }
    if ((fJProj != null) && (!dirName.equals(fOriginalGenSrcDir)))
    {
      IFolder folder = fJProj.getProject().getFolder(dirName);
      if ((folder != null) && (folder.exists()) && (!folder.isDerived())) {
        return new StatusInfo(2, Messages.AptConfigurationBlock_warningContentsMayBeDeleted);
      }
    }
    return new StatusInfo();
  }
  
  private IStatus validateProcessorOptions()
  {
    List<ProcessorOption> elements = getListElements();
    for (ProcessorOption o : elements) {
      if (AptConfig.isAutomaticProcessorOption(key)) {
        return new StatusInfo(2, 
          Messages.AptConfigurationBlock_warningIgnoredOptions + ": " + key);
      }
    }
    return new StatusInfo();
  }
  
  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);
  }
  
  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);
  }
  
  public void useProjectSpecificSettings(boolean enable)
  {
    super.useProjectSpecificSettings(enable);
    if ((enable ^ fPerProjSettingsEnabled))
    {
      fAptEnabledField.setSelection(enable);
      fPerProjSettingsEnabled = enable;
    }
  }
  
  private void saveProcessorOptions(List<ProcessorOption> elements)
  {
    Map<String, String> map = new LinkedHashMap(elements.size());
    for (ProcessorOption o : elements) {
      map.put(key, value.length() > 0 ? value : null);
    }
    AptConfig.setProcessorOptions(map, fJProj);
  }
  
  private void loadProcessorOptions(IJavaProject jproj)
  {
    List<ProcessorOption> options = new ArrayList();
    Map<String, String> parsedOptions = AptConfig.getRawProcessorOptions(jproj);
    for (Map.Entry<String, String> entry : parsedOptions.entrySet())
    {
      ProcessorOption o = new ProcessorOption();
      key = ((String)entry.getKey());
      if ((key != null) && (key.length() >= 1))
      {
        value = (entry.getValue() == null ? "" : (String)entry.getValue());
        options.add(o);
      }
    }
    fProcessorOptionsField.setElements(options);
  }
  
  public void performDefaults()
  {
    fPerProjSettingsEnabled = false;
    if (fJProj != null) {
      loadProcessorOptions(null);
    } else {
      fProcessorOptionsField.removeAllElements();
    }
    super.performDefaults();
  }
  
  public static class ProcessorOption
  {
    public String key;
    public String value;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AptConfigurationBlock
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.jdt.apt.ui.internal.AptUIPlugin;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;

public class AptPreferencePage
  extends BasePreferencePage
{
  private static final String PREF_ID = "org.eclipse.jdt.apt.ui.preferences.aptPreferences";
  private static final String PROP_ID = "org.eclipse.jdt.apt.ui.propertyPages.aptPreferences";
  
  public AptPreferencePage()
  {
    setPreferenceStore(AptUIPlugin.getDefault().getPreferenceStore());
    
    setDescription(Messages.AptPreferencePage_preferences);
    
    setTitle(Messages.AptPreferencePage_preferencesTitle);
  }
  
  public void createControl(Composite parent)
  {
    IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer)getContainer();
    setConfigurationBlock(new AptConfigurationBlock(getNewStatusChangedListener(), getProject(), container));
    
    super.createControl(parent);
  }
  
  protected String getContextHelpId()
  {
    return "org.eclipse.jdt.apt.ui.apt_configuration_preference_page_context";
  }
  
  protected String getPreferencePageID()
  {
    return "org.eclipse.jdt.apt.ui.preferences.aptPreferences";
  }
  
  protected String getPropertyPageID()
  {
    return "org.eclipse.jdt.apt.ui.propertyPages.aptPreferences";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.AptPreferencePage
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;

class BaseConfigurationBlock$1
  extends ExpansionAdapter
{
  BaseConfigurationBlock$1(BaseConfigurationBlock paramBaseConfigurationBlock) {}
  
  public void expansionStateChanged(ExpansionEvent e)
  {
    this$0.expandedStateChanged((ExpandableComposite)e.getSource());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;

class BaseConfigurationBlock$2
  implements SelectionListener
{
  BaseConfigurationBlock$2(BaseConfigurationBlock paramBaseConfigurationBlock) {}
  
  public void widgetDefaultSelected(SelectionEvent e) {}
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.controlChanged(widget);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

class BaseConfigurationBlock$3
  implements ModifyListener
{
  BaseConfigurationBlock$3(BaseConfigurationBlock paramBaseConfigurationBlock) {}
  
  public void modifyText(ModifyEvent e)
  {
    this$0.textChanged((Text)widget);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

public class BaseConfigurationBlock$ControlData
{
  private BaseConfigurationBlock.Key fKey;
  private String[] fValues;
  
  public BaseConfigurationBlock$ControlData(BaseConfigurationBlock.Key key, String[] values)
  {
    fKey = key;
    fValues = values;
  }
  
  public BaseConfigurationBlock.Key getKey()
  {
    return fKey;
  }
  
  public int getSelection(String value)
  {
    if (value != null) {
      for (int i = 0; i < fValues.length; i++) {
        if (value.equals(fValues[i])) {
          return i;
        }
      }
    }
    return fValues.length - 1;
  }
  
  public String getValue(boolean selection)
  {
    int index = selection ? 0 : 1;
    return fValues[index];
  }
  
  public String getValue(int index)
  {
    return fValues[index];
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock.ControlData
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.ui.preferences.IWorkingCopyManager;

public final class BaseConfigurationBlock$Key
{
  private String fKey;
  private String fQualifier;
  
  public BaseConfigurationBlock$Key(String qualifier, String key)
  {
    fQualifier = qualifier;
    fKey = key;
  }
  
  public String getName()
  {
    return fKey;
  }
  
  private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager)
  {
    IEclipsePreferences node = context.getNode(fQualifier);
    if (manager != null) {
      return manager.getWorkingCopy(node);
    }
    return node;
  }
  
  public String getQualifier()
  {
    return fQualifier;
  }
  
  public String getStoredValue(IScopeContext context, IWorkingCopyManager manager)
  {
    return getNode(context, manager).get(fKey, null);
  }
  
  public String getStoredValue(IScopeContext[] lookupOrder, boolean ignoreTopScope, IWorkingCopyManager manager)
  {
    for (int i = ignoreTopScope ? 1 : 0; i < lookupOrder.length; i++)
    {
      String value = getStoredValue(lookupOrder[i], manager);
      if (value != null) {
        return value;
      }
    }
    return null;
  }
  
  public void setStoredValue(IScopeContext context, String value, IWorkingCopyManager manager)
  {
    if (value != null) {
      getNode(context, manager).put(fKey, value);
    } else {
      getNode(context, manager).remove(fKey);
    }
  }
  
  public String toString()
  {
    return fQualifier + '/' + fKey;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock.Key
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;

public class BaseConfigurationBlock$UpdateAdapter
  implements IDialogFieldListener
{
  protected BaseConfigurationBlock$UpdateAdapter(BaseConfigurationBlock paramBaseConfigurationBlock) {}
  
  public void dialogFieldChanged(DialogField field)
  {
    this$0.updateModel(field);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jdt.apt.ui.internal.preferences.BaseConfigurationBlock.UpdateAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jdt.apt.ui.internal.preferences;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jdt.apt.core.internal.AptPlugin;
import org.eclipse.jdt.apt.core.internal.AptProject;
import org.eclipse.jdt.apt.ui.internal.util.ExceptionHandler;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.preferences.ScrolledPageContent;
import org.eclipse.jdt.internal.ui.util.CoreUtility;
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Scrollable;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.forms.events.ExpansionAdapter;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import org.eclipse.ui.preferences.IWorkingCopyManager;
import org.eclipse.ui.preferences.WorkingCopyManager;
import org.osgi.service.prefs.BackingStoreException;

public abstract class BaseConfigurationBlock
{
  private static final String SETTINGS_EXPANDED = "expanded";
  protected final Key[] fAllKeys;
  private boolean fOriginallyHadProjectSettings;
  private Map<Key, String> fDisabledProjectSettings;
  protected IScopeContext[] fLookupOrder;
  protected final IWorkingCopyManager fManager;
  protected final ArrayList<Button> fCheckBoxes;
  protected final ArrayList<Combo> fComboBoxes;
  protected final ArrayList<ExpandableComposite> fExpandedComposites;
  protected final HashMap<Scrollable, Label> fLabels;
  protected final ArrayList<Text> fTextBoxes;
  private ModifyListener fTextModifyListener;
  protected IStatusChangeListener fContext;
  private SelectionListener fSelectionListener;
  protected final IProject fProject;
  protected final AptProject fAptProject;
  private IWorkbenchPreferenceContainer fContainer;
  private Shell fShell;
  private Control fBlockControl;
  
  protected static class ControlData
  {
    private BaseConfigurationBlock.Key fKey;
    private String[] fValues;
    
    public ControlData(BaseConfigurationBlock.Key key, String[] values)
    {
      fKey = key;
      fValues = values;
    }
    
    public BaseConfigurationBlock.Key getKey()
    {
      return fKey;
    }
   
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd