jimm.datavision.gui
Class FieldPickerWin

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by jimm.datavision.gui.FieldPickerWin
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, java.util.Observer, javax.accessibility.Accessible, javax.swing.event.TreeSelectionListener, javax.swing.event.TreeWillExpandListener, javax.swing.RootPaneContainer, javax.swing.WindowConstants

 class FieldPickerWin
extends javax.swing.JDialog
implements java.awt.event.ActionListener, javax.swing.event.TreeSelectionListener, javax.swing.event.TreeWillExpandListener, java.util.Observer

A window that lets the user drag any field available onto the report and create, edit, delete, and rename formulas, parameters, and user columns.

Uses a FieldPickerTree. The classes used to store information about leaf nodes are subclasses of FPLeafInfo and are found in FPLeafInfo.java.

Author:
Jim Menard, jimm@io.com
See Also:
FPTableInfo

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
javax.swing.JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int ALL_DATABASE_FIELDS
           
protected  javax.swing.JMenuItem cutItem
           
protected  javax.swing.JMenuItem deleteItem
           
protected  Designer designer
           
protected  javax.swing.JMenuItem editFormulaItem
           
protected  javax.swing.JMenuItem editParameterItem
           
protected  javax.swing.JMenuItem editUserColumnItem
           
protected  javax.swing.tree.DefaultMutableTreeNode formulaCategoryNode
           
static int FORMULAS
           
protected  java.util.Comparator nameComparator
           
protected  javax.swing.tree.DefaultMutableTreeNode parameterCategoryNode
           
static int PARAMETERS
           
protected  javax.swing.JMenuItem renameFormulaItem
           
protected  javax.swing.JMenuItem renameParameterItem
           
protected  javax.swing.JMenuItem renameUserColumnItem
           
protected  Report report
           
static int REPORT_DATABASE_FIELDS
           
protected  FPLeafInfo selectedInfo
           
protected  javax.swing.tree.DefaultMutableTreeNode selectedNode
           
static int SPECIAL_FIELDS
           
protected  FieldPickerTree tree
           
protected  javax.swing.tree.DefaultTreeModel treeModel
           
static int USERCOLS
           
protected  javax.swing.tree.DefaultMutableTreeNode userColumnCategoryNode
           
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FieldPickerWin(Designer designer, Report report, int startingType)
          Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handles user actions.
protected  void addEditableToTree(FPLeafInfo info, javax.swing.tree.DefaultMutableTreeNode categoryNode)
          Adds a newly created editable object to the tree, makes it visible, and opens its editor.
protected  void addTableNode(javax.swing.tree.DefaultMutableTreeNode categoryNode, Table table)
          Creates and adds a node representing a data source table.
protected  javax.swing.JMenu buildEditMenu()
          Builds and returns the "Edit" menu.
protected  javax.swing.JMenu buildFieldMenu()
          Builds and returns the "Field" menu.
protected  javax.swing.JMenu buildFileMenu()
          Builds and returns the "File" menu.
protected  void buildMenuBar()
          Builds the window menu bar.
protected  void buildWindow(int startingType)
          Builds the contents of the window.
protected  void createAllDatabaseTables(javax.swing.tree.DefaultMutableTreeNode top)
          Creates notes representing tables and columns for all tables in the database.
protected  void createFormulas(javax.swing.tree.DefaultMutableTreeNode top)
          Creates nodes representing formula fields.
protected  void createNodes(javax.swing.tree.DefaultMutableTreeNode top)
          Creates tree nodes.
protected  void createParameters(javax.swing.tree.DefaultMutableTreeNode top)
          Creates nodes representing parameter fields.
protected  void createSpecialFields(javax.swing.tree.DefaultMutableTreeNode top)
          Creates nodes representing each possible special field.
protected  void createUsedDatabaseTables(javax.swing.tree.DefaultMutableTreeNode top)
          Creates nodes representing tables and columns for columns used by report.
protected  void createUserColumns(javax.swing.tree.DefaultMutableTreeNode top)
          Creates nodes representing user column fields.
protected  void editSelection()
          Opens an editor on the currently selected item.
protected  void newFormula()
          Creates a new formula, adds it to the report and the tree, and opens the formula editor.
protected  void newParameter()
          Creates a new parameter, adds it to the report and the tree, and opens the parameter editor.
protected  void newUserColumn()
          Creates a new user column, adds it to the report and the tree, and opens the user column editor.
