net.sf.sdedit.ui.components.configuration
Class Configurator<T,C extends DataObject>
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
net.sf.sdedit.ui.components.configuration.Configurator<T,C>
- Type Parameters:
C - the type of the data object to be configuredT - the type of the property to be configured
- All Implemented Interfaces:
- ActionListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible
- Direct Known Subclasses:
- BooleanConfigurator, ColorConfigurator, FileConfigurator, FontConfigurator, NumberConfigurator, StringConfigurator
public abstract class Configurator<T,C extends DataObject>
- extends JPanel
- implements PropertyChangeListener, ActionListener
An abstract base class for the components used by
ConfigurationUI for configuring properties of a
Bean.
- Author:
- Markus Strauch
- See Also:
- Serialized Form
|
Method Summary |
protected abstract void |
_actionPerformed(ActionEvent evt)
Change the underlying bean such that the it is consistent with the value
displayed by this Configurator. |
protected abstract void |
_setEnabled(boolean enabled)
|
void |
actionPerformed(ActionEvent e)
|
protected void |
applyValue(T value)
Applies the given value, which means that the property that this
Configurator configures is set to the value. |
protected Adjustable |
getAdjustable()
|
Bean<C> |
getBean()
Returns the underlying Bean, of which a property is
configured by this Configurator. |
int |
getLabelWidth()
|
protected abstract T |
getNullValue()
Returns a non-null value that is used as a replacement when a property
has the value null. |
PropertyDescriptor |
getProperty()
Returns the PropertyDescriptor for the particular property
that is being configured. |
protected T |
getValue()
Returns the current value of the underlying property, or the non-null
getNullValue() if the property has the value null. |
boolean |
isDependencySatisfied()
Returns true if there is no boolean property that the configurability of
the property managed by this Configurator depends on, or if
there is such a boolean property that is set true. |
void |
propertyChange(PropertyChangeEvent evt)
This method is called by the underlying Bean when one of its
properties changes. |
void |
refresh()
Changes the component(s) used for configuration such that the current
value of the property is reflected |
protected abstract void |
refresh(T value)
Changes the components for configuring the property such that they
reflect the given value. |
void |
setBean(Bean<C> bean)
|
void |
setEnabled(boolean enabled)
|
void |
setLabelWidth(int width)
|
void |
setToolTipText(String tooltip)
|
| 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, 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 |
Configurator
protected Configurator(Bean<C> bean,
PropertyDescriptor property)
getLabelWidth
public int getLabelWidth()
setLabelWidth
public void setLabelWidth(int width)
refresh
protected abstract void refresh(T value)
- Changes the components for configuring the property such that they
reflect the given value.
- Parameters:
value - the current value of the property
getNullValue
protected abstract T getNullValue()
- Returns a non-null value that is used as a replacement when a property
has the value null.
- Returns:
- a non-null value that is used as a replacement when a property
has the value null
isDependencySatisfied
public boolean isDependencySatisfied()
- Returns true if there is no boolean property that the configurability of
the property managed by this Configurator depends on, or if
there is such a boolean property that is set true.
- Returns:
- flag denoting if the boolean property the configurability depends
on is true
setBean
public void setBean(Bean<C> bean)
getBean
public Bean<C> getBean()
- Returns the underlying Bean, of which a property is
configured by this Configurator.
- Returns:
- the underlying Bean, of which a property is
configured by this Configurator
getProperty
public PropertyDescriptor getProperty()
- Returns the PropertyDescriptor for the particular property
that is being configured.
- Returns:
- the PropertyDescriptor for the particular property
that is being configured
refresh
public void refresh()
- Changes the component(s) used for configuration such that the current
value of the property is reflected
propertyChange
public void propertyChange(PropertyChangeEvent evt)
- This method is called by the underlying Bean when one of its
properties changes. If that property is the one that is configured by
this Configurator, we call refresh(Object) with
the new value as a parameter, so it is graphically reflected.
We always check if the dependency of this Configurator is
satisfied, i. e. we disable/enable it, depending on the state of the
property it depends on.
- Specified by:
propertyChange in interface PropertyChangeListener
- Parameters:
evt - encapsulates the property change
applyValue
protected void applyValue(T value)
- Applies the given value, which means that the property that this
Configurator configures is set to the value.
- Parameters:
value - the value to be applied
getValue
protected T getValue()
- Returns the current value of the underlying property, or the non-null
getNullValue() if the property has the value null.
- Returns:
- the current value of the underlying property, or the non-null
getNullValue() if the property has the value
null
setEnabled
public void setEnabled(boolean enabled)
- Overrides:
setEnabled in class JComponent
setToolTipText
public void setToolTipText(String tooltip)
- Overrides:
setToolTipText in class JComponent
actionPerformed
public void actionPerformed(ActionEvent e)
- Specified by:
actionPerformed in interface ActionListener
getAdjustable
protected Adjustable getAdjustable()
_actionPerformed
protected abstract void _actionPerformed(ActionEvent evt)
- Change the underlying bean such that the it is consistent with the value
displayed by this Configurator.
- Parameters:
evt -
_setEnabled
protected abstract void _setEnabled(boolean enabled)
Copyright © 2011. All Rights Reserved.