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


Java ProjectionAnnotationModel.getAnnotationIterator方法代码示例

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


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

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

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

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

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

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

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

示例7: modifyFiltered

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
/**
 * Collapses or expands all annotations matched by the passed filter.
 *
 * @param filter the filter to use to select which annotations to collapse
 * @param expand <code>true</code> to expand the matched annotations, <code>false</code> to
 *        collapse them
 */
private void modifyFiltered(Filter filter, boolean expand) {
	if (!isInstalled())
		return;

	ProjectionAnnotationModel model= getModel();
	if (model == null)
		return;

	List<JavaProjectionAnnotation> modified= new ArrayList<JavaProjectionAnnotation>();
	Iterator<Annotation> iter= model.getAnnotationIterator();
	while (iter.hasNext()) {
		Object annotation= iter.next();
		if (annotation instanceof JavaProjectionAnnotation) {
			JavaProjectionAnnotation java= (JavaProjectionAnnotation) annotation;

			if (expand == java.isCollapsed() && filter.match(java)) {
				if (expand)
					java.markExpanded();
				else
					java.markCollapsed();
				modified.add(java);
			}

		}
	}

	model.modifyAnnotations(null, null, modified.toArray(new Annotation[modified.size()]));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:36,代码来源:DefaultJavaFoldingStructureProvider.java

示例8: collapseStyle

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
/**
 * Collapses all item with the specified style.
 * 
 * @param style
 *            the style to collapse
 */
private void collapseStyle( int style )
{
	ISourceViewer viewer = getViewer( );

	if ( !( viewer instanceof ProjectionViewer ) )
	{
		return;
	}

	ProjectionAnnotationModel model = ( (ProjectionViewer) viewer ).getProjectionAnnotationModel( );

	if ( model == null )
	{
		return;
	}

	List modified = new ArrayList( );
	Iterator iter = model.getAnnotationIterator( );

	while ( iter.hasNext( ) )
	{
		Object annotation = iter.next( );

		if ( annotation instanceof ScriptProjectionAnnotation )
		{
			ScriptProjectionAnnotation scriptAnnotation = (ScriptProjectionAnnotation) annotation;

			if ( !scriptAnnotation.isCollapsed( )
					&& scriptAnnotation.isStyle( style ) )
			{
				scriptAnnotation.markCollapsed( );
				modified.add( scriptAnnotation );
			}
		}
	}
	model.modifyAnnotations( null,
			null,
			(Annotation[]) modified.toArray( new Annotation[modified.size( )] ) );
}
 
开发者ID:eclipse,项目名称:birt,代码行数:46,代码来源:DecoratedScriptEditor.java

示例9: getAnnotationsIterator

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
/**
 * @param model
 * @return
 */
protected Iterator<Annotation> getAnnotationsIterator(final ProjectionAnnotationModel model,
        boolean useExpanded) {
    //put annotations in array list.
    Iterator<Annotation> iter = model.getAnnotationIterator();
    if (iter != null) {

        //get the not collapsed (expanded) and sort them
        ArrayList<Annotation> expanded = new ArrayList<Annotation>();
        while (iter.hasNext()) {
            PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next();
            if (element.isCollapsed() == useExpanded) {
                expanded.add(element);
            }
        }

        Collections.sort(expanded, new Comparator() {

            @Override
            public int compare(Object o1, Object o2) {
                PyProjectionAnnotation e1 = (PyProjectionAnnotation) o1;
                PyProjectionAnnotation e2 = (PyProjectionAnnotation) o2;
                int e1Off = model.getPosition(e1).getOffset();
                int e2Off = model.getPosition(e2).getOffset();
                if (e1Off < e2Off) {
                    return -1;
                }
                if (e1Off > e2Off) {
                    return 1;
                }
                return 0;
            }
        });

        iter = expanded.iterator();
    }
    return iter;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:42,代码来源:PyFoldingAction.java

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

示例11: addMarksToModel

import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; //导入方法依赖的package包/类
/**
 * Given the ast, create the needed marks and set them in the passed model.
 */
private synchronized void addMarksToModel(SimpleNode root2, ProjectionAnnotationModel model) {
    try {
        if (model != null) {
            ArrayList<Annotation> existing = new ArrayList<Annotation>();

            //get the existing annotations
            Iterator<Annotation> iter = model.getAnnotationIterator();
            while (iter != null && iter.hasNext()) {
                Annotation element = iter.next();
                existing.add(element);
            }

            //now, remove the annotations not used and add the new ones needed
            IDocument doc = editor.getDocument();
            if (doc != null) { //this can happen if we change the input of the editor very quickly.
                boolean foldInitial = initialFolding;
                initialFolding = false;
                List<FoldingEntry> marks = getMarks(doc, root2, foldInitial);
                Map<ProjectionAnnotation, Position> annotationsToAdd;
                if (marks.size() > OptimizationRelatedConstants.MAXIMUM_NUMBER_OF_CODE_FOLDING_MARKS) {
                    annotationsToAdd = new HashMap<ProjectionAnnotation, Position>();

                } else {
                    annotationsToAdd = getAnnotationsToAdd(marks, model, existing);
                }

                model.replaceAnnotations(existing.toArray(new Annotation[existing.size()]), annotationsToAdd);
            }
        }
    } catch (Exception e) {
        Log.log(e);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:37,代码来源:CodeFoldingSetter.java

示例12: 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.getAnnotationIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。