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

 
  public void doubleClick(DoubleClickEvent event)
  {
    Object o = ((IStructuredSelection)event.getSelection()).getFirstElement();
    if (this$0.fViewer.isExpandable(o))
    {
      this$0.fViewer.setExpandedState(o, !this$0.fViewer.getExpandedState(o));
    }
    else if ((o instanceof IApiProblemFilter))
    {
      IApiProblemFilter filter = (IApiProblemFilter)o;
      this$0.handleEdit(filter);
    }
  }
}

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

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ApiFiltersPropertyPage$5
  extends SelectionAdapter
{
  final ApiFiltersPropertyPage this$0;
  
  ApiFiltersPropertyPage$5(ApiFiltersPropertyPage paramApiFiltersPropertyPage)
  {
    this$0 = paramApiFiltersPropertyPage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    IStructuredSelection ss = (IStructuredSelection)this$0.fViewer.getSelection();
    this$0.handleEdit((IApiProblemFilter)ss.getFirstElement());
  }
}

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

import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

class ApiFiltersPropertyPage$6
  extends SelectionAdapter
{
  final ApiFiltersPropertyPage this$0;
  
  ApiFiltersPropertyPage$6(ApiFiltersPropertyPage paramApiFiltersPropertyPage)
  {
    this$0 = paramApiFiltersPropertyPage;
  }
  
  public void widgetSelected(SelectionEvent e)
  {
    IStructuredSelection ss = (IStructuredSelection)this$0.fViewer.getSelection();
    this$0.handleRemove(ss);
  }
}

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

import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;
import org.eclipse.ui.model.WorkbenchViewerComparator;

class ApiFiltersPropertyPage$ApiFilterComparator
  extends WorkbenchViewerComparator
{
  public int category(Object element)
  {
    if ((element instanceof IApiProblemFilter)) {
      return ((IApiProblemFilter)element).getUnderlyingProblem().getCategory();
    }
    return -1;
  }
}

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

import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;

class ApiFiltersPropertyPage$CommentChange
{
  IApiProblemFilter filter;
  String comment;
  final ApiFiltersPropertyPage this$0;
  
  public ApiFiltersPropertyPage$CommentChange(ApiFiltersPropertyPage paramApiFiltersPropertyPage, IApiProblemFilter filter, String orig)
  {
    this$0 = paramApiFiltersPropertyPage;this.filter = null;comment = null;
    this.filter = filter;
    comment = orig;
  }
  
  public boolean equals(Object obj)
  {
    return filter.equals(obj);
  }
  
  public int hashCode()
  {
    return filter.hashCode();
  }
}

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

import java.util.ArrayList;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
import org.eclipse.pde.api.tools.ui.internal.ApiUIPlugin;

class ApiFiltersPropertyPage$TreeContentProvider
  implements ITreeContentProvider
{
  final ApiFiltersPropertyPage this$0;
  
  ApiFiltersPropertyPage$TreeContentProvider(ApiFiltersPropertyPage paramApiFiltersPropertyPage)
  {
    this$0 = paramApiFiltersPropertyPage;
  }
  
  public Object[] getChildren(Object parentElement)
  {
    if ((parentElement instanceof IResource)) {
      try
      {
        return this$0.getFilterStore().getFilters((IResource)parentElement);
      }
      catch (CoreException e)
      {
        ApiUIPlugin.log(e);
      }
    }
    return new Object[0];
  }
  
  public boolean hasChildren(Object element)
  {
    if ((element instanceof IResource)) {
      try
      {
        return this$0.getFilterStore().getFilters((IResource)element).length > 0;
      }
      catch (CoreException e)
      {
        ApiUIPlugin.log(e);
      }
    }
    return false;
  }
  
  public Object[] getElements(Object inputElement)
  {
    if ((inputElement instanceof ArrayList)) {
      return ((ArrayList)inputElement).toArray();
    }
    return new Object[0];
  }
  
  public Object getParent(Object element)
  {
    return null;
  }
  
  public void dispose() {}
  
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
}

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

import com.ibm.icu.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
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.ITreeContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.pde.api.tools.internal.ApiFilterStore;
import org.eclipse.pde.api.tools.internal.problems.ApiProblemFilter;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiBaselineManager;
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;
import org.eclipse.pde.api.tools.internal.util.Util;
import org.eclipse.pde.api.tools.ui.internal.ApiToolsLabelProvider;
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.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.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PropertyPage;
import org.eclipse.ui.help.IWorkbenchHelpSystem;
import org.eclipse.ui.model.WorkbenchViewerComparator;