protected  boolean rename(Nameable nameable, java.lang.String newTitleKey, java.lang.String editTitleKey, java.lang.String promptKey, java.lang.String unnamedKey)
          Opens a name editor to (re)name a nameable object.
protected  boolean renameFormula()
          Opens a name editor to rename the currently select formula.
protected  boolean renameFormula(Formula f)
          Opens a name editor to (re)name a formula.
protected  boolean renameParameter()
          Opens a name editor to rename the currently select parameter.
protected  boolean renameParameter(Parameter p)
          Opens a name editor to (re)name a parameter.
protected  boolean renameUserColumn()
          Opens a name editor to rename the currently select user column.
protected  boolean renameUserColumn(UserColumn f)
          Opens a name editor to (re)name a user column.
 void treeWillCollapse(javax.swing.event.TreeExpansionEvent e)
           
 void treeWillExpand(javax.swing.event.TreeExpansionEvent e)
           
 void update(java.util.Observable o, java.lang.Object arg)
           
 void valueChanged(javax.swing.event.TreeSelectionEvent e)
          Modifies the menu in response to a change in the tree's selection.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setTitle, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REPORT_DATABASE_FIELDS

public static final int REPORT_DATABASE_FIELDS
See Also:
Constant Field Values

FORMULAS

public static final int FORMULAS
See Also:
Constant Field Values

PARAMETERS

public static final int PARAMETERS
See Also:
Constant Field Values

USERCOLS

public static final int USERCOLS
See Also:
Constant Field Values

SPECIAL_FIELDS

public static final int SPECIAL_FIELDS
See Also:
Constant Field Values

ALL_DATABASE_FIELDS

public static final int ALL_DATABASE_FIELDS
See Also:
Constant Field Values

report

protected Report report

designer

protected Designer designer

cutItem

protected javax.swing.JMenuItem cutItem

editFormulaItem

protected javax.swing.JMenuItem editFormulaItem

renameFormulaItem

protected javax.swing.JMenuItem renameFormulaItem

editParameterItem

protected javax.swing.JMenuItem editParameterItem

renameParameterItem

protected javax.swing.JMenuItem renameParameterItem

editUserColumnItem

protected javax.swing.JMenuItem editUserColumnItem

renameUserColumnItem

protected javax.swing.JMenuItem renameUserColumnItem

deleteItem

protected javax.swing.JMenuItem deleteItem

tree

protected FieldPickerTree tree

treeModel

protected javax.swing.tree.DefaultTreeModel treeModel

formulaCategoryNode

protected javax.swing.tree.DefaultMutableTreeNode formulaCategoryNode

parameterCategoryNode

protected javax.swing.tree.DefaultMutableTreeNode parameterCategoryNode

userColumnCategoryNode

protected javax.swing.tree.DefaultMutableTreeNode userColumnCategoryNode

selectedNode

protected javax.swing.tree.DefaultMutableTreeNode selectedNode

selectedInfo

protected FPLeafInfo selectedInfo

nameComparator

protected java.util.Comparator nameComparator
Constructor Detail

FieldPickerWin

FieldPickerWin(Designer designer,
               Report report,
               int startingType)
Constructor.

Parameters:
designer - the design window to which this dialog belongs
report - the report
startingType - the index of the starting type to display
Method Detail

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

buildWindow

protected void buildWindow(int startingType)
Builds the contents of the window.

Parameters:
startingType - the index of the starting type to display

buildMenuBar

protected void buildMenuBar()
Builds the window menu bar.


buildFileMenu

protected javax.swing.JMenu buildFileMenu()
Builds and returns the "File" menu.

Returns:
a menu

buildEditMenu

protected javax.swing.JMenu buildEditMenu()
Builds and returns the "Edit" menu.

Returns:
a menu

buildFieldMenu

protected javax.swing.JMenu buildFieldMenu()
Builds and returns the "Field" menu.

Returns:
a menu

createNodes

protected void createNodes(javax.swing.tree.DefaultMutableTreeNode top)
Creates tree nodes.

Parameters:
top - top-level tree node

createUsedDatabaseTables

protected void createUsedDatabaseTables(javax.swing.tree.DefaultMutableTreeNode top)
Creates nodes representing tables and columns for columns used by report.

Parameters:
top - top-level tree node

createFormulas

protected void createFormulas(javax.swing.tree.DefaultMutableTreeNode top)
Creates nodes representing formula fields.

Parameters:
top - top-level tree node

createParameters

