texteditor marker and annotation
来源:互联网 发布:超感知觉 知乎 编辑:程序博客网 时间:2024/05/17 22:49
http://liugang594.iteye.com/blog/795749
http://stackoverflow.com/questions/2888207/eclipse-plugin-custom-icon-for-a-marker
http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/editors_annotations.htm
http://www.cnblogs.com/yinger/archive/2011/11/21/2257058.html
https://www.ibm.com/developerworks/cn/opensource/os-cn-ecljtf5/
<extension id="wang.andy.validation.groovy.problemmarker" name="Groovy syntax problem" point="org.eclipse.core.resources.markers"> <persistent value="true"> </persistent> <super type="org.eclipse.core.resources.problemmarker"> </super> </extension> <extension id="wang.andy.validation.groovy.textmarker" name="Groovy syntax problem" point="org.eclipse.core.resources.markers"> <persistent value="true"> </persistent> <super type="org.eclipse.core.resources.textmarker"> </super> </extension> <extension point="org.eclipse.ui.ide.markerImageProviders"> <imageprovider icon="icons/error.gif" id="wang.andy.validation.groovy.textmarker.imageprovider" markertype="wang.andy.validation.groovy.textmarker"> </imageprovider> </extension> <extension point="org.eclipse.ui.editors.annotationTypes"> <type markerSeverity="1" markerType="wang.andy.validation.groovy.textmarker" name="wang.andy.validation.texteditor.warning" super="org.eclipse.ui.workbench.texteditor.warning"> </type> <type markerSeverity="2" markerType="wang.andy.validation.groovy.problemmarker" name="wang.andy.validation.texteditor.error" super="org.eclipse.ui.workbench.texteditor.error"> </type> </extension> <extension point="org.eclipse.ui.editors.markerAnnotationSpecification"> <specification annotationType="wang.andy.validation.texteditor.warning" colorPreferenceKey="warningColorKey" colorPreferenceValue="255,255,0" contributesToHeader="true" highlightPreferenceKey="warningHightlightKey" highlightPreferenceValue="true" icon="icons/warning.gif" includeOnPreferencePage="true" isGoToNextNavigationTarget="true" isGoToNextNavigationTargetKey="Warning_isOccurrenceGoToNextNavigationTarget" isGoToPreviousNavigationTarget="true" isGoToPreviousNavigationTargetKey="Warning_isOccurrenceGoToPreviousNavigationTarget" label="WARNING" overviewRulerPreferenceKey="warningOverviewKey" overviewRulerPreferenceValue="true" presentationLayer="4" quickFixIcon="icons/warning.gif" showInNextPrevDropdownToolbarAction="true" showInNextPrevDropdownToolbarActionKey="Warning_showOccurrenceInNextPrevDropdownToolbarAction" symbolicIcon="warning" textPreferenceKey="warningTextKey" textPreferenceValue="true" textStylePreferenceKey="occurrenceTextStyle" textStylePreferenceValue="NONE" verticalRulerPreferenceKey="warningVerticalKey" verticalRulerPreferenceValue="true"> </specification> <specification annotationType="wang.andy.validation.texteditor.error" colorPreferenceKey="errorColorKey" colorPreferenceValue="255,0,0" contributesToHeader="true" highlightPreferenceKey="errorHightlightKey" highlightPreferenceValue="true" icon="icons/error.gif" includeOnPreferencePage="true" isGoToNextNavigationTarget="true" isGoToNextNavigationTargetKey="Error_isOccurrenceGoToNextNavigationTarget" isGoToPreviousNavigationTarget="true" isGoToPreviousNavigationTargetKey="Error_isOccurrenceGoToPreviousNavigationTarget" label="ERROR" overviewRulerPreferenceKey="errorOverviewKey" overviewRulerPreferenceValue="true" presentationLayer="4" quickFixIcon="icons/error.gif" showInNextPrevDropdownToolbarAction="true" showInNextPrevDropdownToolbarActionKey="Error_showOccurrenceInNextPrevDropdownToolbarAction" symbolicIcon="error" textPreferenceKey="errorTextKey" textPreferenceValue="true" textStylePreferenceKey="occurrenceTextStyle" textStylePreferenceValue="NONE" verticalRulerPreferenceKey="errorVerticalKey" verticalRulerPreferenceValue="true"> </specification> </extension>
一个是IFile类型的实例(用来执行marking),一个是IDocument 类型的实例(用于确定插入文档中的marker的位置)。
public IMarker addProblemMarker(String type, String message, String location, int severity, int priority) { if (null != resource) { try {//type是 String GROOVY_PROBLEM_MARKER_ID = "wang.andy.validation.groovy.problemmarker"; IMarker marker = resource.createMarker(type); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.LOCATION, location); marker.setAttribute(IMarker.SEVERITY, severity); marker.setAttribute(IMarker.PRIORITY, priority); return marker; } catch (CoreException e) { e.printStackTrace(); } } return null; } public IMarker addTextMarker(String type, String message, String location, int severity, int priority) { if (null != resource) { try {//type是 String GROOVY_PROBLEM_MARKER_ID = "wang.andy.validation.groovy.textmarker"; IMarker textmarker = resource.createMarker(type); textmarker.setAttribute(IMarker.MESSAGE, message); textmarker.setAttribute(IMarker.LOCATION, location); textmarker.setAttribute(IMarker.SEVERITY, severity); textmarker.setAttribute(IMarker.PRIORITY, priority); return textmarker; } catch (CoreException e) { e.printStackTrace(); } } return null; } public void addTextAnnotation(IMarker textmarker, ITextEditor editor) { if (editor instanceof MappingTextEditor) { IDocumentProvider documentProvider = editor.getDocumentProvider(); // documentProvider = new ExpressionTextDocumentProvider(); ITextSelection textSelection = (ITextSelection)editor.getSelectionProvider() .getSelection(); if (!textSelection.isEmpty()) { // IAnnotationModel model = getAnnotationModel(editor); IAnnotationModel annotationModel = documentProvider.getAnnotationModel(editor.getEditorInput()); // annotationModel = new ExpressionAnnotationModel(resource); if (annotationModel != null) { int start = textSelection.getStartLine(); int end = textSelection.getEndLine(); //annotations SimpleMarkerAnnotation ma = new SimpleMarkerAnnotation( GROOVY_TEXT_ANNOTATION_ERROR_ID, marker); //GROOVY_TEXT_ANNOTATION_ERROR_ID = "wang.andy.validation.texteditor.error"; try { IDocument document = editor.getDocumentProvider() .getDocument(editor.getEditorInput()); int offset = document.getLineOffset(start); int endOffset = document.getLineOffset(end); Position position = new Position(offset, endOffset - offset); //Finally add the new annotation to the model annotationModel.connect(document); annotationModel.addAnnotation(ma, position); annotationModel.disconnect(document); } catch (BadLocationException x) { // ignore } } } } }}
- texteditor marker and annotation
- Builder Marker and Nature
- 关于TextEditor
- Spring annotation and JSR330
- Java Annotation and @Inject
- Variation calling and annotation
- openlayers custom marker and popup 动态标注提示信息
- spring annotation and cache config
- Spring MultiActionController and using Annotation
- ValidateUtil by Annotation and HibernateImplements
- TextEditor 1.0 发布
- TextEditor的基本操作
- sgu 397 TextEditor
- TextEditor相关操作
- e - texteditor 破解
- 精简版的textEditor
- spring mvc annotation and i18n configure
- Spring mvc annotation and xml example
- Android 数据查询query函数参数解析
- 如何使用ant编译Android开源voip代码sipdroid
- Weblogic10.3项目部署出错的一些常见问题
- _variant_t _bstr_t
- SIP
- texteditor marker and annotation
- ibm sametime client 时间显示不正确
- 基础加强_枚举类型Enum
- 【指针】【引用作形参】对三个变量排序
- struts2.1的bug:Exception starting filter struts2 java.lang.NullPointerException
- SQL中的In的用法
- LVS/DR模式原理剖析(FAQs)
- eoe里面的实现GridView 长按跨屏拖动,以及自动移位。
- DM8148 开发记录 四