Package org.eclipse.jface.text.source.projection

Examples of org.eclipse.jface.text.source.projection.ProjectionViewer


  @Override
  protected ISourceViewer createSourceViewer(Composite parent,
      IVerticalRuler ruler, int styles) {
//    if (true) return super.createSourceViewer(parent, ruler, styles);
    // Create with code-folding
    ISourceViewer viewer = new ProjectionViewer(parent, ruler,
        getOverviewRuler(), isOverviewRulerVisible(), styles);
    // ensure decoration support has been created and configured.
    SourceViewerDecorationSupport decSupport = getSourceViewerDecorationSupport(viewer);
//    SourceViewer viewer = (SourceViewer) super.createSourceViewer(parent, ruler, styles);
    // Setup word-wrapping   
    final StyledText widget = viewer.getTextWidget();
    // Listen to pref changes
    prefChangeListener = new IPropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent event) {
        if (event.getProperty().equals(MarkdownPreferencePage.PREF_WORD_WRAP)) {
          widget.setWordWrap(MarkdownPreferencePage.wordWrap());
View Full Code Here


   * @param region can be null
   */
  private void updateSectionFoldingAnnotations(IRegion region) {
    if (!haveRunFolding) region = null; // Do the whole doc
    if ( ! (getSourceViewer() instanceof ProjectionViewer)) return;
    ProjectionViewer viewer = ((ProjectionViewer)getSourceViewer());
    MarkdownPage mPage = getMarkdownPage();
    List<Header> headers = mPage.getHeadings(null);
    // this will hold the new annotations along
    // with their corresponding positions
    Map<Annotation, Position> annotations = new HashMap<Annotation, Position>();
    IDocument doc = getDocument();
    updateSectionFoldingAnnotations2(doc, headers, annotations, doc.getLength());
    // Filter existing ones
    Position[] newValues = annotations.values().toArray(POSITION_ARRAY);   
    List<Annotation> deletedAnnotations = new ArrayList<Annotation>();
    for(Entry<Annotation, Position> ae : oldAnnotations.entrySet()) {
      Position oldp = ae.getValue();
      boolean stillExists = false;
      for (Position newp : newValues) {
        if (oldp.equals(newp)) {
          annotations.remove(newp);
          stillExists = true;
          break;
        }
      }
      if (!stillExists && intersectsRegion(oldp, region)) {
        deletedAnnotations.add(ae.getKey());
      }
    }
    // Filter out-of-region ones
    for(Annotation a : annotations.keySet().toArray(ANNOTATION_ARRAY)) {
      Position p = annotations.get(a);
      if (!intersectsRegion(p , region)) annotations.remove(a);
    }
    // Adjust the page
      ProjectionAnnotationModel annotationModel = viewer.getProjectionAnnotationModel();
      if (annotationModel==null) return;
    annotationModel.modifyAnnotations(deletedAnnotations.toArray(ANNOTATION_ARRAY), annotations, null);
    // Remember old values
    oldAnnotations.putAll(annotations);
    for (Annotation a : deletedAnnotations) {
View Full Code Here

  protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
   
    fAnnotationAccess = createAnnotationAccess();
    fOverviewRuler = createOverviewRuler(getSharedColors());
   
    ISourceViewer viewer= new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
   
    // ensure decoration support has been created and configured.
    // preferred over SourceViewerDecorationSupport due to impending API changes [lonnen] june 11, 2010
    fSourceViewerDecorationSupport = getSourceViewerDecorationSupport(viewer);
   
View Full Code Here

  }
 
  /* @see org.eclipse.ui.texteditor.ExtendedTextEditor#createPartControl(org.eclipse.swt.widgets.Composite) */
  public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    ProjectionViewer viewer= (ProjectionViewer) getSourceViewer();
    fProjectionSupport= new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors());
    fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
    fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
    fProjectionSupport.install();
    viewer.doOperation(ProjectionViewer.TOGGLE);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.source.projection.ProjectionViewer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.