edu.iris.dmc.pdcc.gui
Class PdccObject

java.lang.Object
  extended byjavax.swing.tree.DefaultMutableTreeNode
      extended byedu.iris.dmc.pdcc.gui.PdccObject
All Implemented Interfaces:
java.lang.Cloneable, edu.iris.dmc.isis.Displayable, edu.iris.dmc.isis.Editable, edu.iris.dmc.isis.Listable, javax.swing.tree.MutableTreeNode, edu.iris.dmc.isis.ObjectController, java.io.Serializable, javax.swing.tree.TreeNode
Direct Known Subclasses:
PdccBlocketteObject, PdccTreeNodeObject

public abstract class PdccObject
extends javax.swing.tree.DefaultMutableTreeNode
implements edu.iris.dmc.isis.Editable, edu.iris.dmc.isis.Displayable, edu.iris.dmc.isis.ObjectController

Basic data object in PDCC that is represented in the GUI.

Version:
11/16/2004
Author:
Robert Casey, IRIS DMC
See Also:
Serialized Form

Field Summary
protected  int[] allowedChildTypes
           
protected  ObjectContainer boundContainer
           
protected  java.lang.Object boundObject
           
protected  javax.swing.tree.DefaultTreeModel defaultTreeModel
           
protected  int insertAt
           
protected  java.lang.String originalString
           
protected  javax.swing.tree.MutableTreeNode ourParent
           
protected  int uniqueId
           
protected  boolean userGeneratedObject
           
protected  java.lang.String validatedString
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Fields inherited from interface edu.iris.dmc.isis.Listable
DEFAULT_ICON
 
Constructor Summary
PdccObject(java.lang.Object dataObject)
          Create a new PdccObject with attached object bound to it.
 
Method Summary
 boolean canHaveChild(int childType)
          can this object have a child of the indicated type?
protected abstract  edu.iris.dmc.isis.ObjectController constructController()
           
protected abstract  edu.iris.dmc.isis.EditPanel constructEditPanel()
           
abstract  void deleteGroupRow(int rowNum, int startField)
          An editing function that allows deletion of an existing row in a repeat group.
 java.lang.Object getBoundObject()
          get the bound data object
abstract  java.util.Vector getChildren()
          return a Vector of child objects associated with this object
 javax.swing.tree.MutableTreeNode getContainer()
          returns a reference to ourselves, since we are a MutableTreeNode inheritor.
 edu.iris.dmc.isis.ObjectController getController()
          Editable interface implementation
 int getDictionaryListCount(int fieldNum, int fieldIndex)
          Return the number of dictionary list entries for this fieldNum and fieldIndex entry.
abstract  PdccObject getDictionaryObject(int fieldNum)
          return the PdccObject representing the dictionary referenced by this object field and repeat group offset.
abstract  PdccObject getDictionaryObject(int fieldNum, int fieldIndex)
          return the PdccObject representing the dictionary referenced by this object field and repeat group field index
abstract  int getDictionaryReferenceType(int fieldNum)
          return the type number of the referenced dictionary object for the indicated field number.
abstract  java.lang.String getDictionaryReferenceVal()
          return the dictionary reference index value of this object, provided that it is a dictionary object...return 0 if we are not a dictionary object or we do not have a reference value.
abstract  java.util.Vector getDictionaryVector(int fieldNum, int fieldIndex)
          return a vector of PdccObjects representing the dictionary objects referenced by this object's List-type field and repeat group field index
 javax.swing.JPanel getDisplayPanel()
          Implements Displayable interface.
 edu.iris.dmc.isis.EditPanel getEditPanel()
          Editable interface implementation
abstract  java.lang.String getFieldLength(int fieldNum)
          return a string representation of the length of the indicated field number, which is either a single integer, or two integers separated by a hyphen, which suggests a min and max length.
abstract  java.lang.String getFieldName(int fieldNum)
          return the field name string from the indicated field number in the bound data object.
abstract  java.lang.String getFieldType(int fieldNum)
          return a string representing the data type of the indicated field number of the bound data object.
abstract  java.lang.String getFieldValue(int fieldNum)
          return a String representation of the value contained in the indicated field number of the bound data object.
abstract  java.lang.String getFieldValue(int fieldNum, int fieldIndex)
          in the case of multiple values being present in a given field, return a string representation of the value at the specified index.
