com.gridsystems.config.tools.swing
Class BasePanel

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 com.gridsystems.config.tools.swing.BasePanel
All Implemented Interfaces:
ConfiguratorView, SwingConfiguratorView, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
Direct Known Subclasses:
JVMSwingView, TomcatSwingView

public class BasePanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener, java.awt.event.FocusListener, java.beans.PropertyChangeListener, SwingConfiguratorView

Panel Extension for Swing Configuration Views. It adds some common functionalities, like:

Version:
1.0
Author:
Rodrigo Ruiz Aguayo
See Also:
Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
BasePanel(Configurator config)
          Creates a new instance.
BasePanel(java.awt.LayoutManager layout, Configurator config)
          Creates a new instance with the specified layout.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          If the event source is a button that is "guarding" a component set, it synchronizes the "enabled" state of the component set with the "selected" state of the source button.
 void addChangeListener(javax.swing.event.ChangeListener listener)
          Adds a change listener to the listener list of this panel.
 void focusGained(java.awt.event.FocusEvent e)
          
 void focusLost(java.awt.event.FocusEvent e)
          
 java.util.ResourceBundle getBundle()
          Sets the bundle used by this instance.
 javax.swing.JComponent getComponent()
          Gets a Swing component for visual edition.
 Configurator getConfigurator()
          Gets the configurator this view is associated to.
 javax.swing.Icon getIcon()
          Gets an icon instance for displaying on the view panel topright side.
 javax.swing.Icon getSmallIcon()
          Gets an icon instance for displaying on the menu tree node.
 java.lang.String getString(java.lang.String key)
          Gets a localized string.
 java.lang.String getString(java.lang.String key, java.lang.Object[] params)
          Gets a localized string, using the found string as a pattern to be used by a MessageFormat instance.
 java.lang.String getSubtitle()
          Gets the subtitle of this view.
 java.lang.String getTitle()
          Gets the title of this view.
 void getValues(ConfiguratorModel model)
          Copies the model values into this view fields.
 boolean hasErrors()
          Gets if the view contains any error.
 boolean isModified()
          Gets if a change has been detected on the view.
 void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
          Manages a PropertyChangeEvent.
 void setBundle(java.util.ResourceBundle bundle)
          Sets the bundle to be used by this instance.
 void setBundle(java.lang.String name)
          Sets the name of the bundle to be used by this instance.
protected  void setGuarded(javax.swing.AbstractButton btn, javax.swing.JComponent[] guarded)
          Registers btn as a "enabled" guard for the components in "guarded".
 void setIcon(javax.swing.Icon icon)
          Sets the icon.
protected  void setModified(java.lang.Object src, boolean flag)
          Sets the "isModified" flag, and notifies all registered change listeners.
 void setSmallIcon(javax.swing.Icon icon)
          Sets the small icon.
 void setValues(ConfiguratorModel model)
          Copies this view field values into the destination model.
protected  void watch(javax.swing.JComboBox field)
          Registers itself as interested in changes in the specified combo box.
protected  void watch(javax.swing.JTextField field)
          Registers itself as interested in changes in the specified text field.
protected  void watch(PopupTextField field)
          Registers itself as interested in changes in the specified text field.
 
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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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, 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
 

Constructor Detail

BasePanel

public BasePanel(Configurator config)
Creates a new instance.

Parameters:
config - The configurator this view is associated to

BasePanel

public BasePanel(java.awt.LayoutManager layout,
                 Configurator config)
Creates a new instance with the specified layout.

Parameters:
layout - The layout for this instance
config - The configurator this view is associated to
Method Detail

setBundle

public void setBundle(java.lang.String name)
Sets the name of the bundle to be used by this instance.

Parameters:
name - The name of the resource bundle

setBundle

public void setBundle(java.util.ResourceBundle bundle)
Sets the bundle to be used by this instance.

Parameters:
bundle - The resource bundle

getBundle

public java.util.ResourceBundle getBundle()
Sets the bundle used by this instance.

Returns:
the ResourceBundle used to get the internationalizated messages.

getConfigurator

public Configurator getConfigurator()
Gets the configurator this view is associated to.

Specified by:
getConfigurator in interface ConfiguratorView
Returns:
The configurator

getIcon