public class ApiFiltersPropertyPage
  extends PropertyPage
{
  class CommentChange
  {
    IApiProblemFilter filter = null;
    String comment = null;
    
    public CommentChange(IApiProblemFilter filter, String orig)
    {
      this.filter = filter;
      comment = orig;
    }
    
    public boolean equals(Object obj)
    {
      return filter.equals(obj);
    }
    
    public int hashCode()
    {
      return filter.hashCode();
    }
  }
  
  static class ApiFilterComparator
    extends WorkbenchViewerComparator
  {
    public int category(Object element)
    {
      if ((element instanceof IApiProblemFilter)) {
        return ((IApiProblemFilter)element).getUnderlyingProblem().getCategory();
      }
      return -1;
    }
  }
  
  class TreeContentProvider
    implements ITreeContentProvider
  {
    TreeContentProvider() {}
    
    public Object[] getChildren(Object parentElement)
    {
      if ((parentElement instanceof IResource)) {
        try
        {
          return getFilterStore().getFilters((IResource)parentElement);
        }
        catch (CoreException e)
        {
          ApiUIPlugin.log(e);
        }
      }
      return new Object[0];
    }
    
    public boolean hasChildren(Object element)
    {
      if ((element instanceof IResource)) {
        try
        {
          return getFilterStore().getFilters((IResource)element).length > 0;
        }
        catch (CoreException e)
        {
          ApiUIPlugin.log(e);
        }
      }
      return false;
    }
    
    public Object[] getElements(Object inputElement)
    {
      if ((inputElement instanceof ArrayList)) {
        return ((ArrayList)inputElement).toArray();
      }
      return new Object[0];
    }
    
    public Object getParent(Object element)
    {
      return null;
    }
    
    public void dispose() {}
    
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
  }
  
  TreeViewer fViewer = null;
  Button fRemoveButton;
  Button fEditButton = null;
  Text fCommentText = null;
  private IProject fProject = null;
  ArrayList fDeleteSet = new ArrayList();
  ArrayList fEditSet = new ArrayList();
  private ArrayList fInputset = null;
  
  protected Control createContents(Composite parent)
  {
    noDefaultAndApplyButton();
    Composite comp = SWTFactory.createComposite(parent, 2, 1, 1808);
    SWTFactory.createWrapLabel(comp, PropertiesMessages.ApiFiltersPropertyPage_55, 2);
    Tree tree = new Tree(comp, 68354);
    GridData gd = new GridData(1808);
    widthHint = 300;
    heightHint = 200;
    tree.setLayoutData(gd);
    tree.addKeyListener(new KeyAdapter()
    {
      public void keyPressed(KeyEvent e)
      {
        if ((character == '') && (stateMask == 0)) {
          handleRemove((IStructuredSelection)fViewer.getSelection());
        }
      }
    });
    fViewer = new TreeViewer(tree);
    fViewer.setContentProvider(new TreeContentProvider());
    fViewer.setLabelProvider(new ApiToolsLabelProvider());
    fViewer.setComparator(new ApiFilterComparator());
    fViewer.addFilter(new ViewerFilter()
    {
      public boolean select(Viewer viewer, Object parentElement, Object element)
      {
        return !fDeleteSet.contains(element);
      }
    });
    try
    {
      IApiFilterStore store = getFilterStore();
      if (store != null)
      {
        fInputset = new ArrayList(Arrays.asList(store.getResources()));
        fViewer.setInput(fInputset);
      }
    }
    catch (CoreException e)
    {
      ApiUIPlugin.log(e);
    }
    fViewer.addSelectionChangedListener(new ISelectionChangedListener()
    {
      public void selectionChanged(SelectionChangedEvent event)
      {
        IStructuredSelection ss = (IStructuredSelection)event.getSelection();
        int size = ss.size();
        fRemoveButton.setEnabled(size > 0);
        if (size == 1)
        {
          Object element = ss.getFirstElement();
          if ((element instanceof IApiProblemFilter))
          {
            IApiProblemFilter filter = (IApiProblemFilter)element;
            String comment = filter.getComment();
            fEditButton.setEnabled(true);
            if (comment != null) {
              fCommentText.setText(comment);
            } else {
              fCommentText.setText("");
            }
          }
          else
          {
            fEditButton.setEnabled(false);
            fCommentText.setText("");
          }
        }
        else
        {
          fEditButton.setEnabled(false);
          fCommentText.setText("");
        }
      }
    });
    fViewer.addDoubleClickListener(new IDoubleClickListener()
    {
      public void doubleClick(DoubleClickEvent event)
      {
        Object o = ((IStructuredSelection)event.getSelection()).getFirstElement();
        if (fViewer.isExpandable(o))
        {
          fViewer.setExpandedState(o, !fViewer.getExpandedState(o));
        }
        else if ((o instanceof IApiProblemFilter))
        {
          IApiProblemFilter filter = (IApiProblemFilter)o;
          handleEdit(filter);
        }
      }
    });
    Composite bcomp = SWTFactory.createComposite(comp, 1, 1, 1040, 0, 0);
    fEditButton = SWTFactory.createPushButton(bcomp, PropertiesMessages.ApiFiltersPropertyPage_edit_button, null, 16384);
    fEditButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        IStructuredSelection ss = (IStructuredSelection)fViewer.getSelection();
        handleEdit((IApiProblemFilter)ss.getFirstElement());
      }
    });
    fEditButton.setEnabled(false);
    fRemoveButton = SWTFactory.createPushButton(bcomp, PropertiesMessages.ApiFiltersPropertyPage_57, null, 16384);
    fRemoveButton.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent e)
      {
        IStructuredSelection ss = (IStructuredSelection)fViewer.getSelection();
        handleRemove(ss);
      }
    });
    fRemoveButton.setEnabled(false);
    
    SWTFactory.createLabel(comp, PropertiesMessages.ApiFiltersPropertyPage_comment, 2);
    fCommentText = SWTFactory.createText(comp, 2880, 2, 200, 100, 768);
    fCommentText.setEditable(false);
    if (tree.getItemCount() > 0)
    {
      TreeItem item = tree.getItem(0);
      fViewer.setSelection(new StructuredSelection(item.getData()), true);
      fViewer.expandToLevel(item.getData(), 1);
    }
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IApiToolsHelpContextIds.APITOOLS_FILTERS_PROPERTY_PAGE);
    return comp;
  }
  
  void handleEdit(IApiProblemFilter filter)
  {
    String orignal = filter.getComment();
    String comment = orignal;
    InputDialog dialog = new InputDialog(getShell(), PropertiesMessages.ApiFiltersPropertyPage_edit_comment, PropertiesMessages.ApiFiltersPropertyPage_edit_filter_comment, comment, null);
    if (dialog.open() == 0)
    {
      comment = dialog.getValue();
      if ((comment != null) && (comment.length() < 1)) {
        comment = null;
      }
      ((ApiProblemFilter)filter).setComment(comment);
      CommentChange change = new CommentChange(filter, orignal);
      int idx = fEditSet.indexOf(change);
      if (idx < 0) {
        fEditSet.add(change);
      }
      fViewer.refresh(filter, true);
      fViewer.setSelection(fViewer.getSelection(), true);
    }
  }
  
  void handleRemove(IStructuredSelection selection)
  {
    ArrayList comments = new ArrayList();
    HashSet deletions = collectDeletions(selection, comments);
    boolean refresh = false;
    if (deletions.size() > 0)
    {
      fDeleteSet.addAll(deletions);
      int[] indexes = getIndexes(selection);
      fViewer.remove(deletions.toArray());
      updateParents();
      refresh = true;
      updateSelection(indexes);
    }
    if (comments.size() > 0) {
      for (int i = 0; i < comments.size(); i++)
      {
        ApiProblemFilter filter = (ApiProblemFilter)comments.get(i);
        CommentChange change = new CommentChange(filter, filter.getComment());
        int idx = fEditSet.indexOf(filter);
        if (idx < 0) {
          fEditSet.add(change);
        }
        filter.setComment(null);
        refresh = true;
      }
    }
    if (refresh)
    {
      fViewer.refresh(true);
      fViewer.setSelection(fViewer.getSelection(), true);
    }
  }
  
  private int[] getIndexes(IStructuredSelection selection)
  {
    int[] indexes = new int[2];
    TreeSelection tsel = (TreeSelection)selection;
    TreePath path = tsel.getPaths()[0];
    TreeItem parent = (TreeItem)fViewer.testFindItem(path.getFirstSegment());
    if (parent != null)
    {
      Tree tree = fViewer.getTree();
      
      indexes[0] = tree.indexOf(parent);
      TreeItem item = (TreeItem)fViewer.testFindItem(path.getLastSegment());
      if (item != null) {
        indexes[1] = parent.indexOf(item);
      }
    }
    return indexes;
  }
  
  private void updateSelection(int[] indexes)
  {
    Tree tree = fViewer.getTree();
    TreeItem parent = null;
    if (tree.getItemCount() == 0) {
      return;
    }
    if (indexes[0] < tree.getItemCount())
    {
      TreeItem child = null;
      parent = tree.getItem(indexes[0]);
      int childcount = parent.getItemCount();
      if ((childcount < 1) || (indexes[1] < 0))
      {
        fViewer.setSelection(new StructuredSelection(parent.getData()));
        return;
      }
      if (indexes[1] < childcount) {
        child = parent.getItem(indexes[1]);
      } else {
        child = parent.getItem(childcount - 1);
      }
      fViewer.setSelection(new StructuredSelection(child.getData()));
    }
    else
    {
      parent = tree.getItem(tree.getItemCount() - 1);
      fViewer.setSelection(new StructuredSelection(parent.getData()));
    }
  }
  
  private void updateParents()
  {
    Tree tree = fViewer.getTree();
    TreeItem[] items = tree.getItems();
    for (int i = 0; i < items.length; i++) {
      if (items[i].getItems().length < 1) {
        fInputset.remove(items[i].getData());
      }
    }
  }
  
  private HashSet collectDeletions(IStructuredSelection selection, ArrayList comments)
  {
    HashSet filters = new HashSet();
    Object node = null;
    Object[] children = (Object[])null;
    for (Iterator iter = selection.iterator(); iter.hasNext();)
    {
      node = iter.next();
      if ((node instanceof IResource))
      {
        children = ((TreeContentProvider)fViewer.getContentProvider()).getChildren(node);
        filters.addAll(Arrays.asList(children));
        fInputset.remove(node);
      }
      else if ((node instanceof IApiProblemFilter))
      {
        filters.add(node);
      }
      else if ((node instanceof String))
      {
        TreeItem item = (TreeItem)fViewer.testFindItem(node);
        if (item != null) {
          comments.add(item.getParentItem().getData());
        }
      }
    }
    return filters;
  }
  
  private IProject getProject()
  {
    if (fProject == null) {
      fProject = ((IProject)getElement().getAdapter(IProject.class));
    }
    return fProject;
  }
  
  IApiFilterStore getFilterStore()
    throws CoreException
  {
    IProject project = getProject();
    IApiFilterStore store = null;
    if (project != null)
    {
      IApiComponent component = ApiPlugin.getDefault().getApiBaselineManager().getWorkspaceBaseline().getApiComponent(project);
      if (component != null) {
        return component.getFilterStore();
      }
    }
    return store;
  }
  
  public boolean performCancel()
  {
    for (int i = 0; i < fEditSet.size(); i++)
    {
      CommentChange change = (CommentChange)fEditSet.get(i);
      ((ApiProblemFilter)filter).setComment(comment);
    }
    fEditSet.clear();
    return super.performCancel();
  }
  
  public boolean performOk()
  {
    try
    {
      boolean needsbuild = false;
      if (fDeleteSet.size() > 0)
      {
        IApiProblemFilter[] apiProblemFilters = (IApiProblemFilter[])fDeleteSet.toArray(new IApiProblemFilter[fDeleteSet.size()]);
        getFilterStore().removeFilters(apiProblemFilters);
        
        int i = 0;
        for (int max = apiProblemFilters.length; i < max; i++)
        {
          IApiProblemFilter filter = apiProblemFilters[i];
          IApiProblem apiProblem = filter.getUnderlyingProblem();
          if (apiProblem != null)
          {
            String resourcePath = apiProblem.getResourcePath();
            if (resourcePath != null)
            {
              IResource resource = fProject.findMember(resourcePath);
              if (resource != null) {
                Util.touchCorrespondingResource(fProject, resource, apiProblem.getTypeName());
              }
            }
          }
        }
        needsbuild = true;
      }
      else if (fEditSet.size() > 0)
      {
        ApiFilterStore store = (ApiFilterStore)getFilterStore();
        store.needsSaving();
        store.persistApiFilters();
      }
      if (needsbuild)
      {
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        if (!workspace.isAutoBuilding()) {
          if (MessageDialog.openQuestion(getShell(), PropertiesMessages.ApiFiltersPropertyPage_58, 
            MessageFormat.format(PropertiesMessages.ApiFiltersPropertyPage_59, new String[] { fProject.getName() }))) {
            Util.getBuildJob(new IProject[] { fProject }, 10).schedule();
          }
        }
      }
      fEditSet.clear();
      fDeleteSet.clear();
    }
    catch (CoreException e)
    {
      ApiUIPlugin.log(e);
    }
    catch (OperationCanceledException localOperationCanceledException) {}
    return super.performOk();
  }
}

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

