org.eclipse.ltk.ui.refactoring_3.7.0.v20120523-1543

16:46:15.910 INFO  jd.cli.Main - Decompiling org.eclipse.ltk.ui.refactoring_3.7.0.v20120523-1543.jar
package org.eclipse.ltk.internal.ui.refactoring;

import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.TextEditBasedChange;
import org.eclipse.ltk.ui.refactoring.ChangePreviewViewerInput;
import org.eclipse.ltk.ui.refactoring.IChangePreviewViewer;
import org.eclipse.ltk.ui.refactoring.TextEditChangeNode;

public abstract class AbstractChangeNode
  extends PreviewNode
{
  private final Change fChange;
  private PreviewNode[] fChildren;
  
  public static PreviewNode createNode(PreviewNode parent, RefactoringPreviewChangeFilter filter, Change change)
  {
    if ((change instanceof CompositeChange)) {
      return new CompositeChangeNode(parent, filter, (CompositeChange)change);
    }
    if ((change instanceof TextEditBasedChange))
    {
      InternalTextEditChangeNode result = (TextEditChangeNode)change.getAdapter(TextEditChangeNode.class);
      if (result == null) {
        result = new TextEditChangeNode((TextEditBasedChange)change);
      }
      result.initialize(parent);
      return result;
    }
    return new DefaultChangeNode(parent, change);
  }
  
  public static PreviewNode createNode(PreviewNode parent, Change change)
  {
    return createNode(parent, null, change);
  }
  
  AbstractChangeNode(PreviewNode parent, Change change)
  {
    super(parent);
    Assert.isNotNull(change);
    fChange = change;
  }
  
  Change getChange()
  {
    return fChange;
  }
  
  PreviewNode[] getChildren()
  {
    if (fChildren == null) {
      fChildren = doCreateChildren();
    }
    return fChildren;
  }
  
  abstract PreviewNode[] doCreateChildren();
  
  public String getText()
  {
    return fChange.getName();
  }
  
  public ImageDescriptor getImageDescriptor()
  {
    return RefactoringPluginImages.DESC_OBJS_DEFAULT_CHANGE;
  }
  
  ChangePreviewViewerDescriptor getChangePreviewViewerDescriptor()
    throws CoreException
  {
    return ChangePreviewViewerDescriptor.get(fChange);
  }
  
  void feedInput(IChangePreviewViewer viewer, List categories)
    throws CoreException
  {
    viewer.setInput(new ChangePreviewViewerInput(fChange));
  }
  
  void setEnabled(boolean enabled)
  {
    fChange.setEnabled(enabled);
  }
  
  void setEnabledShallow(boolean enabled)
  {
    fChange.setEnabledShallow(enabled);
  }
  
  boolean hasOneGroupCategory(List categories)
  {
    PreviewNode[] children = getChildren();
    for (int i = 0; i < children.length; i++) {
      if (children[i].hasOneGroupCategory(categories)) {
        return true;
      }
    }
    return false;
  }
  
  boolean hasDerived()
  {
    if (hasDerivedResourceChange(fChange)) {
      return true;
    }
    PreviewNode[] children = getChildren();
    for (int i = 0; i < children.length; i++) {
      if (children[i].hasDerived()) {
        return true;
      }
    }
    return false;
  }
  
  int getDefaultChangeActive()
  {
    int result = fChange.isEnabled() ? 2 : 0;
    if (fChildren != null) {
      for (int i = 0; i < fChildren.length; i++)
      {
        result = ACTIVATION_TABLE[fChildren[i].getActive()][result];
        if (result == 1) {
          break;
        }
      }
    }
    return result;
  }
  
  int getCompositeChangeActive()
  {
    if ((fChildren != null) && (fChildren.length > 0))
    {
      int result = fChildren[0].getActive();
      for (int i = 1; i < fChildren.length; i++)
      {
        result = ACTIVATION_TABLE[fChildren[i].getActive()][result];
        if (result == 1) {
          break;
        }
      }
      return result;
    }
    return fChange.isEnabled() ? 2 : 0;
  }
  
  static boolean hasDerivedResourceChange(Change change)
  {
    Object modifiedElement = change.getModifiedElement();
    if ((modifiedElement instanceof IResource)) {
      return ((IResource)modifiedElement).isDerived(512);
    }
    if ((modifiedElement instanceof IAdaptable))
    {
      IAdaptable adaptable = (IAdaptable)modifiedElement;
      IResource resource = (IResource)adaptable.getAdapter(IResource.class);
      if (resource != null) {
        return resource.isDerived(512);
      }
    }
    return false;
  }
}

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

