Package ucar.unidata.idv.ui
Class DataTree
java.lang.Object
ucar.unidata.idv.ui.DataSourceHolder
ucar.unidata.idv.ui.DataTree
This class provides a JTree interface for a set
of
DataChoice
-s and
DataSource
-s.
It is used two ways:
- To show the data choices in the
DataSelector
- To show all of the data sources and data choices when the user is selecting operands for formulas or when they are adding or changing the data choices in a display control
- Version:
- $Revision: 1.50 $Date: 2007/08/21 12:15:45 $
- Author:
- IDV development team
-
Field Summary
Fields inherited from class ucar.unidata.idv.ui.DataSourceHolder
defaultDimension, formulaDataSource, frame, idv, treatFormulaDataSourceSpecial
-
Constructor Summary
ConstructorsConstructorDescriptionDataTree
(IntegratedDataViewer idv, boolean showDataSourceNode, boolean treatFormulaDataSourceSpecial) Create a DataTree with the given idv reference.DataTree
(IntegratedDataViewer idv, List sources, List categories) Create a DataTree with the given idv reference, list ofDataSource
-s and (potentially null) list ofDataCategory
-s If the categories list is non-null then this DataTree will only show data choices that are applicable to the categories.DataTree
(IntegratedDataViewer idv, List sources, List categories, Dimension defaultSize) Create a DataTree with the given idv reference, list ofDataSource
-s, (potentially null) list ofDataCategory
-s and default window size.DataTree
(IntegratedDataViewer idv, List sources, List categories, String initialSelectedFieldName, Dimension defaultSize) Create a DataTree with the given idv reference, list ofDataSource
-s, (potentially null) list ofDataCategory
-s and default window size.DataTree
(IntegratedDataViewer idv, DataSource formulaDataSource) Create a DataTree with the given idv reference and formula data source.DataTree
(IntegratedDataViewer idv, DataSource formulaDataSource, Dimension defaultSize) Create a DataTree with the given idv reference, formula data source and window size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAsAlias
(Object[] pair) The pair contains a dataalias and a alias name Call AliasEditor.addAsAliasvoid
addDataSource
(DataSource dataSource) Add the givenDataSource
and itsDataChoice
-s into the jtree.void
addDisplayControl
(DisplayControl control, DataChoice choice) We have this here so we can display theDisplayControl
-s in the DataTree.void
CLear the search stateprotected void
createSubtree
(CompositeDataChoice choice, DataTreeNode treeNode) Recurse down theCompositeDataChoice
hierarhcy of DataChoice-s, creating the JTree tree.createTreeNode
(String label, Object data) Create aDataTreeNode
with the given label that holds the given data objectcreateTreeNode
(DataTreeNode parent, String label, Object data) Create aDataTreeNode
with the given label that holds the given data object.void
dataSourceChanged
(DataSource source) Something changed about the given data source.void
dispose()
Remove all references to anything we may have.boolean
doSearch
(String searchString, JComponent near) Search the treeGet the main GUI contentsGet all expanded tree pathsprotected String
getName()
Overwrite the base class getName method.getObjectAt
(int x, int y) Find the data object that is contained by the tree node nearest to the given x/y position.getPath
(DefaultMutableTreeNode treeNode) Get the TreePath to the given treeNodeCreate (if needed) and return the JScrollPane around the JTreeFind and return the first DataChoice that is selected.getSelectedDataChoice
(ControlDescriptor descriptor) Find the first selected data choice that the givenControlDescriptor
is applicable to.Get the list of selected data choicesGet the list of selected data choicesgetTree()
Get the JTree we usegetTreeNode
(Object data) Return the tree node that represents the given data object (e.g., data source, data choice)boolean
isValidData
(Object data) Is the given object (either a data source or a data choice) represented in the JTreevoid
openUp()
If the tree has a single path to a DataChoice then open up the tree to that data choice and select it.void
Remove all data sources from this treevoid
removeDataSource
(DataSource dataSource) Remove the specified data source only if it is not the formulaDataSource.protected boolean
removeDataSourceInner
(DataSource dataSource) Remove the specified data source only if it is not the formulaDataSource.void
removeDisplayControl
(DisplayControl control) Remove the tree node that represents the given display controlvoid
removeObject
(Object dataObject) Find theDataTree
node that represents the given data object and remove it from the treevoid
removeTreeNode
(DataTreeNode node) Remove the givenDataTreeNode
from the tree.void
selectChoices
(List choices) Have the JTree select the paths that lead to theDataChoice
-s in the given list.void
selectChoices
(List choices, boolean shouldSet) Have the JTree select the paths that lead to theDataChoice
-s in the given list.void
setDataSource
(DataSource dataSource) This does a removeAllDataSource/addDataSource resulting in a datatree that holds just the given datasourcevoid
setMultipleSelect
(boolean v) Set the selection mode of the JTreevoid
sort()
Turn on sortingMethods inherited from class ucar.unidata.idv.ui.DataSourceHolder
addDisplayControl, dataSourceTimeChanged, displayTemplatesChanged, doClose, doMakeFrame, getButtons, getDataSources, getDerivedIcon, getFrame, getIdv, getLocationOnScreen, setDefaultSize, setFrame, show
-
Constructor Details
-
DataTree
public DataTree(IntegratedDataViewer idv, boolean showDataSourceNode, boolean treatFormulaDataSourceSpecial) Create a DataTree with the given idv reference.- Parameters:
idv
- The idvshowDataSourceNode
- Should this DataTree display the DataSource-s in the treetreatFormulaDataSourceSpecial
- If true we put the Formula data source (which represents the end-user formulas) at the top.
-
DataTree
Create a DataTree with the given idv reference and formula data source.- Parameters:
idv
- The IDVformulaDataSource
- The formula data source that holds the end-user formulas
-
DataTree
Create a DataTree with the given idv reference, formula data source and window size.- Parameters:
idv
- The IDVformulaDataSource
- The formula data source that holds thedefaultSize
- Default size of the window (if non-null)
-
DataTree
Create a DataTree with the given idv reference, list ofDataSource
-s and (potentially null) list ofDataCategory
-s If the categories list is non-null then this DataTree will only show data choices that are applicable to the categories.- Parameters:
idv
- The IDVsources
- List of data sourcescategories
- List of data categories
-
DataTree
Create a DataTree with the given idv reference, list ofDataSource
-s, (potentially null) list ofDataCategory
-s and default window size. If the categories list is non-null then this DataTree will only show data choices that are applicable to the categories.- Parameters:
idv
- The IDVsources
- List of data sourcescategories
- List of data categoriesdefaultSize
- Windwo size (if non-null)
-
DataTree
public DataTree(IntegratedDataViewer idv, List sources, List categories, String initialSelectedFieldName, Dimension defaultSize) Create a DataTree with the given idv reference, list ofDataSource
-s, (potentially null) list ofDataCategory
-s and default window size. If the categories list is non-null then this DataTree will only show data choices that are applicable to the categories.- Parameters:
idv
- The IDVsources
- List of data sourcescategories
- List of data categoriesinitialSelectedFieldName
- The name of the data choice we should selectdefaultSize
- Window size (if non-null)
-
-
Method Details
-
sort
public void sort()Turn on sorting -
getName
Overwrite the base class getName method.- Overrides:
getName
in classDataSourceHolder
- Returns:
- The name of this class to be used in the gui
-
setDataSource
This does a removeAllDataSource/addDataSource resulting in a datatree that holds just the given datasource- Parameters:
dataSource
- The data source to use
-
getContents
Get the main GUI contents- Specified by:
getContents
in classDataSourceHolder
- Returns:
- The GUI
-
getTree
Get the JTree we use- Returns:
- The JTree
-
addAsAlias
The pair contains a dataalias and a alias name Call AliasEditor.addAsAlias- Parameters:
pair
- Holds a DataAlias and a alias name
-
clearSearchState
public void clearSearchState()CLear the search state -
doSearch
Search the tree- Parameters:
searchString
- search fornear
- component to show dialog near- Returns:
- Success
-
selectChoices
Have the JTree select the paths that lead to theDataChoice
-s in the given list.- Parameters:
choices
- List of data choices
-
selectChoices
Have the JTree select the paths that lead to theDataChoice
-s in the given list.- Parameters:
choices
- List of data choicesshouldSet
- Should we set the selection or add to the selection
-
setMultipleSelect
public void setMultipleSelect(boolean v) Set the selection mode of the JTree- Parameters:
v
- JTree is multiple or single select
-
getScroller
Create (if needed) and return the JScrollPane around the JTree- Returns:
- The tree scroller
-
addDisplayControl
We have this here so we can display theDisplayControl
-s in the DataTree. We display them under the tree node that represents the givenDataChoice
- Overrides:
addDisplayControl
in classDataSourceHolder
- Parameters:
control
- The display control to representchoice
- The data choice to show the display control under
-
removeDisplayControl
Remove the tree node that represents the given display control- Overrides:
removeDisplayControl
in classDataSourceHolder
- Parameters:
control
- The control to remove from the tree
-
isValidData
Is the given object (either a data source or a data choice) represented in the JTree- Parameters:
data
- The object to look for a tree node for- Returns:
- Is object represented in tree
-
getTreeNode
Return the tree node that represents the given data object (e.g., data source, data choice)- Parameters:
data
- The object to look for a tree node- Returns:
- The tree node that represents the given object
-
createTreeNode
Create aDataTreeNode
with the given label that holds the given data object- Parameters:
label
- The labeldata
- The data- Returns:
- The new DataTreeNode
-
createTreeNode
Create aDataTreeNode
with the given label that holds the given data object. Add it as a child if the given parent node.- Parameters:
parent
- The parent nodelabel
- The labeldata
- The data- Returns:
- The new DataTreeNode
-
removeTreeNode
Remove the givenDataTreeNode
from the tree. Remove it from the dataToNode mapping. Jump through some hoops to fire the tree structure changed event and maintain the current expanded tree paths.- Parameters:
node
- The node to remove
-
removeObject
Find theDataTree
node that represents the given data object and remove it from the tree- Parameters:
dataObject
- The object whose tree node is to be removed
-
getPath
Get the TreePath to the given treeNode- Parameters:
treeNode
- The node to find the path to- Returns:
- The path
-
getExpandedPaths
Get all expanded tree paths- Returns:
- All expanded paths
-
dispose
public void dispose()Remove all references to anything we may have. We do this because (stupid) Swing seems to keep around lots of different references to thei component and/or it's frame. So when we do a window.dispose () this DataTree does not get gc'ed.- Overrides:
dispose
in classDataSourceHolder
-
removeAllDataSources
public void removeAllDataSources()Remove all data sources from this tree- Overrides:
removeAllDataSources
in classDataSourceHolder
-
removeDataSource
Remove the specified data source only if it is not the formulaDataSource.- Overrides:
removeDataSource
in classDataSourceHolder
- Parameters:
dataSource
- The data source to remove
-
removeDataSourceInner
Remove the specified data source only if it is not the formulaDataSource.- Overrides:
removeDataSourceInner
in classDataSourceHolder
- Parameters:
dataSource
- The data source to remove- Returns:
- Was this removal successful
-
dataSourceChanged
Something changed about the given data source. Simply re-add it.- Overrides:
dataSourceChanged
in classDataSourceHolder
- Parameters:
source
- The data source that changed.
-
addDataSource
Add the givenDataSource
and itsDataChoice
-s into the jtree.- Overrides:
addDataSource
in classDataSourceHolder
- Parameters:
dataSource
- The data source to add
-
createSubtree
Recurse down theCompositeDataChoice
hierarhcy of DataChoice-s, creating the JTree tree.- Parameters:
choice
- The data choice to recurse down ontreeNode
- The tree node which represents the given composite data choice
-
openUp
public void openUp()If the tree has a single path to a DataChoice then open up the tree to that data choice and select it. -
getSelectedDataChoice
Find and return the first DataChoice that is selected.- Returns:
- The first selected data choice
-
getSelectedDataChoice
Find the first selected data choice that the givenControlDescriptor
is applicable to.- Parameters:
descriptor
- The descriptor to check for data choice applicability- Returns:
- Selected DataChoice or null if none found
-
getSelectedDataChoicesRecursive
Get the list of selected data choices- Returns:
- List of selected data choices
-
getSelectedDataChoices
Get the list of selected data choices- Returns:
- List of selected data choices
-
getObjectAt
Find the data object that is contained by the tree node nearest to the given x/y position.- Parameters:
x
- x positiony
- y position- Returns:
- Nearest data object
-