com.pixelmed.query

## Class QueryTreeBrowser

- java.lang.Object
- - com.pixelmed.query.QueryTreeBrowser

- Direct Known Subclasses:
    DicomCleaner.OurQueryTreeBrowser, DoseUtility.OurQueryTreeBrowser, DownloadOrTransmit.OurQueryTreeBrowser

      public class QueryTreeBrowser
      extends java.lang.Object

  The `QueryTreeBrowser` class implements a Swing graphical user interface to browse the contents of `QueryTreeModel`.

  The browser is rendered as a tree view of the returned query identifier and a one row tabular representation of the contents of any level that the user selects in the tree. Constructors are provided to either add the browser to a frame and creating the tree and table, or to make use of a pair of existing scrolling panes.

  Though a functional browser can be built using this class, to add application-specific behavior to be applied when a user selects from the tree, a sub-class inheriting from this class should be constructed that overrides the `buildTreeSelectionListenerToDoSomethingWithSelectedLevel` method The default implementation is as follows:

              protected TreeSelectionListener buildTreeSelectionListenerToDoSomethingWithSelectedLevel() {
                      return new TreeSelectionListener() {
                              public void valueChanged(TreeSelectionEvent tse) {
                                      TreePath tp = tse.getNewLeadSelectionPath();
                                      if (tp != null) {
                                              Object lastPathComponent = tp.getLastPathComponent();
                                              if (lastPathComponent instanceof QueryTreeRecord) {
                                                      QueryTreeRecord r = (QueryTreeRecord)lastPathComponent;
                                                              System.err.println("TreeSelectionListener.valueChanged: "+r.getUniqueKeys());
                                              }
                                      }
                              }
                      };
              }

  See Also:
    `com.pixelmed.query`, `QueryTreeRecord`, `QueryTreeModel`, `TreePath`, `TreeSelectionListener`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryTreeBrowser(QueryInformationModel q, QueryTreeModel m, java.awt.Container content)` Build and display a graphical user interface view of a database information model.
    `QueryTreeBrowser(QueryInformationModel q, QueryTreeModel m, javax.swing.JFrame frame)` Build and display a graphical user interface view of a database information model.
    `QueryTreeBrowser(QueryInformationModel q, QueryTreeModel m, javax.swing.JScrollPane treeBrowserScrollPane, javax.swing.JScrollPane attributeBrowserScrollPane)` Build and display a graphical user interface view of a database information model.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected javax.swing.event.TreeSelectionListener` | `buildTreeSelectionListenerToDisplayAttributesOfSelectedRecord(javax.swing.JScrollPane attributeBrowserScrollPane)` By default this method populates the tabular attribute browser when an entity is selected in the tree browser.
    `protected javax.swing.event.TreeSelectionListener` | `buildTreeSelectionListenerToDoSomethingWithSelectedLevel()` Override this method to perform application-specific behavior when an entity is selected in the tree browser.
    `QueryTreeRecord[]` | `getSelectionPaths()` Return the records currently selected.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryTreeBrowser

          public QueryTreeBrowser(QueryInformationModel q,
                                  QueryTreeModel m,
                                  javax.swing.JScrollPane treeBrowserScrollPane,
                                  javax.swing.JScrollPane attributeBrowserScrollPane)
                           throws DicomException

      Build and display a graphical user interface view of a database information model.

      Parameters:
        `q` - the query information model
        `m` - the query tree model (i.e. the results returned from an actual query)
        `treeBrowserScrollPane` - the scrolling pane in which the tree view of the query results will be rendered
        `attributeBrowserScrollPane` - the scrolling pane in which the tabular view of the currently selected level will be rendered
      Throws:
        `DicomException` - thrown if the information cannot be extracted

    - #### QueryTreeBrowser

          public QueryTreeBrowser(QueryInformationModel q,
                                  QueryTreeModel m,
                                  java.awt.Container content)
                           throws DicomException

      Build and display a graphical user interface view of a database information model.

      Parameters:
        `q` - the query information model
        `m` - the query tree model (i.e. the results returned from an actual query)
        `content` - content pane will to add scrolling panes containing tree and tabular selection views
      Throws:
        `DicomException` - thrown if the information cannot be extracted

    - #### QueryTreeBrowser

          public QueryTreeBrowser(QueryInformationModel q,
                                  QueryTreeModel m,
                                  javax.swing.JFrame frame)
                           throws DicomException

      Build and display a graphical user interface view of a database information model.

      Parameters:
        `q` - the query information model
        `m` - the query tree model (i.e. the results returned from an actual query)
        `frame` - a frame to whose content pane will be added scrolling panes containing tree and tabular selection views
      Throws:
        `DicomException` - thrown if the information cannot be extracted

  - ### Method Detail

    - #### getSelectionPaths

          public QueryTreeRecord[] getSelectionPaths()

      Return the records currently selected.

      Returns:
        the records currently selected

    - #### buildTreeSelectionListenerToDoSomethingWithSelectedLevel

          protected javax.swing.event.TreeSelectionListener buildTreeSelectionListenerToDoSomethingWithSelectedLevel()

      Override this method to perform application-specific behavior when an entity is selected in the tree browser.

      By default this method dumps the string values of the unique keys to the console for level selection, which is pretty useless.

    - #### buildTreeSelectionListenerToDisplayAttributesOfSelectedRecord

          protected javax.swing.event.TreeSelectionListener buildTreeSelectionListenerToDisplayAttributesOfSelectedRecord(javax.swing.JScrollPane attributeBrowserScrollPane)

      By default this method populates the tabular attribute browser when an entity is selected in the tree browser.

      Override this method to perform application-specific behavior, perhaps if not all attributes in the query identifer for the selected level are to be displayed, or their values are to be rendered specially. The default implementation renders everything as strings.

      Parameters:
        `attributeBrowserScrollPane` - the tabular attribute browser