当前位置: 首页>>代码示例>>Java>>正文


Java ProjectionAnnotationModel类代码示例

本文整理汇总了Java中org.eclipse.jface.text.source.projection.ProjectionAnnotationModel的典型用法代码示例。如果您正苦于以下问题:Java ProjectionAnnotationModel类的具体用法?Java ProjectionAnnotationModel怎么用?Java ProjectionAnnotationModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProjectionAnnotationModel类属于org.eclipse.jface.text.source.projection包,在下文中一共展示了ProjectionAnnotationModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
public void run(IAction action) {
    // get the selection and determine if we want to collapse the current fold
    // or all folds contianed by the current selection
    TexSelections selection = new TexSelections(getTextEditor());
    
    int firstOffset = selection.getStartLine().getOffset();
    int lastOffset = selection.getEndLine().getOffset();
    
    ProjectionAnnotationModel model = (ProjectionAnnotationModel) getTextEditor()
    .getAdapter(ProjectionAnnotationModel.class);
    
    if (model != null) {
        if (firstOffset == lastOffset) {
            collapseDeepestMatching(model, firstOffset);
        } else {
            collapseAllContained(model, firstOffset, lastOffset);
        }
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:20,代码来源:TexCollapseAction.java

示例2: collapseDeepestMatching

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * Collapses the deepest annotation that contains the given offset
 * 
 * @param model The annotation model to use
 * @param offset The offset inside the document
 */
private void collapseDeepestMatching(ProjectionAnnotationModel model, int offset) {
    TexProjectionAnnotation toCollapse = null;
    for (Iterator iter = model.getAnnotationIterator(); iter.hasNext();) {
        TexProjectionAnnotation tpa = (TexProjectionAnnotation) iter.next();
        if (tpa.contains(offset)) {
            if (toCollapse != null) {
                if (tpa.isDeeperThan(toCollapse))
                    toCollapse = tpa;
            } else {
                toCollapse = tpa;
            }
        }
    }
    if (toCollapse != null) {
        model.collapse(toCollapse);
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:24,代码来源:TexCollapseAction.java

示例3: computeDifferences

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
private Annotation[] computeDifferences(ProjectionAnnotationModel model, Set current)
{
    List deletions = new ArrayList();
    for (Iterator iter = model.getAnnotationIterator(); iter.hasNext();)
    {
        Object annotation = iter.next();
        if (annotation instanceof ProjectionAnnotation)
        {
            Position position = model.getPosition((Annotation) annotation);
            if (current.contains(position))
                current.remove(position);
            else
                deletions.add(annotation);
        }
    }
    return (Annotation[]) deletions.toArray(new Annotation[deletions.size()]);
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:18,代码来源:VelocityFoldingStructureProvider.java

示例4: createContext

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
private FoldingStructureComputationContext createContext(boolean allowCollapse) {
	if (!isInstalled())
		return null;
	ProjectionAnnotationModel model= getModel();
	if (model == null)
		return null;
	IDocument doc= getDocument();
	if (doc == null)
		return null;

	IScanner scanner= null;
	if (fUpdatingCount == 1)
		scanner= fSharedScanner; // reuse scanner

	return new FoldingStructureComputationContext(doc, model, allowCollapse, scanner);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:DefaultJavaFoldingStructureProvider.java

示例5: transform

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * A semi-hack... This uses stuff that may change at any time in Eclipse.  
 * In the java editor, the projection annotation model contains the collapsible regions which correspond to methods (and other areas
 * such as import groups).
 * 
 * This may work in other editor types as well... TBD
 */
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection,
		ExecutionEvent event) throws BadLocationException {

	ITextViewerExtension viewer = MarkUtils.getITextViewer(editor);
	if (viewer instanceof ProjectionViewer) {
		ProjectionAnnotationModel projection = ((ProjectionViewer)viewer).getProjectionAnnotationModel();
		@SuppressWarnings("unchecked") // the method name says it all
		Iterator<Annotation> pit = projection.getAnnotationIterator();
		while (pit.hasNext()) {
			Position p = projection.getPosition(pit.next());
			if (p.includes(currentSelection.getOffset())) {
				if (isUniversalPresent()) {
					// Do this here to prevent subsequent scrolling once range is revealed
					MarkUtils.setSelection(editor, new TextSelection(document, p.offset, 0));
				}
				// the viewer is pretty much guaranteed to be a TextViewer
				if (viewer instanceof TextViewer) {
					((TextViewer)viewer).revealRange(p.offset, p.length);
				}
				break;
			}
		}
	}
	return NO_OFFSET;		
}
 
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:33,代码来源:RepositionHandler.java

示例6: isInsideLast

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * @param element
 * @param elements
 * @param model
 * @return
 */
protected boolean isInsideLast(PyProjectionAnnotation element, List elements, ProjectionAnnotationModel model) {
    if (elements.size() == 0) {
        return false;
    }

    PyProjectionAnnotation top = (PyProjectionAnnotation) elements.get(elements.size() - 1);
    Position p1 = model.getPosition(element);
    Position pTop = model.getPosition(top);

    int p1Offset = p1.getOffset();

    int pTopoffset = pTop.getOffset();
    int pTopLen = pTopoffset + pTop.getLength();

    if (p1Offset > pTopoffset && p1Offset < pTopLen) {
        return true;
    }
    return false;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:26,代码来源:PyFoldingAction.java

示例7: modelChanged

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
@Override
public synchronized void modelChanged(final ISimpleNode ast) {
    final SimpleNode root2 = (SimpleNode) ast;
    if (!firstInputChangedCalled) {
        asyncUpdateWaitingFormModelAndInputChanged(root2);
        return;
    }

    ProjectionAnnotationModel model = (ProjectionAnnotationModel) editor
            .getAdapter(ProjectionAnnotationModel.class);

    if (model == null) {
        asyncUpdateWaitingFormModelAndInputChanged(root2);
    } else {
        addMarksToModel(root2, model);
    }

}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:19,代码来源:CodeFoldingSetter.java

示例8: getAnnotationToAdd

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * @return an annotation that should be added (or null if that entry already has an annotation
 * added for it).
 */
private Tuple<ProjectionAnnotation, Position> getAnnotationToAdd(FoldingEntry node, int start, int end,
        ProjectionAnnotationModel model, List<Annotation> existing) throws BadLocationException {
    try {
        IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        int offset = document.getLineOffset(start);
        int endOffset = offset;
        try {
            endOffset = document.getLineOffset(end);
        } catch (Exception e) {
            //sometimes when we are at the last line, the command above will not work very well
            IRegion lineInformation = document.getLineInformation(end);
            endOffset = lineInformation.getOffset() + lineInformation.getLength();
        }
        Position position = new Position(offset, endOffset - offset);

        return getAnnotationToAdd(position, node, model, existing);

    } catch (BadLocationException x) {
        //this could happen
    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:27,代码来源:CodeFoldingSetter.java

示例9: updateFoldingRegions

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * Adds all children of CommonModel as folding regions and folds these regions
 * if <code>bDoFold</code> is <code>true</code>.
 * 
 * @param commonModel
 *          the document model
 * @param bDoFolding
 *          resets the folding         
 */
public void updateFoldingRegions(CommonModel commonModel, boolean bDoFold)
{
  try
  {
    ProjectionAnnotationModel model = (ProjectionAnnotationModel)fEditor
        .getAdapter(ProjectionAnnotationModel.class);
    if (model == null) return;

    Set<Position> currentRegions = new HashSet<Position>();
    Map<Annotation,Position> map = new HashMap<Annotation, Position>();
    addFoldingRegions(currentRegions, commonModel.getAllChildren(), map);
    if (bDoFold)
    {
      model.removeAllAnnotations();
      model.replaceAnnotations(null, map);
    }
    updateFoldingRegions(model, currentRegions);
  }
  catch (BadLocationException e)
  {
    e.printStackTrace();
  }
}
 
开发者ID:matthias-wolff,项目名称:dLabPro-Plugin,代码行数:33,代码来源:CommonFoldingStructureProvider.java

示例10: update

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * Updates the code folds.
 * 
 * @param outline The outline data structure containing the document positions
 */
public void update(List outline) {
    model = (ProjectionAnnotationModel)editor.getAdapter(ProjectionAnnotationModel.class);
    if (model != null) {
        this.addMarks(outline);
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:12,代码来源:BibCodeFolder.java

示例11: run

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
public void run(IAction action) {
    TexSelections selection = new TexSelections(getTextEditor());
    
    int firstOffset = selection.getStartLine().getOffset();
    int lastOffset = selection.getEndLine().getOffset();
    
    ProjectionAnnotationModel model = (ProjectionAnnotationModel) getTextEditor()
    .getAdapter(ProjectionAnnotationModel.class);
    
    if (model != null) {
        // the predefined method permits us to do this, even if length=0
        model.expandAll(firstOffset, lastOffset - firstOffset);
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:15,代码来源:TexUncollapseAction.java

示例12: collapseAllContained

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * Collapses all annotations that are completely contained in the interval
 * defined by <code>startOffset</code> and <code>endOffset</code>.
 * 
 * @param model The annotation model to use
 * @param startOffset The document offset of the start of the interval
 * @param endOffset The document offset of the end of the interval
 */
private void collapseAllContained(ProjectionAnnotationModel model,
        int startOffset, int endOffset) {
    for (Iterator iter = model.getAnnotationIterator(); iter.hasNext();) {
        TexProjectionAnnotation tpa = (TexProjectionAnnotation) iter.next();
        if (tpa.isBetween(startOffset, endOffset)) {
            model.collapse(tpa);
        }
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:18,代码来源:TexCollapseAction.java

示例13: update

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
/**
 * Updates the code folds of the editor.
 * 
 * @param outline The document outline data structure containing the document positions
 */
public void update(ArrayList outline) {
    model = (ProjectionAnnotationModel)editor.getAdapter(ProjectionAnnotationModel.class);

    if (model != null) {
        this.addMarks(outline);
    }
}
 
开发者ID:eclipse,项目名称:texlipse,代码行数:13,代码来源:TexCodeFolder.java

示例14: getAdapter

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
public <T> T getAdapter(Class<T> target) {
	if (IContentOutlinePage.class.equals(target)) {
		if (!isOutlinePageValid()) {
			outlinePage = createOutlinePage();
		}
		return (T) outlinePage;
	}
	if (SmartBackspaceManager.class.equals(target)) {
		if (getSourceViewer() instanceof FluentMkSourceViewer) {
			return (T) ((FluentMkSourceViewer) getSourceViewer()).getBackspaceManager();
		}
	}
	if (PagePart.class.equals(target)) {
		return (T) getPageModel();
	}
	if (ProjectionAnnotationModel.class.equals(target)) {
		if (projectionSupport != null) {
			Object adapter = projectionSupport.getAdapter(getSourceViewer(), target);
			if (adapter != null) return (T) adapter;
		}
	}
	if (target == IFoldingStructureProvider.class) {
		return (T) projectionProvider;
	}
	return super.getAdapter(target);
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:28,代码来源:FluentMkEditor.java

示例15: FoldingStructureComputationContext

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入依赖的package包/类
FoldingStructureComputationContext(IDocument document, ProjectionAnnotationModel model,
		boolean allowCollapsing) {
	Assert.isNotNull(document);
	Assert.isNotNull(model);
	fDocument = document;
	fModel = model;
	fAllowCollapsing = allowCollapsing;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:9,代码来源:FoldingStructureProvider.java


注:本文中的org.eclipse.jface.text.source.projection.ProjectionAnnotationModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。