import org.eclipse.osgi.util.NLS;

public class PropertiesMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.pde.api.tools.ui.internal.properties.propertiesmessages";
  public static String ApiErrorWarningsPropertyPage_0;
  public static String ApiErrorWarningsPropertyPage_1;
  public static String ApiFiltersPropertyPage_55;
  public static String ApiFiltersPropertyPage_57;
  public static String ApiFiltersPropertyPage_58;
  public static String ApiFiltersPropertyPage_59;
  public static String ApiFiltersPropertyPage_comment;
  public static String ApiFiltersPropertyPage_edit_button;
  public static String ApiFiltersPropertyPage_edit_comment;
  public static String ApiFiltersPropertyPage_edit_filter_comment;
  
  static
  {
    NLS.initializeMessages("org.eclipse.pde.api.tools.ui.internal.properties.propertiesmessages", PropertiesMessages.class);
  }
}

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

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;

public abstract class FilterChange
  extends Change
{
  static final int DELETE = 1;
  static final int ADD = 2;
  IApiFilterStore store = null;
  IApiProblemFilter filter = null;
  int kind = 0;
  
  public FilterChange(IApiFilterStore store, IApiProblemFilter filter, int kind)
  {
    this.store = store;
    this.filter = filter;
    this.kind = kind;
  }
  
  protected abstract Change performDelete();
  
  protected abstract Change performAdd();
  
  public Change perform(IProgressMonitor pm)
    throws CoreException
  {
    switch (kind)
    {
    case 1: 
      return performDelete();
    case 2: 
      return performAdd();
    }
    return null;
  }
  
  protected String getAddName()
  {
    return NLS.bind(RefactoringMessages.FilterChange_add_filter, filter.toString());
  }
  
  protected String getDeleteName()
  {
    IApiProblem problem = filter.getUnderlyingProblem();
    return NLS.bind(RefactoringMessages.FilterChange_remove_used_filter, problem.getMessage());
  }
  
  protected String getRenameName()
  {
    IApiProblem problem = filter.getUnderlyingProblem();
    return NLS.bind(RefactoringMessages.FilterChange_remove_used_filter, new Object[] { problem.getMessage() });
  }
  
  protected String getMoveName()
  {
    IApiProblem problem = filter.getUnderlyingProblem();
    return NLS.bind(RefactoringMessages.FilterChange_remove_used_filter, new Object[] { problem.getMessage() });
  }
  
  public String getName()
  {
    switch (kind)
    {
    case 2: 
      return getAddName();
    case 1: 
      return getDeleteName();
    }
    return null;
  }
  
  public void initializeValidationData(IProgressMonitor pm) {}
  
  public RefactoringStatus isValid(IProgressMonitor pm)
    throws CoreException, OperationCanceledException
  {
    return new RefactoringStatus();
  }
  
  public Object getModifiedElement()
  {
    return filter;
  }
}

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

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.DeleteParticipant;
import org.eclipse.osgi.util.NLS;

