org.eclipse.linuxtools.dataviewers.annotatedsourceeditor_4.1.0.201310101546

16:46:04.410 INFO  jd.cli.Main - Decompiling org.eclipse.linuxtools.dataviewers.annotatedsourceeditor_4.1.0.201310101546.jar
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import java.util.ArrayList;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.swt.graphics.Color;
import org.eclipse.ui.ide.FileStoreEditorInput;

public abstract class AbstractSTAnnotatedSourceEditorInput
  extends FileStoreEditorInput
{
  private ArrayList<ISTAnnotationColumn> columns;
  
  public AbstractSTAnnotatedSourceEditorInput(IFileStore fileStore)
  {
    super(fileStore);
  }
  
  public int getColumnCount()
  {
    if (columns == null) {
      columns = getColumns();
    }
    return columns != null ? columns.size() : 0;
  }
  
  public String getTitle(ISTAnnotationColumn column)
  {
    if (columns == null) {
      columns = getColumns();
    }
    return column != null ? column.getTitle() : null;
  }
  
  public abstract Color getColor(int paramInt);
  
  public String getAnnotation(int line, ISTAnnotationColumn column)
  {
    if (columns == null) {
      columns = getColumns();
    }
    return column != null ? column.getAnnotation(line) : null;
  }
  
  public String getLongDescription(int line, ISTAnnotationColumn column)
  {
    if (columns == null) {
      columns = getColumns();
    }
    return column != null ? column.getLongDescription(line) : null;
  }
  
  public String getTooltip(int line, ISTAnnotationColumn column)
  {
    if (columns == null) {
      columns = getColumns();
    }
    return column != null ? column.getTooltip(line) : null;
  }
  
  public abstract ArrayList<ISTAnnotationColumn> getColumns();
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.AbstractSTAnnotatedSourceEditorInput
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

public abstract interface ISTAnnotationColumn
{
  public abstract String getTitle();
  
  public abstract String getAnnotation(int paramInt);
  
  public abstract String getTooltip(int paramInt);
  
  public abstract String getLongDescription(int paramInt);
  
  public abstract String getHeaderTooltip();
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.ISTAnnotationColumn
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import org.eclipse.ui.texteditor.ITextEditorActionConstants;

public abstract interface ISTTextEditorActionConstants
  extends ITextEditorActionConstants
{
  public static final String ST_TOGGLE = "ST.Toggle";
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.ISTTextEditorActionConstants
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;

public abstract interface ISTTextEditorActionDefinitionIds
  extends ITextEditorActionDefinitionIds
{
  public static final String ST_TOGGLE = "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STColumnToggle";
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.ISTTextEditorActionDefinitionIds
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import java.util.ResourceBundle;
import org.eclipse.ui.texteditor.ResourceAction;

class STAnnotatedCSourceEditor$1
  extends ResourceAction
{
  STAnnotatedCSourceEditor$1(STAnnotatedCSourceEditor paramSTAnnotatedCSourceEditor, ResourceBundle $anonymous0, String $anonymous1, int $anonymous2)
  {
    super($anonymous0, $anonymous1, $anonymous2);
  }
  
  public void run()
  {
    STAnnotatedCSourceEditor.access$9(this$0);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import java.util.ArrayList;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.ui.texteditor.rulers.IContributedRulerColumn;
import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor;

class STAnnotatedCSourceEditor$STColumnSupport$1
  extends SafeRunnable
{
  STAnnotatedCSourceEditor$STColumnSupport$1(STAnnotatedCSourceEditor.STColumnSupport paramSTColumnSupport, RulerColumnDescriptor paramRulerColumnDescriptor, ISTAnnotationColumn paramISTAnnotationColumn, CompositeRuler paramCompositeRuler, int paramInt) {}
  
  public void run()
    throws Exception
  {
    IContributedRulerColumn column = val$descriptor.createColumn(STAnnotatedCSourceEditor.STColumnSupport.access$0(this$1));
    STAnnotatedCSourceEditor.STColumnSupport.access$1(this$1).add(val$annotationColumn);
    this$1.initializeColumn(column);
    val$ruler.addDecorator(val$idx, column);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor.STColumnSupport.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import org.eclipse.jface.text.source.IVerticalRulerColumn;
import org.eclipse.ui.internal.texteditor.LineNumberColumn.ICompatibilityForwarder;

class STAnnotatedCSourceEditor$STColumnSupport$2
  implements LineNumberColumn.ICompatibilityForwarder
{
  STAnnotatedCSourceEditor$STColumnSupport$2(STAnnotatedCSourceEditor.STColumnSupport paramSTColumnSupport) {}
  
  public IVerticalRulerColumn createLineNumberRulerColumn()
  {
    return STAnnotatedCSourceEditor.access$4(STAnnotatedCSourceEditor.STColumnSupport.access$0(this$1));
  }
  
  public boolean isQuickDiffEnabled()
  {
    return STAnnotatedCSourceEditor.access$5(STAnnotatedCSourceEditor.STColumnSupport.access$0(this$1));
  }
  
  public boolean isLineNumberRulerVisible()
  {
    return STAnnotatedCSourceEditor.access$6(STAnnotatedCSourceEditor.STColumnSupport.access$0(this$1));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor.STColumnSupport.2
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import java.util.ArrayList;
import org.eclipse.jface.text.source.IVerticalRulerColumn;

class STAnnotatedCSourceEditor$STColumnSupport$3
  implements STContributedRulerColumn.ICompatibilityForwarder
{
  STAnnotatedCSourceEditor$STColumnSupport$3(STAnnotatedCSourceEditor.STColumnSupport paramSTColumnSupport) {}
  
  public IVerticalRulerColumn createSTRulerColumn()
  {
    if ((STAnnotatedCSourceEditor.STColumnSupport.access$1(this$1) != null) && (STAnnotatedCSourceEditor.STColumnSupport.access$1(this$1).size() > 0))
    {
      IVerticalRulerColumn fDelegate = STAnnotatedCSourceEditor.STColumnSupport.access$0(this$1).createSTRulerColumn((ISTAnnotationColumn)STAnnotatedCSourceEditor.STColumnSupport.access$1(this$1).get(STAnnotatedCSourceEditor.STColumnSupport.access$1(this$1).size() - 1));
      return fDelegate;
    }
    return null;
  }
  
  public boolean isQuickDiffEnabled()
  {
    return STAnnotatedCSourceEditor.access$5(STAnnotatedCSourceEditor.STColumnSupport.access$0(this$1));
  }
  
  public boolean isSTRulerVisible()
  {
    return STAnnotatedCSourceEditor.STColumnSupport.access$0(this$1).isSTRulerVisible();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor.STColumnSupport.3
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.IVerticalRulerColumn;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.ui.internal.texteditor.AnnotationColumn;
import org.eclipse.ui.internal.texteditor.LineNumberColumn;
import org.eclipse.ui.internal.texteditor.LineNumberColumn.ICompatibilityForwarder;
import org.eclipse.ui.texteditor.AbstractTextEditor.ColumnSupport;
import org.eclipse.ui.texteditor.rulers.IContributedRulerColumn;
import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor;
import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry;

public class STAnnotatedCSourceEditor$STColumnSupport
  extends AbstractTextEditor.ColumnSupport
{
  private final STAnnotatedCSourceEditor fEditor;
  private final RulerColumnRegistry fRegistry;
  private final ArrayList<ISTAnnotationColumn> fColumns;
  
  public STAnnotatedCSourceEditor$STColumnSupport(STAnnotatedCSourceEditor paramSTAnnotatedCSourceEditor1, STAnnotatedCSourceEditor editor, RulerColumnRegistry registry)
  {
    super(editor, registry);
    fEditor = editor;
    fRegistry = registry;
    fColumns = new ArrayList();
  }
  
  private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor)
  {
    int index = 0;
    List<?> all = fRegistry.getColumnDescriptors();
    int newPos = all.indexOf(descriptor);
    for (Iterator<?> it = ruler.getDecoratorIterator(); it.hasNext();)
    {
      IVerticalRulerColumn column = (IVerticalRulerColumn)it.next();
      if ((column instanceof IContributedRulerColumn))
      {
        RulerColumnDescriptor rcd = ((IContributedRulerColumn)column).getDescriptor();
        if ((rcd != null) && (all.indexOf(rcd) > newPos)) {
          break;
        }
      }
      else
      {
        if ("org.eclipse.jface.text.source.projection.ProjectionRulerColumn".equals(column.getClass().getName())) {
          break;
        }
      }
      index++;
    }
    return index;
  }
  
  public void addSTColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor, final ISTAnnotationColumn annotationColumn)
  {
    final int idx = computeIndex(ruler, descriptor);
    
    SafeRunnable runnable = new SafeRunnable()
    {
      public void run()
        throws Exception
      {
        IContributedRulerColumn column = descriptor.createColumn(fEditor);
        fColumns.add(annotationColumn);
        initializeColumn(column);
        ruler.addDecorator(idx, column);
      }
    };
    SafeRunner.run(runnable);
  }
  
  protected void initializeColumn(IContributedRulerColumn column)
  {
    super.initializeColumn(column);
    RulerColumnDescriptor descriptor = column.getDescriptor();
    IVerticalRuler ruler = STAnnotatedCSourceEditor.access$0(this$0);
    if ((ruler instanceof CompositeRuler))
    {
      if ("org.eclipse.ui.editors.columns.annotations".equals(descriptor.getId()))
      {
        ((AnnotationColumn)column).setDelegate(STAnnotatedCSourceEditor.access$1(this$0, (CompositeRuler)ruler));
      }
      else if ("org.eclipse.ui.editors.columns.linenumbers".equals(descriptor.getId()))
      {
        STAnnotatedCSourceEditor.access$2(this$0, (LineNumberColumn)column);
        STAnnotatedCSourceEditor.access$3(this$0).setForwarder(new LineNumberColumn.ICompatibilityForwarder()
        {
          public IVerticalRulerColumn createLineNumberRulerColumn()
          {
            return STAnnotatedCSourceEditor.access$4(fEditor);
          }
          
          public boolean isQuickDiffEnabled()
          {
            return STAnnotatedCSourceEditor.access$5(fEditor);
          }
          
          public boolean isLineNumberRulerVisible()
          {
            return STAnnotatedCSourceEditor.access$6(fEditor);
          }
        });
      }
      if ("org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.column".equals(descriptor.getId()))
      {
        STAnnotatedCSourceEditor.access$7(this$0, (STContributedRulerColumn)column);
        
        STAnnotatedCSourceEditor.access$8(this$0).setForwarder(new STContributedRulerColumn.ICompatibilityForwarder()
        {
          public IVerticalRulerColumn createSTRulerColumn()
          {
            if ((fColumns != null) && (fColumns.size() > 0))
            {
              IVerticalRulerColumn fDelegate = fEditor.createSTRulerColumn((ISTAnnotationColumn)fColumns.get(fColumns.size() - 1));
              return fDelegate;
            }
            return null;
          }
          
          public boolean isQuickDiffEnabled()
          {
            return STAnnotatedCSourceEditor.access$5(fEditor);
          }
          
          public boolean isSTRulerVisible()
          {
            return fEditor.isSTRulerVisible();
          }
        });
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor.STColumnSupport
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

class STAnnotatedCSourceEditor$ToolTipSupport$ToolTipArea
{
  int line;
  ISTAnnotationColumn ac;
  
  STAnnotatedCSourceEditor$ToolTipSupport$ToolTipArea(STAnnotatedCSourceEditor.ToolTipSupport paramToolTipSupport, int line, ISTAnnotationColumn ac)
  {
    this.line = line;
    this.ac = ac;
  }
  
  public String getToolTip()
  {
    return ac.getTooltip(line);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor.ToolTipSupport.ToolTipArea
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import org.eclipse.jface.window.DefaultToolTip;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;

class STAnnotatedCSourceEditor$ToolTipSupport
  extends DefaultToolTip
{
  private STContributedRulerColumn control;
  
  class ToolTipArea
  {
    int line;
    ISTAnnotationColumn ac;
    
    ToolTipArea(int line, ISTAnnotationColumn ac)
    {
      this.line = line;
      this.ac = ac;
    }
    
    public String getToolTip()
    {
      return ac.getTooltip(line);
    }
  }
  
  protected STAnnotatedCSourceEditor$ToolTipSupport(STContributedRulerColumn control, int style, boolean manualActivation)
  {
    super(control.getControl(), style, manualActivation);
    this.control = control;
  }
  
  protected Object getToolTipArea(Event event)
  {
    int line = control.toDocumentLineNumber(y);
    
    return new ToolTipArea(line, control.getAnnotationColumn(line));
  }
  
  protected Composite createToolTipContentArea(Event event, Composite parent)
  {
    Composite comp = new Composite(parent, 0);
    comp.setLayout(new FillLayout());
    Label b = new Label(comp, 0);
    ToolTipArea area = (ToolTipArea)getToolTipArea(event);
    if ((area != null) && (area.getToolTip().trim().length() > 0)) {
      b.setText(area.getToolTip());
    }
    return comp;
  }
  
  public static void enableFor(STContributedRulerColumn control)
  {
    new ToolTipSupport(control, 2, false);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor.ToolTipSupport
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IChangeRulerColumn;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.IVerticalRulerColumn;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.window.DefaultToolTip;
import org.eclipse.swt.custom.LineBackgroundEvent;
import org.eclipse.swt.custom.LineBackgroundListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.StyledTextContent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IEditorInput;
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.LineNumberColumn;
import org.eclipse.ui.internal.texteditor.LineNumberColumn.ICompatibilityForwarder;
import org.eclipse.ui.texteditor.AbstractTextEditor.ColumnSupport;
import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
import org.eclipse.ui.texteditor.ResourceAction;
import org.eclipse.ui.texteditor.rulers.IColumnSupport;
import org.eclipse.ui.texteditor.rulers.IContributedRulerColumn;
import org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor;
import org.eclipse.ui.texteditor.rulers.RulerColumnRegistry;

public class STAnnotatedCSourceEditor
  extends CEditor
  implements LineBackgroundListener
{
  private static final String ST_RULER = "STRuler";
  protected STContributedRulerColumn fAbstractSTRulerColumn;
  private IColumnSupport fColumnSupport;
  private LineNumberColumn fLineColumn;
  private STContributedRulerColumn fColumn;
  private StyledText fCachedTextWidget;
  private AbstractSTAnnotatedSourceEditorInput fInput;
  private ArrayList<ISTAnnotationColumn> fListColumns;
  private STChangeRulerColumn fSTChangeRulerColumn;
  
  public void createPartControl(Composite parent)
  {
    if (fInput == null)
    {
      super.createPartControl(parent);
      return;
    }
    GridLayout layout = new GridLayout();
    numColumns = (fInput.getColumnCount() + 1);
    horizontalSpacing = 0;
    parent.setLayout(layout);
    GridData gd = new GridData();
    grabExcessHorizontalSpace = false;
    grabExcessVerticalSpace = true;
    
    parent.setLayoutData(gd);
    
    Composite fParentSv = new Composite(parent, 0);
    gd = new GridData(1808);
    horizontalSpan = (fInput.getColumnCount() + 1);
    horizontalIndent = (verticalIndent = 0);
    fParentSv.setLayoutData(gd);
    FillLayout fillLayout = new FillLayout(768);
    marginWidth = (marginHeight = 0);
    fParentSv.setLayout(fillLayout);
    
    super.createPartControl(fParentSv);
    
    STColumnSupport columnSupport = (STColumnSupport)getAdapter(IColumnSupport.class);
    RulerColumnRegistry registry = RulerColumnRegistry.getDefault();
    for (int i = 1; i <= fInput.getColumnCount(); i++)
    {
      RulerColumnDescriptor abstractSTColumnDescriptor = registry.getColumnDescriptor("org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.column");
      columnSupport.addSTColumn((CompositeRuler)getVerticalRuler(), abstractSTColumnDescriptor, (ISTAnnotationColumn)fListColumns.get(i - 1));
    }
    CompositeRuler vr = (CompositeRuler)super.getVerticalRuler();
    int count = 0;
    Font font = parent.getFont();
    FontData fd = font.getFontData()[0];
    fd.setStyle(1);
    for (Iterator<?> iter = vr.getDecoratorIterator(); iter.hasNext();)
    {
      IVerticalRulerColumn column = (IVerticalRulerColumn)iter.next();
      if ((column instanceof STContributedRulerColumn))
      {
        STContributedRulerColumn fSTColumn = (STContributedRulerColumn)column;
        Label label = new Label(parent, 2048);
        gd = new GridData();
        count++;
        if (count == 1) {
          horizontalIndent = 17;
        } else {
          horizontalIndent = 0;
        }
        widthHint = fSTColumn.getWidth();
        label.setFont(new Font(label.getDisplay(), fd));
        label.setLayoutData(gd);
        label.moveAbove(fParentSv);
        label.setText(fSTColumn.getAnnotationColumn(0).getTitle());
        fSTColumn.setLabelColumn(label);
        if (fSTColumn.isShowingSTRuler()) {
          ToolTipSupport.enableFor(fSTColumn);
        }
      }
    }
    Label label = new Label(parent, 2048);
    gd = new GridData();
    horizontalAlignment = 4;
    grabExcessHorizontalSpace = true;
    label.setFont(new Font(label.getDisplay(), fd));
    label.setLayoutData(gd);
    label.moveAbove(fParentSv);
    label.setText(getTitle());
    
    showLinesColored();
    if (getViewer() != null)
    {
      ISourceViewer sv = getViewer();
      if (sv.getTextWidget() != null)
      {
        fCachedTextWidget = sv.getTextWidget();
        fCachedTextWidget.addLineBackgroundListener(this);
      }
    }
  }
  
  protected void rulerContextMenuAboutToShow(IMenuManager menu)
  {
    super.rulerContextMenuAboutToShow(menu);
    
    CompositeRuler vr = (CompositeRuler)super.getVerticalRuler();
    for (Iterator<?> iter = vr.getDecoratorIterator(); iter.hasNext();)
    {
      IVerticalRulerColumn column = (IVerticalRulerColumn)iter.next();
      if ((column instanceof STContributedRulerColumn))
      {
        STContributedRulerColumn fSTColumn = (STContributedRulerColumn)column;
        IAction stprofcolAction = getAction("ST.Toggle");
        stprofcolAction.setChecked((fSTColumn != null) && (fSTColumn.isShowingSTRuler()));
      }
      else if ((column instanceof LineNumberColumn))
      {
        LineNumberColumn fLineColumn = (LineNumberColumn)column;
        IAction lineNumberAction = getAction("Linenumbers.Toggle");
        lineNumberAction.setChecked((fLineColumn != null) && (fLineColumn.isShowingLineNumbers()));
      }
    }
    if (fInput != null)
    {
      IAction stAction = getAction("ST.Toggle");
      menu.appendToGroup("rulers", stAction);
    }
  }
  
  public Object getAdapter(Class required)
  {
    if (IColumnSupport.class.equals(required))
    {
      if (fColumnSupport == null) {
        fColumnSupport = createSTColumnSupport();
      }
      return fColumnSupport;
    }
    return super.getAdapter(required);
  }
  
  protected IColumnSupport createSTColumnSupport()
  {
    return new STColumnSupport(this, RulerColumnRegistry.getDefault());
  }
  
  protected class STColumnSupport
    extends AbstractTextEditor.ColumnSupport
  {
    private final STAnnotatedCSourceEditor fEditor;
    private final RulerColumnRegistry fRegistry;
    private final ArrayList<ISTAnnotationColumn> fColumns;
    
    public STColumnSupport(STAnnotatedCSourceEditor editor, RulerColumnRegistry registry)
    {
      super(registry);
      fEditor = editor;
      fRegistry = registry;
      fColumns = new ArrayList();
    }
    
    private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor)
    {
      int index = 0;
      List<?> all = fRegistry.getColumnDescriptors();
      int newPos = all.indexOf(descriptor);
      for (Iterator<?> it = ruler.getDecoratorIterator(); it.hasNext();)
      {
        IVerticalRulerColumn column = (IVerticalRulerColumn)it.next();
        if ((column instanceof IContributedRulerColumn))
        {
          RulerColumnDescriptor rcd = ((IContributedRulerColumn)column).getDescriptor();
          if ((rcd != null) && (all.indexOf(rcd) > newPos)) {
            break;
          }
        }
        else
        {
          if ("org.eclipse.jface.text.source.projection.ProjectionRulerColumn".equals(column.getClass().getName())) {
            break;
          }
        }
        index++;
      }
      return index;
    }
    
    public void addSTColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor, final ISTAnnotationColumn annotationColumn)
    {
      final int idx = computeIndex(ruler, descriptor);
      
      SafeRunnable runnable = new SafeRunnable()
      {
        public void run()
          throws Exception
        {
          IContributedRulerColumn column = descriptor.createColumn(STAnnotatedCSourceEditor.this);
          fColumns.add(annotationColumn);
          initializeColumn(column);
          ruler.addDecorator(idx, column);
        }
      };
      SafeRunner.run(runnable);
    }
    
    protected void initializeColumn(IContributedRulerColumn column)
    {
      super.initializeColumn(column);
      RulerColumnDescriptor descriptor = column.getDescriptor();
      IVerticalRuler ruler = getVerticalRuler();
      if ((ruler instanceof CompositeRuler))
      {
        if ("org.eclipse.ui.editors.columns.annotations".equals(descriptor.getId()))
        {
          ((AnnotationColumn)column).setDelegate(createAnnotationRulerColumn((CompositeRuler)ruler));
        }
        else if ("org.eclipse.ui.editors.columns.linenumbers".equals(descriptor.getId()))
        {
          fLineColumn = ((LineNumberColumn)column);
          fLineColumn.setForwarder(new LineNumberColumn.ICompatibilityForwarder()
          {
            public IVerticalRulerColumn createLineNumberRulerColumn()
            {
              return STAnnotatedCSourceEditor.this.createLineNumberRulerColumn();
            }
            
            public boolean isQuickDiffEnabled()
            {
              return isPrefQuickDiffAlwaysOn();
            }
            
            public boolean isLineNumberRulerVisible()
            {
              return STAnnotatedCSourceEditor.this.isLineNumberRulerVisible();
            }
          });
        }
        if ("org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.column".equals(descriptor.getId()))
        {
          fColumn = ((STContributedRulerColumn)column);
          
          fColumn.setForwarder(new STContributedRulerColumn.ICompatibilityForwarder()
          {
            public IVerticalRulerColumn createSTRulerColumn()
            {
              if ((fColumns != null) && (fColumns.size() > 0))
              {
                IVerticalRulerColumn fDelegate = createSTRulerColumn((ISTAnnotationColumn)fColumns.get(fColumns.size() - 1));
                return fDelegate;
              }
              return null;
            }
            
            public boolean isQuickDiffEnabled()
            {
              return isPrefQuickDiffAlwaysOn();
            }
            
            public boolean isSTRulerVisible()
            {
              return STAnnotatedCSourceEditor.this.isSTRulerVisible();
            }
          });
        }
      }
    }
  }
  
  protected IVerticalRulerColumn createSTRulerColumn(ISTAnnotationColumn annotationColumn)
  {
    fSTChangeRulerColumn = new STChangeRulerColumn(getSharedColors(), annotationColumn);
    fSTChangeRulerColumn.setHover(createChangeHover());
    initializeLineNumberRulerColumn(fLineNumberRulerColumn);
    
    return fSTChangeRulerColumn;
  }
  
  public void lineGetBackground(LineBackgroundEvent event)
  {
    if (fInput != null)
    {
      StyledTextContent c = (StyledTextContent)data;
      int line = c.getLineAtOffset(lineOffset);
      lineBackground = fInput.getColor(line);
    }
  }
  
  protected void doSetInput(IEditorInput input)
    throws CoreException
  {
    super.doSetInput(input);
    if ((input != null) && ((input instanceof AbstractSTAnnotatedSourceEditorInput)))
    {
      fInput = ((AbstractSTAnnotatedSourceEditorInput)input);
      fListColumns = fInput.getColumns();
    }
  }
  
  protected void createActions()
  {
    super.createActions();
    
    ResourceAction action = new ResourceAction(STTextEditorMessages.getBundleForConstructedKeys(), "Editor.ToggleSTColumnAction.", 2)
    {
      public void run()
      {
        STAnnotatedCSourceEditor.this.toggleSTRuler();
      }
    };
    if (fInput != null)
    {
      action.setActionDefinitionId("org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STColumnToggle");
      setAction("ST.Toggle", action);
    }
  }
  
  private void toggleSTRuler()
  {
    IPreferenceStore store = EditorsUI.getPreferenceStore();
    store.setValue("STRuler", !isSTRulerVisible());
  }
  
  protected boolean isSTRulerVisible()
  {
    IPreferenceStore store = getPreferenceStore();
    return store != null ? store.getBoolean("STRuler") : true;
  }
  
  private static class ToolTipSupport
    extends DefaultToolTip
  {
    private STContributedRulerColumn control;
    
    class ToolTipArea
    {
      int line;
      ISTAnnotationColumn ac;
      
      ToolTipArea(int line, ISTAnnotationColumn ac)
      {
        this.line = line;
        this.ac = ac;
      }
      
      public String getToolTip()
      {
        return ac.getTooltip(line);
      }
    }
    
    protected ToolTipSupport(STContributedRulerColumn control, int style, boolean manualActivation)
    {
      super(style, manualActivation);
      this.control = control;
    }
    
    protected Object getToolTipArea(Event event)
    {
      int line = control.toDocumentLineNumber(y);
      
      return new ToolTipArea(line, control.getAnnotationColumn(line));
    }
    
    protected Composite createToolTipContentArea(Event event, Composite parent)
    {
      Composite comp = new Composite(parent, 0);
      comp.setLayout(new FillLayout());
      Label b = new Label(comp, 0);
      ToolTipArea area = (ToolTipArea)getToolTipArea(event);
      if ((area != null) && (area.getToolTip().trim().length() > 0)) {
        b.setText(area.getToolTip());
      }
      return comp;
    }
    
    public static void enableFor(STContributedRulerColumn control)
    {
      new ToolTipSupport(control, 2, false);
    }
  }
  
  protected IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors)
  {
    IOverviewRuler ruler = new STOverviewRuler(getAnnotationAccess(), 12, sharedColors);
    MarkerAnnotationPreferences fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
    Iterator<?> e = fAnnotationPreferences.getAnnotationPreferences().iterator();
    while (e.hasNext())
    {
      AnnotationPreference preference = (AnnotationPreference)e.next();
      if (preference.contributesToHeader()) {
        ruler.addHeaderAnnotationType(preference.getAnnotationType());
      }
    }
    return ruler;
  }
  
  private void showLinesColored()
  {
    STOverviewRuler or = (STOverviewRuler)getOverviewRuler();
    AnnotationModel am = (AnnotationModel)or.getModel();
    IDocument doc = getSourceViewer().getDocument();
    int lines = doc.getNumberOfLines();
    for (int i = 0; i < lines; i++) {
      try
      {
        Color color = fInput.getColor(i);
        int r = color.getRed();
        int g = color.getGreen();
        int b = color.getBlue();
        if ((r != 255) || (g != 255) || (b != 255))
        {
          int offset = doc.getLineOffset(i);
          String type = STAnnotatedSourceEditorActivator.getUniqueIdentifier() + STAnnotatedSourceEditorActivator.getAnnotationType();
          Annotation annotation = new Annotation(type, true, "");
          or.setAnnotationColor(annotation, color);
          am.addAnnotation(annotation, new Position(offset));
        }
      }
      catch (BadLocationException e)
      {
        Status s = new Status(4, "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor", 4, e.getMessage(), e);
        STAnnotatedSourceEditorActivator.getDefault().getLog().log(s);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedCSourceEditor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class STAnnotatedSourceEditorActivator
  extends AbstractUIPlugin
{
  public static final String PLUGIN_ID = "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor";
  private static final String ANNOTATION_TYPE = ".coloredLines";
  private static STAnnotatedSourceEditorActivator plugin;
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    plugin = this;
    EditorsUI.getPreferenceStore().setValue("STRuler", true);
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    plugin = null;
    super.stop(context);
  }
  
  public static STAnnotatedSourceEditorActivator getDefault()
  {
    return plugin;
  }
  
  public static String getAnnotationType()
  {
    return ".coloredLines";
  }
  
  public static String getUniqueIdentifier()
  {
    return "org.eclipse.linuxtools.dataviewers.annotatedsourceeditor";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STAnnotatedSourceEditorActivator
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.linuxtools.dataviewers.annotatedsourceeditor;

import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.internal.text.revisions.RevisionPainter;
import org.eclipse.jface.internal.text.source.DiffPainter;
import org.eclipse.jface.text.revisions.IRevisionListener;
import org.eclipse.jface.text.revisions.IRevisionRulerColumn;
import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension;
import org.eclipse.jface.text.revisions.IRevisionRulerColumnExtension.RenderingMode;
import org.eclipse.jface.text.revisions.RevisionInformation;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IChangeRulerColumn;
import org.eclipse.jface.text.source.ILineRange;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.text.source.IVerticalRulerInfoExtension;
import org.eclipse.jface.text.source.IVerticalRulerListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

public final class STChangeRulerColumn
  extends STRulerColumn
  implements IVerticalRulerInfo, IVerticalRulerInfoExtension, IChangeRulerColumn, IRevisionRulerColumn, IRevisionRulerColumnExtension
{
  private IAnnotationModel fAnnotationModel;
  private boolean fCharacterDisplay;
  private final RevisionPainter fRevisionPainter;
  private final DiffPainter fDiffPainter;
  private boolean fShowSTRuler = true;
  
  public STChangeRulerColumn(ISharedTextColors sharedColors, ISTAnnotationColumn ac)
  {
    super(ac);
    Assert.isNotNull(sharedColors);
    fRevisionPainter = new RevisionPainter(this, sharedColors);
    fDiffPainter = new DiffPainter(this, sharedColors);
  }
  
  public Control createControl(CompositeRuler parentRuler, Composite parentControl)
  {
    Control control = super.createControl(parentRuler, parentControl);
    fRevisionPainter.setParentRuler(parentRuler);
    fDiffPainter.setParentRuler(parentRuler);
    return control;
  }
  
  public int getLineOfLastMouseButtonActivity()
  {
    return getParentRuler().getLineOfLastMouseButtonActivity();
  }
  
  public int toDocumentLineNumber(int y_coordinate)
  {
    return getParentRuler().toDocumentLineNumber(y_coordinate);
  }
  
  public void setModel(IAnnotationModel model)
  {
    setAnnotationModel(model);
    fRevisionPainter.setModel(model);
    fDiffPainter.setModel(model);
    updateNumberOfDigits();
    computeIndentations();
    layout(true);
    postRedraw();
  }
  
  private void setAnnotationModel(IAnnotationModel model)
  {
    if (fAnnotationModel != model) {
      fAnnotationModel = model;
    }
  }
  
  public void setDisplayMode(boolean characterMode)
  {
    if (characterMode != fCharacterDisplay)
    {
      fCharacterDisplay = characterMode;
      updateNumberOfDigits();
      computeIndentations();
      layout(true);
    }
  }
  
  public IAnnotationModel getModel()
  {
    return fAnnotationModel;
  }
  
  protected String createDisplayString(int line)
  {
    StringBuffer buffer = new StringBuffer();
    if (fShowSTRuler) {
      buffer.append(super.createDisplayString(line));
    }
    if ((fCharacterDisplay) && (getModel() != null)) {
      buffer.append(fDiffPainter.getDisplayCharacter(line));
    }
    return buffer.toString();
  }
  
  protected int computeNumberOfDigits()
  {
    int digits;
    int digits;
    if ((fCharacterDisplay) && (getModel() != null))
    {
      int digits;
      if (fShowSTRuler) {
        digits = super.computeNumberOfDigits() + 1;
      } else {
        digits = 1;
      }
    }
    else
    {
      int digits;
      if (fShowSTRuler) {
        digits = super.computeNumberOfDigits();
      } else {
        digits = 0;
      }
    }
    if (fRevisionPainter.hasInformation()) {
      digits += fRevisionPainter.getRequiredWidth();
    }
    return digits;
  }
  
  public void addVerticalRulerListener(IVerticalRulerListener listener)
  {
    throw new UnsupportedOperationException();
  }
  
  public void removeVerticalRulerListener(IVerticalRulerListener listener)
  {
    throw new UnsupportedOperationException();
  }
  
  void doPaint(GC gc, ILineRange visibleLines)
  {
    Color foreground = gc.getForeground();
    if (visibleLines != null) {
      if (fRevisionPainter.hasInformation()) {
        fRevisionPainter.paint(gc, visibleLines);
      } else if (fDiffPainter.hasInformation()) {
        fDiffPainter.paint(gc, visibleLines);
      }
    }
    gc.setForeground(foreground);
    if ((fShowSTRuler) || (fCharacterDisplay)) {
      super.doPaint(gc, visibleLines);
    }
  }
  
  public IAnnotationHover getHover()
  {
    int activeLine = getParentRuler().getLineOfLastMouseButtonActivity();
    if (fRevisionPainter.hasHover(activeLine)) {
      return fRevisionPainter.getHover();
    }
    if (fDiffPainter.hasHover(activeLine)) {
      return fDiffPainter.getHover();
    }
    return null;
  }
  
  public void setHover(IAnnotationHover hover)
  {
    fRevisionPainter.setHover(hover);
    fDiffPainter.setHover(hover);
  }
  
  public void setBackground(Color background)
  {
    super.setBackground(background);
    fRevisionPainter.setBackground(background);
    fDiffPainter.setBackground(background);
  }
  
  public void setAddedColor(Color addedColor)
  {
    fDiffPainter.setAddedColor(addedColor);
  }
  
  public void setChangedColor(Color changedColor)
  {
    fDiffPainter.setChangedColor(changedColor);
  }
  
  public void setDeletedColor(Color deletedColor)
  {
    fDiffPainter.setDeletedColor(deletedColor);
  }
  
  public void setRevisionInformation(RevisionInformation info)
  {
    fRevisionPainter.setRevisionInformation(info);
    updateNumberOfDigits();
    computeIndentations();
    layout(true);
    postRedraw();
  }
  
  public ISelectionProvider getRevisionSelectionProvider()
  {
    return fRevisionPainter.getRevisionSelectionProvider();
  }
  
  public void setRevisionRenderingMode(IRevisionRulerColumnExtension.RenderingMode renderingMode)
  {
    fRevisionPainter.setRende
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