ucar.unidata.idv.chooser
Class XmlChooser

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ucar.unidata.ui.ChooserPanel
                      extended by ucar.unidata.idv.chooser.IdvChooser
                          extended by ucar.unidata.idv.chooser.XmlChooser
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, IdvConstants

public class XmlChooser
extends IdvChooser
implements ActionListener

This handles a variety of flavors of xml documents (e.g., thredds query capability, thredds catalogs, idv menus) to create data choosers from. It provides a combobox to enter urls to xml documents. It retrieves the xml and creates a XmlHandler based on the type of xml. Currently this class handles two types of xml: Thredds catalog and Web Map Server (WMS) capability documents. The XmlHandler does most of the work.

This class maintains the different xml docs the user has gone to coupled with the XmlHandler for each doc. It uses this list to support navigating back and forth through the history of documents.

Version:
$Revision: 1.80 $Date: 2007/07/09 22:59:58 $
Author:
IDV development team
See Also:
Serialized Form

Nested Class Summary
static class XmlChooser.PropertiedAction
          A holder of a String action and a properties table.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String ATTR_URL
          The xml attr name for any initial url from the choosers.xml segment that created this chooser
static String TAG_ERROR
          If there was some error in loading the xml we construct and xml document with the error tag and popup the message in the GUI
protected  int timestamp
          Keeps track of the outstanding url request
 
Fields inherited from class ucar.unidata.idv.chooser.IdvChooser
ATTR_ID, ATTR_SHOWDETAILS, dirHistoryCbx, ignoreDirHistory, NULL_PROPERTIES, NULL_STRING, PREF_ADDESERVERS, PREF_CATALOGLIST, PREF_DEFAULTDIR, PREF_IMAGEDESCLIST, PREF_POLLINGINFO, PREF_RADARDESCLIST, PREF_TDSRADARSERVER, PROP_CHOOSER_MAPS, PROP_CHOOSER_PROJECTION_BOUNDS, stationMap
 
Fields inherited from class ucar.unidata.ui.ChooserPanel
cancelButton, CMD_LOAD, contents, GRID_INSETS, GRID_SPACING, haveData, helpPath, loadButton, MAP_COLOR, simpleMode
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface ucar.unidata.idv.IdvConstants
ARG_B64BUNDLE, ARG_BUNDLE, ARG_CATALOG, ARG_CHOOSER, ARG_CLEARDEFAULT, ARG_CODE, ARG_CONNECT, ARG_CURRENTTIME, ARG_DATA, ARG_DEBUG, ARG_DEFAULT, ARG_DISPLAY, ARG_DXML, ARG_FIXEDTIME, ARG_HELP, ARG_IMAGE, ARG_IMAGESERVER, ARG_INSTALLPLUGIN, ARG_ISLFILE, ARG_ISLINTERACTIVE, ARG_LISTRESOURCES, ARG_MAINCLASS, ARG_MOVIE, ARG_MSG_DEBUG, ARG_MSG_RECORD, ARG_NODEFAULT, ARG_NOGUI, ARG_NOONEINSTANCE, ARG_NOPLUGINS, ARG_NOPREF, ARG_ONEINSTANCEPORT, ARG_PLUGIN, ARG_PORT, ARG_PRINTJNLP, ARG_PROPERTIES, ARG_SCRIPT, ARG_SERVER, ARG_SETFILES, ARG_SITEPATH, ARG_TEMPLATE, ARG_TEST, ARG_TESTEVAL, ARG_TRACE, ARG_TRACEONLY, ARG_USERPATH, DEFAULT_DATE_FORMAT, DEFAULT_DOCPATH, DEFAULT_TIMEZONE, FILE_VMSTATE, FILTER_CPT, FILTER_ISL, FILTER_JNLP, FILTER_XIDV, FILTER_XIDVZIDV, FILTER_XML, FILTER_ZIDV, ID_COMMANDSTORUN, ID_DATASOURCES, ID_DISPLAYCONTROLS, ID_IDV, ID_JYTHON, ID_MESSAGE, ID_MISCHASHTABLE, ID_VERSION, ID_VIEWMANAGERS, ID_WINDOWS, INITIAL_PROBE_EARTHLOCATION, NULL_DATA_SELECTION, PREF_ARCHIVEDIR, PREF_ARCHIVENAME, PREF_AUTODISPLAYS_ENABLE, PREF_AUTODISPLAYS_SHOWGUI, PREF_AUTOSELECTDATA, PREF_CACHESIZE, PREF_CONTROLSINTABS, PREF_DATAPREFIX, PREF_DATE_FORMAT, PREF_DISTANCEUNIT, PREF_DOCACHE, PREF_EMBEDDATACHOOSERINDASHBOARD, PREF_EMBEDFIELDSELECTORINDASHBOARD, PREF_EMBEDLEGENDINDASHBOARD, PREF_EMBEDQUICKLINKSINDASHBOARD, PREF_EVENT_KEYBOARDMAP, PREF_EVENT_MOUSEMAP, PREF_EVENT_WHEELMAP, PREF_FAST_RENDER, PREF_FIELD_CACHETHRESHOLD, PREF_FILEREADDIR, PREF_FILEWRITEDIR, PREF_HISTORY, PREF_LASTVERSION, PREF_LATLON_FORMAT, PREF_LOCALE, PREF_LOOKANDFEEL, PREF_MAXIMAGESIZE, PREF_OPEN_ASK, PREF_OPEN_MERGE, PREF_OPEN_REMOVE, PREF_PROJ_LIST, PREF_SAMPLINGMODE, PREF_SHOWCONTROLWINDOW, PREF_SHOWDASHBOARD, PREF_SHOWDECODEDIALOG, PREF_SHOWHIDDENFILES, PREF_SHOWQUITCONFIRM, PREF_SITEPATH, PREF_TIMEZONE, PREF_VERTICALCS, PREF_VERTICALUNIT, PREF_ZIDV_ASK, PREF_ZIDV_DIRECTORY, PREF_ZIDV_SAVETOTMP, PROP_3DMODE, PROP_ABOUTTEXT, PROP_APPRESOURCEPATH, PROP_CHOOSERS, PROP_CHOOSERS_ALL, PROP_CONTROLDESCRIPTORS, PROP_CONTROLDESCRIPTORS_ALL, PROP_DATAHOLDERBOUNDS, PROP_DEFAULTLOCATIONS, PROP_JNLPCODEBASE, PROP_JNLPTEMPLATE, PROP_JNLPTITLE, PROP_LOADINGXML, PROP_OLDCONTROLDESCRIPTORS, PROP_ONEINSTANCEPORT, PROP_PREFERENCES, PROP_PROJ_NAME, PROP_RESOURCEFILES, PROP_SHOWDASHBOARD, PROP_SHOWDATATREE, PROP_SHOWFORMULAS, PROP_SHOWSPLASH, PROP_SPLASHICON, PROP_UI_DESKTOP, PROP_VERSIONFILE, PROP_WINDOW_SCREENSIZEOFFSET, PROP_WINDOW_SIZEHEIGHT, PROP_WINDOW_SIZEWIDTH, PROP_WINDOW_USESCREENSIZE, SUFFIX_BAT, SUFFIX_CPT, SUFFIX_ISL, SUFFIX_JNLP, SUFFIX_RBI, SUFFIX_SH, SUFFIX_XIDV, SUFFIX_XML, SUFFIX_ZIDV
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
XmlChooser(IdvChooserManager mgr, Element root)
          Create the XmlChooser
 
