org.eclipse.mylyn.reviews.ui_0.9.1.v20120425-0100

16:46:50.456 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.reviews.ui_0.9.1.v20120425-0100.jar
package org.eclipse.mylyn.reviews.ui;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogBlockedHandler;
import org.eclipse.jface.wizard.ProgressMonitorPart;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;

class ProgressDialog$1
  extends ProgressMonitorPart
{
  ProgressDialog$1(ProgressDialog paramProgressDialog, Composite $anonymous0, Layout $anonymous1, int $anonymous2)
  {
    super($anonymous0, $anonymous1, $anonymous2);
  }
  
  private String currentTask = null;
  
  public void setBlocked(IStatus reason)
  {
    super.setBlocked(reason);
    if (!ProgressDialog.access$0(this$0)) {
      ProgressDialog.getBlockedHandler().showBlocked(getShell(), this, reason, currentTask);
    }
  }
  
  public void clearBlocked()
  {
    super.clearBlocked();
    if (!ProgressDialog.access$0(this$0)) {
      ProgressDialog.getBlockedHandler().clearBlocked();
    }
  }
  
  public void beginTask(String name, int totalWork)
  {
    super.beginTask(name, totalWork);
    currentTask = name;
  }
  
  public void setTaskName(String name)
  {
    super.setTaskName(name);
    currentTask = name;
  }
  
  public void subTask(String name)
  {
    super.subTask(name);
    if (currentTask == null) {
      currentTask = name;
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.reviews.ui.ProgressDialog.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.reviews.ui;

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

class ProgressDialog$2
  extends SelectionAdapter
{
  ProgressDialog$2(ProgressDialog paramProgressDialog) {}
  
  public void widgetSelected(SelectionEvent event)
  {
    ProgressDialog.access$1(this$0, ((Integer)widget.getData()).intValue());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.reviews.ui.ProgressDialog.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.reviews.ui;

import java.util.Collection;
import java.util.HashMap;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.IDialogBlockedHandler;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.wizard.ProgressMonitorPart;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Widget;

public abstract class ProgressDialog
  extends TitleAreaDialog
{
  private boolean lockedUI = false;
  private Composite pageContainer;
  private Cursor waitCursor;
  private ProgressMonitorPart progressMonitorPart;
  private long activeRunningOperations = 0L;
  private final HashMap<Integer, Button> buttons = new HashMap();
  
  public ProgressDialog(Shell parentShell)
  {
    super(parentShell);
    setDialogHelpAvailable(false);
    setHelpAvailable(false);
  }
  
  protected Control createDialogArea(Composite parent)
  {
    Composite composite = (Composite)super.createDialogArea(parent);
    
    pageContainer = new Composite(composite, 0);
    pageContainer.setLayout(new FillLayout());
    GridData gd = new GridData(1808);
    pageContainer.setLayoutData(gd);
    pageContainer.setFont(parent.getFont());
    createPageControls(pageContainer);
    
    GridLayout pmlayout = new GridLayout();
    numColumns = 1;
    progressMonitorPart = createProgressMonitorPart(composite, pmlayout);
    GridData gridData = new GridData(768);
    progressMonitorPart.setLayoutData(gridData);
    progressMonitorPart.setVisible(true);
    
    Label separator = new Label(parent, 258);
    separator.setLayoutData(new GridData(768));
    
    applyDialogFont(progressMonitorPart);
    return composite;
  }
  
  protected abstract Control createPageControls(Composite paramComposite);
  
  protected Collection<? extends Control> getDisableableControls()
  {
    return buttons.values();
  }
  
  private void aboutToStart(boolean enableCancelButton)
  {
    if (getShell() != null)
    {
      Control focusControl = getShell().getDisplay().getFocusControl();
      if ((focusControl != null) && (focusControl.getShell() != getShell())) {
        focusControl = null;
      }
      Display d = getShell().getDisplay();
      waitCursor = new Cursor(d, 1);
      setDisplayCursor(waitCursor);
      for (Control button : getDisableableControls()) {
        button.setEnabled(false);
      }
      progressMonitorPart.setVisible(true);
    }
  }
  
  private void stopped(Object savedState)
  {
    if (getShell() != null)
    {
      progressMonitorPart.setVisible(false);
      setDisplayCursor(null);
      waitCursor.dispose();
      waitCursor = null;
      for (Control button : getDisableableControls()) {
        button.setEnabled(true);
      }
    }
  }
  
  protected ProgressMonitorPart createProgressMonitorPart(Composite composite, GridLayout pmlayout)
  {
    new ProgressMonitorPart(composite, pmlayout, -1)
    {
      private String currentTask = null;
      
      public void setBlocked(IStatus reason)
      {
        super.setBlocked(reason);
        if (!lockedUI) {
          ProgressDialog.getBlockedHandler().showBlocked(getShell(), this, reason, currentTask);
        }
      }
      
      public void clearBlocked()
      {
        super.clearBlocked();
        if (!lockedUI) {
          ProgressDialog.getBlockedHandler().clearBlocked();
        }
      }
      
      public void beginTask(String name, int totalWork)
      {
        super.beginTask(name, totalWork);
        currentTask = name;
      }
      
      public void setTaskName(String name)
      {
        super.setTaskName(name);
        currentTask = name;
      }
      
      public void subTask(String name)
      {
        super.subTask(name);
        if (currentTask == null) {
          currentTask = name;
        }
      }
    };
  }
  
  /* Error */
  public void run(boolean fork, boolean cancelable, org.eclipse.jface.operation.IRunnableWithProgress runnable)
    throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore 4
    //   3: aload_0
    //   4: getfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   7: lconst_0
    //   8: lcmp
    //   9: ifne +20 -> 29
    //   12: aload_0
    //   13: iload_1
    //   14: ifeq +11 -> 25
    //   17: iload_2
    //   18: ifeq +7 -> 25
    //   21: iconst_1
    //   22: goto +4 -> 26
    //   25: iconst_0
    //   26: invokespecial 244	org/eclipse/mylyn/reviews/ui/ProgressDialog:aboutToStart	(Z)V
    //   29: aload_0
    //   30: dup
    //   31: getfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   34: lconst_1
    //   35: ladd
    //   36: putfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   39: iload_1
    //   40: ifne +8 -> 48
    //   43: aload_0
    //   44: iconst_1
    //   45: putfield 227	org/eclipse/mylyn/reviews/ui/ProgressDialog:lockedUI	Z
    //   48: aload_3
    //   49: iload_1
    //   50: aload_0
    //   51: invokevirtual 249	org/eclipse/mylyn/reviews/ui/ProgressDialog:getProgressMonitor	()Lorg/eclipse/core/runtime/IProgressMonitor;
    //   54: aload_0
    //   55: invokevirtual 253	org/eclipse/mylyn/reviews/ui/ProgressDialog:getShell	()Lorg/eclipse/swt/widgets/Shell;
    //   58: invokevirtual 283	org/eclipse/swt/widgets/Shell:getDisplay	()Lorg/eclipse/swt/widgets/Display;
    //   61: invokestatic 239	org/eclipse/jface/operation/ModalContext:run	(Lorg/eclipse/jface/operation/IRunnableWithProgress;ZLorg/eclipse/core/runtime/IProgressMonitor;Lorg/eclipse/swt/widgets/Display;)V
    //   64: aload_0
    //   65: iconst_0
    //   66: putfield 227	org/eclipse/mylyn/reviews/ui/ProgressDialog:lockedUI	Z
    //   69: goto +33 -> 102
    //   72: astore 5
    //   74: aload_0
    //   75: dup
    //   76: getfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   79: lconst_1
    //   80: lsub
    //   81: putfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   84: aload_0
    //   85: getfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   88: lconst_0
    //   89: lcmp
    //   90: ifgt +9 -> 99
    //   93: aload_0
    //   94: aload 4
    //   96: invokespecial 247	org/eclipse/mylyn/reviews/ui/ProgressDialog:stopped	(Ljava/lang/Object;)V
    //   99: aload 5
    //   101: athrow
    //   102: aload_0
    //   103: dup
    //   104: getfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   107: lconst_1
    //   108: lsub
    //   109: putfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   112: aload_0
    //   113: getfield 226	org/eclipse/mylyn/reviews/ui/ProgressDialog:activeRunningOperations	J
    //   116: lconst_0
    //   117: lcmp
    //   118: ifgt +9 -> 127
    //   121: aload_0
    //   122: aload 4
    //   124: invokespecial 247	org/eclipse/mylyn/reviews/ui/ProgressDialog:stopped	(Ljava/lang/Object;)V
    //   127: return
    // Line number table:
    //   Java source line #212	-> byte code offset #0
    //   Java source line #213	-> byte code offset #3
    //   Java source line #214	-> byte code offset #12
    //   Java source line #216	-> byte code offset #29
    //   Java source line #218	-> byte code offset #39
    //   Java source line #219	-> byte code offset #43
    //   Java source line #221	-> byte code offset #48
    //   Java source line #222	-> byte code offset #64
    //   Java source line #223	-> byte code offset #72
    //   Java source line #224	-> byte code offset #74
    //   Java source line #226	-> byte code offset #84
    //   Java source line #227	-> byte code offset #93
    //   Java source line #229	-> byte code offset #99
    //   Java source line #224	-> byte code offset #102
    //   Java source line #226	-> byte code offset #112
    //   Java source line #227	-> byte code offset #121
    //   Java source line #230	-> byte code offset #127
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	128	0	this	ProgressDialog
    //   0	128	1	fork	boolean
    //   0	128	2	cancelable	boolean
    //   0	128	3	runnable	org.eclipse.jface.operation.IRunnableWithProgress
    //   1	122	4	state	Object
    //   72	28	5	localObject1	Object
    // Exception table:
    //   from	to	target	type
    //   39	72	72	finally
  }
  
  protected IProgressMonitor getProgressMonitor()
  {
    return progressMonitorPart;
  }
  
  private void setDisplayCursor(Cursor c)
  {
    Shell[] shells = getShell().getDisplay().getShells();
    Shell[] arrayOfShell1;
    int j = (arrayOfShell1 = shells).length;
    for (int i = 0; i < j; i++)
    {
      Shell element = arrayOfShell1[i];
      element.setCursor(c);
    }
  }
  
  protected Button createButton(Composite parent, int id, String label, boolean defaultButton)
  {
    getLayoutnumColumns += 1;
    Button button = new Button(parent, 8);
    button.setText(label);
    button.setFont(JFaceResources.getDialogFont());
    button.setData(new Integer(id));
    button.addSelectionListener(new SelectionAdapter()
    {
      public void widgetSelected(SelectionEvent event)
      {
        buttonPressed(((Integer)widget.getData()).intValue());
      }
    });
    if (defaultButton)
    {
      Shell shell = parent.getShell();
      if (shell != null) {
        shell.setDefaultButton(button);
      }
    }
    buttons.put(new Integer(id), button);
    setButtonLayoutData(button);
    return button;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.reviews.ui.ProgressDialog
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.reviews.ui;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.mylyn.reviews.core.model.IReviewItem;
import org.eclipse.mylyn.reviews.core.model.ITopic;
import org.eclipse.mylyn.tasks.core.ITask;

public abstract class ReviewBehavior
{
  private final ITask task;
  
  public ReviewBehavior(ITask task)
  {
    this.task = task;
  }
  
  public ITask getTask()
  {
    return task;
  }
  
  public abstract IStatus addTopic(IReviewItem paramIReviewItem, ITopic paramITopic, IProgressMonitor paramIProgressMonitor);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.reviews.ui.ReviewBehavior
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.reviews.ui;

public class ReviewUi
{
  private static final String PROPERTY = "org.eclipse.mylyn.reviews.ui.review.Active";
  private static ReviewBehavior activeReview;
  
  public static ReviewBehavior getActiveReview()
  {
    return activeReview;
  }
  
  public static void setActiveReview(ReviewBehavior activeReview)
  {
    activeReview = activeReview;
    if (activeReview != null) {
      System.setProperty("org.eclipse.mylyn.reviews.ui.review.Active", Boolean.TRUE.toString());
    } else {
      System.setProperty("org.eclipse.mylyn.reviews.ui.review.Active", null);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.reviews.ui.ReviewUi
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.reviews.ui;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;

public class SizeCachingComposite
  extends Composite
{
  private Point cachedSize = null;
  
  public SizeCachingComposite(Composite parent, int style)
  {
    super(parent, style);
  }
  
  public Point computeSize(int wHint, int hHint, boolean changed)
  {
    if (cachedSize == null) {
      cachedSize = super.computeSize(wHint, hHint, changed);
    }
    return cachedSize;
  }
  
  public void clearCache()
  {
    cachedSize = null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.reviews.ui.SizeCachingComposite
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import java.util.Iterator;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.reviews.ui.annotations.CommentAnnotation;
import org.eclipse.mylyn.internal.reviews.ui.annotations.ReviewAnnotationModel;
import org.eclipse.mylyn.internal.reviews.ui.editors.ruler.CommentAnnotationRulerColumn;
import org.eclipse.mylyn.reviews.core.model.ILineLocation;
import org.eclipse.mylyn.reviews.core.model.ITopic;
import org.eclipse.swt.custom.LineBackgroundEvent;
import org.eclipse.swt.custom.LineBackgroundListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.internal.texteditor.PropertyEventDispatcher;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;

final class ReviewCompareInputListener$ColoringLineBackgroundListener
  implements LineBackgroundListener
{
  private Color colorCommented;
  private PropertyEventDispatcher fDispatcher;
  private final StyledText styledText;
  
  private ReviewCompareInputListener$ColoringLineBackgroundListener(ReviewCompareInputListener paramReviewCompareInputListener, StyledText styledText)
  {
    this.styledText = styledText;
    initialize();
  }
  
  public void lineGetBackground(LineBackgroundEvent event)
  {
    int lineNr = styledText.getLineAtOffset(lineOffset) + 1;
    Iterator<CommentAnnotation> it = ReviewCompareInputListener.access$0(this$0).getAnnotationIterator();
    while (it.hasNext())
    {
      CommentAnnotation annotation = (CommentAnnotation)it.next();
      
      ITopic comment = annotation.getTopic();
      int startLine = ((ILineLocation)comment.getLocation()).getTotalMin();
      int endLine = ((ILineLocation)comment.getLocation()).getTotalMax();
      if ((lineNr >= startLine) && (lineNr <= endLine))
      {
        AnnotationPreference pref = new AnnotationPreferenceLookup().getAnnotationPreference(annotation);
        if (pref.getHighlightPreferenceValue()) {
          lineBackground = colorCommented;
        }
      }
    }
  }
  
  private int getDocumentOffset(LineBackgroundEvent event)
  {
    if ((widget instanceof StyledText))
    {
      String currentText = ((StyledText)widget).getText();
      if (ReviewCompareInputListener.access$1(this$0) == null)
      {
        ReviewCompareInputListener.access$2(this$0, currentText);
        
        return 0;
      }
      if (currentText.equals(ReviewCompareInputListener.access$1(this$0))) {
        return 0;
      }
      if (ReviewCompareInputListener.access$1(this$0).contains(currentText))
      {
        int charoffset = ReviewCompareInputListener.access$1(this$0).indexOf(currentText);
        int lineOffset = 0;
        String delimiter = ((StyledText)widget).getLineDelimiter();
        String[] arrayOfString;
        int j = (arrayOfString = ReviewCompareInputListener.access$1(this$0).split(delimiter)).length;
        for (int i = 0; i < j; i++)
        {
          String line = arrayOfString[i];
          if (charoffset <= 0) {
            break;
          }
          charoffset -= line.length() + delimiter.length();
          lineOffset++;
        }
        return lineOffset;
      }
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.reviews.ui", 
        "Could not find text offset for annotation highlighting - current text not contained in initial text."));
    }
    return 0;
  }
  
  private void initialize()
  {
    final IPreferenceStore store = EditorsUI.getPreferenceStore();
    if (store == null) {
      return;
    }
    AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup();
    final AnnotationPreference commentedPref = lookup.getAnnotationPreference("org.eclipse.mylyn.reviews.ui.comment.Annotation");
    
    updateCommentedColor(commentedPref, store);
    
    fDispatcher = new PropertyEventDispatcher(store);
    if (commentedPref != null) {
      fDispatcher.addPropertyChangeListener(commentedPref.getColorPreferenceKey(), 
        new IPropertyChangeListener()
        {
          public void propertyChange(PropertyChangeEvent event)
          {
            ReviewCompareInputListener.ColoringLineBackgroundListener.this.updateCommentedColor(commentedPref, store);
          }
        });
    }
  }
  
  private void updateCommentedColor(AnnotationPreference pref, IPreferenceStore store)
  {
    if (pref != null)
    {
      RGB rgb = CommentAnnotationRulerColumn.getColorFromAnnotationPreference(store, pref);
      colorCommented = EditorsUI.getSharedTextColors().getColor(rgb);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.reviews.ui.compare.ReviewCompareInputListener.ColoringLineBackgroundListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;

class ReviewCompareAnnotationSupport$1
  implements Runnable
{
  ReviewCompareAnnotationSupport$1(ReviewCompareAnnotationSupport paramReviewCompareAnnotationSupport) {}
  
  public void run()
  {
    try
    {
      ReviewCompareAnnotationSupport.access$0(this$0).forceCustomAnnotationHover();
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.reviews.ui", 
        "Error attaching annotation hover", e));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.reviews.ui.compare.ReviewCompareAnnotationSupport.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import java.lang.reflect.Field;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.compare.internal.MergeSourceViewer;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.reviews.ui.annotations.ReviewAnnotationModel;
import org.eclipse.mylyn.reviews.core.model.IFileItem;
import org.eclipse.mylyn.reviews.ui.ReviewBehavior;
import org.eclipse.swt.widgets.Display;

public class ReviewCompareAnnotationSupport
{
  private static String KEY_ANNOTAION_SUPPORT = ReviewItemSetCompareEditorInput.class.getName();
  private ReviewBehavior behavior;
  private final ReviewAnnotationModel leftAnnotationModel;
  private ReviewCompareInputListener leftViewerListener;
  private final ReviewAnnotationModel rightAnnotationModel;
  private ReviewCompareInputListener rightViewerListener;
  
  public static ReviewCompareAnnotationSupport getAnnotationSupport(Viewer contentViewer)
  {
    ReviewCompareAnnotationSupport support = (ReviewCompareAnnotationSupport)contentViewer.getData(KEY_ANNOTAION_SUPPORT);
    if (support == null)
    {
      support = new ReviewCompareAnnotationSupport(contentViewer);
      contentViewer.setData(KEY_ANNOTAION_SUPPORT, support);
    }
    return support;
  }
  
  public ReviewCompareAnnotationSupport(Viewer contentViewer)
  {
    leftAnnotationModel = new ReviewAnnotationModel();
    rightAnnotationModel = new ReviewAnnotationModel();
    install(contentViewer);
  }
  
  public void attachToViewer(TextMergeViewer viewer, MergeSourceViewer fLeft, MergeSourceViewer fRight)
  {
    if (!isListenerFor(leftViewerListener, fLeft, leftAnnotationModel)) {
      leftViewerListener = registerInputListener(fLeft, leftAnnotationModel);
    } else {
      Display.getDefault().asyncExec(new Runnable()
      {
        public void run()
        {
          try
          {
            leftViewerListener.forceCustomAnnotationHover();
          }
          catch (Exception e)
          {
            StatusHandler.log(new Status(4, "org.eclipse.mylyn.reviews.ui", 
              "Error attaching annotation hover", e));
          }
        }
      });
    }
    if (!isListenerFor(rightViewerListener, fRight, rightAnnotationModel)) {
      rightViewerListener = registerInputListener(fRight, rightAnnotationModel);
    } else {
      Display.getDefault().asyncExec(new Runnable()
      {
        public void run()
        {
          try
          {
            rightViewerListener.forceCustomAnnotationHover();
          }
          catch (Exception e)
          {
            StatusHandler.log(new Status(4, "org.eclipse.mylyn.reviews.ui", 
              "Error attaching annotation hover", e));
          }
        }
      });
    }
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    ReviewCompareAnnotationSupport other = (ReviewCompareAnnotationSupport)obj;
    if (leftAnnotationModel == null)
    {
      if (leftAnnotationModel != null) {
        return false;
      }
    }
    else if (!leftAnnotationModel.equals(leftAnnotationModel)) {
      return false;
    }
    if (rightAnnotationModel == null)
    {
      if (rightAnnotationModel != null) {
        return false;
      }
    }
    else if (!rightAnnotationModel.equals(rightAnnotationModel)) {
      return false;
    }
    return true;
  }
  
  public ReviewBehavior getBehavior()
  {
    return behavior;
  }
  
  public int hashCode()
  {
    int result = 1;
    result = 31 * result + (leftAnnotationModel == null ? 0 : leftAnnotationModel.hashCode());
    result = 31 * result + (rightAnnotationModel == null ? 0 : rightAnnotationModel.hashCode());
    return result;
  }
  
  public void install(Viewer contentViewer)
  {
    if ((contentViewer instanceof TextMergeViewer))
    {
      TextMergeViewer textMergeViewer = (TextMergeViewer)contentViewer;
      try
      {
        Class<TextMergeViewer> clazz = TextMergeViewer.class;
        Field declaredField = clazz.getDeclaredField("fLeft");
        declaredField.setAccessible(true);
        MergeSourceViewer fLeft = (MergeSourceViewer)declaredField.get(textMergeViewer);
        
        declaredField = clazz.getDeclaredField("fRight");
        declaredField.setAccessible(true);
        MergeSourceViewer fRight = (MergeSourceViewer)declaredField.get(textMergeViewer);
        
        leftViewerListener = registerInputListener(fLeft, leftAnnotationModel);
        rightViewerListener = registerInputListener(fRight, rightAnnotationModel);
      }
      catch (Throwable t)
      {
        StatusHandler.log(new Status(2, "org.eclipse.mylyn.reviews.ui", 
          "Could not initialize annotation model for " + Viewer.class.getName(), t));
      }
    }
  }
  
  public void setReviewItem(IFileItem item, ReviewBehavior behavior)
  {
    leftAnnotationModel.setItem(item.getTarget(), behavior);
    rightAnnotationModel.setItem(item.getBase(), behavior);
    Display.getDefault().asyncExec(new Runnable()
    {
      public void run()
      {
        try
        {
          leftViewerListener.forceCustomAnnotationHover();
        }
        catch (Exception e)
        {
          StatusHandler.log(new Status(4, "org.eclipse.mylyn.reviews.ui", 
            "Error attaching annotation hover", e));
        }
      }
    });
  }
  
  private boolean isListenerFor(ReviewCompareInputListener listener, MergeSourceViewer viewer, ReviewAnnotationModel annotationModel)
  {
    if (listener == null) {
      return false;
    }
    return listener.isListenerFor(viewer, annotationModel);
  }
  
  private ReviewCompareInputListener registerInputListener(MergeSourceViewer sourceViewer, ReviewAnnotationModel annotationModel)
  {
    ReviewCompareInputListener listener = new ReviewCompareInputListener(sourceViewer, annotationModel);
    SourceViewer viewer = CompareUtil.getSourceViewer(sourceViewer);
    if (viewer != null) {
      viewer.addTextInputListener(listener);
    }
    listener.registerContextMenu();
    return listener;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.reviews.ui.compare.ReviewCompareAnnotationSupport
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.apache.commons.io.FilenameUtils;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;

class ByteArrayInput
  implements ITypedElement, IStreamContentAccessor
{
  byte[] content;
  private final String name;
  
  public ByteArrayInput(byte[] content, String name)
  {
    this.content = content;
    this.name = name;
  }
  
  public String getName()
  {
    return name;
  }
  
  public Image getImage()
  {
    return null;
  }
  
  public String getType()
  {
    String extension = FilenameUtils.getExtension(name);
    return (extension != null) && (extension.length() > 0) ? extension : "txt";
  }
  
  public InputStream getContents()
    throws CoreException
  {
    return new ByteArrayInputStream(content);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.reviews.ui.compare.ByteArrayInput
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;

class ReviewCompareAnnotationSupport$2
  implements Runnable
{
  ReviewCompareAnnotationSupport$2(ReviewCompareAnnotationSupport paramReviewCompareAnnotationSupport) {}
  
  public void run()
  {
    try
    {
      ReviewCompareAnnotationSupport.access$1(this$0).forceCustomAnnotationHover();
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.reviews.ui", 
        "Error attaching annotation hover", e));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.reviews.ui.compare.ReviewCompareAnnotationSupport.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.contentmergeviewer.ContentMergeViewer;
import org.eclipse.compare.contentmergeviewer.IMergeViewerContentProvider;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
import org.eclipse.compare.internal.MergeSourceViewer;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.reviews.core.model.IFileItem;
import org.eclipse.mylyn.reviews.core.model.IFileRevision;

public class CompareUtil
{
  public static DiffNode createDiffNode(IFileItem file)
  {
    byte[] targetContent = getContent(file.getTarget());
    byte[] baseContent = getContent(file.getBase());
    String targetPath = file.getTarget().getPath();
    if (targetPath == null) {
      targetPath = file.getBase().getPath();
    }
    String basePath = file.getBase().getPath();
    if (basePath == null) {
      basePath = targetPath;
    }
    return new DiffNode(new ByteArrayInput(targetContent, targetPath), new ByteArrayInput(baseContent, basePath));
  }
  
  static byte[] getContent(IFileRevision revision)
  {
    String content = revision.getContent();
    return content != null ? content.getBytes() : new byte[0];
  }
  
  static SourceViewer getSourceViewer(MergeSourceViewer sourceViewer)
  {
    if (SourceViewer.class.isInstance(sourceViewer)) {
      return (SourceViewer)SourceViewer.class.cast(sourceViewer);
    }
    try
    {
      Method getSourceViewerRefl = MergeSourceViewer.class.getDeclaredMethod("getSourceViewer", new Class[0]);
      getSourceViewerRefl.setAccessible(true);
      Object returnValue = getSourceViewerRefl.invoke(sourceViewer, new Object[0]);
      if ((returnValue instanceof SourceViewer)) {
        return (SourceViewer)returnValue;
      }
    }
    catch (Exception localException) {}
    return null;
  }
  
  static void setActiveViewer(TextMergeViewer mergeViewer, MergeSourceViewer focusViewer)
  {
    try
    {
      Method setActiveViewer = TextMergeViewer.class.getDeclaredMethod("setActiveViewer", new Class[] {
        MergeSourceViewer.class, Boolean.TYPE });
      setActiveViewer.setAccessible(true);
      setActiveViewer.invoke(mergeViewer, new Object[] { focusViewer, Boolean.valueOf(true) });
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(2, "org.eclipse.mylyn.reviews.ui", "Failed to activate viewer", e));
    }
  }
  
  static void configureSourceViewers(Viewer contentViewer, TextMergeViewer textMergeViewer, MergeSourceViewer fLeft, MergeSourceViewer fRight)
  {
    try
    {
      Method getCompareConfiguration = ContentMergeViewer.class.getDeclaredMethod("getCompareConfiguration", new Class[0]);
      getCompareConfiguration.setAccessible(true);
      CompareConfiguration cc = (CompareConfiguration)getCompareConfiguration.invoke(textMergeViewer, new Object[0]);
      
      Method getMergeContentProvider = ContentMergeViewer.class.getDeclaredMethod("getMergeContentProvider", new Class[0]);
      getMergeContentProvider.setAccessible(true);
      IMergeViewerContentProvider cp = (IMergeViewerContentProvider)getMergeContentProvider.invoke(textMergeViewer, new Object[0]);
      
      Method getSourceViewer = MergeSourceViewer.class.getDeclaredMethod("getSourceViewer", new Class[0]);
      
      Method configureSourceViewer = TextMergeViewer.class.getDeclaredMethod("configureSourceViewer", new Class[] {
        SourceViewer.class, Boolean.TYPE });
      configureSourceViewer.setAccessible(true);
      configureSourceViewer.invoke(contentViewer, new Object[] { getSourceViewer.invoke(fLeft, new Object[0]), 
        Boolean.valueOf((cc.isLeftEditable()) && (cp.isLeftEditable(textMergeViewer.getInput())) ? 1 : false) });
      configureSourceViewer.invoke(contentViewer, new Object[] { getSourceViewer.invoke(fRight, new Object[0]), 
        Boolean.valueOf((cc.isRightEditable()) && (cp.isRightEditable(textMergeViewer.getInput())) ? 1 : false) });
      
      Field isConfiguredField = TextMergeViewer.class.getDeclaredField("isConfigured");
      isConfiguredField.setAccessible(true);
      isConfiguredField.set(contentViewer, Boolean.valueOf(true));
    }
    catch (Throwable t)
    {
      t.printStackTrace();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.reviews.ui.compare.CompareUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;

class ReviewCompareAnnotationSupport$3
  implements Runnable
{
  ReviewCompareAnnotationSupport$3(ReviewCompareAnnotationSupport paramReviewCompareAnnotationSupport) {}
  
  public void run()
  {
    try
    {
      ReviewCompareAnnotationSupport.access$0(this$0).forceCustomAnnotationHover();
    }
    catch (Exception e)
    {
      StatusHandler.log(new Status(4, "org.eclipse.mylyn.reviews.ui", 
        "Error attaching annotation hover", e));
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.reviews.ui.compare.ReviewCompareAnnotationSupport.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.reviews.ui.compare;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import org.eclipse.compare.internal.MergeSourceViewer;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextInputListener;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.text.source.AnnotationBarHoverManager;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IAnnotationAccess;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelExtension;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.LineRange;
import org.eclipse.jface.text.source.OverviewRuler;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.reviews.ui.actions.AddLineCommentToFileAction;
import org.eclipse.mylyn.internal.reviews.ui.annotations.CommentAnnotation;
import org.eclipse.mylyn.internal.reviews.ui.annotations.CommentAnnotationHover;
import org.eclipse.mylyn.internal.reviews.ui.annotations.CommentInformationControlCreator;
import org.eclipse.mylyn.internal.reviews.ui.annotations.IReviewCompareSourceViewer;
import org.eclipse.mylyn.internal.reviews.ui.annotations.ReviewAnnotationModel;
import org.eclipse.mylyn.internal.reviews.ui.editors.ruler.CommentAnnotationRulerColumn;
import org.eclipse.mylyn.reviews.core.model.ILineLocation;
import org.eclipse.mylyn.reviews.core.model.ITopic;
import org.eclipse.swt.custom.LineBackgroundEvent;
import org.eclipse.swt.custom.LineBackgroundListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
import org.eclipse.ui.internal.texteditor.AnnotationColumn;
import org.eclipse.ui.internal.texteditor.PropertyEventDispatcher;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;

class ReviewCompareInputListener
  implements ITextInputListener, IReviewCompareSourceViewer
{
  private AddLineCommentToFileAction addLineCommentAction;
  private final ReviewAnnotationModel annotationModel;
  private String initialText;
  private final MergeSourceViewer mergeSourceViewer;
  private final SourceViewer sourceViewer;
  
  private final class ColoringLineBackgroundListener
    implements LineBackgroundListener
  {
    private Color colorCommented;
    private PropertyEventDispatcher fDispatcher;
    private final StyledText styledText;
    
    private ColoringLineBackgroundListener(StyledText styledText)
    {
      this.styledText = styledText;
      initialize();
    }
    
    public void lineGetBackground(LineBackgroundEvent event)
    {
      int lineNr = styledText.getLineAtOffset(lineOffset) + 1;
      Iterator<CommentAnnotation> it = annotationModel.getAnnotationIterator();
      while (it.hasNext())
      {
        CommentAnnotation annotation = (CommentAnnotation)it.next();
        
        ITopic comment = annotation.getTopic();
        int startLine = ((ILineLocation)comment.getLocation()).getTotalMin();
        int endLine = ((ILineLocation)comment.getLocation()).getTotalMax();
        if ((lineNr >= startLine) && (lineNr <= endLine))
        {
          AnnotationPreference pref = new AnnotationPreferenceLookup().getAnnotationPreference(annotation);
          if (pref.getHighlightPreferenceValue()) {
            lineBackground = colorCommented;
          }
        }
      }
    }
    
    private int getDocumentOffset(LineBackgroundEvent event)
    {
      if ((widget instanceof StyledText))
      {
        String currentText = ((StyledText)widget).getText();
        if (initialText == null)
        {
          initialText = currentText;
          
          return 0;
        }
        if (currentText.equals(initialText)) {
          return 0;
        }
        if (initialText.contains(currentText))
        {
          int charoffset = initialText.indexOf(currentText);
          int lineOffset = 0;
          String delimiter = ((StyledText)widget).getLineDelimiter();
          String[] arrayOfString;
          int j = (arrayOfString = initialText.split(delimiter)).length;
          for (int i = 0; i < j; i++)
          {
            String line = arrayOfString[i];
            if (charoffset <= 0) {
              break;
            }
            charoffset -= line.length() + delimiter.length();
            lineOffset++;
          }
 
1 2 3 4 5

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