Skip to content

Instantly share code, notes, and snippets.

@karreiro
Last active June 25, 2019 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karreiro/a43c1a3e5cd0d2811ac44f5cc7ccc285 to your computer and use it in GitHub Desktop.
Save karreiro/a43c1a3e5cd0d2811ac44f5cc7ccc285 to your computer and use it in GitHub Desktop.

GDT / DMN - Search feature

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment