diff --git a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java index fc4edd5f93e1e9197c3a53edb8f0e6ba8fb96b6c..ef1bb3c3d5b65eef63e74d92ec32006e33bd8991 100644 --- a/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java +++ b/org.fortiss.tooling.base.ui/trunk/src/org/fortiss/tooling/base/ui/annotation/view/AnnotationViewPartBase.java @@ -123,33 +123,18 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect } /** Update registration of model listeners. */ - private void updateChangeListener(Collection<AnnotationEntry> annotationEntryList) { - // Determine all root elements - Set<EObject> rootElements = new HashSet<EObject>(); - for(AnnotationEntry entry : annotationEntryList) { - EObject rootElement = entry.getModelElement(); - while(!(rootElement instanceof IProjectRootElement)) { - rootElement = rootElement.eContainer(); - } - rootElements.add(rootElement); - } - + private void updateChangeListener(EObject rootElement) { // Determine all IModelElements, and their specifications below the current root elements. // Specifications must be watched, too, since the state of an editing support for a given // specification can depend on the state of one or more other specifications. Set<EObject> currentWatchedModelElements = new HashSet<EObject>(); - for(EObject rootElement : rootElements) { - for(EObject modelElement : EcoreUtils.getChildrenWithType(rootElement, - IModelElement.class)) { - currentWatchedModelElements.add(modelElement); - currentWatchedModelElements.addAll(((IModelElement)modelElement) - .getSpecifications()); - } - if(rootElement instanceof IModelElement) { - currentWatchedModelElements.add(rootElement); - currentWatchedModelElements - .addAll(((IModelElement)rootElement).getSpecifications()); - } + for(EObject modelElement : EcoreUtils.getChildrenWithType(rootElement, IModelElement.class)) { + currentWatchedModelElements.add(modelElement); + currentWatchedModelElements.addAll(((IModelElement)modelElement).getSpecifications()); + } + if(rootElement instanceof IModelElement) { + currentWatchedModelElements.add(rootElement); + currentWatchedModelElements.addAll(((IModelElement)rootElement).getSpecifications()); } // Add change listeners to IModelElements that are about to appear in the view @@ -189,17 +174,25 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect } }); - // Collect all AnnotationEntries for the current model element and its offspring - annotationEntries.addAll(IAnnotationValueService.INSTANCE.getValues(modelElement)); - for(IModelElement childModelElement : EcoreUtils.getChildrenWithType(modelElement, + // Determine root element of selected / modified model element + EObject rootElement = modelElement; + while(!(rootElement instanceof IProjectRootElement)) { + rootElement = rootElement.eContainer(); + } + + // Collect all AnnotationEntries for the current root element and its offspring + if(rootElement instanceof IModelElement) { + annotationEntries.addAll(IAnnotationValueService.INSTANCE + .getValues((IModelElement)rootElement)); + } + for(IModelElement childModelElement : EcoreUtils.getChildrenWithType(rootElement, IModelElement.class)) { annotationEntries.addAll(IAnnotationValueService.INSTANCE.getValues(childModelElement)); } - // Update the view + // Update the view and change listener registration update(annotationEntries); - - updateChangeListener(annotationEntries); + updateChangeListener(rootElement); } /** Update concrete view */