\r
return annotation;\r
}\r
+ \r
+ public void updateLineFromAnnotation(Object element, LineAnnotation annotation, String text) {\r
+ IAnnotationModel model = getAnnotationModel(element);\r
+ IDocument document = getDocument(element);\r
+ try {\r
+ if (model.getPosition(annotation) == null) {\r
+ return;\r
+ }\r
+ int offset = model.getPosition(annotation).getOffset(); \r
+ int line = document.getLineOfOffset(offset);\r
+ int lineLength = document.getLineLength(document.getLineOfOffset(offset));\r
+ if (document.getLineDelimiter(line) != null) {\r
+ lineLength -= document.getLineDelimiter(line).length();\r
+ }\r
+ document.replace(offset, lineLength, text);\r
+ } catch (BadLocationException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ }\r
+ }\r
\r
class EntityListenerImpl extends EntityListener {\r
\r
\r
annotation.setDirty(true);\r
\r
- IAnnotationModel model = getAnnotationModel(element);\r
- IDocument document = getDocument(element);\r
- \r
Object entity = annotation.getEntity();\r
String text;\r
if (lineDisplay.isEntityCacheEmpty(entity)) {\r
text = lineDisplay.getEmptyCacheMessage(entity);\r
} else {\r
text = lineDisplay.getText(entity);\r
- } \r
- try {\r
- if (model.getPosition(annotation) == null) {\r
- return;\r
- }\r
- int offset = model.getPosition(annotation).getOffset(); \r
- int line = document.getLineOfOffset(offset);\r
- int lineLength = document.getLineLength(document.getLineOfOffset(offset));\r
- if (document.getLineDelimiter(line) != null) {\r
- lineLength -= document.getLineDelimiter(line).length();\r
- }\r
- document.replace(offset, lineLength, text);\r
- } catch (BadLocationException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
}\r
+\r
+ updateLineFromAnnotation(element, annotation, text);\r
}\r
}\r
\r