org.eclipse.mylyn.wikitext.ui_1.6.1.v20120425-0100

ilteredId)
  {
    if (filteredId == null) {
      throw new IllegalArgumentException();
    }
    this.filteredId = filteredId;
  }
  
  public boolean filter(HyperlinkDetectorDescriptor descriptor)
  {
    String id = descriptor.getId();
    if (filteredId.equals(id)) {
      return true;
    }
    return false;
  }
}

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

import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationAccess;

class HtmlViewer$1
  implements IAnnotationAccess
{
  HtmlViewer$1(HtmlViewer paramHtmlViewer) {}
  
  public Object getType(Annotation annotation)
  {
    return annotation.getType();
  }
  
  public boolean isMultiLine(Annotation annotation)
  {
    return true;
  }
  
  public boolean isTemporary(Annotation annotation)
  {
    return true;
  }
}

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

import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.DefaultAnnotationHover;

class HtmlViewerConfiguration$1
  extends DefaultAnnotationHover
{
  HtmlViewerConfiguration$1(HtmlViewerConfiguration paramHtmlViewerConfiguration) {}
  
  protected boolean isIncluded(Annotation annotation)
  {
    return (annotation.getType().equals("org.eclipse.mylyn.wikitext.ui.annotation.title")) || (HtmlViewerConfiguration.access$2(this$0, annotation));
  }
}

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

import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.source.AnnotationModel;

public class HtmlViewer$ParseResult
{
  public TextPresentation textPresentation;
  String text;
  AnnotationModel annotationModel;
}

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

import org.eclipse.mylyn.internal.wikitext.ui.util.ImageCache;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;

class HtmlViewer$2
  implements DisposeListener
{
  HtmlViewer$2(HtmlViewer paramHtmlViewer) {}
  
  public void widgetDisposed(DisposeEvent e)
  {
    HtmlViewer.access$0(this$0).dispose();
  }
}

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

import org.eclipse.jface.resource.ColorRegistry;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IFindReplaceTarget;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.AnnotationPainter;
import org.eclipse.jface.text.source.IAnnotationAccess;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.mylyn.internal.wikitext.core.util.css.Stylesheet;
import org.eclipse.mylyn.internal.wikitext.ui.editor.FindAndReplaceTarget;
import org.eclipse.mylyn.internal.wikitext.ui.util.ImageCache;
import org.eclipse.mylyn.internal.wikitext.ui.util.WikiTextUiResources;
import org.eclipse.mylyn.internal.wikitext.ui.viewer.ImageManager;
import org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.BulletDrawingStrategy;
import org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.HorizontalRuleDrawingStrategy;
import org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.ImageDrawingStrategy;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;

public class HtmlViewer
  extends SourceViewer
{
  private TextPresentation textPresentation;
  private boolean haveInit = false;
  private HtmlViewerConfiguration configuration;
  private final ImageCache imageCache = new ImageCache();
  private boolean displayImages = true;
  private Stylesheet stylesheet;
  private Font defaultMonospaceFont;
  private IFindReplaceTarget findReplaceTarget;
  
  public HtmlViewer(Composite parent, IVerticalRuler ruler, int styles)
  {
    super(parent, ruler, styles);
    setEditable(false);
  }
  
  public HtmlViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles)
  {
    super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
    setEditable(false);
  }
  
  private void initPainter()
  {
    if (haveInit) {
      return;
    }
    haveInit = true;
    
    ColorRegistry colorRegistry = WikiTextUiResources.getColors();
    
    IAnnotationAccess annotationAccess = new IAnnotationAccess()
    {
      public Object getType(Annotation annotation)
      {
        return annotation.getType();
      }
      
      public boolean isMultiLine(Annotation annotation)
      {
        return true;
      }
      
      public boolean isTemporary(Annotation annotation)
      {
        return true;
      }
    };
    AnnotationPainter painter = new AnnotationPainter(this, annotationAccess);
    
    painter.addDrawingStrategy("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.bullet", new BulletDrawingStrategy());
    painter.addAnnotationType("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.bullet", "org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.bullet");
    painter.setAnnotationTypeColor("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.bullet", getTextWidget().getForeground());
    
    painter.addDrawingStrategy("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.hr", new HorizontalRuleDrawingStrategy());
    painter.addAnnotationType("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.hr", "org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.hr");
    painter.setAnnotationTypeColor("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.hr", colorRegistry.get("HR"));
    if (displayImages)
    {
      painter.addDrawingStrategy("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.image", new ImageDrawingStrategy(this));
      painter.addAnnotationType("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.image", "org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.image");
      painter.setAnnotationTypeColor("org.eclipse.mylyn.internal.wikitext.ui.viewer.annotation.image", getTextWidget().getForeground());
    }
    addTextPresentationListener(painter);
    addPainter(painter);
    
    getTextWidget().addDisposeListener(new DisposeListener()
    {
      public void widgetDisposed(DisposeEvent e)
      {
        imageCache.dispose();
      }
    });
    if (displayImages) {
      new ImageManager(this, imageCache, painter);
    }
  }
  
  /* Error */
  protected ParseResult parse(String htmlText)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokespecial 301	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:initPainter	()V
    //   4: new 134	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer$ParseResult
    //   7: dup
    //   8: invokespecial 311	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer$ParseResult:<init>	()V
    //   11: astore_2
    //   12: aload_2
    //   13: new 118	org/eclipse/jface/text/TextPresentation
    //   16: dup
    //   17: invokespecial 271	org/eclipse/jface/text/TextPresentation:<init>	()V
    //   20: putfield 265	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer$ParseResult:textPresentation	Lorg/eclipse/jface/text/TextPresentation;
    //   23: new 126	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser
    //   26: dup
    //   27: invokespecial 286	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:<init>	()V
    //   30: astore_3
    //   31: aload_0
    //   32: getfield 260	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:stylesheet	Lorg/eclipse/mylyn/internal/wikitext/core/util/css/Stylesheet;
    //   35: ifnull +11 -> 46
    //   38: aload_3
    //   39: aload_0
    //   40: getfield 260	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:stylesheet	Lorg/eclipse/mylyn/internal/wikitext/core/util/css/Stylesheet;
    //   43: invokevirtual 292	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setStylesheet	(Lorg/eclipse/mylyn/internal/wikitext/core/util/css/Stylesheet;)V
    //   46: aload_0
    //   47: getfield 256	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:displayImages	Z
    //   50: ifeq +19 -> 69
    //   53: aload_3
    //   54: aload_0
    //   55: getfield 261	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:imageCache	Lorg/eclipse/mylyn/internal/wikitext/ui/util/ImageCache;
    //   58: invokevirtual 293	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setImageCache	(Lorg/eclipse/mylyn/internal/wikitext/ui/util/ImageCache;)V
    //   61: aload_3
    //   62: aload_0
    //   63: getfield 256	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:displayImages	Z
    //   66: invokevirtual 287	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setEnableImages	(Z)V
    //   69: aload_3
    //   70: aload_2
    //   71: getfield 265	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer$ParseResult:textPresentation	Lorg/eclipse/jface/text/TextPresentation;
    //   74: invokevirtual 290	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setPresentation	(Lorg/eclipse/jface/text/TextPresentation;)V
    //   77: aload_3
    //   78: aload_0
    //   79: invokevirtual 306	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:getTextWidget	()Lorg/eclipse/swt/custom/StyledText;
    //   82: invokevirtual 316	org/eclipse/swt/custom/StyledText:getFont	()Lorg/eclipse/swt/graphics/Font;
    //   85: invokevirtual 294	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setDefaultFont	(Lorg/eclipse/swt/graphics/Font;)V
    //   88: aload_3
    //   89: aload_0
    //   90: getfield 263	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:defaultMonospaceFont	Lorg/eclipse/swt/graphics/Font;
    //   93: invokevirtual 295	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setDefaultMonospaceFont	(Lorg/eclipse/swt/graphics/Font;)V
    //   96: aload_2
    //   97: new 119	org/eclipse/jface/text/source/AnnotationModel
    //   100: dup
    //   101: invokespecial 273	org/eclipse/jface/text/source/AnnotationModel:<init>	()V
    //   104: putfield 266	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer$ParseResult:annotationModel	Lorg/eclipse/jface/text/source/AnnotationModel;
    //   107: aload_3
    //   108: aload_2
    //   109: getfield 266	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer$ParseResult:annotationModel	Lorg/eclipse/jface/text/source/AnnotationModel;
    //   112: invokevirtual 291	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setAnnotationModel	(Lorg/eclipse/jface/text/source/IAnnotationModel;)V
    //   115: new 137	org/eclipse/swt/graphics/GC
    //   118: dup
    //   119: aload_0
    //   120: invokevirtual 306	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer:getTextWidget	()Lorg/eclipse/swt/custom/StyledText;
    //   123: invokespecial 318	org/eclipse/swt/graphics/GC:<init>	(Lorg/eclipse/swt/graphics/Drawable;)V
    //   126: astore 4
    //   128: aload_3
    //   129: aload 4
    //   131: invokevirtual 296	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:setGC	(Lorg/eclipse/swt/graphics/GC;)V
    //   134: aload_3
    //   135: aload_1
    //   136: invokevirtual 289	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:parse	(Ljava/lang/String;)V
    //   139: goto +37 -> 176
    //   142: astore 5
    //   144: new 113	java/lang/IllegalStateException
    //   147: dup
    //   148: aload 5
    //   150: invokespecial 267	java/lang/IllegalStateException:<init>	(Ljava/lang/Throwable;)V
    //   153: athrow
    //   154: astore 5
    //   156: new 113	java/lang/IllegalStateException
    //   159: dup
    //   160: aload 5
    //   162: invokespecial 267	java/lang/IllegalStateException:<init>	(Ljava/lang/Throwable;)V
    //   165: athrow
    //   166: astore 6
    //   168: aload 4
    //   170: invokevirtual 317	org/eclipse/swt/graphics/GC:dispose	()V
    //   173: aload 6
    //   175: athrow
    //   176: aload 4
    //   178: invokevirtual 317	org/eclipse/swt/graphics/GC:dispose	()V
    //   181: aload_2
    //   182: aload_3
    //   183: invokevirtual 288	org/eclipse/mylyn/internal/wikitext/ui/viewer/HtmlTextPresentationParser:getText	()Ljava/lang/String;
    //   186: putfield 264	org/eclipse/mylyn/wikitext/ui/viewer/HtmlViewer$ParseResult:text	Ljava/lang/String;
    //   189: aload_2
    //   190: areturn
    // Line number table:
    //   Java source line #140	-> byte code offset #0
    //   Java source line #142	-> byte code offset #4
    //   Java source line #144	-> byte code offset #12
    //   Java source line #146	-> byte code offset #23
    //   Java source line #147	-> byte code offset #31
    //   Java source line #148	-> byte code offset #38
    //   Java source line #150	-> byte code offset #46
    //   Java source line #151	-> byte code offset #53
    //   Java source line #152	-> byte code offset #61
    //   Java source line #154	-> byte code offset #69
    //   Java source line #155	-> byte code offset #77
    //   Java source line #156	-> byte code offset #88
    //   Java source line #157	-> byte code offset #96
    //   Java source line #158	-> byte code offset #107
    //   Java source line #160	-> byte code offset #115
    //   Java source line #162	-> byte code offset #128
    //   Java source line #164	-> byte code offset #134
    //   Java source line #165	-> byte code offset #142
    //   Java source line #166	-> byte code offset #144
    //   Java source line #167	-> byte code offset #154
    //   Java source line #168	-> byte code offset #156
    //   Java source line #169	-> byte code offset #166
    //   Java source line #170	-> byte code offset #168
    //   Java source line #171	-> byte code offset #173
    //   Java source line #170	-> byte code offset #176
    //   Java source line #173	-> byte code offset #181
    //   Java source line #175	-> byte code offset #189
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	191	0	this	HtmlViewer
    //   0	191	1	htmlText	String
    //   11	179	2	result	ParseResult
    //   30	153	3	parser	org.eclipse.mylyn.internal.wikitext.ui.viewer.HtmlTextPresentationParser
    //   126	51	4	gc	org.eclipse.swt.graphics.GC
    //   142	7	5	e	org.xml.sax.SAXException
    //   154	7	5	e	java.io.IOException
    //   166	8	6	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   128	139	142	org/xml/sax/SAXException
    //   128	139	154	java/io/IOException
    //   128	166	166	finally
  }
  
  public IFindReplaceTarget getFindReplaceTarget()
  {
    if (findReplaceTarget != null) {
      return findReplaceTarget;
    }
    return super.getFindReplaceTarget();
  }
  
  public void configure(SourceViewerConfiguration configuration)
  {
    if ((configuration instanceof HtmlViewerConfiguration))
    {
      this.configuration = ((HtmlViewerConfiguration)configuration);
      if (textPresentation != null) {
        this.configuration.setTextPresentation(textPresentation);
      }
      if (((HtmlViewerConfiguration)configuration).isEnableSelfContainedIncrementalFind()) {
        findReplaceTarget = new FindAndReplaceTarget(this);
      }
    }
    super.configure(configuration);
  }
  
  public void setHtml(String htmlText)
  {
    ParseResult result = parse(htmlText);
    textPresentation = textPresentation;
    if (configuration != null) {
      configuration.setTextPresentation(textPresentation);
    }
    setDocumentNoMarkup(new Document(text), annotationModel);
  }
  
  public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength)
  {
    if (document != null)
    {
      String htmlText = document.get();
      if (htmlText.length() > 0)
      {
        ParseResult result = parse(htmlText);
        textPresentation = textPresentation;
        document.set(text);
        annotationModel = annotationModel;
      }
      else if (textPresentation != null)
      {
        textPresentation.clear();
      }
      else
      {
        textPresentation = new TextPresentation();
      }
      if (configuration != null) {
        configuration.setTextPresentation(textPresentation);
      }
    }
    setDocumentNoMarkup(document, annotationModel);
  }
  
  protected void setDocumentNoMarkup(IDocument document, IAnnotationModel annotationModel)
  {
    super.setDocument(document, annotationModel, -1, -1);
  }
  
  public TextPresentation getTextPresentation()
  {
    return textPresentation;
  }
  
  public void setTextPresentation(TextPresentation textPresentation)
  {
    this.textPresentation = textPresentation;
    if (configuration != null) {
      configuration.setTextPresentation(textPresentation);
    }
    changeTextPresentation(textPresentation, false);
  }
  
  public boolean isDisplayImages()
  {
    return displayImages;
  }
  
  public void setDisplayImages(boolean displayImages)
  {
    this.displayImages = displayImages;
  }
  
  public Stylesheet getStylesheet()
  {
    return stylesheet;
  }
  
  public void setStylesheet(Stylesheet stylesheet)
  {
    this.stylesheet = stylesheet;
  }
  
  public Font getDefaultMonospaceFont()
  {
    return defaultMonospaceFont;
  }
  
  public void setDefaultMonospaceFont(Font defaultMonospaceFont)
  {
    this.defaultMonospaceFont = defaultMonospaceFont;
  }
  
  protected static class ParseResult
  {
    public TextPresentation textPresentation;
    String text;
    AnnotationModel annotationModel;
  }
}

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

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.mylyn.internal.wikitext.ui.util.HyperlinkDetectorDelegate;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
import org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor;
import org.eclipse.ui.texteditor.HyperlinkDetectorRegistry;

public abstract class AbstractTextSourceViewerConfiguration
  extends TextSourceViewerConfiguration
{
  protected boolean markupHyperlinksFirst = true;
  private List<HyperlinkDetectorDescriptorFilter> hyperlinkDetectorDescriptorFilters;
  private List<IHyperlinkDetector> hyperlinkDetectors;
  
  public AbstractTextSourceViewerConfiguration() {}
  
  public AbstractTextSourceViewerConfiguration(IPreferenceStore preferenceStore)
  {
    super(preferenceStore);
  }
  
  public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer)
  {
    List<IHyperlinkDetector> customDetectors = createCustomHyperlinkDetectors(sourceViewer);
    if ((sourceViewer == null) || (fPreferenceStore == null)) {
      return (IHyperlinkDetector[])customDetectors.toArray(new IHyperlinkDetector[customDetectors.size()]);
    }
    HyperlinkDetectorRegistry registry = EditorsUI.getHyperlinkDetectorRegistry();
    HyperlinkDetectorDescriptor[] descriptors = registry.getHyperlinkDetectorDescriptors();
    Map<String, IAdaptable> targets = getHyperlinkDetectorTargets(sourceViewer);
    
    List<IHyperlinkDetector> detectors = new ArrayList(8);
    if (markupHyperlinksFirst) {
      detectors.addAll(customDetectors);
    }
    if (hyperlinkDetectors != null) {
      detectors.addAll(hyperlinkDetectors);
    }
    int j;
    int i;
    for (Iterator localIterator = targets.entrySet().iterator(); localIterator.hasNext(); i < j)
    {
      Map.Entry<String, IAdaptable> target = (Map.Entry)localIterator.next();
      String targetId = (String)target.getKey();
      IAdaptable context = (IAdaptable)target.getValue();
      HyperlinkDetectorDescriptor[] arrayOfHyperlinkDetectorDescriptor1;
      j = (arrayOfHyperlinkDetectorDescriptor1 = descriptors).length;i = 0; continue;HyperlinkDetectorDescriptor descriptor = arrayOfHyperlinkDetectorDescriptor1[i];
      if ((targetId.equals(descriptor.getTargetId())) && 
        (!filterHyperlinkDescriptor(descriptor)))
      {
        HyperlinkDetectorDelegate delegate = new HyperlinkDetectorDelegate(descriptor, fPreferenceStore);
        delegate.setContext(context);
        detectors.add(delegate);
      }
      i++;
    }
    if (!markupHyperlinksFirst) {
      detectors.addAll(customDetectors);
    }
    return (IHyperlinkDetector[])detectors.toArray(new IHyperlinkDetector[detectors.size()]);
  }
  
  protected List<IHyperlinkDetector> createCustomHyperlinkDetectors(ISourceViewer sourceViewer)
  {
    return Collections.emptyList();
  }
  
  private boolean filterHyperlinkDescriptor(HyperlinkDetectorDescriptor descriptor)
  {
    if ((hyperlinkDetectorDescriptorFilters == null) || (hyperlinkDetectorDescriptorFilters.isEmpty())) {
      return false;
    }
    for (HyperlinkDetectorDescriptorFilter filter : hyperlinkDetectorDescriptorFilters) {
      if (filter.filter(descriptor)) {
        return true;
      }
    }
    return false;
  }
  
  public void addHyperlinkDetectorDescriptorFilter(HyperlinkDetectorDescriptorFilter filter)
  {
    if (hyperlinkDetectorDescriptorFilters == null) {
      hyperlinkDetectorDescriptorFilters = new ArrayList();
    }
    hyperlinkDetectorDescriptorFilters.add(filter);
  }
  
  public void addHyperlinkDetector(IHyperlinkDetector detector)
  {
    if (hyperlinkDetectors == null) {
      hyperlinkDetectors = new ArrayList();
    }
    hyperlinkDetectors.add(detector);
  }
  
  public static abstract interface HyperlinkDetectorDescriptorFilter
  {
    public abstract boolean filter(HyperlinkDetectorDescriptor paramHyperlinkDetectorDescriptor);
  }
}

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

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jface.resource.FontRegistry;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.DefaultInformationControl.IInformationPresenter;
import org.eclipse.jface.text.DefaultInformationControl.IInformationPresenterExtension;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.mylyn.internal.wikitext.ui.viewer.HtmlTextPresentationParser;
import org.eclipse.swt.graphics.Drawable;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;

public class HtmlTextPresenter
  implements DefaultInformationControl.IInformationPresenter, DefaultInformationControl.IInformationPresenterExtension
{
  private static Pattern HTML_OPEN_TAG_PATTERN = Pattern.compile("<html", 2);
  
  public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight)
  {
    return updatePresentation(display, hoverInfo, presentation, maxWidth, maxHeight);
  }
  
  public String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight)
  {
    if ((hoverInfo == null) || (hoverInfo.length() == 0)) {
      return hoverInfo;
    }
    HtmlTextPresentationParser parser = new HtmlTextPresentationParser();
    parser.setPresentation(presentation);
    parser.setDefaultFont(JFaceResources.getFontRegistry().defaultFont());
    String html = hoverInfo;
    if (!HTML_OPEN_TAG_PATTERN.matcher(html).find()) {
      html = "<html><body>" + html + "</body></html>";
    }
    GC gc = new GC(drawable);
    try
    {
      html = html.replaceAll("<br>", "<br/>");
      parser.setMaxWidth(maxWidth);
      parser.setGC(gc);
      parser.parse(html);
      return parser.getText();
    }
    catch (Exception e)
    {
      String str1;
      return exceptionToHoverInfo(hoverInfo, presentation, e);
    }
    finally
    {
      gc.dispose();
    }
  }
  
  protected String exceptionToHoverInfo(String hoverInfo, TextPresentation presentation, Exception e)
  {
    presentation.clear();
    return hoverInfo;
  }
}

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