public class FilterDeleteParticipant
  extends DeleteParticipant
{
  private IJavaElement element = null;
  
  public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
    throws OperationCanceledException
  {
    return new RefactoringStatus();
  }
  
  public Change createChange(IProgressMonitor pm)
    throws CoreException, OperationCanceledException
  {
    return null;
  }
  
  public String getName()
  {
    return NLS.bind(RefactoringMessages.FilterDeleteParticipant_remove_unused_filters_for_0, element.getElementName());
  }
  
  public Change createPreChange(IProgressMonitor pm)
    throws CoreException, OperationCanceledException
  {
    switch (element.getElementType())
    {
    case 7: 
      return RefactoringUtils.createDeleteFilterChanges((IType)element);
    case 4: 
      return RefactoringUtils.createDeleteFilterChanges((IPackageFragment)element);
    }
    return null;
  }
  
  protected boolean initialize(Object element)
  {
    if ((element instanceof IJavaElement))
    {
      this.element = ((IJavaElement)element);
      return true;
    }
    return false;
  }
}

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

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.MoveParticipant;
import org.eclipse.osgi.util.NLS;

public class FilterMoveParticipant
  extends MoveParticipant
{
  private IJavaElement element = null;
  
  public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
    throws OperationCanceledException
  {
    return new RefactoringStatus();
  }
  
  public Change createChange(IProgressMonitor pm)
    throws CoreException, OperationCanceledException
  {
    return null;
  }
  
  public Change createPreChange(IProgressMonitor pm)
    throws CoreException, OperationCanceledException
  {
    switch (element.getElementType())
    {
    case 7: 
      return RefactoringUtils.createDeleteFilterChanges((IType)element);
    case 4: 
      return RefactoringUtils.createDeleteFilterChanges((IPackageFragment)element);
    }
    return null;
  }
  
  public String getName()
  {
    return NLS.bind(RefactoringMessages.FilterDeleteParticipant_remove_unused_filters_for_0, element.getElementName());
  }
  
  protected boolean initialize(Object element)
  {
    if ((element instanceof IJavaElement))
    {
      this.element = ((IJavaElement)element);
      return true;
    }
    return false;
  }
}

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

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
import org.eclipse.osgi.util.NLS;