import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionConverter;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;

public abstract class AbstractDescriptor
{
  protected IConfigurationElement fConfigurationElement;
  protected Expression fExpression;
  protected static final String ID = "id";
  protected static final String OBJECT_STATE = "objectState";
  protected static final String CLASS = "class";
  
  protected AbstractDescriptor(IConfigurationElement element)
  {
    fConfigurationElement = element;
  }
  
  public String getId()
  {
    return fConfigurationElement.getAttribute("id");
  }
  
  public boolean matches(Object element, String variableName)
    throws CoreException
  {
    Assert.isNotNull(element);
    Assert.isNotNull(variableName);
    Expression exp = getExpression();
    EvaluationContext evaluationContext = new EvaluationContext(null, element);
    evaluationContext.addVariable(variableName, element);
    if (exp.evaluate(evaluationContext) == EvaluationResult.FALSE) {
      return false;
    }
    return true;
  }
  
  public Expression getExpression()
    throws CoreException
  {
    if (fExpression == null) {
      fExpression = createExpression(fConfigurationElement);
    }
    return fExpression;
  }
  
  public void clear()
  {
    fExpression = null;
  }
  
  protected Expression createExpression(IConfigurationElement element)
    throws CoreException
  {
    IConfigurationElement[] children = element.getChildren("enablement");
    if (children.length == 0) {
      return Expression.FALSE;
    }
    Assert.isTrue(children.length == 1);
    return ExpressionConverter.getDefault().perform(children[0]);
  }
}

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

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.osgi.util.TextProcessor;

public class BasicElementLabels
{
  private static String markLTR(String string, String delimiters)
  {
    return TextProcessor.process(string, delimiters);
  }
  
  public static String getPathLabel(IPath path, boolean isOSPath)
  {
    String label;
    String label;
    if (isOSPath) {
      label = path.toOSString();
    } else {
      label = path.makeRelative().toString();
    }
    return markLTR(label, "/\\:.");
  }
  
  public static String getFilePattern(String name)
  {
    return markLTR(name, "*.?/\\:.");
  }
  
  public static String getURLPart(String name)
  {
    return markLTR(name, ":@?-#/\\:.");
  }
  
  public static String getResourceName(IResource resource)
  {
    return markLTR(resource.getName(), "/\\:.");
  }
  
  public static String getVersionName(String name)
  {
    return markLTR(name, ":.");
  }
}

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

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

class ChangeElementContentProvider
  implements ITreeContentProvider
{
  public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
  
  public Object[] getChildren(Object o)
  {
    PreviewNode element = (PreviewNode)o;
    return element.getChildren();
  }
  
  public Object getParent(Object element)
  {
    return ((PreviewNode)element).getParent();
  }
  
  public boolean hasChildren(Object element)
  {
    Object[] children = getChildren(element);
    return (children != null) && (children.length > 0);
  }
  
  public void dispose() {}
  
  public Object[] getElements(Object element)
  {
    return getChildren(element);
  }
}

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

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;

