Skip to content
Snippets Groups Projects
Commit ecf082db authored by Andreas Bayha's avatar Andreas Bayha
Browse files

Annotations: Fixed problem with filtering

The content provider did not filter, whenever there was an empty filter
expression set.

Issue-Ref: 4014
Issue-Url: https://af3-developer.fortiss.org/issues/4014


Signed-off-by: default avatarAndreas Bayha <bayha@fortiss.org>
parent e79a0a21
No related branches found
No related tags found
1 merge request!1254014
AnnotationFxViewPart.java 34c845f7162a8a8bb680df6ee08160ce63a5a5a3 YELLOW
AnnotationViewFXController.java 50e745f4f700b165c3d138d9f9cd2463252da31d RED
FXAnnotationFilter.java 05bc78a530becbce573545d67e5b0ef9ac3f697f YELLOW
......@@ -81,6 +81,8 @@ import javafx.scene.control.TreeTableView;
public class AnnotationViewFXController extends CompositeFXControllerBase<SplitPane, Node>
implements ISelectionListener {
private static final String SHOW_ALL_ANNOTATION_TYPES = "Show all annotation types";
@FXML
TextField txtFilterText;
......@@ -111,9 +113,9 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
/** */
private IProjectRootElement curentRootElement;
IModelElement selected;
private FXAnnotationFilter filter = new FXAnnotationFilter();
private Set<ColumnHandle<IAnnotatedSpecification>> columnHandles = new TreeSet<>();
......@@ -122,6 +124,8 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
private Map<String, IAnnotatedSpecification> colNameToSpecification = new HashMap<String, IAnnotatedSpecification>();
DynamicTreeContentProviderBase<AnnotationEntry> contentProvider;
/**
* Associates the handles of the annotations with their ordered column indexes.
* Used for the UI providers of cell items.
......@@ -169,11 +173,16 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
this.selected = (IModelElement) selected;
}
ObservableList<String> annotationTypeOptions = comboAnnotationType.getItems();
annotationTypeOptions.add("Show all annotation types.");
annotationTypeOptions.addAll(columnHandles.stream().map(h -> h.getColumnName()).collect(toList()));
setupAnnotationTree();
// After the ColumHandles are created in setupAnnotationTree(), we can fill the
// corresponding filter combo.
ObservableList<String> annotationTypeOptions = comboAnnotationType.getItems();
annotationTypeOptions.clear();
annotationTypeOptions.add(SHOW_ALL_ANNOTATION_TYPES);
List<String> annotations = columnHandles.stream().map(h -> h.getColumnName()).collect(toList());
annotationTypeOptions.addAll(annotations);
comboAnnotationType.setValue(SHOW_ALL_ANNOTATION_TYPES);
}
/**
......@@ -218,7 +227,7 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
boolean showRoot = false;
int revealLevel = 1;
DynamicTreeTableUIProviderBase<AnnotationEntry> uiProvider = new AnnotationTreeTableUIProvider();
DynamicTreeContentProviderBase<AnnotationEntry> contentProvider = new AnnotationTableContentProvider();
contentProvider = new AnnotationTableContentProvider();
annotationViewer = new DynamicTreeTableViewer<AnnotationEntry>(annotationTreeTableView, rootElement, showRoot,
revealLevel, contentProvider, uiProvider);
......@@ -236,14 +245,17 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
}
private void clearTableViewer() {
// colIdxAnnotationMap.clear();
// columnHandles.clear();
// columnHandleToColumn.clear();
// annotationTreeTableView.getColumns().clear();
// annotationTreeTableView.setRoot(null);
colIdxAnnotationMap.clear();
columnHandles.clear();
columnHandleToColumn.clear();
annotationTreeTableView.getColumns().clear();
annotationTreeTableView.setRoot(null);
}
private void setupFilterWidgets() {
comboAnnotationType.getItems().add(SHOW_ALL_ANNOTATION_TYPES);
comboAnnotationType.setValue(SHOW_ALL_ANNOTATION_TYPES);
ObservableList<String> hierarchyLevels = comboHierarchy.getItems();
hierarchyLevels.clear();
hierarchyLevels.add(HIERARCHY_LEVELS_ALL);
......@@ -254,7 +266,6 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
comboHierarchy.valueProperty().addListener((obs, oVal, nVal) -> {
filter.setHierarchyLevelFilter(nVal);
filterColumns();
updateAnnotationTree();
});
......@@ -267,7 +278,9 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
txtFilterText.textProperty().addListener((obs, oVal, nVal) -> {
filter.setNameFilterPattern(nVal);
filterColumns();
if (radBtnFilterAnnotationNames.isSelected()) {
filterColumns();
}
updateAnnotationTree();
});
......@@ -275,12 +288,24 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
radBtnFilterAnnotationNames.selectedProperty().addListener((obs, oVal, nVal) -> {
filter.setFilterColumnName(nVal);
filterColumns();
updateAnnotationTree();
});
radBtnFilterModelElements.selectedProperty().addListener((obs, oVal, nVal) -> {
filter.setFilterRowName(nVal);
updateAnnotationTree();
});
chkBoxMatchCase.selectedProperty().addListener((obs, oVal, nVal) -> {
filter.setFilterNameMatchCase(nVal);
if (radBtnFilterAnnotationNames.isSelected()) {
filterColumns();
}
updateAnnotationTree();
});
......@@ -305,8 +330,6 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
}
private void updateAnnotationTree() {
annotationTreeTableView.refresh();
annotationViewer.update();
annotationViewer.expandAllItems();
}
......@@ -459,6 +482,13 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
* The tree under this root has only one layer.
*/
protected class AnnotationTableContentProvider extends DynamicTreeContentProviderBase<AnnotationEntry> {
/** Constructor */
public AnnotationTableContentProvider() {
// Initializes the filterExpressino to be non empty.
super.setFilterExpression("*");
}
/** {@inheritDoc} */
@Override
protected Collection<? extends AnnotationEntry> getChildren(AnnotationEntry parent) {
......@@ -469,10 +499,19 @@ public class AnnotationViewFXController extends CompositeFXControllerBase<SplitP
return emptyList();
}
/** {@inheritDoc} */
@Override
protected boolean filter(AnnotationEntry entry, String filterValue) {
return filter.passesRowFilter(entry);
}
/** {@inheritDoc} */
@Override
public void setFilterExpression(String filterExpression) {
throw new UnsupportedOperationException(
"The AnnotationTableContentProvider class does not use the build in filter expression. "
+ "This set operation would not have any effect.");
}
}
/**
......
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