public class FilterRenameParticipant
  extends RenameParticipant
{
  private IJavaElement element = null;
  
  public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
    throws OperationCanceledException
  {
    return new RefactoringStatus();
  }
  
  public Change createChange(IProgressMonitor pm)
    throws CoreException, OperationCanceledException
  {
    return null;
  }
  
  public Change createPreChange(IProgressMonitor pm)
    throws CoreException, OperationCanceledException
  {
    switch (element.getElementType())
    {
    case 7: 
      return RefactoringUtils.createRenameFilterChanges((IType)element, getArguments().getNewName());
    case 4: 
      return RefactoringUtils.createRenameFilterChanges((IPackageFragment)element, getArguments().getNewName());
    }
    return null;
  }
  
  public String getName()
  {
    return NLS.bind(RefactoringMessages.FilterDeleteParticipant_remove_unused_filters_for_0, element.getElementName());
  }
  
  protected boolean initialize(Object element)
  {
    if ((element instanceof IJavaElement))
    {
      this.element = ((IJavaElement)element);
      return true;
    }
    return false;
  }
}

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

import org.eclipse.osgi.util.NLS;

public class RefactoringMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.pde.api.tools.ui.internal.refactoring.refactoringmessages";
  public static String FilterChange_add_filter;
  public static String FilterChange_remove_used_filter;
  public static String FilterDeleteParticipant_remove_unused_filters_for_0;
  public static String RefactoringUtils_remove_usused_filters;
  
  static
  {
    NLS.initializeMessages("org.eclipse.pde.api.tools.ui.internal.refactoring.refactoringmessages", RefactoringMessages.class);
  }
}

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

