diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/.ratings index 26bb3a835dea918050199977ce7353786458f373..53fade13b8758a48fa5917a0d6012b49210a3d04 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/.ratings @@ -1,2 +1,3 @@ AnnotationFxViewPart.java 34c845f7162a8a8bb680df6ee08160ce63a5a5a3 YELLOW +AnnotationViewFXController.java 50e745f4f700b165c3d138d9f9cd2463252da31d RED FXAnnotationFilter.java 05bc78a530becbce573545d67e5b0ef9ac3f697f YELLOW diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/AnnotationViewFXController.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/AnnotationViewFXController.java index 7b8902b4b11508690a8924b9b742a4b0cf9fc379..50e745f4f700b165c3d138d9f9cd2463252da31d 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/AnnotationViewFXController.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/annotation/view/fx/AnnotationViewFXController.java @@ -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."); + } } /**