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

- Fix the following bugs introduced with the last performance optimizations

  - Crash when setting an annotation type based filter
  - Missing updates for filters that depend on the currently selected model element
refs 1841
parent 1a01c12b
No related branches found
No related tags found
No related merge requests found
......@@ -172,10 +172,9 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
// following scenario:
// - Filter is set for annotation names.
// - Filter scope is changed to component names -> annotation filter needs to be undone
// - Filter is based on annotation entry type
// - Filter is set to current level / current sub model
if(lastAnnotationEntries != null) {
// Reset lastAnnotationEntries in order to enforce full update in
// update(Collection<AnnotationEntry> annotationEntries)
lastAnnotationEntries = null;
update(lastAnnotationEntries);
}
}
......@@ -183,14 +182,17 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
/** {@inheritDoc} */
@Override
protected void update(Collection<AnnotationEntry> annotationEntries) {
// Update filter
// Update row filter with currently selected element
annotationFilter.setCurrentySelectedModelElement(getCurrentlySelectedObject());
if(annotationFilterWidget != null) {
annotationFilterWidget.updateAnnotationTypeFilterOptionsComboBox(annotationEntries,
this);
}
if(lastAnnotationEntries == null || !annotationEntries.equals(lastAnnotationEntries)) {
if(annotationFilter.annotationViewQueryUpdateRequired() || lastAnnotationEntries == null ||
!annotationEntries.equals(lastAnnotationEntries)) {
// Update filter widget
if(annotationFilterWidget != null) {
annotationFilterWidget.updateAnnotationTypeFilterOptionsComboBox(annotationEntries,
this);
}
// Remember last annotation entries (required to re-draw table after changing the
// column/annotation filter
lastAnnotationEntries = annotationEntries;
......
......@@ -74,6 +74,9 @@ public class AnnotationFilter extends ViewerFilter {
/** Column filter option based on annotation type */
private Class<? extends IAnnotatedSpecification> annotationTypeFilter;
/** Flag if a full update of the annotation view has been requested. */
boolean annotationViewFullUpdateRequested;
/** {@inheritDoc} */
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
......@@ -180,6 +183,29 @@ public class AnnotationFilter extends ViewerFilter {
.getModelElement()).getName())) && passesSelectedElementTypeFilter(annotationEntry);
}
/**
* Query if a full update of the annotation view as been requested (and reset the request), or
* if the current filter settings require a full update in any case.
*/
public boolean annotationViewQueryUpdateRequired() {
// In case an update has been explicitly requested, reset the request here.
boolean annotationViewFullUpdateRequested = this.annotationViewFullUpdateRequested;
this.annotationViewFullUpdateRequested = false;
// If the filter is based on the current selection (i.e., currently selected model element
// type, current level, or current sub-model, ), a full update is required on very
// selection change since the newly selected element might contribute a different set of
// annotations.
return restrictToSelectedModelElementType ||
!hierarchyLevelFilter.equals(HIERARCHY_LEVELS_ALL) ||
annotationViewFullUpdateRequested;
}
/** Request a full update of the annotation view (due to changed filter settings). */
public void annotationViewRequestFullUpdate() {
this.annotationViewFullUpdateRequested = true;
}
/** Sets the model element / annotation name filter pattern. */
public void setNameFilterPattern(String filterPattern) {
this.filterPattern = filterPattern;
......
......@@ -129,7 +129,7 @@ public class AnnotationFilterWidget extends Composite {
SWT.COLOR_WIDGET_FOREGROUND));
}
view.getAnnotationFilter().setNameFilterPattern(filterPattern);
view.update();
updateView(view);
}
});
......@@ -187,7 +187,7 @@ public class AnnotationFilterWidget extends Composite {
}
view.getAnnotationFilter().setFilterRowName(true);
view.getAnnotationFilter().setFilterColumnName(false);
view.update();
updateView(view);
}
});
......@@ -205,7 +205,7 @@ public class AnnotationFilterWidget extends Composite {
}
view.getAnnotationFilter().setFilterRowName(false);
view.getAnnotationFilter().setFilterColumnName(true);
view.update();
updateView(view);
}
});
......@@ -235,7 +235,7 @@ public class AnnotationFilterWidget extends Composite {
// button, so check, if this is the button that just obtained the selection
view.getAnnotationFilter().setRestrictToSelectedModelElementType(
((Button)e.getSource()).getSelection());
view.update();
updateView(view);
}
});
......@@ -265,7 +265,7 @@ public class AnnotationFilterWidget extends Composite {
public void widgetSelected(SelectionEvent e) {
view.getAnnotationFilter().setHierarchyLevelFilter(
filterHierarchyLevelCombo.getText());
view.update();
updateView(view);
}
});
......@@ -292,7 +292,7 @@ public class AnnotationFilterWidget extends Composite {
view.getAnnotationFilter().setAnnotationTypeFilter(
filterAnnotationTypeCombo.getObject(filterAnnotationTypeCombo
.getSelectionIndex()));
view.update();
updateView(view);
}
});
......@@ -343,4 +343,11 @@ public class AnnotationFilterWidget extends Composite {
// Adjust size to new content
filterAnnotationTypeCombo.pack(true);
}
/** Updates the annotation view */
private void updateView(final GenericAnnotationView view) {
view.getAnnotationFilter().annotationViewRequestFullUpdate();
view.update();
}
}
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