import java.util.HashSet;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
import org.eclipse.pde.api.tools.internal.provisional.IApiBaselineManager;
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiBaseline;
import org.eclipse.pde.api.tools.internal.provisional.model.IApiComponent;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;

public class RefactoringUtils
{
  static Change createDeleteFilterChanges(IType type)
  {
    try
    {
      IResource resource = type.getUnderlyingResource();
      if (resource != null)
      {
        IApiFilterStore store = resolveFilterStore(resource.getProject());
        if (store == null) {
          return null;
        }
        IApiProblemFilter[] filters = store.getFilters(resource);
        if (filters.length != 0)
        {
          CompositeChange cchange = new CompositeChange(RefactoringMessages.RefactoringUtils_remove_usused_filters);
          for (int i = 0; i < filters.length; i++) {
            cchange.add(new TypeFilterChange(store, filters[i], null, null, 1));
          }
          return cchange;
        }
      }
    }
    catch (CoreException localCoreException) {}
    return null;
  }
  
  static Change createDeleteFilterChanges(IPackageFragment fragment)
  {
    try
    {
      IResource resource = fragment.getUnderlyingResource();
      if (resource != null)
      {
        IApiFilterStore store = resolveFilterStore(resource.getProject());
        if (store == null) {
          return null;
        }
        IApiProblemFilter[] filters = collectAllAffectedFilters(store, collectAffectedTypes(fragment));
        if (filters.length != 0)
        {
          CompositeChange cchange = new CompositeChange(RefactoringMessages.RefactoringUtils_remove_usused_filters);
          for (int i = 0; i < filters.length; i++) {
            cchange.add(new TypeFilterChange(store, filters[i], null, null, 1));
          }
          return cchange;
        }
      }
    }
    catch (CoreException localCoreException) {}
    return null;
  }
  