Method Summary
 void actionPerformed(ActionEvent ae)
          Handle any Gui actions.
 void doLoadInThread()
          Load the currently selected xml element.
protected  JComponent doMakeContents()
          Create and return the Gui contents.
 void doUpdate()
          Reload the current xml and update the display.
 void doUpdateInner()
          Reload the current xml and update the display.
 Document getDocument()
          Get the xml doc
 String getXml()
          Get the xml
 void goBack()
          Go back and display the previous document.
 void goForward()
          Go forward and display the next document in the history list.
protected  void handleAction(String action)
          A wrapper around @see{handleAction}, passing in an empty properties table.
protected  void handleAction(String action, Hashtable properties)
          Process the given action (e.g., url, idv command) with the given properties.
protected  void handleActions(List actions)
          Process the given list of XmlChooser.PropertiedActions.
protected  void handleActionsInThread(List actions)
          Actually does the work of handling the actions
protected  void makeUi(Document doc, Element xmlRoot, String path)
          Generate a user interface from the given xml document (derived from the given path).
 boolean makeUiFromPath(String xmlPath)
          Load the xml defined by the given xmlPath.
 boolean makeUiFromPath(String xmlPath, int myTimestamp)
          Load the xml defined by the given xmlPath.
 void setHaveData(boolean have)
          Set whether the user has made a selection that contains data.
protected  boolean shouldDoUpdateOnFirstDisplay()
          Overwrite base class method to do the update on first display.
protected  void updateStatus()
          _more_
 
Methods inherited from class ucar.unidata.idv.chooser.IdvChooser
clearSelectedStations, clearStations, closeChooser, createStationMap, decorateButtons, doCancel, doClose, errorMessage, getAttribute, getContents, getDataManager, getDataSourceId, getDataSourceId, getDataSourceProperties, getDataSourcesComponent, getDataSourcesComponent, getDataSourcesComponent, getDataSourcesComponent, getDefaultButtons, getDefaultDisplayType, getDefaultMap, getDefaultMaps, getDefaultProjection, getDefaultProjectionRect, getId, getIdv, getMenuTitle, getPreferenceList, getPreferenceList, getPreferenceList, getPreferenceList, getProperty, getProperty, getPropList, getSelectedStation, getSelectedStations, getShowInMenu, getStationMap, getTitle, getXmlNode, haveStationSelected, init, initChooserPanel, initStationMap, logException, makeDataSource, makeDataSource, makeTimeMenus, newSelectedStations, resetDataSourceId, setDataSourceListener, showNormalCursor, showWaitCursor, startTask, stopTask, stopTaskAndIsOk, taskOk, userMessage, usingStations
 
