PamView
Class SourcePanel

java.lang.Object
  extended by PamView.SourcePanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener
Direct Known Subclasses:
GroupedSourcePanel, PlaybackSourcePanel

public class SourcePanel
extends java.lang.Object
implements java.awt.event.ActionListener

Standard panel for dialogs that shows a list of available data sources and, optionally a list of data channels.

This is for general use within other dialog panels.

Author:
Doug Gillespie

Nested Class Summary
(package private)  class SourcePanel.SelectionListener
           
 
Field Summary
protected  java.lang.String borderTitle
           
protected  javax.swing.JCheckBox[] channelBoxes
           
private  int currentNShown
           
protected  java.util.ArrayList<PamDataBlock> excludedBlocks
           
protected  boolean hasChannels
           
protected  boolean includeSubClasses
           
private  int localisationRequirements
          Flags to specify the minimum localisation data requirements from a data block.
protected  java.awt.Window ownerWindow
           
protected  javax.swing.JPanel panel
           
protected  javax.swing.JComboBox sourceList
           
protected  java.lang.Class sourceType
           
private  java.util.ArrayList<SourcePanelMonitor> spMonitors
           
 
Constructor Summary
SourcePanel(java.awt.Window ownerWindow, java.lang.Class sourceType, boolean hasChannels, boolean includeSubClasses)
          Construct a panel without a border
SourcePanel(java.awt.Window ownerWindow, java.lang.String borderTitle, java.lang.Class sourceType, boolean hasChannels, boolean includeSubClasses)
          Construct a panel with a titles border
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          action listener to update channel list when a a different source is selected
 void addSelectionListener(java.awt.event.ActionListener listener)
          Add a listener to the data source drop down list
 void addSourcePanelMonitor(SourcePanelMonitor gspm)
           
 void clearExcludeList()
          Clear the list of excluded data blocks.
protected  void createPanel()
           
 void excludeDataBlock(PamDataBlock block, boolean exclude)
          Exclude specific data blocks from the source list.
 javax.swing.JCheckBox[] getChannelBoxes()
           
 int getChannelList()
          Get a list of selected channels
 int getLocalisationRequirements()
           
 javax.swing.JPanel getPanel()
          Get a reference to the JPanel containing the controls
 PamDataBlock getSource()
          return the selected data source
 int getSourceCount()
          Get the number of items in the list.
 int getSourceIndex()
          Get the currently selected source index
 java.lang.Class getSourceType()
          get the data source type for this SourcePanel
private  void notifySourcePanelMonitors()
           
 void removeSourcePanelMonitor(SourcePanelMonitor gspm)
           
protected  void rePackOwner(int channelsMap)
          Repack the owner window if the number of channels has changed
protected  void selectionChanged(int channel)
           
 void setChannelList(int channelList)
          Set the current channel selection
 void setEnabled(boolean enabled)
           
 void setLocalisationRequirements(int localisationRequirements)
           
 void setSource(PamDataBlock sourceBlock)
          Set the current data source by block reference
 boolean setSource(java.lang.String sourceName)
          Set the current data source using the data source name
 boolean setSourceList()
          Fill the list of available data sources, taking into account the list of excluded sources
 boolean setSourceList(boolean replaceChosen)
           
 void setSourceType(java.lang.Class sourceType)
          Set the source type for this SourcePanel
protected  void showChannels()
           
protected  void sourceChanged()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

panel

protected javax.swing.JPanel panel

sourceType

protected java.lang.Class sourceType

hasChannels

protected boolean hasChannels

borderTitle

protected java.lang.String borderTitle

includeSubClasses

protected boolean includeSubClasses

sourceList

protected javax.swing.JComboBox sourceList

channelBoxes

protected javax.swing.JCheckBox[] channelBoxes

ownerWindow

protected java.awt.Window ownerWindow

localisationRequirements

private int localisationRequirements
Flags to specify the minimum localisation data requirements from a data block. N.B. Just because a data block says it data MAY have particular localisation information, that is no guarantee that those information are there within individual data units.


excludedBlocks

