org.eclipse.pde.api.tools.ui_1.0.301.v20110803_r371

ettings(null, null, null);
    fDirty = true;
    fRebuildcount = 0;
  }
  
  private void updateControls()
  {
    for (int i = 0; i < fCombos.size(); i++)
    {
      Combo combo = (Combo)fCombos.get(i);
      ControlData data = (ControlData)combo.getData();
      combo.select(data.getSelection(getValue(data.getKey())));
    }
    for (int i = fCheckBoxes.size() - 1; i >= 0; i--)
    {
      Button button = (Button)fCheckBoxes.get(i);
      ControlData data = (ControlData)button.getData();
      String currValue = getValue(data.getKey());
      button.setSelection(data.getSelection(currValue) == 0);
    }
  }
  
  private void enableControl(Control ctrl, boolean enabled)
  {
    ctrl.setEnabled(enabled);
    if ((ctrl instanceof Composite))
    {
      Composite comp = (Composite)ctrl;
      Control[] children = comp.getChildren();
      for (int i = 0; i < children.length; i++) {
        enableControl(children[i], enabled);
      }
    }
  }
  
  public void dispose()
  {
    fMainComp.getParent().dispose();
    fExpComps.clear();
    fCombos.clear();
    fCheckBoxes.clear();
  }
  
  protected void createComboControl(Composite parent, String label, Key key)
  {
    Label lbl = new Label(parent, 0);
    GridData gd = new GridData(1, 2, true, false);
    lbl.setLayoutData(gd);
    lbl.setText(label);
    Combo combo = new Combo(parent, 12);
    gd = new GridData(3, 2, false, false);
    combo.setLayoutData(gd);
    ControlData data = new ControlData(key, SEVERITIES);
    combo.setData(data);
    combo.setItems(SEVERITIES_LABELS);
    combo.addSelectionListener(selectionlistener);
    combo.select(data.getSelection(key.getStoredValue(fLookupOrder, false, fManager)));
    fCombos.add(combo);
  }
  
  private void restoreExpansionState()
  {
    IDialogSettings settings = ApiUIPlugin.getDefault().getDialogSettings().getSection("api_errorswarnings_block");
    if (settings != null) {
      for (int i = 0; i < fExpComps.size(); i++) {
        ((ExpandableComposite)fExpComps.get(i)).setExpanded(settings.getBoolean(Integer.toString(i)));
      }
    } else {
      ((ExpandableComposite)fExpComps.get(0)).setExpanded(true);
    }
  }
  
  private void persistExpansionState()
  {
    IDialogSettings settings = ApiUIPlugin.getDefault().getDialogSettings().addNewSection("api_errorswarnings_block");
    for (int i = 0; i < fExpComps.size(); i++) {
      settings.put(Integer.toString(i), ((ExpandableComposite)fExpComps.get(i)).isExpanded());
    }
  }
  
  public void useProjectSpecificSettings(boolean enable)
  {
    boolean disabled = fOldProjectSettings == null;
    if ((enable != disabled) && (fProject != null)) {
      if (enable)
      {
        for (int i = 0; i < fgAllKeys.length; i++) {
          fgAllKeys[i].setStoredValue(fLookupOrder[0], (String)fOldProjectSettings.get(fgAllKeys[i]), fManager);
        }
        fOldProjectSettings = null;
        updateControls();
      }
      else
      {
        fOldProjectSettings = new IdentityHashMap();
        String old = null;
        for (int i = 0; i < fgAllKeys.length; i++)
        {
          old = fgAllKeys[i].getStoredValue(fLookupOrder, false, fManager);
          fOldProjectSettings.put(fgAllKeys[i], old);
          fgAllKeys[i].setStoredValue(fLookupOrder[0], null, fManager);
        }
      }
    }
    fDirty = true;
    enableControl(fMainComp, enable);
    if (enable) {
      validateSettings(null, null, null);
    }
  }
  
  public boolean hasProjectSpecificSettings(IProject project)
  {
    if (project != null)
    {
      IScopeContext projectContext = new ProjectScope(project);
      for (int i = 0; i < fgAllKeys.length; i++) {
        if (fgAllKeys[i].getStoredValue(projectContext, fManager) != null) {
          return true;
        }
      }
    }
    return false;
  }
  
  private void collectChanges(IScopeContext context, List changes)
  {
    boolean complete = (fOldProjectSettings == null) && (fProject != null);
    for (int i = 0; i < fgAllKeys.length; i++)
    {
      Key key = fgAllKeys[i];
      String origval = key.getStoredValue(context, null);
      String newval = key.getStoredValue(context, fManager);
      if (newval == null)
      {
        if (origval != null)
        {
          changes.add(key);
        }
        else if (complete)
        {
          key.setStoredValue(context, key.getStoredValue(fLookupOrder, true, fManager), fManager);
          changes.add(key);
        }
      }
      else if (!newval.equals(origval)) {
        changes.add(key);
      }
    }
  }
  
  public static Key[] getAllKeys()
  {
    return fgAllKeys;
  }
  
  protected Button getCheckBox(Key key)
  {
    for (int i = fCheckBoxes.size() - 1; i >= 0; i--)
    {
      Button curr = (Button)fCheckBoxes.get(i);
      ControlData data = (ControlData)curr.getData();
      if (key.equals(data.getKey())) {
        return curr;
      }
    }
    return null;
  }
  
  public void selectTab(int tabID)
  {
    if ((tabID >= 0) && (tabID < fTabFolder.getItemCount())) {
      fTabFolder.setSelection(tabID);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiErrorsWarningsConfigurationBlock
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import java.util.HashMap;
import java.util.HashSet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.ui.dialogs.PreferencesUtil;

class ApiErrorsWarningsPreferencePage$1
  extends SelectionAdapter
{
  final ApiErrorsWarningsPreferencePage this$0;
  
  ApiErrorsWarningsPreferencePage$1(ApiErrorsWarningsPreferencePage paramApiErrorsWarningsPreferencePage)
  {
    this$0 = paramApiErrorsWarningsPreferencePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    HashSet set = new HashSet();
    try
    {
      IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
      IProject project = null;
      for (int i = 0; i < projects.length; i++)
      {
        project = projects[i].getProject();
        try
        {
          if ((project.hasNature("org.eclipse.pde.api.tools.apiAnalysisNature")) && (this$0.block.hasProjectSpecificSettings(project))) {
            set.add(projects[i]);
          }
        }
        catch (CoreException localCoreException) {}
      }
    }
    catch (JavaModelException localJavaModelException) {}
    ProjectSelectionDialog psd = new ProjectSelectionDialog(this$0.getShell(), set);
    if (psd.open() == 0)
    {
      HashMap data = new HashMap();
      data.put("PropertyAndPreferencePage.nolink", Boolean.TRUE);
      PreferencesUtil.createPropertyDialogOn(this$0.getShell(), ((IJavaProject)psd.getFirstResult()).getProject(), 
        "org.eclipse.pde.api.tools.ui.apitools.warningspage", 
        new String[] { "org.eclipse.pde.api.tools.ui.apitools.warningspage" }, data).open();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiErrorsWarningsPreferencePage.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaModel;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.pde.api.tools.ui.internal.IApiToolsHelpContextIds;
import org.eclipse.pde.api.tools.ui.internal.SWTFactory;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Link;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;

public class ApiErrorsWarningsPreferencePage
  extends PreferencePage
  implements IWorkbenchPreferencePage
{
  public static final String ID = "org.eclipse.pde.api.tools.ui.apitools.errorwarnings.prefpage";
  public static final String NO_LINK = "PropertyAndPreferencePage.nolink";
  public static final String INITIAL_TAB = "PropertyAndPreferencePage.initialTab";
  ApiErrorsWarningsConfigurationBlock block = null;
  private Link link = null;
  private Map fPageData = null;
  
  public ApiErrorsWarningsPreferencePage()
  {
    super(PreferenceMessages.ApiErrorsWarningsPreferencePage_0);
  }
  
  protected Control createContents(Composite parent)
  {
    Composite comp = SWTFactory.createComposite(parent, 1, 1, 1808, 0, 0);
    link = new Link(comp, 0);
    link.setLayoutData(new GridData(3, 2, true, false));
    link.setFont(comp.getFont());
    link.setText(PreferenceMessages.ApiErrorsWarningsPreferencePage_1);
    link.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        HashSet set = new HashSet();
        try
        {
          IJavaProject[] projects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
          IProject project = null;
          for (int i = 0; i < projects.length; i++)
          {
            project = projects[i].getProject();
            try
            {
              if ((project.hasNature("org.eclipse.pde.api.tools.apiAnalysisNature")) && (block.hasProjectSpecificSettings(project))) {
                set.add(projects[i]);
              }
            }
            catch (CoreException localCoreException) {}
          }
        }
        catch (JavaModelException localJavaModelException) {}
        ProjectSelectionDialog psd = new ProjectSelectionDialog(getShell(), set);
        if (psd.open() == 0)
        {
          HashMap data = new HashMap();
          data.put("PropertyAndPreferencePage.nolink", Boolean.TRUE);
          PreferencesUtil.createPropertyDialogOn(getShell(), ((IJavaProject)psd.getFirstResult()).getProject(), 
            "org.eclipse.pde.api.tools.ui.apitools.warningspage", 
            new String[] { "org.eclipse.pde.api.tools.ui.apitools.warningspage" }, data).open();
        }
      }
    });
    block = new ApiErrorsWarningsConfigurationBlock(null, (IWorkbenchPreferenceContainer)getContainer());
    block.createControl(comp);
    
    applyData(fPageData);
    
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IApiToolsHelpContextIds.APITOOLS_ERROR_WARNING_PREF_PAGE);
    return comp;
  }
  
  public void dispose()
  {
    if (block != null) {
      block.dispose();
    }
    super.dispose();
  }
  
  public void init(IWorkbench workbench) {}
  
  public boolean performCancel()
  {
    block.performCancel();
    return super.performCancel();
  }
  
  public boolean performOk()
  {
    block.performOK();
    return super.performOk();
  }
  
  protected void performApply()
  {
    block.performApply();
    super.performApply();
  }
  
  protected void performDefaults()
  {
    block.performDefaults();
    super.performDefaults();
  }
  
  public void applyData(Object data)
  {
    if ((data instanceof Map))
    {
      fPageData = ((Map)data);
      if ((link != null) && (fPageData.containsKey("PropertyAndPreferencePage.nolink"))) {
        link.setVisible(!Boolean.TRUE.equals(fPageData.get("PropertyAndPreferencePage.nolink")));
      }
      if ((block != null) && (fPageData.containsKey("PropertyAndPreferencePage.initialTab")))
      {
        Integer tabIndex = (Integer)fPageData.get("PropertyAndPreferencePage.initialTab");
        if (tabIndex != null) {
          try
          {
            block.selectTab(tabIndex.intValue());
          }
          catch (NumberFormatException localNumberFormatException) {}
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiErrorsWarningsPreferencePage
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Combo;

class ApiUseScanConfigurationBlock$1
  extends SelectionAdapter
{
  final ApiUseScanConfigurationBlock this$0;
  
  ApiUseScanConfigurationBlock$1(ApiUseScanConfigurationBlock paramApiUseScanConfigurationBlock)
  {
    this$0 = paramApiUseScanConfigurationBlock;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    if ((widget instanceof Combo))
    {
      Combo combo = (Combo)widget;
      ApiUseScanConfigurationBlock.ControlData data = (ApiUseScanConfigurationBlock.ControlData)combo.getData();
      key.setStoredValue(this$0.fLookupOrder[0], combo.getText(), 
        this$0.fManager);
      ApiBaselinePreferencePage.rebuildcount = 0;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanConfigurationBlock.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

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

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanConfigurationBlock.ControlData
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

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

public class ApiUseScanConfigurationBlock$Key
{
  private String qualifier;
  private String key;
  
  public ApiUseScanConfigurationBlock$Key(String qualifier, String key)
  {
    this.qualifier = qualifier;
    this.key = key;
  }
  
  private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager)
  {
    IEclipsePreferences node = context.getNode(qualifier);
    if (manager != null) {
      return manager.getWorkingCopy(node);
    }
    return node;
  }
  
  public String getStoredValue(IScopeContext context, IWorkingCopyManager manager)
  {
    IEclipsePreferences node = getNode(context, manager);
    if (node != null) {
      return node.get(key, null);
    }
    return 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)
  {
    IEclipsePreferences node = getNode(context, manager);
    if (value != null) {
      node.put(key, value);
    } else {
      node.remove(key);
    }
  }
  
  public String toString()
  {
    return qualifier + '/' + key;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanConfigurationBlock.Key
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;
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.jface.dialogs.Dialog;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.ui.internal.SWTFactory;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.preferences.IWorkingCopyManager;
import org.osgi.service.prefs.BackingStoreException;

public class ApiUseScanConfigurationBlock
{
  protected static class ControlData
  {
    ApiUseScanConfigurationBlock.Key key;
    private String[] values;
    
    public ControlData(ApiUseScanConfigurationBlock.Key key, String[] values)
    {
      this.key = key;
      this.values = values;
    }
    
    public ApiUseScanConfigurationBlock.Key getKey()
    {
      return key;
    }
    
    public String getValue(boolean selection)
    {
      int index = selection ? 0 : 1;
      return values[index];
    }
    
    public String getValue(int index)
    {
      return values[index];
    }
    
    public int getSelection(String value)
    {
      if (value != null) {
        for (int i = 0; i < values.length; i++) {
          if (value.equals(values[i])) {
            return i;
          }
        }
      }
      return values.length - 1;
    }
  }
  
  protected static class Key
  {
    private String qualifier;
    private String key;
    
    public Key(String qualifier, String key)
    {
      this.qualifier = qualifier;
      this.key = key;
    }
    
    private IEclipsePreferences getNode(IScopeContext context, IWorkingCopyManager manager)
    {
      IEclipsePreferences node = context.getNode(qualifier);
      if (manager != null) {
        return manager.getWorkingCopy(node);
      }
      return node;
    }
    
    public String getStoredValue(IScopeContext context, IWorkingCopyManager manager)
    {
      IEclipsePreferences node = getNode(context, manager);
      if (node != null) {
        return node.get(key, null);
      }
      return 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)
    {
      IEclipsePreferences node = getNode(context, manager);
      if (value != null) {
        node.put(key, value);
      } else {
        node.remove(key);
      }
    }
    
    public String toString()
    {
      return qualifier + '/' + key;
    }
  }
  
  protected static final Key getApiToolsKey(String key)
  {
    return new Key("org.eclipse.pde.api.tools", key);
  }
  
  private static final Key KEY_API_USE_SCAN_TYPE_PROBLEM = getApiToolsKey("API_USE_SCAN_TYPE_SEVERITY");
  private static final Key KEY_API_USE_SCAN_METHOD_PROBLEM = getApiToolsKey("API_USE_SCAN_METHOD_SEVERITY");
  private static final Key KEY_API_USE_SCAN_FIELD_PROBLEM = getApiToolsKey("API_USE_SCAN_FIELD_SEVERITY");
  private static Key[] fgAllKeys = { KEY_API_USE_SCAN_TYPE_PROBLEM, 
    KEY_API_USE_SCAN_METHOD_PROBLEM, KEY_API_USE_SCAN_FIELD_PROBLEM };
  private static final String[] SEVERITIES_LABELS = {
    PreferenceMessages.ApiErrorsWarningsConfigurationBlock_error, 
    PreferenceMessages.ApiErrorsWarningsConfigurationBlock_warning, 
    PreferenceMessages.ApiErrorsWarningsConfigurationBlock_ignore };
  private static final String[] SEVERITIES = { "Error", 
    "Warning", "Ignore" };
  private SelectionListener selectionlistener = new SelectionAdapter()
  {
    public void widgetSelected(SelectionEvent e)
    {
      if ((widget instanceof Combo))
      {
        Combo combo = (Combo)widget;
        ApiUseScanConfigurationBlock.ControlData data = (ApiUseScanConfigurationBlock.ControlData)combo.getData();
        key.setStoredValue(fLookupOrder[0], combo.getText(), 
          fManager);
        ApiBaselinePreferencePage.rebuildcount = 0;
      }
    }
  };
  private Combo[] fCombo = null;
  IScopeContext[] fLookupOrder = null;
  IWorkingCopyManager fManager = null;
  private Composite fMainComp = null;
  private IdentityHashMap fOldProjectSettings = null;
  
  public ApiUseScanConfigurationBlock(IWorkingCopyManager manager)
  {
    fLookupOrder = new IScopeContext[] { InstanceScope.INSTANCE, 
      DefaultScope.INSTANCE };
    fManager = manager;
    fOldProjectSettings = null;
  }
  
  public Control createControl(Composite parent)
  {
    fMainComp = SWTFactory.createComposite(parent, 1, 1, 
      768, 0, 0);
    Group optionsProfileGroup = SWTFactory.createGroup(fMainComp, 
      PreferenceMessages.ApiUseScanConfigurationBlock_0, 2, 1, 
      1808);
    fCombo = new Combo[3];
    fCombo[0] = createComboControl(optionsProfileGroup, 
      PreferenceMessages.ApiUseScanConfigurationBlock_unresolvedTypeProblem, 
      KEY_API_USE_SCAN_TYPE_PROBLEM);
    fCombo[1] = createComboControl(optionsProfileGroup, 
      PreferenceMessages.ApiUseScanConfigurationBlock_unresolvedMethodProblem, 
      KEY_API_USE_SCAN_METHOD_PROBLEM);
    fCombo[2] = createComboControl(optionsProfileGroup, 
      PreferenceMessages.ApiUseScanConfigurationBlock_unresolvedFieldProblem, 
      KEY_API_USE_SCAN_FIELD_PROBLEM);
    Dialog.applyDialogFont(fMainComp);
    return fMainComp;
  }
  
  public void performOK()
  {
    save();
  }
  
  public void performApply()
  {
    save();
  }
  
  private void save()
  {
    try
    {
      ArrayList changes = new ArrayList();
      collectChanges(fLookupOrder[0], changes);
      if (changes.size() > 0) {
        fManager.applyChanges();
      }
    }
    catch (BackingStoreException bse)
    {
      ApiPlugin.log(bse);
    }
  }
  
  public void performCancel() {}
  
  public void performDefaults()
  {
    String defval = null;
    for (int i = 0; i < fgAllKeys.length; i++)
    {
      defval = fgAllKeys[i].getStoredValue(fLookupOrder, true, fManager);
      fgAllKeys[i].setStoredValue(fLookupOrder[0], defval, fManager);
    }
    updateCombos();
  }
  
  private void updateCombos()
  {
    if (fCombo != null) {
      for (int i = 0; i < fCombo.length; i++)
      {
        ControlData data = (ControlData)fCombo[i].getData();
        fCombo[i].select(data.getSelection(data.getKey()
          .getStoredValue(fLookupOrder, false, fManager)));
      }
    }
  }
  
  public void dispose()
  {
    fMainComp.getParent().dispose();
  }
  
  protected Combo createComboControl(Composite parent, String label, Key key)
  {
    Label lbl = new Label(parent, 0);
    GridData gd = new GridData(1, 2, true, 
      false);
    lbl.setLayoutData(gd);
    lbl.setText(label);
    Combo combo = new Combo(parent, 12);
    gd = new GridData(3, 2, false, false);
    combo.setLayoutData(gd);
    ControlData data = new ControlData(key, SEVERITIES);
    combo.setData(data);
    combo.setItems(SEVERITIES_LABELS);
    combo.addSelectionListener(selectionlistener);
    combo.select(data.getSelection(key.getStoredValue(fLookupOrder, false, 
      fManager)));
    return combo;
  }
  
  private void collectChanges(IScopeContext context, List changes)
  {
    Key key = null;
    String origval = null;String newval = null;
    boolean complete = fOldProjectSettings == null;
    for (int i = 0; i < fgAllKeys.length; i++)
    {
      key = fgAllKeys[i];
      origval = key.getStoredValue(context, null);
      newval = key.getStoredValue(context, fManager);
      if (newval == null)
      {
        if (origval != null)
        {
          changes.add(key);
        }
        else if (complete)
        {
          key.setStoredValue(context, 
            key.getStoredValue(fLookupOrder, true, fManager), 
            fManager);
          changes.add(key);
        }
      }
      else if (!newval.equals(origval)) {
        changes.add(key);
      }
    }
  }
  
  public static Key[] getAllKeys()
  {
    return fgAllKeys;
  }
  
  public void setEnabled(boolean enabled)
  {
    fMainComp.setEnabled(enabled);
    for (int i = 0; i < fCombo.length; i++) {
      fCombo[i].setEnabled(enabled);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanConfigurationBlock
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;

class ApiUseScanPreferencePage$1
  extends KeyAdapter
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$1(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void keyReleased(KeyEvent e)
  {
    if ((stateMask == 0) && (keyCode == 127)) {
      this$0.removeLocation();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

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

class ApiUseScanPreferencePage$2
  extends SelectionAdapter
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$2(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.select(true);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

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

class ApiUseScanPreferencePage$3
  extends SelectionAdapter
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$3(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.select(false);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.3
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import org.eclipse.pde.api.tools.internal.search.UseScanManager;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ApiUseScanPreferencePage$4
  extends SelectionAdapter
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$4(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    String loc = this$0.getDirectory(null);
    if (loc != null)
    {
      String exactLocation = UseScanManager.getExactScanLocation(loc);
      if (exactLocation == null) {
        this$0.addLocation(loc);
      } else {
        this$0.addLocation(exactLocation);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.4
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

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

class ApiUseScanPreferencePage$5
  extends SelectionAdapter
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$5(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    String loc = this$0.getArchive(null);
    if (loc != null) {
      this$0.addLocation(loc);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.5
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

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

class ApiUseScanPreferencePage$6
  extends SelectionAdapter
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$6(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.edit();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.6
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

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

class ApiUseScanPreferencePage$7
  extends SelectionAdapter
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$7(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    this$0.removeLocation();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.7
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.widgets.Button;

class ApiUseScanPreferencePage$8
  implements ISelectionChangedListener
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$8(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void selectionChanged(SelectionChangedEvent event)
  {
    IStructuredSelection selection = (IStructuredSelection)this$0.fTableViewer.getSelection();
    this$0.remove.setEnabled(!selection.isEmpty());
    this$0.editbutton.setEnabled(selection.size() == 1);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.8
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;

class ApiUseScanPreferencePage$9
  implements IDoubleClickListener
{
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$9(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
  }
  
  public void doubleClick(DoubleClickEvent event)
  {
    this$0.edit();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.9
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import java.io.File;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

class ApiUseScanPreferencePage$TableColumnLabelProvider
  extends ColumnLabelProvider
{
  Image archive;
  final ApiUseScanPreferencePage this$0;
  
  ApiUseScanPreferencePage$TableColumnLabelProvider(ApiUseScanPreferencePage paramApiUseScanPreferencePage)
  {
    this$0 = paramApiUseScanPreferencePage;
    
    archive = null;
  }
  
  public void dispose()
  {
    if (archive != null) {
      archive.dispose();
    }
    super.dispose();
  }
  
  public Image getImage(Object element)
  {
    File file = new File(element.toString());
    if (file.isDirectory()) {
      return PlatformUI.getWorkbench().getSharedImages().getImage("IMG_OBJ_FOLDER");
    }
    if (archive == null)
    {
      ImageDescriptor image = PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(file.getName());
      archive = image.createImage();
    }
    return archive;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.api.tools.ui.internal.preferences.ApiUseScanPreferencePage.TableColumnLabelProvider
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.api.tools.ui.internal.preferences;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.search.UseScanManager;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;
import org.eclipse.pde.api.tools.ui.internal.IApiToolsHelpContextIds;
import org.eclipse.pde.api.tools.ui.internal.SWTFactory;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Table;
import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferenceLinkArea;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
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 class ApiUseScanPreferencePage
  extends PreferencePage
  implements IWorkbenchPreferencePage
{
  public static final String ID = "org.eclipse.pde.api.tools.ui.apiusescan.prefpage";
  private IWorkingCopyManager fManager;
  CheckboxTableViewer fTableViewer;
  HashSet fLocationList = new HashSet();
  Button remove = null;
  Button editbutton = null;
  public void init(IWorkbench workbench) {}
  
  class TableColumnLabelProvider
    extends ColumnLabelProvider
  {
    Image archive = null;
    
    TableColumnLabelProvider() {}
    
    public void dispose()
    {
      if (archive != null) {
        archive.dispose();
      }
      super.dispose();
    }
    
    public Image getImage(Object element)
    {
      File file = new File(element.toString());
      if (file.isDirectory()) {
        return PlatformUI.getWorkbench().getSharedImages().getImage("IMG_OBJ_FOLDER");
      }
      if (archive == null)
      {
        ImageDescriptor image = PlatformUI.getWorkbench().getEditorRegistry().getImageDescriptor(file.getName());
        archive = image.createImage();
      }
      return archive;
    }
  }
  
  protected Control createContents(Composite parent)
  {
    Composite comp = SWTFactory.createComposite(parent, 2, 1, 768, 0, 0);
    
    SWTFactory.createWrapLabel(comp, PreferenceMessages.ApiUseScanPreferencePage_0, 2, 250);
    SWTFactory.createVerticalSpacer(comp, 1);
    SWTFactory.createWrapLabel(comp, PreferenceMessages.ApiUseScanPreferencePage_2, 2);
    
    Table table = new Table(comp, 68130);
    table.setLayoutData(new GridData(1808));
    GridData gd = (GridData)table.getLayoutData();
    widthHint = 250;
    table.addKeyListener(new KeyAdapter()
    {
      public void keyReleased(KeyEvent e)
      {
        if ((stateMask == 0) && (keyCode == 127)) {
          removeLocation();
        }
      }
    });
    fTableViewer = new CheckboxTableViewer(table);
    fTableViewer.setLabelProvider(new TableColumnLabelProvider());
    fTableViewer.setContentProvider(new ArrayContentProvider());
    
    Composite bcomp = SWTFactory.createComposite(comp, 1, 1, 1042, 0, 0);
    Button button = SWTFactory.createPushButton(bcomp, PreferenceMessages.ApiUseScanPreferencePage_3, null);
    button.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        select(true);
      }
    });
    button = SWTFactory.createPushButton(bcomp, PreferenceMessages.ApiUseScanPreferencePage_10, null);
    button.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        select(false);
      }
    });
    SWTFactory.createHorizontalSpacer(bcomp, 1);
    
    button = SWTFactory.createPushButton(bcomp, PreferenceMessages.ApiUseScanPreferencePage_4, null);
    button.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        String loc = getDirectory(null);
        if (loc != null)
        {
          String exactLocation = UseScanManager.getExactScanLocation(loc);
          if (exactLocation == null) {
            addLocation(loc);
          } else {
            addLocation(exactLocation);
          }
        }
      }
    });
    button = SWTFactory.createPushButton(bcomp, PreferenceMessages.ApiUseScanPreferencePage_5, null);
    button.addSelectionListener(new SelectionAdapter()
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

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