Skip to content
Snippets Groups Projects
Commit fdde6fd1 authored by Simon Barner's avatar Simon Barner
Browse files

- Ensure that independently of the currently selected model element type,...

- Ensure that independently of the currently selected model element type, annotations are shown for the entire sub-model below the IProjectRoot element above that currently selected model element. E.g., in the LA, show annotations for Channels in case a Component is currently selected
refs 1841
parent 1b98da4d
No related branches found
No related tags found
No related merge requests found
......@@ -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 */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment