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


Java ProjectionAnnotationModel.getPosition方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: mergeFoldingRegions

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected Annotation[] mergeFoldingRegions(Collection<FoldedPosition> foldedPositions,
		ProjectionAnnotationModel projectionAnnotationModel) {
	List<Annotation> deletions = new ArrayList<Annotation>();
	for (Iterator<Annotation> iterator = projectionAnnotationModel.getAnnotationIterator(); iterator.hasNext();) {
		Annotation annotation = iterator.next();
		if (annotation instanceof ProjectionAnnotation) {
			Position position = projectionAnnotationModel.getPosition(annotation);
			if (!foldedPositions.remove(position)) {
				deletions.add(annotation);
			}
		}
	}
	return deletions.toArray(new Annotation[deletions.size()]);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:16,代码来源:DefaultFoldingStructureProvider.java

示例5: updateFoldingStructure

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
public void updateFoldingStructure(Map<ProjectionAnnotation, Position> annotations)
{
	synchronized (lockUpdateFoldingStructure)
	{
		List<Annotation> deletions = new ArrayList<Annotation>();
		Collection<Position> additions = annotations.values();
		ProjectionAnnotationModel currentModel = getAnnotationModel();
		if (currentModel == null)
		{
			return;
		}
		for (@SuppressWarnings("rawtypes")
		Iterator iter = currentModel.getAnnotationIterator(); iter.hasNext();)
		{
			Object annotation = iter.next();
			if (annotation instanceof ProjectionAnnotation)
			{
				Position position = currentModel.getPosition((Annotation) annotation);
				if (additions.contains(position))
				{
					additions.remove(position);
				}
				else
				{
					deletions.add((Annotation) annotation);
				}
			}
		}
		if (annotations.size() != 0 || deletions.size() != 0)
		{
			currentModel.modifyAnnotations(deletions.toArray(new Annotation[deletions.size()]), annotations, null);
		}
	}
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:35,代码来源:AbstractFoldingEditor.java

示例6: run

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
@Override
public void run(IAction action) {
    PySelection ps = PySelectionFromEditor.createPySelectionFromEditor(getTextEditor());

    ProjectionAnnotationModel model = getTextEditor().getAdapter(
            ProjectionAnnotationModel.class);
    try {
        if (model != null) {
            //put annotations in array list.
            Iterator iter = model.getAnnotationIterator();
            while (iter != null && iter.hasNext()) {
                PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next();
                Position position = model.getPosition(element);

                int line = ps.getDoc().getLineOfOffset(position.offset);

                int start = ps.getStartLineIndex();
                int end = ps.getEndLineIndex();

                for (int i = start; i <= end; i++) {
                    if (i == line) {
                        model.collapse(element);
                        break;
                    }
                }
            }

        }
    } catch (BadLocationException e) {
        Log.log(IStatus.ERROR, "Unexpected error collapsing", e);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:33,代码来源:PyCollapse.java

示例7: getAnnotationToAdd

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
/**
 * We have to be careful not to remove existing annotations because if this happens, previous code folding is not correct.
 */
private Tuple<ProjectionAnnotation, Position> getAnnotationToAdd(Position position, FoldingEntry node,
        ProjectionAnnotationModel model, List<Annotation> existing) {
    for (Iterator<Annotation> iter = existing.iterator(); iter.hasNext();) {
        Annotation element = iter.next();
        Position existingPosition = model.getPosition(element);
        if (existingPosition.equals(position)) {
            //ok, do nothing to this annotation (neither remove nor add, as it already exists in the correct place).
            existing.remove(element);
            return null;
        }
    }
    return new Tuple<ProjectionAnnotation, Position>(new PyProjectionAnnotation(node.getAstEntry(),
            node.isCollapsed), position);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:18,代码来源:CodeFoldingSetter.java

示例8: computeDifferences

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
private Annotation[] computeDifferences(ProjectionAnnotationModel model, Set<Position> current)
{
  List<Object> deletions = new ArrayList<Object>();
  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:matthias-wolff,项目名称:dLabPro-Plugin,代码行数:16,代码来源:CommonFoldingStructureProvider.java


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