org.greenstone.gs3client
Class BrowseDisplay

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 org.greenstone.gs3client.BrowseDisplay
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.TreeSelectionListener, javax.swing.event.TreeWillExpandListener, ColourCombo.ColourChangeable

public class BrowseDisplay
extends javax.swing.JPanel
implements javax.swing.event.TreeSelectionListener, javax.swing.event.TreeWillExpandListener, ColourCombo.ColourChangeable

The Browse panel inside the Java-client's tab pane that's labelled "Browse". This panel contains a tree view for expanding classifiers and their documents. It also contains an area where the metadata is displayed, and a text area where the textual or image content of a selected documentNode is displayed.

Author:
ak19
See Also:
Serialized Form

Nested Class Summary
 class BrowseDisplay.ClassifierButton
          Inner class (not static, as it needs access to outerclass' this object.
static class BrowseDisplay.ClassifierData
          Static inner class that represents the data in a <classifier> element - itself nested inside a list (<classifierList>) of them.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  javax.swing.JPanel browseBar
           
protected  javax.swing.JLabel browseLabel
           
protected  javax.swing.JPanel browsePanel
           
protected  javax.swing.JTree browsingTree
           
protected  BrowseDisplay.ClassifierButton[] classifierList
           
protected  GS3JavaClient client
          Access to the running instance of GS3JavaClient
protected  java.util.HashMap displayData
          A HashMap to store the displayData for the Browse operation.
protected  javax.swing.JEditorPane htmlPane
           
(package private) static org.apache.log4j.Logger LOG
          The Logger for this class
protected  javax.swing.JList metanames
           
protected  javax.swing.JList metavalues
           
protected  javax.swing.JPopupMenu popup
          Context menu that pops up when users right click in the browse tree area
protected  javax.swing.JSplitPane splitViewPane
           
protected  javax.swing.JSplitPane structureMetaView
           
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BrowseDisplay(GS3JavaClient client)
          Constructor that creates the Browse Panel and its internal GUI items.
 
Method Summary
 void changeUIColour()
          Changes the colour of the query form and its controls to the current colours set in class ColourCombo.
 void clear()
          Clears the service-specific buttons in the browseBar and the service-specific display-data.
 void displayBrowseOptions(org.w3c.dom.Element describeRespMsgTag)
          Will clear previous browse service's classification options and widgets, and redisplay browse options as specified by the describe Response Message XML returned from the browse Service.
 void displayBrowseResults(BrowseResponseData browseResponseObj, java.lang.String rootName)
          Called to populate the browsing tree with browse data.
 java.awt.Dimension getPreferredSize()
          Overrode this method to resize the splitpanes within, upon resize.
 void paint(java.awt.Graphics g)
          For some reason, the overriden getPreferredSize() is not called upon resize of this panel, so I am calling it manually whenever there's a call to paint this Panel.
 void treeWillCollapse(javax.swing.event.TreeExpansionEvent e)
          Part of the TreeWillExpandListener interface.
 void treeWillExpand(javax.swing.event.TreeExpansionEvent e)
          This method of the TreeWillExpandListener interface is called when the user clicked on an expandable node in the browsingTree.
 void valueChanged(javax.swing.event.TreeSelectionEvent e)
          Whenever an item is clicked in the browsingTree, this method is called.
 
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, revalidate, 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, 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, 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

LOG

static org.apache.log4j.Logger LOG
The Logger for this class


client

protected GS3JavaClient client
Access to the running instance of GS3JavaClient


displayData

protected java.util.HashMap displayData
A HashMap to store the displayData for the Browse operation. Usually just 2 elements long at most: displayName and displayDescription.


browseLabel

protected javax.swing.JLabel browseLabel

browsePanel

protected javax.swing.JPanel browsePanel

splitViewPane

protected javax.swing.JSplitPane splitViewPane

structureMetaView

protected javax.swing.JSplitPane structureMetaView

browseBar

protected javax.swing.JPanel browseBar

classifierList

protected BrowseDisplay.ClassifierButton[] classifierList

browsingTree

protected javax.swing.JTree browsingTree

htmlPane

protected javax.swing.JEditorPane htmlPane

metanames

protected javax.swing.JList metanames

metavalues

protected javax.swing.JList metavalues

popup

protected javax.swing.JPopupMenu popup
Context menu that pops up when users right click in the browse tree area

Constructor Detail

BrowseDisplay

public BrowseDisplay(GS3JavaClient client)
Constructor that creates the Browse Panel and its internal GUI items.

Parameters:
client - is the running instance of the client application through which its methods can be accessed.
Method Detail

clear

public void clear()
Clears the service-specific buttons in the browseBar and the service-specific display-data. The rest of the GUI (split panes, panels) remain as they are.


changeUIColour

public void changeUIColour()
Changes the colour of the query form and its controls to the current colours set in class ColourCombo. Specified by the ColourCombo.ColourChangeable interface.

Specified by:
changeUIColour in interface ColourCombo.ColourChangeable

paint

public void paint(java.awt.Graphics g)
For some reason, the overriden getPreferredSize() is not called upon resize of this panel, so I am calling it manually whenever there's a call to paint this Panel. Painting will be done when the parent container is resized (and this panel made visible) anyway, so it might as well work out what size the interior panels will have on every resize.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - is the Graphics object
See Also:
"JPanel's paint(Graphics g)"

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrode this method to resize the splitpanes within, upon resize. It calculates the size of this panel, as well as setting those of the splitpanes it contains based on the size of the parent container.

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
the preferred dimensions of this JPanel.

displayBrowseOptions

public void displayBrowseOptions(org.w3c.dom.Element describeRespMsgTag)
Will clear previous browse service's classification options and widgets, and redisplay browse options as specified by the describe Response Message XML returned from the browse Service.

Parameters:
describeRespMsgTag - - the (Classifier)Browse Service's describe response message element, used to reset the classifier buttons in the browseBar of this panel.

displayBrowseResults

public void displayBrowseResults(BrowseResponseData browseResponseObj,
                                 java.lang.String rootName)
Called to populate the browsing tree with browse data. Only the data for the top-level classifier and its direct descendants are retrieved.

Parameters:
browseResponseObj - - stores the data of the response XML message returned by the (Classifier)Browse service.
rootName - - the title/name of the root classifier

treeWillExpand

public void treeWillExpand(javax.swing.event.TreeExpansionEvent e)
This method of the TreeWillExpandListener interface is called when the user clicked on an expandable node in the browsingTree. Since we are loading substructures in the tree lazily (i.e. loading childnodes lazily) we have dummy/null childTreeNodes that make expandable parentNodes look like folders (make the parents look expandable). Therefore, when the user clicks on an expandable node, we first check whether we already have loaded the datastructure/subtree or whether its child is a dummy (null). If a dummy (null child), then we work out whether it's a classifierNodeData or a documentNodeData that the expanding treeNode represents. Based on that, we retrieve the sub- structure for the treeNode that's expanding.

Specified by:
treeWillExpand in interface javax.swing.event.TreeWillExpandListener

treeWillCollapse

public void treeWillCollapse(javax.swing.event.TreeExpansionEvent e)
Part of the TreeWillExpandListener interface. Nothing to do here.

Specified by:
treeWillCollapse in interface javax.swing.event.TreeWillExpandListener

valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent e)
Whenever an item is clicked in the browsingTree, this method is called. We display the document associated with a documentNode that is clicked, or "" for classifierNodes.

Specified by:
valueChanged in interface javax.swing.event.TreeSelectionListener