protected void createParameters(javax.swing.tree.DefaultMutableTreeNode top)
Creates nodes representing parameter fields.

Parameters:
top - top-level tree node

createUserColumns

protected void createUserColumns(javax.swing.tree.DefaultMutableTreeNode top)
Creates nodes representing user column fields.

Parameters:
top - top-level tree node

createSpecialFields

protected void createSpecialFields(javax.swing.tree.DefaultMutableTreeNode top)
Creates nodes representing each possible special field.

Parameters:
top - top-level tree node

createAllDatabaseTables

protected void createAllDatabaseTables(javax.swing.tree.DefaultMutableTreeNode top)
Creates notes representing tables and columns for all tables in the database.

Parameters:
top - top-level tree node

addTableNode

protected void addTableNode(javax.swing.tree.DefaultMutableTreeNode categoryNode,
                            Table table)
Creates and adds a node representing a data source table. The node is given one dummy node that will be removed when the table node loads its column nodes.

Parameters:
categoryNode - the parent node
table - the database table

rename

protected boolean rename(Nameable nameable,
                         java.lang.String newTitleKey,
                         java.lang.String editTitleKey,
                         java.lang.String promptKey,
                         java.lang.String unnamedKey)
Opens a name editor to (re)name a nameable object. Returns true if the user clicked OK, false if the user clicked Cancel.

Parameters:
nameable - a nameable object
editTitleKey - I18N lookup key for "edit" title
newTitleKey - I18N lookup key for "new" title
promptKey - I18N lookup key for prompt
unnamedKey - I18N lookup key for "unnamed" name
Returns:
true if the user clicked OK, false if the user clicked Cancel

addEditableToTree

protected void addEditableToTree(FPLeafInfo info,
                                 javax.swing.tree.DefaultMutableTreeNode categoryNode)
Adds a newly created editable object to the tree, makes it visible, and opens its editor.

Parameters:
info - describes what is being added to add to the tree
categoryNode - where in the tree to put the new item

newFormula

protected void newFormula()
Creates a new formula, adds it to the report and the tree, and opens the formula editor.


renameFormula

protected boolean renameFormula()
Opens a name editor to rename the currently select formula. Returns true if the user clicked OK, false if the user clicked Cancel.

Returns:
true if the user clicked OK, false if the user clicked Cancel

renameFormula

protected boolean renameFormula(Formula f)
Opens a name editor to (re)name a formula. Returns true if the user clicked OK, false if the user clicked Cancel.

Parameters:
f - a formula
Returns:
true if the user clicked OK, false if the user clicked Cancel

editSelection

protected void editSelection()
Opens an editor on the currently selected item.


newParameter

protected void newParameter()
Creates a new parameter, adds it to the report and the tree, and opens the parameter editor.


renameParameter

protected boolean renameParameter()
Opens a name editor to rename the currently select parameter. Returns true if the user clicked OK, false if the user clicked Cancel.

Returns:
true if the user clicked OK, false if the user clicked Cancel

renameParameter

protected boolean renameParameter(Parameter p)
Opens a name editor to (re)name a parameter. Returns true if the user clicked OK, false if the user clicked Cancel.

Parameters:
p - a parameter
Returns:
true if the user clicked OK, false if the user clicked Cancel

newUserColumn

protected void newUserColumn()
Creates a new user column, adds it to the report and the tree, and opens the user column editor.


renameUserColumn

protected boolean renameUserColumn()
Opens a name editor to rename the currently select user column. Returns true if the user clicked OK, false if the user clicked Cancel.

Returns:
true if the user clicked OK, false if the user clicked Cancel

renameUserColumn

protected boolean renameUserColumn(UserColumn f)
Opens a name editor to (re)name a user column. Returns true if the user clicked OK, false if the user clicked Cancel.

Parameters:
f - a user column
Returns:
true if the user clicked OK, false if the user clicked Cancel

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handles user actions. Actions are only allowed when legal. For example, the "Cut" menu item will only be enabled when a delete operation is possible.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent e)
Modifies the menu in response to a change in the tree's selection.

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

treeWillExpand

public void treeWillExpand(javax.swing.event.TreeExpansionEvent e)
Specified by:
treeWillExpand in interface javax.swing.event.TreeWillExpandListener

treeWillCollapse

public void treeWillCollapse(javax.swing.event.TreeExpansionEvent e)
Specified by:
treeWillCollapse in interface javax.swing.event.TreeWillExpandListener