ucar.unidata.idv.ui
Class DataSourceHolder

java.lang.Object
  extended by ucar.unidata.idv.ui.DataSourceHolder
Direct Known Subclasses:
DataSelector, DataTree

public abstract class DataSourceHolder
extends Object

A base class for those components that show a set of DataSources. For now these are the DataTree and DataSelector. This class provides basic facilities to manage the list of data sources, create the window, etc.

Author:
IDV development team

Field Summary
protected  Dimension defaultDimension
          The size of the window
protected  DataSource formulaDataSource
          The formula data source, i.e., the one that holds the end-user formulas
protected  IdvWindow frame
          The window this gui is in
protected  IntegratedDataViewer idv
          The IDV
protected  boolean treatFormulaDataSourceSpecial
          If true then we don't remove the formula data source
 
Constructor Summary
DataSourceHolder(IntegratedDataViewer idv, DataSource formulaDataSource, Dimension defaultDimension)
          Create this object
 
Method Summary
 void addDataSource(DataSource dataSource)
          Add the given DataSource
 void addDisplayControl(DisplayControl control)
          Adds the given DisplayControl
 void addDisplayControl(DisplayControl control, DataChoice choice)
          A no-op that can be overrode by a derived class
 void dataSourceChanged(DataSource source)
          Be notified that the given DataSource has changed.
 void dataSourceTimeChanged(DataSource source)
          Be notified that the tim selection on the given DataSource has changed.
 void displayTemplatesChanged()
          A hook to notify that the list of favorites has changed
 void dispose()
          Remove all references to anything we may have.
 void doClose()
          Remove this holder from the IDV and dispose of the window
 IdvWindow doMakeFrame()
          Make the IdvWindow.
 JComponent getButtons()
          Hook for derived classes to provide their own dialog buttons
abstract  JComponent getContents()
          Needs to be overrode by derived classes to return the GUI
 List getDataSources()
          Return the list of DataSources
static ImageIcon getDerivedIcon()
          Utility method to create, if needed, and return the ImageIcon to be used to show DerivedDataChoices
 IdvWindow getFrame()
          Get our window.
 IntegratedDataViewer getIdv()
          Return the IDV member.
 Point getLocationOnScreen()
          Utility to determine the location on the screen.
protected  String getName()
          Get the name of this data source holder.
 void removeAllDataSources()
          Remove all data sources
 void removeDataSource(DataSource dataSource)
          Remove the given DataSource 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 given DisplayControl
 void setDefaultSize(Dimension d)
          Set the default window size to be used by this component
 void setFrame(IdvWindow f)
          Set our window
 void show()
          Show the window if it is non-null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

idv

protected IntegratedDataViewer idv
The IDV


frame

protected IdvWindow frame
The window this gui is in


formulaDataSource

protected DataSource formulaDataSource
The formula data source, i.e., the one that holds the end-user formulas


treatFormulaDataSourceSpecial

protected boolean treatFormulaDataSourceSpecial
If true then we don't remove the formula data source


defaultDimension

protected Dimension defaultDimension
The size of the window

Constructor Detail

DataSourceHolder

public DataSourceHolder(IntegratedDataViewer idv,
                        DataSource formulaDataSource,
                        Dimension defaultDimension)
Create this object

Parameters:
idv - The IDV
formulaDataSource - The singleton formula data source. We treat this special.
defaultDimension - How big is the window.
Method Detail

doMakeFrame

public IdvWindow doMakeFrame()
Make the IdvWindow. Add event handlers for adding new data sources and closing the window.

Returns:
The window to put the gui in

getIdv

public IntegratedDataViewer getIdv()
Return the IDV member.

Returns:
The IDV

getName

protected String getName()
Get the name of this data source holder. Can be overrode by derived classes to provide their own name.

Returns:
The name

doClose

public void doClose()
Remove this holder from the IDV and dispose of the window


show

public void show()
Show the window if it is non-null


setFrame

public void setFrame(IdvWindow f)
Set our window

Parameters:
f - The window

getFrame

public IdvWindow getFrame()
Get our window.

Returns:
The window

getContents

public abstract JComponent getContents()
Needs to be overrode by derived classes to return the GUI

Returns:
The GUI

getLocationOnScreen

public Point getLocationOnScreen()
Utility to determine the location on the screen.

Returns:
Screen location

getButtons

public JComponent getButtons()
Hook for derived classes to provide their own dialog buttons

Returns:
This returns null but is meant to return dialog buttons

getDataSources

public List getDataSources()
Return the list of DataSources

Returns:
List of data sources

getDerivedIcon

public static ImageIcon getDerivedIcon()
Utility method to create, if needed, and return the ImageIcon to be used to show DerivedDataChoices

Returns:
The icon for derived data choices

setDefaultSize

public void setDefaultSize(Dimension d)
Set the default window size to be used by this component

Parameters:
d - The default size

addDisplayControl

public void addDisplayControl(DisplayControl control,
                              DataChoice choice)
A no-op that can be overrode by a derived class

Parameters:
control - The new display control
choice - The data choice

removeDisplayControl

public void removeDisplayControl(DisplayControl control)
Remove the given DisplayControl

Parameters:
control - The removed display control

addDisplayControl

public void addDisplayControl(DisplayControl control)
Adds the given DisplayControl

Parameters:
control - The new display control

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 DataSourceHolder does not get gc'ed.


removeAllDataSources

public void removeAllDataSources()
Remove all data sources


addDataSource

public void addDataSource(DataSource dataSource)
Add the given DataSource

Parameters:
dataSource - The new data source

removeDataSource

public void removeDataSource(DataSource dataSource)
Remove the given DataSource only if it is not the formulaDataSource.

Parameters:
dataSource - The data source to be removed

removeDataSourceInner

protected boolean removeDataSourceInner(DataSource dataSource)
Remove the specified data source only if it is not the formulaDataSource.

Parameters:
dataSource - The data source to be removed
Returns:
Was this actually removed

dataSourceChanged

public void dataSourceChanged(DataSource source)
Be notified that the given DataSource has changed.

Parameters:
source - The data source that changed

dataSourceTimeChanged

public void dataSourceTimeChanged(DataSource source)
Be notified that the tim selection on the given DataSource has changed.

Parameters:
source - The data source whose time has changed

displayTemplatesChanged

public void displayTemplatesChanged()
A hook to notify that the list of favorites has changed