Class ChooserGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--ChooserGUI
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

class ChooserGUI
extends java.awt.Panel
implements java.awt.event.ActionListener

The ChooserGUI class is a base class for creating chooser GUIs. It creates Remainder/Selected text area(s) for selecting items from possibly paired lists.

 Notes: 
 1. TextAreas (ta) include scroll bars and the sizes can be
    changed.  Set one size for now. 
 2. There is a global font size for all text in text areas and labels. 
 3. Data returned: callee gets from remObjList[] & selObjList[] 
    with remObjListSize & selObjListSize being the sizes of final 
    data arrays.
 4. The OK RESET CANCEL buttons are implemented by callee module.

  The following is the basic chooserGUI layout

                                    (optional)
  |-----------|       |----------|  |--------|
  | ta1       |   ->  | ta2      |  |  up    |
  | REMAINDER |   <-  | SELECTED |  |        |
  | list      |   >>  | list     |  |        | 
  | LEFT      |   >>  | RIGHT    |  | down   |
  |-----------|       |----------|  |--------|

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.

Version:
$Date: 2002/11/04 16:34:35 $ $Revision: 1.7 $
Author:
P. Lemkin (NCI), G. Thornwall (SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home, PopupHPChooser, Serialized Form

Inner Class Summary
(package private)  class ChooserGUI.MouseEventHandler
           
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
private  java.awt.Button addAllButton
          mv ALL Remainder entries to Selected
private  java.awt.Button addButton
          mv Remainder entry to Selected
(package private)  boolean addChangePosFlag
          if can move SELECTED entry up/down
private  java.awt.Panel addDelAllButtonPanel
          add,del,all buttons
private  java.awt.Panel buttonPanel
          buttons panel
(package private)  ChooserGUI cGUI
          This is either the remote instance or 'this' instance of ChooserGUI for the instance of REMAINDER to use.
private  java.awt.Panel cGUIpanel
          main GUI panel
private  java.awt.Panel changePosPanel
          change up/down position panel
private  java.awt.Panel controlPanel
          control panel for main ok/reset buttons
(package private)  java.awt.Font dataFont
          font used by data
private  java.awt.Button delButton
          mv Selected entry to Remainder
private  java.awt.Button downButton
          move SELECTED entry down if possible
(package private)  int id
          id # for this instance
(package private)  java.awt.Font labelFont
          font used by label
private  java.awt.Label lTitle
          label for title for entire GUI window
private static MAExplorer mae
          link to global MAExplorer instance
private static int masterID
          increments for each instance
private  ChooserGUI.MouseEventHandler meh1
          handle mouse events for text areas for ta1 LEFT
private  ChooserGUI.MouseEventHandler meh2
          handle mouse events for text areas for ta2 RIGHT
private  java.awt.Panel objButtonPanel
          set prj button
private  java.awt.Panel objListTApanel
          obj list ta1
(package private)  java.lang.String[] origRemObjs
          original REMAINDER list
(package private)  int origRemObjsSize
          REMAINDER list size
(package private)  java.lang.String[] origSelObjs
          original SELECTED list
(package private)  int origSelObjsSize
          SELECTED list size
private  java.lang.Object parentWindow
          parent window
private  java.awt.Panel prjListPanel
          project prj ta
(package private)  java.lang.String[] remObjList
          REMAINDER list, returned if needed
(package private)  int remObjListSize
          REMAINDER list size
(package private)  boolean remoteFlag
          true if using other prj data/ta
private  java.awt.Button rmvAllButton
          mv ALL Selected entries to Remainder
private  java.awt.Panel selectedPanel
          SELECTED list
(package private)  java.lang.String[] selObjList
          SELECTED list to be returned
(package private)  int selObjListSize
          SELECTED list size
(package private)  java.awt.TextArea ta1
          REMAINDER objs
private  java.awt.Label ta1Label
          label under ta1
(package private)  java.awt.TextArea ta2
          SELECTED obj list
private  java.awt.Label ta2Label
          label under ta2
(package private)  int taCols
          columns/text area
(package private)  int taRows
          rows/text area
(package private)  java.lang.String taStr1
          label for SELECTED LEFT text area
(package private)  java.lang.String taStr2
          label for REMAINDER RIGHT text area
(package private)  java.lang.String title
          title for entire GUI window
(package private)  java.awt.Font titleFont
          font used by title
private  java.awt.Button upButton
          move SELECTED entry up if possible
private  java.awt.Panel upDownPanel
          panel with up/down buttons
private  java.awt.Label useAbove
          optional label if not to use ta1 from above
 
Fields inherited from class java.awt.Panel
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
(package private) ChooserGUI(MAExplorer mae, ChooserGUI remoteC_GUI, int taRows, int taCols, java.awt.Font titleFont, java.awt.Font labelFont, java.awt.Font dataFont, java.lang.Object parentWindow, boolean addChangePosFlag)
          ChooserGUI() - constructor for base class of Chooser GUI
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          actionPerformed() - handle action events buttons and text areas
(package private)  void addAllObjs()
          addAllObjs() - move all REMAINDER ta1 objects to SELECTED ta2.
(package private)  void addObjGridBagLayout(java.awt.Container cont, java.lang.Object arg, int x, int y, int w, int h, double weightX, double weightY)
          addObjGridBagLayout() - add object to GridBagLayout using x,y grid system.
(package private)  void addObjs(java.lang.String objName)
          addObjs() - move object to (remainder) TA1 from (selected) TA2.
(package private)  void buildChooserGUI()
          buildChooserGUI() - create single instance GUI for Chooser
(package private)  void copyOrigToWorkingData()
          copyOrigToWorkingData() - copy original data to working data.
(package private)  void delObjs(java.lang.String objName)
          delObjs() - move SELECTED obj from ta2 (RIGHT) to REMAINDER ta1 (LEFT) list if ta1 is not same prj list.
 void keyPressed(java.awt.event.KeyEvent e)
          keyPressed() - get key Pressed event
 void keyReleased(java.awt.event.KeyEvent e)
          keyReleased() - get key Released event
 void keyTyped(java.awt.event.KeyEvent e)
          keyTyped() - get key typed event
(package private)  void moveObjDown(java.lang.String objName)
          moveObjDown() - move SELECTED obj ta2 (RIGHT) Down one position unless it is at the bottom of list.
(package private)  void moveObjUp(java.lang.String objName)
          moveObjUp() - move SELECTED obj ta2 (RIGHT) UP one position unless it is at the top of list.
(package private)  void quit()
          quit() - kill this window
(package private)  void resetChooserGUI()
          resetChooserGUI() - reset original data to working data, reset ta1 and ta2 text areas.
(package private)  void rmvAllObjs()
          rmvAllObjs() - move all objects from (SELECTED) ta2 to ta1 (REMAINDER).
(package private)  void setListData(int maxObjs, int offset, int nRem, int nSel, java.lang.String[] remData, java.lang.String[] selData)
          setListData() - copy original data for REMAINDER and SELECTED lists.
(package private)  void setTitles(java.lang.String taStr1, java.lang.String taStr2)
          setTitles() - set titles for REMAINDER and SELECTED text areas
(package private)  java.lang.String toString(java.lang.String msg, boolean allFlag)
          toString() - pretty-print instance of this ChooserGUI
private  void updateBothTextAreas()
          updateBothTextAreas() - update both text areas ta1 and ta2
(package private)  void updateInfo(int index, java.lang.String foundStr)
          updateInfo() - update info for index entry in parentWindow if any
private  void updateSelTextArea()
          updateSelTextAreas() - update selected text area ta2 (SELECTED)
 void windowActivated(java.awt.event.WindowEvent e)
           
 void windowClosed(java.awt.event.WindowEvent e)
           
 void windowClosing(java.awt.event.WindowEvent e)
          windowclosing() - close the window
 void windowDeactivated(java.awt.event.WindowEvent e)
           
 void windowDeiconified(java.awt.event.WindowEvent e)
           
 void windowIconified(java.awt.event.WindowEvent e)
           
 void windowOpened(java.awt.event.WindowEvent e)
           
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paint, paintComponents, paintHeavyweightComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, update, validate, validateTree, writeObject
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

mae

private static MAExplorer mae
link to global MAExplorer instance

masterID

private static int masterID
increments for each instance

id

int id
id # for this instance

addChangePosFlag

boolean addChangePosFlag
if can move SELECTED entry up/down

remoteFlag

boolean remoteFlag
true if using other prj data/ta

meh1

private ChooserGUI.MouseEventHandler meh1
handle mouse events for text areas for ta1 LEFT

meh2

private ChooserGUI.MouseEventHandler meh2
handle mouse events for text areas for ta2 RIGHT

ta1

java.awt.TextArea ta1
REMAINDER objs

ta2

java.awt.TextArea ta2
SELECTED obj list

addButton

private java.awt.Button addButton
mv Remainder entry to Selected

delButton

private java.awt.Button delButton
mv Selected entry to Remainder

addAllButton

private java.awt.Button addAllButton
mv ALL Remainder entries to Selected

rmvAllButton

private java.awt.Button rmvAllButton
mv ALL Selected entries to Remainder

upButton

private java.awt.Button upButton
move SELECTED entry up if possible

downButton

private java.awt.Button downButton
move SELECTED entry down if possible

controlPanel

private java.awt.Panel controlPanel
control panel for main ok/reset buttons

buttonPanel

private java.awt.Panel buttonPanel
buttons panel

prjListPanel

private java.awt.Panel prjListPanel
project prj ta

objButtonPanel

private java.awt.Panel objButtonPanel
set prj button

objListTApanel

private java.awt.Panel objListTApanel
obj list ta1

upDownPanel

private java.awt.Panel upDownPanel
panel with up/down buttons

addDelAllButtonPanel

private java.awt.Panel addDelAllButtonPanel
add,del,all buttons

selectedPanel

private java.awt.Panel selectedPanel
SELECTED list

changePosPanel

private java.awt.Panel changePosPanel
change up/down position panel

ta1Label

private java.awt.Label ta1Label
label under ta1

ta2Label

private java.awt.Label ta2Label
label under ta2

useAbove

private java.awt.Label useAbove
optional label if not to use ta1 from above

lTitle

private java.awt.Label lTitle
label for title for entire GUI window

taRows

int taRows
rows/text area

taCols

int taCols
columns/text area

origRemObjsSize

int origRemObjsSize
REMAINDER list size

origSelObjsSize

int origSelObjsSize
SELECTED list size

remObjListSize

int remObjListSize
REMAINDER list size

selObjListSize

int selObjListSize
SELECTED list size

title

java.lang.String title
title for entire GUI window

taStr1

java.lang.String taStr1
label for SELECTED LEFT text area

taStr2

java.lang.String taStr2
label for REMAINDER RIGHT text area

origRemObjs

java.lang.String[] origRemObjs
original REMAINDER list

origSelObjs

java.lang.String[] origSelObjs
original SELECTED list

remObjList

java.lang.String[] remObjList
REMAINDER list, returned if needed

selObjList

java.lang.String[] selObjList
SELECTED list to be returned

cGUI

ChooserGUI cGUI
This is either the remote instance or 'this' instance of ChooserGUI for the instance of REMAINDER to use.

titleFont

java.awt.Font titleFont
font used by title

labelFont

java.awt.Font labelFont
font used by label

dataFont

java.awt.Font dataFont
font used by data

cGUIpanel

private java.awt.Panel cGUIpanel
main GUI panel

parentWindow

private java.lang.Object parentWindow
parent window
Constructor Detail

ChooserGUI

ChooserGUI(MAExplorer mae,
           ChooserGUI remoteC_GUI,
           int taRows,
           int taCols,
           java.awt.Font titleFont,
           java.awt.Font labelFont,
           java.awt.Font dataFont,
           java.lang.Object parentWindow,
           boolean addChangePosFlag)
ChooserGUI() - constructor for base class of Chooser GUI
Parameters:
mae - is instance of MAExplorer
remoteC_GUI - is the alternate ChooserGUI to use if share REMAINDER else null
taRows - is the # rows visible in scroller
taColsis - the # columns visible in scroller
titleFont - is the top level title Font
labelFont - is the LEFT and RIGHT titles Font
dataFont - is the Text Areas Font
parentWindow - is the parent window
addChangePosFlag - is flag to move entry position in SELECTED window
Method Detail

setTitles

void setTitles(java.lang.String taStr1,
               java.lang.String taStr2)
setTitles() - set titles for REMAINDER and SELECTED text areas
Parameters:
taStr1 - is the REMAINDER caption
taStr2 - is the SELECTED caption

setListData

void setListData(int maxObjs,
                 int offset,
                 int nRem,
                 int nSel,
                 java.lang.String[] remData,
                 java.lang.String[] selData)
setListData() - copy original data for REMAINDER and SELECTED lists. Note: can use offset 'off' to copy data from [1:n] arrays into the origXXXObjs[0:n-1] arrays.int
Parameters:
maxObjs - is the max # objects
offset - 1 if [1:n] else 0
nRem - is the # REMAINDER objects
nSel - is # SELECTED objects
remData - is [off:nRem+off-1] REMAINDER
selData - is [off:nRem+off-1] SELECTED
See Also:
copyOrigToWorkingData()

buildChooserGUI

void buildChooserGUI()
buildChooserGUI() - create single instance GUI for Chooser
See Also:
MouseEventHandler

addObjGridBagLayout

void addObjGridBagLayout(java.awt.Container cont,
                         java.lang.Object arg,
                         int x,
                         int y,
                         int w,
                         int h,
                         double weightX,
                         double weightY)
addObjGridBagLayout() - add object to GridBagLayout using x,y grid system. See GridBagConstriants in Patrick Chans book p.738.
Parameters:
cont - is panel, window, etc
arg - is Label/Panel
x - is x coord location
y - is y coord location
w - is cell width
h - is cell height
weightX - is row weight
weightY - is col weight

addObjs

void addObjs(java.lang.String objName)
addObjs() - move object to (remainder) TA1 from (selected) TA2.
Parameters:
objName - to add
See Also:
updateBothTextAreas()

delObjs

void delObjs(java.lang.String objName)
delObjs() - move SELECTED obj from ta2 (RIGHT) to REMAINDER ta1 (LEFT) list if ta1 is not same prj list.
Parameters:
objName - objName to delete
See Also:
updateBothTextAreas()

moveObjUp

void moveObjUp(java.lang.String objName)
moveObjUp() - move SELECTED obj ta2 (RIGHT) UP one position unless it is at the top of list.
Parameters:
objName - objName to move
See Also:
updateSelTextArea()

moveObjDown

void moveObjDown(java.lang.String objName)
moveObjDown() - move SELECTED obj ta2 (RIGHT) Down one position unless it is at the bottom of list.
Parameters:
objName - objName to move
See Also:
updateSelTextArea()

addAllObjs

void addAllObjs()
addAllObjs() - move all REMAINDER ta1 objects to SELECTED ta2.

rmvAllObjs

void rmvAllObjs()
rmvAllObjs() - move all objects from (SELECTED) ta2 to ta1 (REMAINDER).
See Also:
updateBothTextAreas()

updateSelTextArea

private void updateSelTextArea()
updateSelTextAreas() - update selected text area ta2 (SELECTED)
See Also:
updateBothTextAreas(), MouseEventHandler.resetMouseEventHandler(java.lang.String[])

updateBothTextAreas

private void updateBothTextAreas()
updateBothTextAreas() - update both text areas ta1 and ta2
See Also:
MouseEventHandler.resetMouseEventHandler(java.lang.String[])

updateInfo

void updateInfo(int index,
                java.lang.String foundStr)
updateInfo() - update info for index entry in parentWindow if any
Parameters:
index - is index to display in the the information text area
foundStr - is the data
See Also:
PopupHPChooser.updateInfo(ChooserGUI, int, java.lang.String)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed() - handle action events buttons and text areas
Specified by:
actionPerformed in interface java.awt.event.ActionListener
See Also:
addObjs(java.lang.String), delObjs(java.lang.String), rmvAllObjs(), moveObjUp(java.lang.String), moveObjDown(java.lang.String)

copyOrigToWorkingData

void copyOrigToWorkingData()
copyOrigToWorkingData() - copy original data to working data. Note: allocate object lists required.

resetChooserGUI

void resetChooserGUI()
resetChooserGUI() - reset original data to working data, reset ta1 and ta2 text areas. Note: allocate object lists required.
See Also:
MouseEventHandler.resetMouseEventHandler(java.lang.String[]), copyOrigToWorkingData()

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
windowclosing() - close the window
Parameters:
e - is window closing event

quit

void quit()
quit() - kill this window

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
keyPressed() - get key Pressed event

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
keyReleased() - get key Released event

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
keyTyped() - get key typed event

toString

java.lang.String toString(java.lang.String msg,
                          boolean allFlag)
toString() - pretty-print instance of this ChooserGUI
Parameters:
msg - to display in summary
allFlag - display additional data
Returns:
converted string