class ChangeElementLabelProvider
  extends LabelProvider
  implements IFontProvider
{
  private Map fDescriptorImageMap = new HashMap();
  
  public Image getImage(Object object)
  {
    return manageImageDescriptor(((PreviewNode)object).getImageDescriptor());
  }
  
  public String getText(Object object)
  {
    String text = ((PreviewNode)object).getText();
    if (isDerived(object)) {
      return Messages.format(RefactoringUIMessages.ChangeElementLabelProvider_derived, text);
    }
    return text;
  }
  
  public Font getFont(Object element)
  {
    if (isDerived(element)) {
      return JFaceResources.getFontRegistry().getItalic("org.eclipse.jface.dialogfont");
    }
    return null;
  }
  
  private boolean isDerived(Object element)
  {
    PreviewNode node = (PreviewNode)element;
    return node.hasDerived();
  }
  
  public void dispose()
  {
    for (Iterator iter = fDescriptorImageMap.values().iterator(); iter.hasNext();)
    {
      Image image = (Image)iter.next();
      image.dispose();
    }
    super.dispose();
  }
  
  private Image manageImageDescriptor(ImageDescriptor descriptor)
  {
    Image image = (Image)fDescriptorImageMap.get(descriptor);
    if (image == null)
    {
      image = descriptor.createImage();
      fDescriptorImageMap.put(descriptor, image);
    }
    return image;
  }
}

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

import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.ICheckStateListener;