public javax.swing.Icon getIcon()
Gets an icon instance for displaying on the view panel topright side. Its recommended size is 55 x 55 pixels

Specified by:
getIcon in interface SwingConfiguratorView
Returns:
An icon for the view

setIcon

public void setIcon(javax.swing.Icon icon)
Sets the icon.

Parameters:
icon - The icon

getSmallIcon

public javax.swing.Icon getSmallIcon()
Gets an icon instance for displaying on the menu tree node. Its recommended size is 18 x 18 pixels

Specified by:
getSmallIcon in interface SwingConfiguratorView
Returns:
An icon for the menu tree

setSmallIcon

public void setSmallIcon(javax.swing.Icon icon)
Sets the small icon.

Parameters:
icon - The small icon

getComponent

public javax.swing.JComponent getComponent()
Gets a Swing component for visual edition.

Specified by:
getComponent in interface SwingConfiguratorView
Returns:
A Swing component

getTitle

public java.lang.String getTitle()
Gets the title of this view. It will normally be the same as the configurator name, but it can change on some implementations.

Specified by:
getTitle in interface ConfiguratorView
Returns:
This view title

getSubtitle

public java.lang.String getSubtitle()
Gets the subtitle of this view. It can contain a short description of the configurator.

Specified by:
getSubtitle in interface ConfiguratorView
Returns:
This view subtitle

getValues

public void getValues(ConfiguratorModel model)
Copies the model values into this view fields.

Specified by:
getValues in interface ConfiguratorView
Parameters:
model - The source model

setValues

public void setValues(ConfiguratorModel model)
Copies this view field values into the destination model.

This copy should not involve validation or persistence storage, as these actions will be performed later.

Specified by:
setValues in interface ConfiguratorView
Parameters:
model - The destination model

getString

public java.lang.String getString(java.lang.String key)
Gets a localized string.

Parameters:
key - The i18n key
Returns:
The localized string, or null if none found for key
Throws:
java.lang.NullPointerException - if the bundle is not set

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.Object[] params)
Gets a localized string, using the found string as a pattern to be used by a MessageFormat instance.

Parameters:
key - The key for the localized pattern
params - The parameters for pattern substitution
Returns:
The localized / formatter string
Throws:
java.lang.NullPointerException - if the bundle is not set

isModified

public boolean isModified()
Gets if a change has been detected on the view.

Specified by:
isModified in interface SwingConfiguratorView
Returns:
true if a change has been detected on this view, false otherwise

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)
Adds a change listener to the listener list of this panel.

Specified by:
addChangeListener in interface SwingConfiguratorView
Parameters:
listener - The listener to add

setModified

protected void setModified(java.lang.Object src,
                           boolean flag)
Sets the "isModified" flag, and notifies all registered change listeners.

Parameters:
src - The event source, for listeners notification
flag - The new value of the flag

watch

protected void watch(javax.swing.JTextField field)
Registers itself as interested in changes in the specified text field.

Parameters:
field - The text field to listen

watch

protected void watch(PopupTextField field)
Registers itself as interested in changes in the specified text field.

Parameters:
field - The text field to listen

watch

protected void watch(javax.swing.JComboBox field)
Registers itself as interested in changes in the specified combo box.

Parameters:
field - the combo box field to listen

setGuarded

protected void setGuarded(javax.swing.AbstractButton btn,
                          javax.swing.JComponent[] guarded)
Registers btn as a "enabled" guard for the components in "guarded". The state of guarded components will be synchronized with the selection state of btn.

Parameters:
btn - The guarding button
guarded - The list of components

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
If the event source is a button that is "guarding" a component set, it synchronizes the "enabled" state of the component set with the "selected" state of the source button.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The event containing the event source

focusGained

public void focusGained(java.awt.event.FocusEvent e)

Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)

Specified by:
focusLost in interface java.awt.event.FocusListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
Manages a PropertyChangeEvent. Manages a PropertyChangeEvent. It uses the input verifier (if any) from the source object to check the new value. If it is not valid, the old value is set again to the component.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
propertyChangeEvent - a propertyChangeEvent with the information of the event.

hasErrors

public boolean hasErrors()
Gets if the view contains any error.

Specified by:
hasErrors in interface ConfiguratorView
Returns:
true if there is any error in the view


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.