protected java.util.ArrayList<PamDataBlock> excludedBlocks

spMonitors

private java.util.ArrayList<SourcePanelMonitor> spMonitors

currentNShown

private int currentNShown
Constructor Detail

SourcePanel

public SourcePanel(java.awt.Window ownerWindow,
                   java.lang.String borderTitle,
                   java.lang.Class sourceType,
                   boolean hasChannels,
                   boolean includeSubClasses)
Construct a panel with a titles border

Parameters:
borderTitle - Title to go in border
sourceType - Data Source type
hasChannels - Include a set of checkboxes to list available channels
includeSubClasses - inlcude all subclasses of sourceType in the list.

SourcePanel

public SourcePanel(java.awt.Window ownerWindow,
                   java.lang.Class sourceType,
                   boolean hasChannels,
                   boolean includeSubClasses)
Construct a panel without a border

Parameters:
ownerWindow - Parent window
sourceType - Data Source type
hasChannels - Include a set of checkboxes to list available channels
include - subclasses of the sourceType
Method Detail

setEnabled

public void setEnabled(boolean enabled)

addSelectionListener

public void addSelectionListener(java.awt.event.ActionListener listener)
Add a listener to the data source drop down list

Parameters:
listener - listener

selectionChanged

protected void selectionChanged(int channel)

createPanel

protected void createPanel()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
action listener to update channel list when a a different source is selected

Specified by:
actionPerformed in interface java.awt.event.ActionListener

sourceChanged

protected void sourceChanged()

showChannels

protected void showChannels()

rePackOwner

protected void rePackOwner(int channelsMap)
Repack the owner window if the number of channels has changed

Parameters:
channelsMap - bitmap of used channels.

setSource

public boolean setSource(java.lang.String sourceName)
Set the current data source using the data source name

Parameters:
sourceName -
Returns:
true if OK

setSource

public void setSource(PamDataBlock sourceBlock)
Set the current data source by block reference

Parameters:
sourceBlock -

setSourceList

public boolean setSourceList()
Fill the list of available data sources, taking into account the list of excluded sources

Returns:
sets a list of available sources. Returns false if no sources are available.

setSourceList

public boolean setSourceList(boolean replaceChosen)

getSource

public PamDataBlock getSource()
return the selected data source

Returns:
source data block

getChannelList

public int getChannelList()
Get a list of selected channels

Returns:
bitmap of selected channels

setChannelList

public void setChannelList(int channelList)
Set the current channel selection

Parameters:
channelList - bitmap of currently selected channels

getSourceType

public java.lang.Class getSourceType()
get the data source type for this SourcePanel

Returns:
data type of a data source

setSourceType

public void setSourceType(java.lang.Class sourceType)
Set the source type for this SourcePanel

Parameters:
sourceType -

getSourceIndex

public int getSourceIndex()
Get the currently selected source index

Returns:
source index within the source list

getPanel

public javax.swing.JPanel getPanel()
Get a reference to the JPanel containing the controls

Returns:
JPanel container

excludeDataBlock

public void excludeDataBlock(PamDataBlock block,
                             boolean exclude)
Exclude specific data blocks from the source list. e.g. a process would normally not be able to use it's own output data block as an input source and should therefore exclude it from the list.

Parameters:
block - PamDataBlock to exlcude
exclude - true - excluse; false - allow

clearExcludeList

public void clearExcludeList()
Clear the list of excluded data blocks.


getChannelBoxes

public javax.swing.JCheckBox[] getChannelBoxes()

getLocalisationRequirements

public int getLocalisationRequirements()

setLocalisationRequirements

public void setLocalisationRequirements(int localisationRequirements)

getSourceCount

public int getSourceCount()
Get the number of items in the list.

Returns:
number of sources of this type of data

addSourcePanelMonitor

public void addSourcePanelMonitor(SourcePanelMonitor gspm)

removeSourcePanelMonitor

public void removeSourcePanelMonitor(SourcePanelMonitor gspm)

notifySourcePanelMonitors

private void notifySourcePanelMonitors()