class ChangeElementTreeViewer$1
  implements ICheckStateListener
{
  final ChangeElementTreeViewer this$0;
  
  ChangeElementTreeViewer$1(ChangeElementTreeViewer paramChangeElementTreeViewer)
  {
    this$0 = paramChangeElementTreeViewer;
  }
  
  public void checkStateChanged(CheckStateChangedEvent event)
  {
    PreviewNode element = (PreviewNode)event.getElement();
    boolean checked = event.getChecked();
    
    element.setEnabled(checked);
    this$0.setSubtreeChecked(element, checked);
    ChangeElementTreeViewer.access$0(this$0, element, false);
    PreviewNode parent = element.getParent();
    while (parent != null)
    {
      int active = parent.getActive();
      parent.setEnabledShallow((active == 1) || (active == 2));
      boolean grayed = active == 1;
      this$0.setChecked(parent, checked ? true : grayed);
      this$0.setGrayed(parent, grayed);
      parent = parent.getParent();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ltk.internal.ui.refactoring.ChangeElementTreeViewer.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ltk.internal.ui.refactoring;

import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

class ChangeElementTreeViewer$DerivedFilter
  extends ViewerFilter
{
  ChangeElementTreeViewer$DerivedFilter(DerivedFilter paramDerivedFilter)
  {
    this();
  }
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    return !((PreviewNode)element).hasDerived();
  }
  
  private ChangeElementTreeViewer$DerivedFilter() {}
}

/* Location:
 * Qualified Name:     org.eclipse.ltk.internal.ui.refactoring.ChangeElementTreeViewer.DerivedFilter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ltk.internal.ui.refactoring;

import java.util.List;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

class ChangeElementTreeViewer$GroupCategoryFilter
  extends ViewerFilter
{
  private List fGroupCategories;
  
  ChangeElementTreeViewer$GroupCategoryFilter(GroupCategoryFilter paramGroupCategoryFilter)
  {
    this();
  }
  
  public void setGroupCategory(List groupCategories)
  {
    fGroupCategories = groupCategories;
  }
  
  public boolean select(Viewer viewer, Object parentElement, Object element)
  {
    if (fGroupCategories == null) {
      return true;
    }
    return ((PreviewNode)element).hasOneGroupCategory(fGroupCategories);
  }
  
  private ChangeElementTreeViewer$GroupCategoryFilter() {}
}

/* Location:
 * Qualified Name:     org.eclipse.ltk.internal.ui.refactoring.ChangeElementTreeViewer.GroupCategoryFilter
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ltk.internal.ui.refactoring;

import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget;

class ChangeElementTreeViewer
  extends CheckboxTreeViewer
{
  private static class GroupCategoryFilter
    extends ViewerFilter
  {
    private List fGroupCategories;
    
    GroupCategoryFilter(GroupCategoryFilter paramGroupCategoryFilter)
    {
      this();
    }
    
    public void setGroupCategory(List groupCategories)
    {
      fGroupCategories = groupCategories;
    }
    
    public boolean select(Viewer viewer, Object parentElement, Object element)
    {
      if (fGroupCategories == null) {
        return true;
      }
      return ((PreviewNode)element).hasOneGroupCategory(fGroupCategories);
    }
    
    private GroupCategoryFilter() {}
  }
  
  private static class DerivedFilter
    extends ViewerFilter
  {
    DerivedFilter(DerivedFilter paramDerivedFilter)
    {
      this();
    }
    
    public boolean select(Viewer viewer, Object parentElement, Object element)
    {
      return !((PreviewNode)element).hasDerived();
    }
    
    private DerivedFilter() {}
  }
  
  private static final DerivedFilter DERIVED_FILTER = new DerivedFilter(null);
  private List fDeferredTreeItemUpdates;
  
  public ChangeElementTreeViewer(Composite parentComposite)
  {
    super(parentComposite, 0);
    addFilter(new GroupCategoryFilter(null));
    addCheckStateListener(new ICheckStateListener()
    {
      public void checkStateChanged(CheckStateChangedEvent event)
      {
        PreviewNode element = (PreviewNode)event.getElement();
        boolean checked = event.getChecked();
        
        element.setEnabled(checked);
        setSubtreeChecked(element, checked);
        ChangeElementTreeViewer.this.setSubtreeGrayed(element, false);
        PreviewNode parent = element.getParent();
        while (parent != null)
        {
          int active = parent.getActive();
          parent.setEnabledShallow((active == 1) || (active == 2));
          boolean grayed = active == 1;
          setChecked(parent, checked ? true : grayed);
          setGrayed(parent, grayed);
          parent = parent.getParent();
        }
      }
    });
  }
  
  public void setGroupCategory(List groupCategories)
  {
    ((GroupCategoryFilter)getFilters()[0]).setGroupCategory(groupCategories);
    refresh();
  }
  
  public void setHideDerived(boolean hide)
  {
    if (hide) {
      addFilter(DERIVED_FILTER);
    } else {
      removeFilter(DERIVED_FILTER);
    }
  }
  
  /* Error */
  public void refresh()
  {
    // Byte code:
    //   0: aload_0
    //   1: new 96	java/util/ArrayList
    //   4: dup
    //   5: invokespecial 205	java/util/ArrayList:<init>	()V
    //   8: putfield 203	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:fDeferredTreeItemUpdates	Ljava/util/List;
    //   11: aload_0
    //   12: invokespecial 206	org/eclipse/jface/viewers/CheckboxTreeViewer:refresh	()V
    //   15: aload_0
    //   16: invokespecial 212	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:processDeferredTreeItemUpdates	()V
    //   19: goto +11 -> 30
    //   22: astore_1
    //   23: aload_0
    //   24: aconst_null
    //   25: putfield 203	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:fDeferredTreeItemUpdates	Ljava/util/List;
    //   28: aload_1
    //   29: athrow
    //   30: aload_0
    //   31: aconst_null
    //   32: putfield 203	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:fDeferredTreeItemUpdates	Ljava/util/List;
    //   35: return
    // Line number table:
    //   Java source line #97	-> byte code offset #0
    //   Java source line #98	-> byte code offset #11
    //   Java source line #99	-> byte code offset #15
    //   Java source line #100	-> byte code offset #22
    //   Java source line #101	-> byte code offset #23
    //   Java source line #102	-> byte code offset #28
    //   Java source line #101	-> byte code offset #30
    //   Java source line #103	-> byte code offset #35
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	36	0	this	ChangeElementTreeViewer
    //   22	7	1	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	22	22	finally
  }
  
  protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection)
  {
    PreviewNode next = getLeaf((PreviewNode)getInput(), true);
    if (next != null)
    {
      newSelection = new StructuredSelection(next);
      setSelection(newSelection);
    }
    super.handleInvalidSelection(invalidSelection, newSelection);
  }
  
  /* Error */
  protected void inputChanged(Object input, Object oldInput)
  {
    // Byte code:
    //   0: aload_0
    //   1: new 96	java/util/ArrayList
    //   4: dup
    //   5: invokespecial 205	java/util/ArrayList:<init>	()V
    //   8: putfield 203	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:fDeferredTreeItemUpdates	Ljava/util/List;
    //   11: aload_0
    //   12: aload_1
    //   13: aload_2
    //   14: invokespecial 208	org/eclipse/jface/viewers/CheckboxTreeViewer:inputChanged	(Ljava/lang/Object;Ljava/lang/Object;)V
    //   17: aload_0
    //   18: invokespecial 212	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:processDeferredTreeItemUpdates	()V
    //   21: goto +11 -> 32
    //   24: astore_3
    //   25: aload_0
    //   26: aconst_null
    //   27: putfield 203	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:fDeferredTreeItemUpdates	Ljava/util/List;
    //   30: aload_3
    //   31: athrow
    //   32: aload_0
    //   33: aconst_null
    //   34: putfield 203	org/eclipse/ltk/internal/ui/refactoring/ChangeElementTreeViewer:fDeferredTreeItemUpdates	Ljava/util/List;
    //   37: return
    // Line number table:
    //   Java source line #116	-> byte code offset #0
    //   Java source line #117	-> byte code offset #11
    //   Java source line #118	-> byte code offset #17
    //   Java source line #119	-> byte code offset #24
    //   Java source line #120	-> byte code offset #25
    //   Java source line #121	-> byte code offset #30
    //   Java source line #120	-> byte code offset #32
    //   Java source line #122	-> byte code offset #37
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	38	0	this	ChangeElementTreeViewer
    //   0	38	1	input	Object
    //   0	38	2	oldInput	Object
    //   24	7	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   0	24	24	finally
  }
  
  protected void doUpdateItem(Item item, Object element)
  {
    super.doUpdateItem(item, element);
    if (fDeferredTreeItemUpdates == null) {
      applyCheckedState((TreeItem)item, (PreviewNode)element);
    } else {
      fDeferredTreeItemUpdates.add(item);
    }
  }
  
  private void processDeferredTreeItemUpdates()
  {
    for (Iterator iter = fDeferredTreeItemUpdates.iterator(); iter.hasNext();)
    {
      TreeItem item = (TreeItem)iter.next();
      applyCheckedState(item, (PreviewNode)item.getData());
    }
  }
  
  private void applyCheckedState(TreeItem item, PreviewNode ce)
  {
    int state = ce.getActive();
    boolean checked = state != 0;
    item.setChecked(checked);
    boolean grayed = state == 1;
    item.setGrayed(grayed);
  }
  
  protected void revealNext()
  {
    revealElement(true);
  }
  
  protected void revealPrevious()
  {
    revealElement(false);
  }
  
  private void setSubtreeGrayed(Object element, boolean grayed)
  {
    Widget widget = findItem(element);
    if ((widget instanceof TreeItem))
    {
      TreeItem item = (TreeItem)widget;
      if (item.getGrayed() != grayed)
      {
        item.setGrayed(grayed);
        grayChildren(getChildren(item), grayed);
      }
    }
  }
  
  private void grayChildren(Item[] items, boolean grayed)
  {
    for (int i = 0; i < items.length; i++)
    {
      Item element = items[i];
      if ((element instanceof TreeItem))
      {
        TreeItem item = (TreeItem)element;
        if (item.getGrayed() != grayed)
        {
          item.setGrayed(grayed);
          grayChildren(getChildren(item), grayed);
        }
      }
    }
  }
  
  private void revealElement(boolean next)
  {
    PreviewNode current = (PreviewNode)getInput();
    IStructuredSelection selection = (IStructuredSelection)getSelection();
    if (!selection.isEmpty()) {
      current = (PreviewNode)selection.iterator().next();
    }
    PreviewNode candidate = getLeaf(current, next);
    if (candidate == null)
    {
      candidate = getElement(current, next);
      if (candidate != null)
      {
        PreviewNode leaf = getLeaf(candidate, next);
        if (leaf != null) {
          candidate = leaf;
        }
      }
    }
    if (candidate != null) {
      setSelection(new StructuredSelection(candidate), true);
    } else {
      getControl().getDisplay().beep();
    }
  }
  
  private PreviewNode getLeaf(PreviewNode element, boolean first)
  {
    PreviewNode result = null;
    PreviewNode[] children = getSortedChildrenAsPreviewNodes(element);
    while ((children != null) && (children.length > 0))
    {
      result = children[(children.length - 1)];
      children = getSortedChildrenAsPreviewNodes(result);
    }
    return result;
  }
  
  private PreviewNode getElement(PreviewNode element, boolean next)
  {
    for (;;)
    {
      PreviewNode parent = element.getParent();
      if (parent == null) {
        return null;
      }
      PreviewNode candidate = getSibling(
        getSortedChildrenAsPreviewNodes(parent), 
        element, next);
      if (candidate != null) {
        return candidate;
      }
      element = parent;
    }
  }
  
  private PreviewNode getSibling(PreviewNode[] children, PreviewNode element, boolean next)
  {
    for (int i = 0; i < children.length; i++) {
      if (children[i] == element)
      {
        if (next)
        {
          if (i < children.length - 1) {
            return children[(i + 1)];
          }
          return null;
        }
        if (i > 0) {
          return children[(i - 1)];
        }
        return null;
      }
    }
    return null;
  }
  
  private PreviewNode[] getSortedChildrenAsPreviewNodes(PreviewNode parent)
  {
    Object[] sorted = getSortedChildren(parent);
    PreviewNode[] result = new PreviewNode[sorted.length];
    for (int i = 0; i < result.length; i++) {
      result[i] = ((PreviewNode)sorted[i]);
    }
    return result;
  }
}

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