abstract  int getId()
          return a unique ID number for this object, perhaps identical to the unique ID of the bound data object.
abstract  java.lang.String getName()
          return the name of the type of the bound data object
abstract  int getNumFields()
          return an integer indicating the number of fields in the bound data object
abstract  int getNumFieldValues(int fieldNum)
          get the number of values available for this field.
 ObjectContainer getObjectContainer()
          get the registered object container
 java.lang.String getOriginalString()
          return the last original field value before the change made by validate()
 javax.swing.tree.MutableTreeNode getParentNode()
          Get the tree node that is our parent in the JTree.
abstract  java.lang.String getRepeatGroupName(int fieldNum)
          for the indicated field, which should be a repeating field, return the appropriate label representing the entire repeat group.
abstract  int getRepeatGroupSize(int fieldNum)
          get the number of fields in this repeat group, starting at the indicated field number...this represents the 'width' size of the group, or number of columns.
 int getSortField()
          return an integer representing the field number whose value can be used in a sorting routine based on the provided object type number.
static int getSortField(int type)
          Static implementation.
abstract  int getType()
          return an integer representing the 'type' of the bound data object
 java.lang.String getValidatedString()
          return the last formatted string generated by validate(), or return null
 void handleObject(java.lang.Object o)
          ObjectController interface implementation.
abstract  void insertGroupRow(int rowNum, int startField)
          An editing function that allows insertion of a new row to a repeat group.
abstract  boolean isDictionaryField(int fieldNum)
          return true if this field references a dictionary object (referencing field)
abstract  boolean isDictionaryReference(int fieldNum)
          return true if this field is the reference number field of a dictionary blockette (referenced field)
abstract  boolean isRepeatingField(int fieldNum)
          return true if this field is part of a repeat group ...
 boolean isUserGenerated()
          ask if this is an object generated by the user through the GUI, and is not source data from a file.
 javax.swing.ImageIcon listIcon()
          Implements Displayable->Listable.
 java.lang.String listString()
          Implements Displayable->Listable.
abstract  int numberOfChildren()
          return the number of child objects associated with this object
 void refreshTreeModel()
          send a notification to the tree model that the node represented by this object is in need of a refresh on the display
 void registerDefaultTreeModel(javax.swing.tree.DefaultTreeModel dtm)
          register the tree node data model
 void registerObjectContainer(java.lang.Object container)
          register an object container with this object for reference lookups NOTE: not to be confused with getContainer, which is a MutableTreeNode implementation.
 void releaseDisplayPanel()
          may be called to release memory for a display/edit panel created by the call to getDisplayPanel().
protected abstract  void releaseEditPanel()
           
 void removeBoundObject()
          remove references to the bound object both in this instance and the bound object container...used as a precursor to permanently deleting this node from the JTree.
 java.lang.String resolveDictionaryLookup(int fieldNum)
          Return the string value at the referenced dictionary field.
 java.lang.String resolveDictionaryLookup(int fieldNum, int fieldIndex)
          Return the string value at the referenced dictionary field and repeat group offset (fieldIndex).
 java.lang.String resolveDictionaryLookup(int fieldNum, int fieldIndex, int listIndex)
          Return the string value at the referenced dictionary field and repeat group offset (fieldIndex) and list index for List type field.
abstract  void restoreOriginal(java.lang.Object restoreObj, int startField, int endField)
          restore the original values from restoreObj's start to end fields to regress edit changes
 void setId(int id)
          sets the unique Id value for this object, perhaps specific to the type of data object bound to us.
 void setInsertAt(int index)
          set the index where we want the tree insertion to occur
 void setParentNode(javax.swing.tree.MutableTreeNode parentNode)
          Set the parentNode as our parent in the JTree.
 void setUserGenerated(boolean flag)
          flag true if this is an object generated by the user through the GUI, and is not source data from a file.
 java.lang.String toString()
          return string representation of this object, perhaps as relates to the bound data object.
abstract  void updateDictionaryLookup(int fieldNum, PdccObject newDictionary)
          update this object with a new dictionary reference based on the lookup value at the indicated fieldnum.
 int validate(java.lang.String value, int fieldNum)
          validate the string at the indicated field
abstract  int validate(java.lang.String value, int fieldNum, int fieldIndex)
          Validate the offered string value against the field specification of the given field number and fieldIndex.
abstract  int validate(java.lang.String value, int fieldNum, int fieldIndex, int listIndex)
          expanded version of validate that accomodiates list fields, which are sub-groups within a repeat group.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

uniqueId

protected int uniqueId

boundObject

protected java.lang.Object boundObject

ourParent

protected javax.swing.tree.MutableTreeNode ourParent

boundContainer

protected ObjectContainer boundContainer

validatedString

protected java.lang.String validatedString

originalString

protected java.lang.String originalString

allowedChildTypes

protected int[] allowedChildTypes

insertAt

protected int insertAt

defaultTreeModel

protected javax.swing.tree.DefaultTreeModel defaultTreeModel

userGeneratedObject

protected boolean userGeneratedObject
Constructor Detail

PdccObject

public PdccObject(java.lang.Object dataObject)
Create a new PdccObject with attached object bound to it.

Parameters:
dataObject - data object to be bound to us.
Method Detail

constructEditPanel

protected abstract edu.iris.dmc.isis.EditPanel constructEditPanel()

releaseEditPanel

protected abstract void releaseEditPanel()

constructController

protected abstract edu.iris.dmc.isis.ObjectController constructController()

getId

public abstract int getId()
return a unique ID number for this object, perhaps identical to the unique ID of the bound data object.


getType

public abstract int getType()
return an integer representing the 'type' of the bound data object


getName

public abstract java.lang.String getName()
                                  throws java.lang.Exception
return the name of the type of the bound data object

Throws:
java.lang.Exception

getNumFields

public abstract int getNumFields()
                          throws java.lang.Exception
return an integer indicating the number of fields in the bound data object

Throws:
java.lang.Exception

getFieldName

public abstract java.lang.String getFieldName(int fieldNum)
                                       throws java.lang.Exception
return the field name string from the indicated field number in the bound data object.

Throws:
java.lang.Exception

getFieldValue

public abstract java.lang.String getFieldValue(int fieldNum)
return a String representation of the value contained in the indicated field number of the bound data object.


getFieldValue

public abstract java.lang.String getFieldValue(int fieldNum,
                                               int fieldIndex)
in the case of multiple values being present in a given field, return a string representation of the value at the specified index.


getFieldType

public abstract java.lang.String getFieldType(int fieldNum)
                                       throws java.lang.Exception
return a string representing the data type of the indicated field number of the bound data object.

Throws:
java.lang.Exception

getFieldLength

public abstract java.lang.String getFieldLength(int fieldNum)
                                         throws java.lang.Exception
return a string representation of the length of the indicated field number, which is either a single integer, or two integers separated by a hyphen, which suggests a min and max length.

Throws:
java.lang.Exception

isDictionaryField

public abstract boolean isDictionaryField(int fieldNum)
return true if this field references a dictionary object (referencing field)


isDictionaryReference

public abstract boolean isDictionaryReference(int fieldNum)
return true if this field is the reference number field of a dictionary blockette (referenced field)


getDictionaryReferenceType

public abstract int getDictionaryReferenceType(int fieldNum)
return the type number of the referenced dictionary object for the indicated field number.


getDictionaryObject

public abstract PdccObject getDictionaryObject(int fieldNum)
                                        throws java.lang.Exception
return the PdccObject representing the dictionary referenced by this object field and repeat group offset.

Throws:
java.lang.Exception

getDictionaryObject

public abstract PdccObject getDictionaryObject(int fieldNum,
                                               int fieldIndex)
                                        throws java.lang.Exception
return the PdccObject representing the dictionary referenced by this object field and repeat group field index

Throws:
java.lang.Exception

getDictionaryVector

public abstract java.util.Vector getDictionaryVector(int fieldNum,
                                                     int fieldIndex)
                                              throws java.lang.Exception
return a vector of PdccObjects representing the dictionary objects referenced by this object's List-type field and repeat group field index

Throws:
java.lang.Exception

getDictionaryReferenceVal

public abstract java.lang.String getDictionaryReferenceVal()
return the dictionary reference index value of this object, provided that it is a dictionary object...return 0 if we are not a dictionary object or we do not have a reference value.


updateDictionaryLookup

public abstract void updateDictionaryLookup(int fieldNum,
                                            PdccObject newDictionary)
update this object with a new dictionary reference based on the lookup value at the indicated fieldnum.


isRepeatingField

public abstract boolean isRepeatingField(int fieldNum)
                                  throws java.lang.Exception
return true if this field is part of a repeat group ... it does not mean that the field contains any values, only that it might contain multiple values.

Throws:
java.lang.Exception

getRepeatGroupName

public abstract java.lang.String getRepeatGroupName(int fieldNum)
                                             throws java.lang.Exception
for the indicated field, which should be a repeating field, return the appropriate label representing the entire repeat group.

Throws:
java.lang.Exception

getNumFieldValues

public abstract int getNumFieldValues(int fieldNum)
                               throws java.lang.Exception
get the number of values available for this field.

Throws:
java.lang.Exception

getRepeatGroupSize

public abstract int getRepeatGroupSize(int fieldNum)
                                throws java.lang.Exception
get the number of fields in this repeat group, starting at the indicated field number...this represents the 'width' size of the group, or number of columns.

Throws:
java.lang.Exception

validate

public abstract int validate(java.lang.String value,
                             int fieldNum,
                             int fieldIndex)
Validate the offered string value against the field specification of the given field number and fieldIndex. Return 0 if the string is validated successfully. Place the validated string so that it can be accessed by getValidatedString(). Else, return 1 if there is an error and place the error message in the same holding place to be accessed by getValidatedString(). Return 2 if there is no change detected between the current value and the new value.


validate

public abstract int validate(java.lang.String value,
                             int fieldNum,
                             int fieldIndex,
                             int listIndex)
expanded version of validate that accomodiates list fields, which are sub-groups within a repeat group.


restoreOriginal

public abstract void restoreOriginal(java.lang.Object restoreObj,
                                     int startField,
                                     int endField)
                              throws java.lang.Exception
restore the original values from restoreObj's start to end fields to regress edit changes

Throws:
java.lang.Exception

numberOfChildren

public abstract int numberOfChildren()
                              throws java.lang.Exception
return the number of child objects associated with this object

Throws:
java.lang.Exception

getChildren

public abstract java.util.Vector getChildren()
                                      throws java.lang.Exception
return a Vector of child objects associated with this object

Throws:
java.lang.Exception

insertGroupRow

public abstract void insertGroupRow(int rowNum,
                                    int startField)
                             throws java.lang.Exception
An editing function that allows insertion of a new row to a repeat group.

Throws:
java.lang.Exception

deleteGroupRow

public abstract void deleteGroupRow(int rowNum,
                                    int startField)
                             throws java.lang.Exception
An editing function that allows deletion of an existing row in a repeat group.

Throws:
java.lang.Exception

getEditPanel

public edu.iris.dmc.isis.EditPanel getEditPanel()
Editable interface implementation

Specified by:
getEditPanel in interface edu.iris.dmc.isis.Editable

getController

public edu.iris.dmc.isis.ObjectController getController()
Editable interface implementation

Specified by:
getController in interface edu.iris.dmc.isis.Editable

handleObject

public void handleObject(java.lang.Object o)
ObjectController interface implementation. performs this node's insertion into the JTree App Model

Specified by:
handleObject in interface edu.iris.dmc.isis.ObjectController

getDisplayPanel

public javax.swing.JPanel getDisplayPanel()
Implements Displayable interface.

Specified by:
getDisplayPanel in interface edu.iris.dmc.isis.Displayable

listString

public java.lang.String listString()
Implements Displayable->Listable.

Specified by:
listString in interface edu.iris.dmc.isis.Listable

listIcon

public javax.swing.ImageIcon listIcon()
Implements Displayable->Listable.

Specified by:
listIcon in interface edu.iris.dmc.isis.Listable

getSortField

public int getSortField()
return an integer representing the field number whose value can be used in a sorting routine based on the provided object type number. Return a -1 when no such field can be found.


getSortField

public static int getSortField(int type)
Static implementation. return an integer representing the field number whose value can be used in a sorting routine based on the provided object type number. Return a -1 when no such field can be found.


registerDefaultTreeModel

public void registerDefaultTreeModel(javax.swing.tree.DefaultTreeModel dtm)
register the tree node data model


registerObjectContainer

public void registerObjectContainer(java.lang.Object container)
register an object container with this object for reference lookups NOTE: not to be confused with getContainer, which is a MutableTreeNode implementation.


getObjectContainer

public ObjectContainer getObjectContainer()
get the registered object container


getBoundObject

public java.lang.Object getBoundObject()
get the bound data object


toString

public java.lang.String toString()
return string representation of this object, perhaps as relates to the bound data object. Default behavior is to run the bound object's toString() method.


setId

public void setId(int id)
sets the unique Id value for this object, perhaps specific to the type of data object bound to us.


getContainer

public javax.swing.tree.MutableTreeNode getContainer()
returns a reference to ourselves, since we are a MutableTreeNode inheritor.


getParentNode

public javax.swing.tree.MutableTreeNode getParentNode()
Get the tree node that is our parent in the JTree.


setParentNode

public void setParentNode(javax.swing.tree.MutableTreeNode parentNode)
Set the parentNode as our parent in the JTree.

Parameters:
parentNode - our parent TreeNode

resolveDictionaryLookup

public java.lang.String resolveDictionaryLookup(int fieldNum)
                                         throws java.lang.Exception
Return the string value at the referenced dictionary field.

Parameters:
fieldNum - field number doing the dictionary referencinng
Returns:
descriptive string value of the referenced dictionary object or "" for no referenced value
Throws:
java.lang.Exception

resolveDictionaryLookup

public java.lang.String resolveDictionaryLookup(int fieldNum,
                                                int fieldIndex)
                                         throws java.lang.Exception
Return the string value at the referenced dictionary field and repeat group offset (fieldIndex).

Parameters:
fieldNum - field number doing the dictionary referencing
fieldIndex - index of the repeating field doing the dictionary referencing
Returns:
descriptive string value of the referenced dictionary object
Throws:
PdccDictionaryException - when a dictionary object cannot be found
java.lang.Exception - in all other cases

resolveDictionaryLookup

public java.lang.String resolveDictionaryLookup(int fieldNum,
                                                int fieldIndex,
                                                int listIndex)
                                         throws java.lang.Exception
Return the string value at the referenced dictionary field and repeat group offset (fieldIndex) and list index for List type field.

Parameters:
fieldNum - field number doing the dictionary referencing
fieldIndex - index of the repeating field doing the dictionary referencing
listIndex - index of the list at fieldNum and fieldIndex
Returns:
descriptive string value of the referenced dictionary object or "" if no string available
Throws:
java.lang.Exception

getDictionaryListCount

public int getDictionaryListCount(int fieldNum,
                                  int fieldIndex)
                           throws java.lang.Exception
Return the number of dictionary list entries for this fieldNum and fieldIndex entry. Needed for data structures like Blockette 60. Non-list fields just return a count of 1. Returns a 0 if there are no entries to be found.

Throws:
java.lang.Exception

validate

public int validate(java.lang.String value,
                    int fieldNum)
validate the string at the indicated field


getValidatedString

public java.lang.String getValidatedString()
return the last formatted string generated by validate(), or return null


getOriginalString

public java.lang.String getOriginalString()
return the last original field value before the change made by validate()


canHaveChild

public boolean canHaveChild(int childType)
can this object have a child of the indicated type?


setInsertAt

public void setInsertAt(int index)
set the index where we want the tree insertion to occur


isUserGenerated

public boolean isUserGenerated()
ask if this is an object generated by the user through the GUI, and is not source data from a file.


setUserGenerated

public void setUserGenerated(boolean flag)
flag true if this is an object generated by the user through the GUI, and is not source data from a file.


removeBoundObject

public void removeBoundObject()
                       throws java.lang.Exception
remove references to the bound object both in this instance and the bound object container...used as a precursor to permanently deleting this node from the JTree.

Throws:
java.lang.Exception

releaseDisplayPanel

public void releaseDisplayPanel()
may be called to release memory for a display/edit panel created by the call to getDisplayPanel(). Calls an abstract method.


refreshTreeModel

public void refreshTreeModel()
send a notification to the tree model that the node represented by this object is in need of a refresh on the display



brought to you by Incorporated Research Institutions for Seismology
June 29 2006