|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.pixelmed.database.DatabaseTreeBrowser
public class DatabaseTreeBrowser
The DatabaseTreeBrowser class implements a Swing graphical user interface
to browse the contents of DatabaseInformationModel.
The browser is rendered as a tree view of the entire database and a one row tabular representation of the contents of any entity (record) 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.
Only selection of single nodes is permitted by default.
Though a functional browser can be built using this class, to add application-specific behavior
to be applied when a user selects an instance of an entity from the tree, a sub-class inheriting
from this class should be constructed that overrides the
buildTreeSelectionListenerToDoSomethingWithSelectedFiles
method. The default implementation is as follows:
protected TreeSelectionListener buildTreeSelectionListenerToDoSomethingWithSelectedFiles() {
return new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent tse) {
TreePath tp = tse.getNewLeadSelectionPath();
if (tp != null) {
Object lastPathComponent = tp.getLastPathComponent();
if (lastPathComponent instanceof DatabaseTreeRecord) {
DatabaseTreeRecord r = (DatabaseTreeRecord)lastPathComponent;
// now recurse throughout whole sub tree, adding to a vector of file names for all instances ...
names = new Vector();
recurseThroughChildrenGatheringFileNames(r,names);
}
}
doSomethingWithSelectedFiles(names);
}
}
};
}
Note that this allows you to take the simpler approach of overriding the protected method
doSomethingWithSelectedFiles, the default
implementation of which is just to print the file name.
com.pixelmed.database,
DatabaseTreeRecord,
DatabaseInformationModel,
TreePath,
TreeSelectionListener| Constructor Summary | |
|---|---|
DatabaseTreeBrowser(DatabaseInformationModel d,
Container content)
Build and display a graphical user interface view of a database information model. |
|
DatabaseTreeBrowser(DatabaseInformationModel d,
JFrame frame)
Build and display a graphical user interface view of a database information model. |
|
DatabaseTreeBrowser(DatabaseInformationModel d,
JScrollPane treeBrowserScrollPane,
JScrollPane attributeBrowserScrollPane)
Build and display a graphical user interface view of a database information model. |
|
| Method Summary | |
|---|---|
protected MouseListener |
buildMouseListenerToDetectDoubleClickEvents()
|
protected TreeSelectionListener |
buildTreeSelectionListenerToDisplayAttributesOfSelectedRecord(JScrollPane attributeBrowserScrollPane)
By default this method populates the tabular attribute browser when an entity is selected in the tree browser. |
protected TreeSelectionListener |
buildTreeSelectionListenerToDoSomethingWithSelectedFiles()
Override this method to perform application-specific behavior when an entity is selected in the tree browser. |
protected void |
doSomethingMoreWithWhateverWasSelected()
|
protected void |
doSomethingWithSelectedFiles(Vector paths)
Will be called when a selection is made and doSomethingWithSelection() returns false and not otherwise |
protected boolean |
doSomethingWithSelection(DatabaseTreeRecord selection)
Will be called when a selection is made |
static void |
recurseThroughChildrenGatheringFileNames(DatabaseTreeRecord r,
Vector names)
Recursively process the specified DatabaseTreeRecord and all its children finding file paths at the instance level. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DatabaseTreeBrowser(DatabaseInformationModel d,
JScrollPane treeBrowserScrollPane,
JScrollPane attributeBrowserScrollPane)
throws DicomException
Build and display a graphical user interface view of a database information model.
d - the instance of the database (information model)treeBrowserScrollPane - the scrolling pane in which the tree view of the entire model (database) will be renderedattributeBrowserScrollPane - the scrolling pane in which the tabular view of the currently selected entity (record) will be rendered
DicomException - thrown if the information cannot be extracted
public DatabaseTreeBrowser(DatabaseInformationModel d,
JFrame frame)
throws DicomException
Build and display a graphical user interface view of a database information model.
d - the instance of the database (information model)frame - a frame to whose content pane will be added scrolling panes containing tree and tabular selection views
DicomException - thrown if the information cannot be extracted
public DatabaseTreeBrowser(DatabaseInformationModel d,
Container content)
throws DicomException
Build and display a graphical user interface view of a database information model.
d - the instance of the database (information model)content - a container to which will be added scrolling panes containing tree and tabular selection views
DicomException - thrown if the information cannot be extracted| Method Detail |
|---|
protected TreeSelectionListener buildTreeSelectionListenerToDoSomethingWithSelectedFiles()
Override this method to perform application-specific behavior when an entity is selected in the tree browser.
By default this method builds a Vector of all the file names (paths) of
the selected record and the subtree below it, then calls doSomethingWithSelectedFiles.
public static void recurseThroughChildrenGatheringFileNames(DatabaseTreeRecord r,
Vector names)
Recursively process the specified DatabaseTreeRecord and all its children finding file paths at the instance level.
A static helper method, that is public so that it can be used in subclasses that override
buildTreeSelectionListenerToDoSomethingWithSelectedFiles.
r - the current DatabaseTreeRecord to processnames - the file names (paths) to add toprotected TreeSelectionListener buildTreeSelectionListenerToDisplayAttributesOfSelectedRecord(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 database for the selected entity are to be displayed, or their values are to be rendered specially. The default implementation renders everything as strings except those local database administrative attributes normally excluded.
attributeBrowserScrollPane - the tabular attribute browserprotected MouseListener buildMouseListenerToDetectDoubleClickEvents()
protected boolean doSomethingWithSelection(DatabaseTreeRecord selection)
selection - return true if did something and hence should do no moreprotected void doSomethingWithSelectedFiles(Vector paths)
doSomethingWithSelection() returns false and not otherwise
paths - protected void doSomethingMoreWithWhateverWasSelected()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||