下面列出了怎么用org.eclipse.jface.text.source.AnnotationModelEvent的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void modelChanged(AnnotationModelEvent event) {
// if (event instanceof CompilationUnitAnnotationModelEvent) {
// CompilationUnitAnnotationModelEvent cuEvent= (CompilationUnitAnnotationModelEvent) event;
// if (cuEvent.includesProblemMarkerAnnotationChanges()) {
// boolean hasChanges= false;
// synchronized (this) {
// IResource changedResource= cuEvent.getUnderlyingResource();
// hasChanges= fResourcesWithAnnotationChanges.add(changedResource);
// }
// if (hasChanges) {
// fireChanges();
// }
// }
// }
}
@Override
public void modelChanged(AnnotationModelEvent event) {
if (sender == event.getAnnotationModel()) {
if (event.isWorldChange()) {
Assert.assertEquals("addAnnotationModelListener", Thread.currentThread().getStackTrace()[2].getMethodName());
} else {
if (event.getAddedAnnotations().length != event.getRemovedAnnotations().length) {
Assert.assertNull(this.event);
this.event = event;
}
}
}
}
/**
* @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
*/
public void modelChanged(AnnotationModelEvent event) {
Object[] listeners= fListenerList.getListeners();
for (int i= 0; i < listeners.length; i++) {
Object curr= listeners[i];
if (curr instanceof IAnnotationModelListenerExtension) {
((IAnnotationModelListenerExtension) curr).modelChanged(event);
}
}
}
public void modelChanged(AnnotationModelEvent event) {
if (event instanceof CompilationUnitAnnotationModelEvent) {
CompilationUnitAnnotationModelEvent cuEvent= (CompilationUnitAnnotationModelEvent) event;
if (cuEvent.includesProblemMarkerAnnotationChanges()) {
boolean hasChanges= false;
synchronized (this) {
IResource changedResource= cuEvent.getUnderlyingResource();
hasChanges= fResourcesWithAnnotationChanges.add(changedResource);
}
if (hasChanges) {
fireChanges();
}
}
}
}
@Override
public void modelChanged(AnnotationModelEvent event) {
if (!event.isValid()) {
return;
}
if (event.isWorldChange()) {
update();
return;
}
Annotation[] annotations = event.getAddedAnnotations();
int length = annotations.length;
for (int i = 0; i < length; i++) {
if (!skip(annotations[i].getType())) {
update();
return;
}
}
annotations = event.getRemovedAnnotations();
length = annotations.length;
for (int i = 0; i < length; i++) {
if (!skip(annotations[i].getType())) {
update();
return;
}
}
annotations = event.getChangedAnnotations();
length = annotations.length;
for (int i = 0; i < length; i++) {
if (!skip(annotations[i].getType())) {
update();
return;
}
}
}
@Override
protected AnnotationModelEvent createAnnotationModelEvent() {
return new CompilationUnitAnnotationModelEvent(this, getResource());
}