import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;

class ChangeExceptionHandler$1
  implements IWorkspaceRunnable
{
  final ChangeExceptionHandler this$0;
  private final Change val$undo;
  
  ChangeExceptionHandler$1(ChangeExceptionHandler paramChangeExceptionHandler, Change paramChange)
  {
    this$0 = paramChangeExceptionHandler;val$undo = paramChange;
  }
  
  public void run(IProgressMonitor monitor)
    throws CoreException
  {
    monitor.beginTask("", 11);
    try
    {
      val$undo.initializeValidationData(new NotCancelableProgressMonitor(new SubProgressMonitor(monitor, 1)));
      if (val$undo.isValid(new SubProgressMonitor(monitor, 1)).hasFatalError())
      {
        monitor.done();
        return;
      }
      val$undo.perform(new SubProgressMonitor(monitor, 9));
    }
    finally
    {
      val$undo.dispose();
    }
    val$undo.dispose();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ltk.internal.ui.refactoring.ChangeExceptionHandler.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ltk.internal.ui.refactoring;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.ErrorDialog;
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.Label;
import org.eclipse.swt.widgets.Shell;

class ChangeExceptionHandler$RefactorErrorDialog
  extends ErrorDialog
{
  public ChangeExceptionHandler$RefactorErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, IStatus status, int displayMask)
  {
    super(parentShell, dialogTitle, dialogMessage, status, displayMask);
  }
  
  protected void createButtonsForButtonBar(Composite parent)
  {
    super.createButtonsForButtonBar(parent);
    Button ok = getButton(0);
    ok.setText(RefactoringUIMessages.ChangeExceptionHandler_undo);
    Button abort = createButton(parent, 1, RefactoringUIMessages.ChangeExceptionHandler_abort, true);
    abort.moveBelow(ok);
    abort.setFocus();
  }
  
  protected Control createMessageArea(Composite parent)
  {
    Control result = super.createMessageArea(parent);
    
    new Label(parent, 0);
    Label label = new Label(parent, 0);
    label.setText(RefactoringUIMessages.ChangeExceptionHandler_button_explanation);
    label.setLayoutData(new GridData(768));
    
    applyDialogFont(result);
    return result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ltk.internal.ui.refactoring.ChangeExceptionHandler.RefactorErrorDialog
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ltk.internal.ui.refactoring;

import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.Refactoring;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
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.Label;
import org.eclipse.swt.widgets.Shell;

public class ChangeExceptionHandler
{
  private Shell fParent;
  private String fName;
  
  private static class RefactorErrorDialog
    extends ErrorDialog
  {
    public RefactorErrorDialog(Shell parentShell, String dialogTitle, String dialogMessage, IStatus status, int displayMask)
    {
      super(dialogTitle, dialogMessage, status, displayMask);
    }
    
    protected void createButtonsForButtonBar(Composite parent)
    {
      super.createButtonsForButtonBar(parent);
      Button ok = getButton(0);
      ok.setText(RefactoringUIMessages.ChangeExceptionHandler_undo);
      Button abort = createButton(parent, 1, RefactoringUIMessages.ChangeExceptionHandler_abort, true);
      abort.moveBelow(ok);
      abort.setFocus();
    }
    
    protected Control createMessageArea(Composite parent)
    {
      Control result = super.createMessageArea(parent);
      
      new Label(parent, 0);
      Label label = new Label(parent, 0);
      label.setText(RefactoringUIMessages.ChangeExceptionHandler_button_explanation);
      label.setLayoutData(new GridData(768));
      
      applyDialogFont(result);
      return result;
    }
  }
  
  public ChangeExceptionHandler(Shell parent, Refactoring refactoring)
  {
    fParent = parent;
    fName = refactoring.getName();
  }
  
  public void handle(Change change, RuntimeException exception)
  {
    RefactoringUIPlugin.log(exception);
    IStatus status = null;
    if (exception.getMessage() == null) {
      status = new Status(4, RefactoringUIPlugin.getPluginId(), 4, 
        RefactoringUIMessages.ChangeExceptionHandler_no_details, exception);
    } else {
      status = new Status(4, RefactoringUIPlugin.getPluginId(), 4, 
        exception.getMessage(), exception);
    }
    handle(change, status);
  }
  
  public void handle(Change change, CoreException exception)
  {
    RefactoringUIPlugin.log(exception);
    handle(change, exception.getStatus());
  }
  
  private void handle(Change change, IStatus status)
  {
    if ((change instanceof CompositeChange))
    {
      Change undo = ((CompositeChange)change).getUndoUntilException();
      if (undo != null)
      {
        RefactoringUIPlugin.log(status);
        ErrorDialog dialog = new RefactorErrorDialog(fParent, 
          change.getName(), 
          Messages.format(RefactoringUIMessages.ChangeExceptionHandler_unexpected_exception, fName), 
          status, 7);
        int result = dialog.open();
        if (result == 0) {
          performUndo(undo);
        }
        return;
      }
    }
    ErrorDialog dialog = new ErrorDialog(fParent, 
      change.getName(), 
      Messages.format(RefactoringUIMessages.ChangeExceptionHandler_unexpected_exception, fName), 
      status, 7);
    dialog.open();
  }
  
  private void performUndo(Change undo)
  {
    IWorkspaceRunnable runnable = new IWorkspaceRunnable()
    {
      private final Change val$undo;
      
      public void run(IProgressMonitor monitor)
        throws CoreException
      {
        monitor.beginTask("", 11);
        try
        {
          val$undo.initializeValidationData(new NotCancelableProgressMonitor(new SubProgressMonitor(monitor, 1)));
          if (val$undo.isValid(new SubProgressMonitor(monitor, 1)).hasFatalError())
          {
            monitor.done();
            return;
          }
          val$undo.perform(new SubProgressMonitor(monitor, 9));
        }
        finally
        {
          val$undo.dispose();
        }
        val$undo.dispose();
      }
    };
    WorkbenchRunnableAdapter adapter = new WorkbenchRunnableAdapter(runnable, 
      ResourcesPlugin.getWorkspace().getRoot());
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(fParent);
    try
    {
      dialog.run(false, false, adapter);
    }
    catch (InvocationTargetException e)
    {
      ExceptionHandler.handle(e, fParent, 
        RefactoringUIMessages.ChangeExceptionHandler_rollback_title, 
        RefactoringUIMessages.ChangeExceptionHandler_rollback_message + fName);
    }
    catch (InterruptedException localInterruptedException) {}
  }
}

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

import org.eclipse.core.runtime.IConfigurationElement;

class ChangePreviewViewerDescriptor$1
  extends DescriptorManager
{
  ChangePreviewViewerDescriptor$1(String $anonymous0, String $anonymous1)
  {
    super($anonymous0, $anonymous1);
  }
  
  protected AbstractDescriptor createDescriptor(IConfigurationElement element)
  {
    return new ChangePreviewViewerDescriptor(element);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.ltk.internal.ui.refactoring.ChangePreviewViewerDescriptor.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.ltk.internal.ui.refactoring;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.ltk.ui.refactoring.IChangePreviewViewer;

public class ChangePreviewViewerDescriptor
  extends AbstractDescriptor
{
  private static final String EXT_ID = "changePreviewViewers";
  private static DescriptorManager fgDescriptions = new DescriptorManager("changePreviewViewers", "change")
  {
    protected AbstractDescriptor createDescriptor(IConfigurationElement element)
    {
      return new ChangePreviewViewerDescriptor(element);
    }
  };
  
  public static ChangePreviewViewerDescriptor get(Object element)
    throws CoreException
  {
    return (ChangePreviewViewerDescriptor)fgDescriptions.getDescriptor(element);
  }
  
  public ChangePreviewViewerDescriptor(IConfigurationElement element)
  {
    super(element);
  }
  
  public IChangePreviewViewer createViewer()
    throws CoreException
  {
    return (IChangePreviewViewer)fConfigurationElement.createExecutableExtension("class");
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;

public class CompositeChangeNode
  extends AbstractChangeNode
{
  private final RefactoringPreviewChangeFilter fFilter;
  
  public CompositeChangeNode(PreviewNode parent, RefactoringPreviewChangeFilter filter, CompositeChange change)
  {
    super(parent, change);
    fFilter = filter;
  }
  
  int getActive()
  {
    return getCompositeChangeActive();
  }
  
  public ImageDescriptor getImageDescriptor()
  {
    return RefactoringPluginImages.DESC_OBJS_COMPOSITE_CHANGE;
  }
  
  PreviewNode[] doCreateChildren()
  {
    List children = new ArrayList();
    getFlattendedChildren(children, this, (CompositeChange)getChange());
    return (PreviewNode[])children.toArray(new PreviewNode[children.size()]);
  }
  
  private void getFlattendedChildren(List result, CompositeChangeNode parent, CompositeChange focus)
  {
    Change[] changes = focus.getChildren();
    for (int i = 0; i < changes.length; i++)
    {
      Change change = changes[i];
      if ((fFilter == null) || (fFilter.select(change))) {
        if (((change instanceof CompositeChange)) && (((CompositeChange)change).isSynthetic())) {
          getFlattendedChildren(result, parent, (CompositeChange)change);
        } else {
          result.add(createNode(parent, change));
        }
      }
    }
  }
}

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

import org.eclipse.ltk.core.refactoring.Change;

public class DefaultChangeNode
  extends AbstractChangeNode
{
  public DefaultChangeNode(PreviewNode parent, Change change)
  {
    super(parent, change);
  }
  
  int getActive()
  {
    return getDefaultChangeActive();
  }
  
  PreviewNode[] doCreateChildren()
  {
    return EMPTY_CHILDREN;
  }
}

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

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;

public abstract class DescriptorManager
{
  private String fExtensionPoint;
  private String fVariableName;
  private AbstractDescriptor[] fExtensions;
  
  public DescriptorManager(String extensionPoint, String variableName)
  {
    Assert.isNotNull(extensionPoint);
    Assert.isNotNull(variableName);
    fExtensionPoint = extensionPoint;
    fVariableName = variableName;
  }
  
  public AbstractDescriptor getDescriptor(Object element)
    throws CoreException
  {
    if (fExtensions == null) {
      init();
    }
    List candidates = new ArrayList(1);
    for (int i = 0; i < fExtensions.length; i++)
    {
      AbstractDescriptor descriptor = fExtensions[i];
      if (descriptor.matches(element, fVariableName)) {
        candidates.add(descriptor);
      }
      descriptor.clear();
    }
    if (candidates.size() == 0) {
      return null;
    }
    return (AbstractDescriptor)candidates.get(0);
  }
  
  protected abstract AbstractDescriptor createDescriptor(IConfigurationElement paramIConfigurationElement);
  
  private void init()
  {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IConfigurationElement[] ces = registry.getConfigurationElementsFor(
      RefactoringUIPlugin.getPluginId(), 
      fExtensionPoint);
    fExtensions = new AbstractDescriptor[ces.length];
    for (int i = 0; i < ces.length; i++) {
      fExtensions[i] = createDescriptor(ces[i]);
    }
  }
}

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

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CreateChangeOperation;
import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.ui.refactoring.Re
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

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