Commit 4ec19b23 authored by Simon Barner's avatar Simon Barner
Browse files

- Enforce full update of annotation views on setUpdateEnabled(true)

parent e7740cdf
......@@ -60,7 +60,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: E5338A681AFA613876C560BD968F34A9
* @ConQAT.Rating YELLOW Hash: B5EED9862BC0107F49D3E471B16282D7
*/
public abstract class AnnotationViewPartBase extends ViewPart implements ISelectionListener,
IAnnotationViewPart {
......@@ -71,6 +71,9 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect
/** Last selected object. */
private IModelElement lastSelectedObject;
/** Last root element determined during the last successful {@link #update(IModelElement)}. */
private IProjectRootElement lastRootElement;
/**
* Root element for which the {@link #changeListener} has been installed to (recursively)
* watch for model changes (to trigger an update of this {@link AnnotationViewPartBase}).
......@@ -229,11 +232,19 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect
* {@link #update(Collection)}, and update model change listeners.
*/
protected void update(IModelElement modelElement) {
EObject rootElement = getParentElement(modelElement, IProjectRootElement.class, true);
IProjectRootElement rootElement =
getParentElement(modelElement, IProjectRootElement.class, true);
if(rootElement == null) {
return;
}
lastRootElement = rootElement;
update(rootElement);
}
/** Perform update for given {@link IProjectRootElement}. */
private void update(IProjectRootElement rootElement) {
// Check cache if annotation entries for the given root element have already been determined
Collection<AnnotationEntry> annotationEntries = lastAnnotationEntriesMap.get(rootElement);
......@@ -315,6 +326,12 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect
activeInstances.remove(this);
}
/** Enforces a full update of the view based on {@link #lastRootElement}. */
private void forceFullUpdate() {
lastAnnotationEntriesMap.clear();
update(lastRootElement);
}
/** Sets {@link #isUpdateEnabled}. If the update is re-enabled, the view is refreshed. */
public static synchronized void setUpdateEnabled(boolean isUpdateEnabled) {
AnnotationViewPartBase.isUpdateEnabled = isUpdateEnabled;
......@@ -323,7 +340,7 @@ public abstract class AnnotationViewPartBase extends ViewPart implements ISelect
@Override
public void run() {
for(AnnotationViewPartBase avp : activeInstances) {
avp.update();
avp.forceFullUpdate();
}
}
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment