edu.ucsb.nceas.morpho.datapackage
Class ReferencesHandler

java.lang.Object
  extended byedu.ucsb.nceas.morpho.datapackage.ReferencesHandler

public class ReferencesHandler
extends java.lang.Object


Constructor Summary
ReferencesHandler(java.lang.String genericName, java.lang.String[] surrogateXPaths)
          constructor
 
Method Summary
 void addReferencesListener(ReferencesListener listener)
          register a listener
static org.w3c.dom.Node deleteOriginalReferenceSubtree(AbstractDataPackage adp, java.lang.String subtreeID)
          deletes referenced subtree and transfers its children to te first subtree that references it (if any)
 java.lang.String getGenericName()
          Method to return genericName
 javax.swing.JComboBox getJComboBox(AbstractDataPackage dataPkg, ReferencesListener listener, java.awt.Frame parent)
          get a JComboBox containing a blank entry at location (0), an entry to launch an ExternalRefsDialog at location (1), and all the IDs in the current DataPackage that point to subtree root-nodes corresponding to the genericName used to instantiate this ReferencesHandler, and whose values are String surrogates for those referenced subtrees
protected  java.util.List getReferences(AbstractDataPackage dataPkg, java.lang.String suppressRefID)
          get a Map whose keys are all the IDs currently in the DataPackage that point to subtree root-nodes corresponding to the genericName used to instantiate this ReferencesHandler, and whose values are String surrogates for those referenced subtrees
 void removeReferencesListener(ReferencesListener listener)
          unregister a listener
 void setDisplayName(java.lang.String displayName)
          Method to set displayName for the ExternalRefsDialog
 void updateJComboBox(AbstractDataPackage dataPkg, javax.swing.JComboBox dropdown, java.lang.String suppressRefID)
          update the ListModel backing the passed JComboBox - @see getJComboBox()
static org.w3c.dom.Node updateOriginalReferenceSubtree(AbstractDataPackage adp, java.lang.String subtreeID, OrderedMap newData)
          gets the subtree with refID "subtreeID" from the datapackage "adp", and replaces it with the subtree described in the newData OrderedMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReferencesHandler

public ReferencesHandler(java.lang.String genericName,
                         java.lang.String[] surrogateXPaths)
constructor

Parameters:
genericName - String that defines which part of the EML schema this ReferencesHandler will be handling (eg Party, etc). Generic name strings are defined in schema-specific KeymapConfig xml file (e.g. eml200KeymapConfig.xml)
surrogateXPaths - String[] array containing any mixture of:

(a) xpaths pointing to the fields within the DOM subtree that should be used to construct the surrogate strings returned by this class. XPaths must start with a "/" and be relative to the subtree root-node, but must *NOT* include the subtree root node itself (because, for example, if the subtree is "Party", its root node could be "Creator" or "Owner" or any number of other things

(b) strings that will be inserted between the values returned from the above xpaths (these strings are identified by their first character not being a "/").

So for example, if the genericName is set to "parties" and you want the surrogate to be: "firstname lastname - (role)", then the array will look like this for EML2.0:

     {
       "/individualName/givenName",
       "/individualName/surName",
       " - (",
       "/role",
       ")",
     }
Method Detail

setDisplayName

public void setDisplayName(java.lang.String displayName)
Method to set displayName for the ExternalRefsDialog

Parameters:
displayName - displayName for the ExternalRefsDialog

getGenericName

public java.lang.String getGenericName()
Method to return genericName

Returns:
String

getReferences

protected java.util.List getReferences(AbstractDataPackage dataPkg,
                                       java.lang.String suppressRefID)
get a Map whose keys are all the IDs currently in the DataPackage that point to subtree root-nodes corresponding to the genericName used to instantiate this ReferencesHandler, and whose values are String surrogates for those referenced subtrees

Parameters:
dataPkg - the AbstractDataPackage from whence the references should be obtained. If this is null, an empty Map is returned
suppressRefID - String
Returns:
a List of ReferenceMapping objects containing all the IDs currently in the DataPackage that point to subtree root-nodes corresponding to the genericName used to instantiate this ReferencesHandler, and String surrogates for those referenced subtrees. An empty List is returned if the passed dataPkg parameter is null

getJComboBox

public javax.swing.JComboBox getJComboBox(AbstractDataPackage dataPkg,
                                          ReferencesListener listener,
                                          java.awt.Frame parent)
get a JComboBox containing a blank entry at location (0), an entry to launch an ExternalRefsDialog at location (1), and all the IDs in the current DataPackage that point to subtree root-nodes corresponding to the genericName used to instantiate this ReferencesHandler, and whose values are String surrogates for those referenced subtrees

Parameters:
dataPkg - the AbstractDataPackage from whence the references should be obtained. If this is null, an empty JComboBox is returned
listener - ReferencesListener to be called back when a selection is made.
parent - JFrame that will be the parent of any modal dialogs that this class may create
Returns:
a JComboBox containing a blank entry at location (0), an entry to launch an ExternalRefsDialog at location (1), and all the IDs in the current DataPackage that point to subtree root-nodes corresponding to the genericName used to instantiate this ReferencesHandler, and whose values are String surrogates for those referenced subtrees. An empty JComboBox is returned if passed AbstractDataPackage is null

updateJComboBox

public void updateJComboBox(AbstractDataPackage dataPkg,
                            javax.swing.JComboBox dropdown,
                            java.lang.String suppressRefID)
update the ListModel backing the passed JComboBox - @see getJComboBox()

Parameters:
dataPkg - the AbstractDataPackage from whence the references should be obtained. If this is null, an empty JComboBox is returned
dropdown - ReferencesListener to be called back when a selection is made.
suppressRefID - String refID whose list entry will be removed - set this to the refID of the subtree represented by the calling dialog, so the dialog can't reference itself

updateOriginalReferenceSubtree

public static org.w3c.dom.Node updateOriginalReferenceSubtree(AbstractDataPackage adp,
                                                              java.lang.String subtreeID,
                                                              OrderedMap newData)
gets the subtree with refID "subtreeID" from the datapackage "adp", and replaces it with the subtree described in the newData OrderedMap

Parameters:
adp - AbstractDataPackage the current datapkg
subtreeID - String refID of the subtree to be replaced
newData - OrderedMap containing new data to replace referenced subtree
Returns:
Node the replacement subtree, or null if original subtree not found, or if any of the input parameters are invalid

deleteOriginalReferenceSubtree

public static org.w3c.dom.Node deleteOriginalReferenceSubtree(AbstractDataPackage adp,
                                                              java.lang.String subtreeID)
deletes referenced subtree and transfers its children to te first subtree that references it (if any)

Parameters:
adp - CustomList
subtreeID - String
Returns:
Node pointer to the new subtree, or null if unsuccessful

addReferencesListener

public void addReferencesListener(ReferencesListener listener)
register a listener

Parameters:
listener - ReferencesListener

removeReferencesListener

public void removeReferencesListener(ReferencesListener listener)
unregister a listener

Parameters:
listener - ReferencesListener


Copyright © 2000 National Center for Ecological Analysis and Synthesis. All Rights Reserved.