import org.eclipse.jface.text.TextPresentation;
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;
import org.eclipse.swt.graphics.Drawable;

public class MarkupTextPresenter
  extends HtmlTextPresenter
{
  private MarkupLanguage markupLanguage;
  
  public MarkupLanguage getMarkupLanguage()
  {
    return markupLanguage;
  }
  
  public void setMarkupLanguage(MarkupLanguage markupLanguage)
  {
    this.markupLanguage = markupLanguage;
  }
  
  public String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight)
  {
    if (markupLanguage == null) {
      throw new IllegalStateException();
    }
    if ((hoverInfo == null) || (hoverInfo.length() == 0)) {
      return hoverInfo;
    }
    MarkupParser parser = new MarkupParser();
    parser.setMarkupLanguage(markupLanguage);
    String html = parser.parseToHtml(hoverInfo);
    
    return super.updatePresentation(drawable, html, presentation, maxWidth, maxHeight);
  }
}

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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.presentation.IPresentationDamager;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.IPresentationRepairer;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.DefaultAnnotationHover;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.mylyn.internal.wikitext.ui.WikiTextUiPlugin;
import org.eclipse.mylyn.internal.wikitext.ui.viewer.AnnotationHyperlinkDetector;
import org.eclipse.mylyn.internal.wikitext.ui.viewer.TextHover;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.ui.editors.text.EditorsUI;

public class HtmlViewerConfiguration
  extends AbstractTextSourceViewerConfiguration
{
  private final HtmlViewer viewer;
  private TextPresentation textPresentation;
  private boolean disableHyperlinkModifiers = true;
  private boolean enableSelfContainedIncrementalFind = false;
  
  public HtmlViewerConfiguration(HtmlViewer viewer)
  {
    super(getDefaultPreferenceStore());
    this.viewer = viewer;
    
    addHyperlinkDetectorDescriptorFilter(new DefaultHyperlinkDetectorDescriptorFilter(
      "org.eclipse.ui.internal.editors.text.URLHyperlinkDetector"));
  }
  
  private static IPreferenceStore getDefaultPreferenceStore()
  {
    return WikiTextUiPlugin.getDefault() == null ? null : EditorsUI.getPreferenceStore();
  }
  
  public HtmlViewerConfiguration(HtmlViewer viewer, IPreferenceStore preferenceStore)
  {
    super(preferenceStore);
    this.viewer = viewer;
  }
  
  public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer)
  {
    PresentationReconciler reconciler = new PresentationReconciler();
    reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    
    MarkupViewerDamagerRepairer dr = createMarkupViewerDamagerRepairer();
    reconciler.setDamager(dr, "__dftl_partition_content_type");
    reconciler.setRepairer(dr, "__dftl_partition_content_type");
    
    return reconciler;
  }
  
  public IReconciler getReconciler(ISourceViewer sourceViewer)
  {
    return null;
  }
  
  private MarkupViewerDamagerRepairer createMarkupViewerDamagerRepairer()
  {
    return new MarkupViewerDamagerRepairer();
  }
  
  public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer)
  {
    new DefaultAnnotationHover()
    {
      protected boolean isIncluded(Annotation annotation)
      {
        return (annotation.getType().equals("org.eclipse.mylyn.wikitext.ui.annotation.title")) || (isShowInVerticalRuler(annotation));
      }
    };
  }
  
  public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType)
  {
    return new TextHover(sourceViewer);
  }
  
  protected List<IHyperlinkDetector> createCustomHyperlinkDetectors(ISourceViewer sourceViewer)
  {
    List<IHyperlinkDetector> detectors = new ArrayList(1);
    AnnotationHyperlinkDetector annotationHyperlinkDetector = createAnnotationHyperlinkDetector();
    sourceViewer.getTextWidget().setData(AnnotationHyperlinkDetector.class.getName(), annotationHyperlinkDetector);
    detectors.add(annotationHyperlinkDetector);
    return detectors;
  }
  
  protected AnnotationHyperlinkDetector createAnnotationHyperlinkDetector()
  {
    return new AnnotationHyperlinkDetector();
  }
  
  protected class MarkupViewerDamagerRepairer
    implements IPresentationDamager, IPresentationRepairer
  {
    private IDocument document;
    
    protected MarkupViewerDamagerRepairer() {}
    
    public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged)
    {
      return new Region(0, document.getLength());
    }
    
    public void setDocument(IDocument document)
    {
      this.document = document;
    }
    
    public void createPresentation(TextPresentation presentation, ITypedRegion damage)
    {
      TextPresentation viewerPresentation = textPresentation == null ? 
        viewer.getTextPresentation() : 
        textPresentation;
      presentation.clear();
      if (viewerPresentation == null) {
        return;
      }
      StyleRange defaultStyleRange = viewerPresentation.getDefaultStyleRange();
      presentation.setDefaultStyleRange(
      
        (StyleRange)(defaultStyleRange == null ? null : defaultStyleRange.clone()));
      List<StyleRange> ranges = new ArrayList();
      
      Iterator<?> allStyleRangeIterator = viewerPresentation.getAllStyleRangeIterator();
      while (allStyleRangeIterator.hasNext())
      {
        StyleRange range = (StyleRange)allStyleRangeIterator.next();
        ranges.add((StyleRange)range.clone());
      }
      int start = damage.getOffset();
      for (int x = 0; x < ranges.size(); x++)
      {
        StyleRange range = (StyleRange)ranges.get(x);
        if (start > start)
        {
          StyleRange newRange = defaultStyleRange == null ? 
            new StyleRange() : 
            (StyleRange)defaultStyleRange.clone();
          start = start;
          length = (start - start);
          
          ranges.add(++x, newRange);
        }
        start = start + length + 1;
      }
      if (start < damage.getOffset() + damage.getLength())
      {
        StyleRange newRange = defaultStyleRange == null ? 
          new StyleRange() : 
          (StyleRange)defaultStyleRange.clone();
        start = start;
        length = (damage.getOffset() + damage.getLength() - start);
        ranges.add(newRange);
      }
      presentation.replaceStyleRanges((StyleRange[])ranges.toArray(new StyleRange[ranges.size()]));
    }
  }
  
  public void setTextPresentation(TextPresentation textPresentation)
  {
    if (textPresentation != null)
    {
      TextPresentation textPresentationCopy = new TextPresentation();
      textPresentationCopy.setDefaultStyleRange(
      
        (StyleRange)(textPresentation.getDefaultStyleRange() == null ? null : textPresentation.getDefaultStyleRange().clone()));
      Iterator<StyleRange> iterator = textPresentation.getAllStyleRangeIterator();
      while (iterator.hasNext())
      {
        StyleRange styleRange = (StyleRange)iterator.next();
        textPresentationCopy.addStyleRange((StyleRange)styleRange.clone());
      }
      textPresentation = textPresentationCopy;
    }
    this.textPresentation = textPresentation;
  }
  
  public int getHyperlinkStateMask(ISourceViewer sourceViewer)
  {
    if (disableHyperlinkModifiers) {
      return 0;
    }
    return super.getHyperlinkStateMask(sourceViewer);
  }
  
  public boolean isDisableHyperlinkModifiers()
  {
    return disableHyperlinkModifiers;
  }
  
  public void setDisableHyperlinkModifiers(boolean disableHyperlinkModifiers)
  {
    this.disableHyperlinkModifiers = disableHyperlinkModifiers;
  }
  
  public boolean isEnableSelfContainedIncrementalFind()
  {
    return enableSelfContainedIncrementalFind;
  }
  
  public void setEnableSelfContainedIncrementalFind(boolean enableSelfContainedIncrementalFind)
  {
    this.enableSelfContainedIncrementalFind = enableSelfContainedIncrementalFind;
  }
}

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