  static IApiProblemFilter[] collectAllAffectedFilters(IApiFilterStore store, IType[] types)
  {
    HashSet filters = new HashSet();
    IApiProblemFilter[] fs = (IApiProblemFilter[])null;
    IResource resource = null;
    for (int i = 0; i < types.length; i++) {
      try
      {
        resource = types[i].getUnderlyingResource();
        if (resource != null)
        {
          fs = store.getFilters(resource);
          for (int j = 0; j < fs.length; j++) {
            filters.add(fs[j]);
          }
        }
      }
      catch (JavaModelException localJavaModelException) {}
    }
    return (IApiProblemFilter[])filters.toArray(new IApiProblemFilter[filters.size()]);
  }
  
  static IType[] collectAffectedTypes(IPackageFragment fragment)
  {
    HashSet types = new HashSet();
    try
    {
      if (fragment.containsJavaResources())
      {
        ICompilationUnit[] cunits = fragment.getCompilationUnits();
        IType type = null;
        for (int i = 0; i < cunits.length; i++)
        {
          type = cunits[i].findPrimaryType();
          if (type != null) {
            types.add(type);
          }
        }
      }
    }
    catch (JavaModelException localJavaModelException) {}
    return (IType[])types.toArray(new IType[types.size()]);
  }
  
  static Change createRenameFilterChanges(IType type, String newname)
  {
    return createDeleteFilterChanges(type);
  }
  
  static Change createRenameFilterChanges(IPackageFragment fragment, String newname)
  {
    return createDeleteFilterChanges(fragment);
  }
  
  static IApiFilterStore resolveFilterStore(IProject project)
    throws CoreException
  {
    IApiComponent component = ApiPlugin.getDefault().getApiBaselineManager().getWorkspaceBaseline().getApiComponent(project);
    if (component != null) {
      return component.getFilterStore();
    }
    return null;
  }
  
  static String getNewQualifiedName(IType type, String newname)
  {
    IType dtype = type.getDeclaringType();
    String newqname = newname;
    if (dtype == null)
    {
      IPackageFragment packageFragment = type.getPackageFragment();
      if (!packageFragment.isDefaultPackage()) {
        newqname = packageFragment.getElementName() + '.' + newname;
      }
    }
    else
    {
      newqname = dtype.getFullyQualifiedName() + '$' + newname;
    }
    return newqname;
  }
  
  static String getNewQualifiedName(String newname, String oldtypename)
  {
    return oldtypename;
  }
  
  static String getNewResourcePath(IPath oldpath, String typename)
  {
    if (typename.indexOf('$') < 0)
    {
      String ext = oldpath.getFileExtension();
      IPath newpath = oldpath.removeLastSegments(1).append(typename);
      if (ext != null) {
        return newpath.addFileExtension(ext).toString();
      }
      return newpath.toString();
    }
    return oldpath.toString();
  }
}

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

import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.pde.api.tools.internal.provisional.IApiFilterStore;
import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblemFilter;

public class TypeFilterChange
  extends FilterChange
{
  String newname = null;
  String newpath = null;
  
  public TypeFilterChange(IApiFilterStore store, IApiProblemFilter filter, String newname, String newpath, int kind)
  {
    super(store, filter, kind);
    this.newname = newname;
    this.newpath = newpath;
  }
  
  protected Change performAdd()
  {
    store.addFilters(new IApiProblemFilter[] { filter });
    return new TypeFilterChange(store, filter, null, null, 1);
  }
  
  protected Change performDelete()
  {
    if (store.removeFilters(new IApiProblemFilter[] { filter })) {
      return new TypeFilterChange(store, filter, null, null, 2);
    }
    return null;
  }
}

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

import org.eclipse.core.run
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