This document covers a re-usable approach for searching terms on Guided Decision Tables, DMN graphs, and DMN Decision Tables. It can be re-used in other editors, including non-canvas-based components.
All GDT Cells, DRG Elements, and any other searchable element will implement this interface:
interface Searchable {
boolean matches(final String text)
Command onFound()
}
In the UI, editors will have an instance of SearchBarComponent.java
(..and a SearchBarComponentView.java
and SearchBarComponentView.html
). This simple UI component will call the EditorSearchIndex
, that can access all searchable elements.
interface EditorSearchIndex<T> {
List<HasSearchableElements<T>> getHasSearchableElements();
List<Searchable> getSearchableElements();
}
When a given component has the desired text, the respective onFound
command is executed and the element is highlighted.
A bean that has searchable elements implements this:
interface HasSearchableElements<? extends Searchable> {
BTree<? extends Searchable> getSearchableElements();
boolean isDirty();
}
I think users are more inclined to wait for a result when they are actively acting. So, instead of indexing the UI model when the diagram loads (and many other operations are happening), I think we could index elements when users try to search for some term.
Thus, the getSearchableElements
returns the indexed list when: I) it has an indexed list; and II) the editor is not dirty; otherwise it re-indexes the list.