import org.eclipse.ui.texteditor.HyperlinkDetectorDescriptor;

public abstract interface AbstractTextSourceViewerConfiguration$HyperlinkDetectorDescriptorFilter
{
  public abstract boolean filter(HyperlinkDetectorDescriptor paramHyperlinkDetectorDescriptor);
}

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

import java.io.StringWriter;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.source.AnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.mylyn.internal.wikitext.ui.WikiTextUiPlugin;
import org.eclipse.mylyn.wikitext.core.parser.MarkupParser;
import org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder;
import org.eclipse.mylyn.wikitext.core.parser.markup.MarkupLanguage;
import org.eclipse.swt.widgets.Composite;

public class MarkupViewer
  extends HtmlViewer
{
  private MarkupParser parser = new MarkupParser();
  
  public MarkupViewer(Composite parent, IVerticalRuler ruler, int styles)
  {
    super(parent, ruler, styles);
    setEditable(false);
  }
  
  public MarkupViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles)
  {
    super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
    setEditable(false);
  }
  
  public void setMarkup(String source)
  {
    try
    {
      String htmlText = computeHtml(source);
      setHtml(htmlText);
    }
    catch (Throwable t)
    {
      if (getTextPresentation() != null) {
        getTextPresentation().clear();
      }
      setDocumentNoMarkup(new Document(source), new AnnotationModel());
      if (WikiTextUiPlugin.getDefault() != null) {
        WikiTextUiPlugin.getDefault().log(4, Messages.MarkupViewer_parseFailure, t);
      } else {
        t.printStackTrace();
      }
    }
  }
  
  public MarkupParser getParser()
  {
    return parser;
  }
  
  public void setParser(MarkupParser parser)
  {
    this.parser = parser;
  }
  
  public MarkupLanguage getMarkupLanguage()
  {
    return parser.getMarkupLanguage();
  }
  
  public void setMarkupLanguage(MarkupLanguage markupLanguage)
  {
    parser.setMarkupLanguage(markupLanguage);
  }
  
  public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset, int modelRangeLength)
  {
    String markupContent = null;
    if (document != null)
    {
      markupContent = document.get();
      if (markupContent.length() > 0)
      {
        String htmlText = computeHtml(markupContent);
        document.set(htmlText);
      }
    }
    try
    {
      super.setDocument(document, annotationModel, modelRangeOffset, modelRangeLength);
    }
    catch (Exception localException)
    {
      if (document != null)
      {
        document.set(markupContent);
        setDocumentNoMarkup(document, annotationModel);
      }
    }
  }
  
  private String computeHtml(String markupContent)
  {
    StringWriter out = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out);
    builder.setFilterEntityReferences(true);
    
    parser.setBuilder(builder);
    parser.parse(markupContent);
    parser.setBuilder(null);
    
    String htmlText = out.toString();
    return htmlText;
  }
}

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

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.presentation.IPresentationDamager;
import org.eclipse.jface.text.presentation.IPresentationRepairer;
import org.eclipse.swt.custom.StyleRange;

public class HtmlViewerConfiguration$MarkupViewerDamagerRepairer
  implements IPresentationDamager, IPresentationRepairer
{
  private IDocument document;
  
  protected HtmlViewerConfiguration$MarkupViewerDamagerRepairer(HtmlViewerConfiguration paramHtmlViewerConfiguration) {}
  
  public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged)
  {
    return new Region(0, document.getLength());
  }
  
  public void setDocument(IDocument document)
  {
    this.document = document;
  }
  
  public void createPresentation(TextPresentation presentation, ITypedRegion damage)
  {
    TextPresentation viewerPresentation = HtmlViewerConfiguration.access$0(this$0) == null ? 
  
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

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-2019. Infinite Loop Ltd