generalDatabase.lookupTables
Class LookUpTables

java.lang.Object
  extended by generalDatabase.lookupTables.LookUpTables

public class LookUpTables
extends java.lang.Object

Singleton class for managing a common lookup table for many PAMGUARD modules (following from Logger format)

Author:
Doug Gillespie

Field Summary
private  PamTableItem borderColourItem
           
private  java.sql.Connection checkedTableConnection
           
static int CODE_LENGTH
          Maximum length of a lookup code
private  PamTableItem codeItem
           
private  PamTableItem fillcolourItem
           
private  EmptyTableDefinition lutTableDef
           
private  PamTableItem orderItem
           
private  PamTableItem selectableItem
           
private static LookUpTables singleInstance
           
private  PamTableItem symbolItem
           
static int TEXT_LENGTH
          Maximum length of a lookup item text
private  PamTableItem textItem
           
static int TOPIC_LENGTH
          Maximum length of topic text for a lookup collection
private  PamTableItem topicItem
           
 
Constructor Summary
private LookUpTables()
           
 
Method Summary
 boolean checkTable()
          Check the database module is present and that the lookup table exists.
 LookupList createLookupList(PamCursor resultSet, java.lang.String topic)
           
private  PamCursor createPamCursor(java.lang.String topic)
           
 LookupList editLookupTopic(java.awt.Window window, java.lang.String topic)
          Query all LUT items with the given topic name.
private  java.awt.Color getColour(java.lang.String colString)
          Interpret colour strings from the lookup table
private  java.lang.String getColourString(java.awt.Color colour)
          Convert a colour into a string that can be written to the table
 LookupList getLookupList(java.lang.String topic)
           
static LookUpTables getLookUpTables()
          Access the LookUpTables class
private  boolean reWriteList(LookupList newList, PamCursor resultSet)
          write back to database
private  void setTableData(PamCursor resultSet, LookupItem lookupItem)
          Set data in the result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleInstance

private static LookUpTables singleInstance

lutTableDef

private EmptyTableDefinition lutTableDef

TOPIC_LENGTH

public static final int TOPIC_LENGTH
Maximum length of topic text for a lookup collection

See Also:
Constant Field Values

CODE_LENGTH

public static final int CODE_LENGTH
Maximum length of a lookup code

See Also:
Constant Field Values

TEXT_LENGTH

public static final int TEXT_LENGTH
Maximum length of a lookup item text

See Also:
Constant Field Values

topicItem

private PamTableItem topicItem

codeItem

private PamTableItem codeItem

textItem

private PamTableItem textItem

selectableItem

private PamTableItem selectableItem

borderColourItem

private PamTableItem borderColourItem

fillcolourItem

private PamTableItem fillcolourItem

orderItem

private PamTableItem orderItem

symbolItem

private PamTableItem symbolItem

checkedTableConnection

private java.sql.Connection checkedTableConnection
Constructor Detail

LookUpTables

private LookUpTables()
Method Detail

getLookUpTables

public static LookUpTables getLookUpTables()
Access the LookUpTables class

Returns:
reference to a single instance of the Look up table manager.

checkTable

public boolean checkTable()
Check the database module is present and that the lookup table exists.

Returns:
true if the table exists and is correctly formatted with all the right columns.

createLookupList

public LookupList createLookupList(PamCursor resultSet,
                                   java.lang.String topic)

reWriteList

private boolean reWriteList(LookupList newList,
                            PamCursor resultSet)
write back to database

Parameters:
newList -
resultSet -
Returns:

setTableData

private void setTableData(PamCursor resultSet,
                          LookupItem lookupItem)
Set data in the result set. It's slightly easier for this to be done by copying the data back into the table items since they are accessible by named objects, these then get copied in the correct order into the PamCursor.

they could be copied straight into the cursor, but this would have to be done in the exact right order.

Parameters:
resultSet - Pamguard cursor object
lookupItem - lookup item

getColour

private java.awt.Color getColour(java.lang.String colString)
Interpret colour strings from the lookup table

Parameters:
deblankedStringValue -
Returns:
a color, or null if the string cannot be interpreted.

getColourString

private java.lang.String getColourString(java.awt.Color colour)
Convert a colour into a string that can be written to the table

Parameters:
colour - Colour
Returns:
String representation in the format RGB(%d,%d,%d).

editLookupTopic

public LookupList editLookupTopic(java.awt.Window window,
                                  java.lang.String topic)
Query all LUT items with the given topic name. display these in a table / list (which might be empty) and provide facilities for the user to add to and remove items from this list

Parameters:
window -
topic - LUT topic
Returns:
a new list, or null if no new list created.

getLookupList

public LookupList getLookupList(java.lang.String topic)

createPamCursor

private PamCursor createPamCursor(java.lang.String topic)