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


Java ProjectionAnnotation类代码示例

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


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

示例1: calculatePositions

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
private void calculatePositions() {
	if (hasSnippetsModifications()) {
		final Map<ProjectionAnnotation, Position> annotations = getAllSnippetsAnnotations();

		Display.getDefault().asyncExec(new Runnable() {

			@Override
			public void run() {
				if (!annotations.isEmpty() && getProjectionAnnotationModel() == null) {
					enableProjection();
				}
				if (getProjectionAnnotationModel() != null) {
					Annotation[] oldAnno = oldAnnotations.keySet().toArray(new Annotation[0]);
					getProjectionAnnotationModel().modifyAnnotations(oldAnno, annotations, null);
					oldAnnotations.clear();
					oldAnnotations.putAll(annotations);
					if (annotations.isEmpty()) {
						disableProjection();
					}
				}
			}

		});
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:26,代码来源:SourceViewer.java

示例2: updateFolding

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
private void updateFolding(EditorConfig editorConfig) {
	if (projectionAnnotationModel == null) {
		return;
	}
	List<Section> sections = editorConfig.getSections();
	CommentBlocks commentBlocks = editorConfig.getAdapter(CommentBlocks.class);
	List<CommentBlock> comments = commentBlocks != null ? commentBlocks.getCommentBlocks()
			: Collections.emptyList();
	Map<Annotation, Position> newAnnotations = new HashMap<>();
	// Collection section and comment spans;
	List<Span> spans = /*Stream.concat(sections.stream(), comments.stream())*/
			sections.stream()
			.map(a -> a.getAdapter(Span.class))
			.sorted((s1, s2) -> s1.getStart().getLine() - s2.getStart().getLine()).collect(Collectors.toList());
	Annotation[] annotations = new Annotation[spans.size()];
	for (int i = 0; i < spans.size(); i++) {
		Span span = spans.get(i);
		int startOffset = span.getStart().getOffset();
		int endOffset = span.getEnd().getOffset();
		ProjectionAnnotation annotation = new ProjectionAnnotation();
		newAnnotations.put(annotation, new Position(startOffset, endOffset - startOffset));
		annotations[i] = annotation;
	}
	projectionAnnotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
	oldAnnotations = annotations;
}
 
开发者ID:angelozerr,项目名称:ec4e,代码行数:27,代码来源:EditorConfigFoldingStrategy.java

示例3: updateCodefolding

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
/**
 * <p>
 * Checks whether the given positions are in the
 * <code>ProjectionAnnotationModel</code> or in the addition set. If not it tries
 * to add into <code>additions</code>. Deletes old ProjectionAnnotation with line
 * count less than 2.
 * </p>
 * 
 * @param positions a list of available foldable positions
 */
public void updateCodefolding(List<Position> positions) {
	IDocument document = sourceViewer.getDocument();
	if (document == null) {
		return;
	}
	oldAnnotations.clear();
	Iterator<?> annotationIterator = projectionAnnotationModel.getAnnotationIterator();
	while (annotationIterator.hasNext()) {
		oldAnnotations.add((ProjectionAnnotation) annotationIterator.next());
	}
	// Add new Position with a unique line offset
	for (Position position : positions) {
		if (!isInAdditions(position)) {
			addPosition(position);
		}
	}
	projectionAnnotationModel.modifyAnnotations(oldAnnotations.toArray(new Annotation[0]), additions, null);
	additions.clear();
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:30,代码来源:DwprofileCodeFoldingManager.java

示例4: saveCodeFolding

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
/**
 * Saves the code folding state into the given memento.
 */
public void saveCodeFolding(IMemento memento) {
	// The annotation model might be null if the editor opened an storage input
	// instead of a file input.
	if (projectionAnnotationModel == null) {
		return;
	}
	Iterator<?> annotationIt = projectionAnnotationModel.getAnnotationIterator();
	while (annotationIt.hasNext()) {
		ProjectionAnnotation annotation = (ProjectionAnnotation) annotationIt.next();
		IMemento annotationMemento = memento.createChild(ANNOTATION);
		Position position = projectionAnnotationModel.getPosition(annotation);
		annotationMemento.putBoolean(IS_COLLAPSED, annotation.isCollapsed());
		annotationMemento.putInteger(OFFSET, position.offset);
		annotationMemento.putInteger(LENGTH, position.length);
	}
}
 
开发者ID:DarwinSPL,项目名称:DarwinSPL,代码行数:20,代码来源:DwprofileCodeFoldingManager.java

示例5: updateFoldingStructure

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
/**
 * Update the annotation structure in the editor.
 * 
 * This is only currently used by comment
 * folding and should be removed because it
 * is incorrect.
 * 
 * @param positions
 * @deprecated
 */
public void updateFoldingStructure(List<Position> positions)
{
	if (annotationModel == null) {
		return;
	}

    Annotation[] annotations = new Annotation[positions.size()];

    // this will hold the new annotations along
    // with their corresponding positions
    Map<ProjectionAnnotation, Position> newAnnotations = new HashMap<ProjectionAnnotation, Position>();

    for (int i = 0; i < positions.size(); i++)
    {
        ProjectionAnnotation annotation = new ProjectionAnnotation();
        newAnnotations.put(annotation, positions.get(i));
        annotations[i] = annotation;
    }
    // If this method is called too early, then annotationModel
    // can be null. This should obviously be addressed.
    this.annotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
    oldAnnotations = annotations;
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:34,代码来源:TLAEditor.java

示例6: foldAllProofs

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
/**
 * Collapses all proofs.
 * 
 * @param cursorOffset
 */
private void foldAllProofs()
{
    Vector<Annotation> modifiedAnnotations = new Vector<Annotation>();
    for (Iterator<TLAProofPosition> it = foldPositions.iterator(); it.hasNext();)
    {
        TLAProofPosition proofPosition = it.next();
        if (!proofPosition.getAnnotation().isCollapsed())
        {
            // should fold every proof
            // so that only theorem statements are shown
            proofPosition.getAnnotation().markCollapsed();
            modifiedAnnotations.add(proofPosition.getAnnotation());
        }
    }

    editor.modifyProjectionAnnotations((Annotation[]) modifiedAnnotations
            .toArray(new ProjectionAnnotation[modifiedAnnotations.size()]));
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:24,代码来源:TLAProofFoldingStructureProvider.java

示例7: expandAllProofs

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
private void expandAllProofs()
{
    Vector<Annotation> modifiedAnnotations = new Vector<Annotation>();
    for (Iterator<TLAProofPosition> it = foldPositions.iterator(); it.hasNext();)
    {
        TLAProofPosition proofPosition = it.next();
        if (proofPosition.getAnnotation().isCollapsed())
        {
            // should fold every proof
            // so that only theorem statements are shown
            proofPosition.getAnnotation().markExpanded();
            modifiedAnnotations.add(proofPosition.getAnnotation());
        }
    }

    editor.modifyProjectionAnnotations((Annotation[]) modifiedAnnotations
            .toArray(new ProjectionAnnotation[modifiedAnnotations.size()]));
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:19,代码来源:TLAProofFoldingStructureProvider.java

示例8: computeDifferences

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的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

示例9: run

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
@Override
public void run() {
    ITextEditor editor = getTextEditor();
    ISelection selection = editor.getSelectionProvider().getSelection();
    if (selection instanceof ITextSelection) {
        ITextSelection textSelection = (ITextSelection) selection;
        if (!textSelection.isEmpty()) {
            IAnnotationModel model = getAnnotationModel(editor);
            if (model != null) {
                int start = textSelection.getStartLine();
                int end = textSelection.getEndLine();
                try {
                    IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
                    int offset = document.getLineOffset(start);
                    int endOffset = document.getLineOffset(end + 1);
                    Position position = new Position(offset, endOffset - offset);
                    model.addAnnotation(new ProjectionAnnotation(), position);
                } catch (BadLocationException x) {
                    // ignore
                }
            }
        }
    }
}
 
开发者ID:forcedotcom,项目名称:idecore,代码行数:25,代码来源:ApexCodeEditor.java

示例10: updateSectionFoldingAnnotations2

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
/**
 * Calculate where to fold, sticking the info into newAnnotations
 * @param doc 
 * @param headers
 * @param newAnnotations
 * @param endParent
 */
private void updateSectionFoldingAnnotations2(IDocument doc, List<Header> headers,
		Map<Annotation, Position> newAnnotations, int endParent) {
	for (int i=0; i<headers.size(); i++) {
		Header header = headers.get(i);
		ProjectionAnnotation annotation = new ProjectionAnnotation();
		try {
			int line = header.getLineNumber();
			int start = doc.getLineOffset(line);
			int end = (i==headers.size()-1)? endParent
					: doc.getLineOffset(headers.get(i+1).getLineNumber());
			Position position = new Position(start, end-start);
			newAnnotations.put(annotation, position);
			// Recurse
			List<Header> subHeaders = header.getSubHeaders();
			if (subHeaders.size() > 0) {
				updateSectionFoldingAnnotations2(doc, subHeaders, newAnnotations, end);
			}
		} catch (Exception ex) {
			System.out.println(ex);
		}			
	}		
}
 
开发者ID:shvenkat,项目名称:Eclipse-Markdown-Editor-Plugin,代码行数:30,代码来源:MarkdownEditor.java

示例11: updateFoldingStructure

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
public void updateFoldingStructure(List<Position> positions)
{
	ProjectionAnnotation[] annotations = new ProjectionAnnotation[positions.size()];

	//this will hold the new annotations along
	//with their corresponding positions
	HashMap<ProjectionAnnotation, Position> newAnnotations = new HashMap<ProjectionAnnotation, Position>();

	for (int i = 0; i < positions.size(); i++)
	{
		ProjectionAnnotation annotation = new ProjectionAnnotation();
		newAnnotations.put(annotation,positions.get(i));
		annotations[i] = annotation;
		if (annotationCollapsedState != null && annotationCollapsedState.length > i && annotationCollapsedState[i]) {
			annotation.markCollapsed();
		}
	}

	annotationModel.modifyAnnotations(oldAnnotations,newAnnotations,null);

	oldAnnotations = annotations;
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:23,代码来源:JsonTextEditor.java

示例12: getAnnotationToAdd

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的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

示例13: addFoldingRegions

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
private void addFoldingRegions(Set<Position> regions, CommonElement[] elements, Map<Annotation,Position> map) throws BadLocationException
{
  for (int i = 0; i < elements.length; i++)
  {
    CommonElement element = elements[i];
    try
    {
      int startLine = fDocument.getLineOfOffset(element.getOffset());
      int endLine = fDocument.getLineOfOffset(element.getOffset() + element.getLength());
      if (startLine >= 0 && startLine < endLine)
      {
        int start = fDocument.getLineOffset(startLine);
        int end = fDocument.getLineOffset(endLine) + fDocument.getLineLength(endLine);
        Position position = new Position(start, end - start);
        regions.add(position);
        if (isInitiallyFolded(element))
          map.put(new ProjectionAnnotation(true), position);
      }
    }
    catch (BadLocationException x)
    {
    }
    CommonElement[] children = element.getChildren();
    if (children != null) addFoldingRegions(regions, children, map);
  }
}
 
开发者ID:matthias-wolff,项目名称:dLabPro-Plugin,代码行数:27,代码来源:CommonFoldingStructureProvider.java

示例14: getAllSnippetsAnnotations

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
private Map<ProjectionAnnotation, Position> getAllSnippetsAnnotations() {
	Map<ProjectionAnnotation, Position> annotations = new HashMap<ProjectionAnnotation, Position>();
	IDocument document = getDocument();
	int curOffset = 0;
	FindReplaceDocumentAdapter frda = new FindReplaceDocumentAdapter(document);
	try {
		IRegion startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
		while (startRegion != null && startRegion.getOffset() >= curOffset) {
			int startLine = document.getLineOfOffset(startRegion.getOffset());
			int startOffset = document.getLineOffset(startLine);
			curOffset = startOffset + document.getLineLength(startLine);
			IRegion endRegion = frda.find(startRegion.getOffset(), "SNIPPET_END", true, false, false, false); //$NON-NLS-1$
			if (endRegion != null) {
				int endLine = document.getLineOfOffset(endRegion.getOffset());
				int endOffset = document.getLineOffset(endLine);
				endOffset += document.getLineLength(endLine);
				curOffset = endOffset;
				String text = document.get(startOffset, endOffset - startOffset);
				ProjectionAnnotation annotation = new ProjectionAnnotation(true);
				annotation.setText(text);
				annotation.setRangeIndication(true);
				annotations.put(annotation, new Position(startOffset, endOffset - startOffset));
			}
			if (curOffset < document.getLength()) {
				startRegion = frda.find(curOffset, "SNIPPET_START", true, false, false, false); //$NON-NLS-1$
			}
		}

	} catch (BadLocationException e) {

	}
	return annotations;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:34,代码来源:SourceViewer.java

示例15: run

import org.eclipse.jface.text.source.projection.ProjectionAnnotation; //导入依赖的package包/类
public void run()
{
    ITextEditor editor = getTextEditor();
    ISelection selection = editor.getSelectionProvider().getSelection();
    if (selection instanceof ITextSelection)
    {
        ITextSelection textSelection = (ITextSelection) selection;
        if (textSelection.getLength() != 0)
        {
            IAnnotationModel model = getAnnotationModel(editor);
            if (model != null)
            {

                int start = textSelection.getStartLine();
                int end = textSelection.getEndLine();

                try
                {
                    IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
                    int offset = document.getLineOffset(start);
                    int endOffset = document.getLineOffset(end + 1);
                    Position position = new Position(offset, endOffset - offset);
                    model.addAnnotation(new ProjectionAnnotation(), position);
                } catch (BadLocationException x)
                {
                    // ignore
                }
            }
        }
    }
}
 
开发者ID:tlaplus,项目名称:tlaplus,代码行数:32,代码来源:DefineFoldingRegionAction.java


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