Methods inherited from class ucar.unidata.ui.ChooserPanel
addPropertyChangeListener, clearWaitCursor, doHelp, doLoad, firePropertyChange, getButtonLabels, getDefaultButtons, getHaveData, getLoadCommandName, getLoadToolTip, getSimpleMode, getStatusComponent, getStatusLabel, getUpdateToolTip, registerStatusComp, revalidate, setHelpPath, setStatus, setStatus
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TAG_ERROR

public static final String TAG_ERROR
If there was some error in loading the xml we construct and xml document with the error tag and popup the message in the GUI

See Also:
Constant Field Values

ATTR_URL

public static final String ATTR_URL
The xml attr name for any initial url from the choosers.xml segment that created this chooser

See Also:
Constant Field Values

timestamp

protected int timestamp
Keeps track of the outstanding url request

Constructor Detail

XmlChooser

public XmlChooser(IdvChooserManager mgr,
                  Element root)
Create the XmlChooser

Parameters:
mgr - The IdvChooserManager
root - The xml root that defines this chooser
Method Detail

updateStatus

protected void updateStatus()
Description copied from class: ChooserPanel
_more_

Overrides:
updateStatus in class IdvChooser

setHaveData

public void setHaveData(boolean have)
Description copied from class: ChooserPanel
Set whether the user has made a selection that contains data.

Overrides:
setHaveData in class ChooserPanel
Parameters:
have - true to set the haveData property. Enables the loading button

shouldDoUpdateOnFirstDisplay

protected boolean shouldDoUpdateOnFirstDisplay()
Overwrite base class method to do the update on first display.

Overrides:
shouldDoUpdateOnFirstDisplay in class IdvChooser
Returns:
Return true. We do want to do an update on initial display.

actionPerformed

public void actionPerformed(ActionEvent ae)
Handle any Gui actions.

Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class ChooserPanel
Parameters:
ae - The ActionEvent.

doMakeContents

protected JComponent doMakeContents()
Create and return the Gui contents.

Overrides:
doMakeContents in class ChooserPanel
Returns:
The gui contents.

makeUiFromPath

public boolean makeUiFromPath(String xmlPath)
Load the xml defined by the given xmlPath. Try to create a display from it.

Parameters:
xmlPath - The url pointing to the xml to display.
Returns:
Was this successful

makeUiFromPath

public boolean makeUiFromPath(String xmlPath,
                              int myTimestamp)
Load the xml defined by the given xmlPath. Try to create a display from it.

Parameters:
xmlPath - The url pointing to the xml to display.
myTimestamp - Keeps track of which request this is.
Returns:
Was this successful

makeUi

protected void makeUi(Document doc,
                      Element xmlRoot,
                      String path)
Generate a user interface from the given xml document (derived from the given path). The xml can be a thredds query capability, any verion of a thredds catalog or an IDV menus xml file.

Parameters:
doc - the xml document
xmlRoot - The root of the xml document to create a display for.
path - The url path we got the xml from.

goBack

public void goBack()
Go back and display the previous document.


goForward

public void goForward()
Go forward and display the next document in the history list.


handleAction

protected void handleAction(String action)
A wrapper around @see{handleAction}, passing in an empty properties table.

Parameters:
action - The String action (Url, Idv command, etc.) to handle.

handleAction

protected void handleAction(String action,
                            Hashtable properties)
Process the given action (e.g., url, idv command) with the given properties. This just creates a new PropertiedAction, adds it to a list and turns around and calls the handleActions method.

Parameters:
action - The String action (Url, Idv command, etc.) to handle.
properties - The properties for this action.

handleActions

protected void handleActions(List actions)
Process the given list of XmlChooser.PropertiedActions.

Parameters:
actions - The list of actions to process

handleActionsInThread

protected void handleActionsInThread(List actions)
Actually does the work of handling the actions

Parameters:
actions - List of PropertiedActions

doUpdate

public void doUpdate()
Reload the current xml and update the display.

Overrides:
doUpdate in class ChooserPanel

doUpdateInner

public void doUpdateInner()
Reload the current xml and update the display.


doLoadInThread

public void doLoadInThread()
Load the currently selected xml element.

Overrides:
doLoadInThread in class ChooserPanel

getXml

public String getXml()
Get the xml

Returns:
The xml

getDocument

public Document getDocument()
Get the xml doc

Returns:
The xml doc