本文整理汇总了Java中org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel类的典型用法代码示例。如果您正苦于以下问题:Java AbstractMarkerAnnotationModel类的具体用法?Java AbstractMarkerAnnotationModel怎么用?Java AbstractMarkerAnnotationModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractMarkerAnnotationModel类属于org.eclipse.ui.texteditor包,在下文中一共展示了AbstractMarkerAnnotationModel类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMarkerPosition
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
/**
* Returns the actual position of <i>marker</i> or null if the marker was
* deleted. Code inspired by
* @param marker
* @param sourceViewer
* @return
*/
private static int[] getMarkerPosition(IMarker marker, ISourceViewer sourceViewer) {
int[] p = new int[2];
p[0] = marker.getAttribute(IMarker.CHAR_START, -1);
p[1] = marker.getAttribute(IMarker.CHAR_END, -1);
// look up the current range of the marker when the document has been edited
IAnnotationModel model= sourceViewer.getAnnotationModel();
if (model instanceof AbstractMarkerAnnotationModel) {
AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
Position pos= markerModel.getMarkerPosition(marker);
if (pos != null && !pos.isDeleted()) {
// use position instead of marker values
p[0] = pos.getOffset();
p[1] = pos.getOffset() + pos.getLength();
}
if (pos != null && pos.isDeleted()) {
// do nothing if position has been deleted
return null;
}
}
return p;
}
示例2: getMarkers
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
/**
* Gets the {@link List} of {@link IMarker} for the current line of the given {@link ITextEditor}.
*
* @param editor
* the {@link ITextEditor}
* @param rulerInfo
* the {@link IVerticalRulerInfo}
* @return the {@link List} of {@link IMarker} for the current line of the given {@link ITextEditor}
*/
protected List<IMarker> getMarkers(final ITextEditor editor, final IVerticalRulerInfo rulerInfo) {
final List<IMarker> res = new ArrayList<IMarker>();
final IDocument document = (IDocument)editor.getDocumentProvider().getDocument(editor
.getEditorInput());
if (document != null) {
final AbstractMarkerAnnotationModel model = getAnnotationModel(editor);
if (model != null) {
final int activeLine = rulerInfo.getLineOfLastMouseButtonActivity();
res.addAll(getMarkers(document, model, activeLine));
}
}
return res;
}
示例3: getAnnotationModel
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
private AbstractMarkerAnnotationModel getAnnotationModel(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
IAnnotationModel model = provider.getAnnotationModel(editor.getEditorInput());
if (model instanceof AbstractMarkerAnnotationModel)
return (AbstractMarkerAnnotationModel) model;
return null;
}
示例4: obtainFindBugsMarkers
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
/**
* Fills markers field with all of the FindBugs markers associated with the
* current line in the text editor's ruler marign.
*/
protected void obtainFindBugsMarkers() {
// Delete old markers
markers.clear();
if (editor == null || ruler == null) {
return;
}
// Obtain all markers in the editor
IResource resource = (IResource) editor.getEditorInput().getAdapter(IFile.class);
if(resource == null){
return;
}
IMarker[] allMarkers = MarkerUtil.getMarkers(resource, IResource.DEPTH_ZERO);
if(allMarkers.length == 0) {
return;
}
// Discover relevant markers, i.e. FindBugsMarkers
AbstractMarkerAnnotationModel model = getModel();
IDocument document = getDocument();
for (int i = 0; i < allMarkers.length; i++) {
if (includesRulerLine(model.getMarkerPosition(allMarkers[i]), document)) {
if (MarkerUtil.isFindBugsMarker(allMarkers[i])) {
markers.add(allMarkers[i]);
}
}
}
}
示例5: getModel
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
/**
* Retrieves the AbstractMarkerAnnontationsModel from the editor.
*
* @return AbstractMarkerAnnotatiosnModel from the editor
*/
@CheckForNull
protected AbstractMarkerAnnotationModel getModel() {
if(editor == null) {
return null;
}
IDocumentProvider provider = editor.getDocumentProvider();
IAnnotationModel model = provider.getAnnotationModel(editor.getEditorInput());
if (model instanceof AbstractMarkerAnnotationModel) {
return (AbstractMarkerAnnotationModel) model;
}
return null;
}
示例6: saveDocument
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
public void saveDocument( )
{
ScriptDocumentProvider provider = (ScriptDocumentProvider) getDocumentProvider( );
try
{
( (AbstractMarkerAnnotationModel) provider.getAnnotationModel( getEditorInput( ) ) ).commit( provider.getDocument( getEditorInput( ) ) );
}
catch ( CoreException e )
{
// do nothing
}
}
示例7: getMarkerPosition
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
/**
* @return the position for a marker.
*/
public static Position getMarkerPosition(IDocument document, IMarker marker, IAnnotationModel model) {
if (model instanceof AbstractMarkerAnnotationModel) {
Position ret = ((AbstractMarkerAnnotationModel) model).getMarkerPosition(marker);
if (ret != null) {
return ret;
}
}
int start = MarkerUtilities.getCharStart(marker);
int end = MarkerUtilities.getCharEnd(marker);
if (start > end) {
end = start + end;
start = end - start;
end = end - start;
}
if (start == -1 && end == -1) {
// marker line number is 1-based
int line = MarkerUtilities.getLineNumber(marker);
if (line > 0 && document != null) {
try {
start = document.getLineOffset(line - 1);
end = start;
} catch (BadLocationException x) {
}
}
}
if (start > -1 && end > -1) {
return new Position(start, end - start);
}
return null;
}
示例8: getAnnotationModel
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
private AbstractMarkerAnnotationModel getAnnotationModel() {
IAnnotationModel m = sourceViewer.getAnnotationModel();
Check.isTrue(m instanceof AbstractMarkerAnnotationModel);
return (AbstractMarkerAnnotationModel) m;
}
示例9: findJavaAnnotation
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
private void findJavaAnnotation() {
fPosition= null;
fAnnotation= null;
fHasCorrection= false;
AbstractMarkerAnnotationModel model= getAnnotationModel();
IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();
IDocument document= getDocument();
if (model == null)
return ;
boolean hasAssistLightbulb= fStore.getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);
Iterator<Annotation> iter= model.getAnnotationIterator();
int layer= Integer.MIN_VALUE;
while (iter.hasNext()) {
Annotation annotation= iter.next();
if (annotation.isMarkedDeleted())
continue;
int annotationLayer= layer;
if (annotationAccess != null) {
annotationLayer= annotationAccess.getLayer(annotation);
if (annotationLayer < layer)
continue;
}
Position position= model.getPosition(annotation);
if (!includesRulerLine(position, document))
continue;
AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
if (preference == null)
continue;
String key= preference.getVerticalRulerPreferenceKey();
if (key == null)
continue;
if (!fStore.getBoolean(key))
continue;
boolean isReadOnly= fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
if (!isReadOnly
&& (
((hasAssistLightbulb && annotation instanceof AssistAnnotation)
|| JavaCorrectionProcessor.hasCorrections(annotation)))) {
fPosition= position;
fAnnotation= annotation;
fHasCorrection= true;
layer= annotationLayer;
continue;
} else if (!fHasCorrection) {
fPosition= position;
fAnnotation= annotation;
layer= annotationLayer;
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:62,代码来源:JavaSelectAnnotationRulerAction.java
示例10: findJavaAnnotation
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
private void findJavaAnnotation() {
fPosition= null;
fAnnotation= null;
fHasCorrection= false;
AbstractMarkerAnnotationModel model= getAnnotationModel();
IAnnotationAccessExtension annotationAccess= getAnnotationAccessExtension();
IDocument document= getDocument();
if (model == null)
return ;
boolean hasAssistLightbulb= fStore.getBoolean(PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB);
Iterator<Annotation> iter= model.getAnnotationIterator();
int layer= Integer.MIN_VALUE;
while (iter.hasNext()) {
Annotation annotation= iter.next();
if (annotation.isMarkedDeleted())
continue;
int annotationLayer= layer;
if (annotationAccess != null) {
annotationLayer= annotationAccess.getLayer(annotation);
if (annotationLayer < layer)
continue;
}
Position position= model.getPosition(annotation);
if (!includesRulerLine(position, document))
continue;
boolean isReadOnly= fTextEditor instanceof ITextEditorExtension && ((ITextEditorExtension)fTextEditor).isEditorInputReadOnly();
if (!isReadOnly
&& (
((hasAssistLightbulb && annotation instanceof AssistAnnotation)
|| JavaCorrectionProcessor.hasCorrections(annotation)))) {
fPosition= position;
fAnnotation= annotation;
fHasCorrection= true;
layer= annotationLayer;
continue;
} else if (!fHasCorrection) {
AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
if (preference == null)
continue;
String key= preference.getVerticalRulerPreferenceKey();
if (key == null)
continue;
if (fStore.getBoolean(key)) {
fPosition= position;
fAnnotation= annotation;
layer= annotationLayer;
}
}
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:61,代码来源:JavaSelectAnnotationRulerAction.java
示例11: selectReveal
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; //导入依赖的package包/类
public boolean selectReveal( Object marker )
{
int start = MarkerUtilities.getCharStart( (IMarker) marker );
int end = MarkerUtilities.getCharEnd( (IMarker) marker );
boolean selectLine = start < 0 || end < 0;
// look up the current range of the marker when the document has been
// edited
IAnnotationModel model = reportXMLEditor.getDocumentProvider( )
.getAnnotationModel( reportXMLEditor.getEditorInput( ) );
if ( model instanceof AbstractMarkerAnnotationModel )
{
AbstractMarkerAnnotationModel markerModel = (AbstractMarkerAnnotationModel) model;
Position pos = markerModel.getMarkerPosition( (IMarker) marker );
if ( pos != null )
{
if ( !pos.isDeleted( ) )
{
// use position instead of marker values
start = pos.getOffset( );
end = pos.getOffset( ) + pos.getLength( );
}
else
{
return false;
}
}
}
IDocument document = reportXMLEditor.getDocumentProvider( )
.getDocument( reportXMLEditor.getEditorInput( ) );
if ( selectLine )
{
int line;
try
{
if ( start >= 0 )
line = document.getLineOfOffset( start );
else
{
line = MarkerUtilities.getLineNumber( (IMarker) marker );
// Marker line numbers are 1-based
if ( line >= 1 )
{
line--;
}
start = document.getLineOffset( line );
}
end = start + document.getLineLength( line ) - 1;
}
catch ( BadLocationException e )
{
return false;
}
}
int length = document.getLength( );
if ( end - 1 < length && start < length )
reportXMLEditor.selectAndReveal( start, end - start );
return true;
}