Package nz.ac.waikato.cms.gui.core
Class PropertiesParameterPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
nz.ac.waikato.cms.gui.core.BasePanel
nz.ac.waikato.cms.gui.core.PropertiesParameterPanel
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible
Displays all properties in a props file as parameters (alphabetically
sorted if no custom order for properties provided).
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe various data types a property can have.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intthe default width for choosers.protected HashMap<String,PropertiesParameterPanel.PropertyType> the actual property/property type relation.protected JButtonthe load props button.protected JButtonthe save props button.protected HashMap<String,AbstractChooserPanel> the property/chooser relation.the property/component relation.protected BaseFileChooserthe filechooser for loading/saving properties.the property/help relation.the identifiers of the property.the property/label relation.the property/lists relation.the custom order for the properties.protected JPanelthe panel for the buttons.protected ParameterPanelthe panel for the properties.protected HashMap<String,PropertiesParameterPanel.PropertyType> the property/property type relation.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the change listener.voidaddProperty(String identifier, String label, Component comp) Adds a property.voidaddProperty(String identifier, String label, AbstractChooserPanel chooser) Adds the chooser panel at the end.voidaddPropertyType(String property, PropertiesParameterPanel.PropertyType type) Associates the property type with the specified property.protected voidRemoves all properties.voidRemoves all property/property type relations.protected voidfinishes the initialization.protected PropertiesParameterPanel.PropertyTypeMakes sure that the specified property type can be actually displayed.getActualPropertyType(String property) Checks whether a property type has been specified for a particular property.getChooser(String property) Returns the chooser associated with a particular property.getComponent(String property) Returns the custom component associated with a particular property.protected BaseFileChooserReturns the file chooser to use for loading/saving of props files.Returns the help associated with a particular property.Returns the label associated with a particular property.String[]Returns the list associated with a particular property.Returns the currently display properties as a properties object.getProperty(int index) Returns the component at the specified location.getProperty(String identifier) Returns the component associated with the identifier.intReturns the number of properties currently displayed.Returns the order for the properties.getPropertyType(String property) Checks whether a property type has been specified for a particular property.protected StringReturns the text from the component.booleanhasChooser(String property) Checks whether a chooser has been specified for a particular property.booleanhasComponent(String property) Checks whether a custom component has been specified for a particular property.booleanChecks whether a help has been specified for a particular property.booleanChecks whether a label has been specified for a particular property.booleanChecks whether a list has been specified for a particular property.booleanhasPropertyType(String property) Checks whether a property type has been specified for a particular property.protected voidinitGUI()For initializing the GUI.protected voidInitializes the members.booleanReturns the visibility state of the buttons panel (load/save).protected voidLoads properties from a file, prompts the user to select props file.voidRemoves the change listener.protected voidSaves properties to a file, prompts the user to select props file.voidsetButtonPanelVisible(boolean value) Sets the visibility state of the buttons panel (load/save).voidsetChooser(String property, AbstractChooserPanel value) Associates the chooser with a particular property.voidsetComponent(String property, Component value) Associates the custom component with a particular property.\ Must have setText(String) and getText() methods!voidAssociates the help with a particular property.voidAssociates the label with a particular property.voidAssociates the list with a particular property.voidsetProperties(Properties value) Sets the properties to base the properties on.voidsetPropertyOrder(String[] value) Sets the order for the properties.voidsetPropertyOrder(List<String> value) Sets the order for the properties.protected voidUpdates the text of the component.protected voidupdateToolTipText(Component comp, String help) Updates the tool tip.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
DEFAULT_WIDTH_CHOOSERS
public static final int DEFAULT_WIDTH_CHOOSERSthe default width for choosers.- See Also:
-
m_PanelProperties
the panel for the properties. -
m_Identifiers
the identifiers of the property. -
m_PropertyTypes
the property/property type relation. -
m_ActualPropertyTypes
the actual property/property type relation. -
m_Choosers
the property/chooser relation. -
m_Lists
the property/lists relation. -
m_Help
the property/help relation. -
m_Label
the property/label relation. -
m_Component
the property/component relation. -
m_Order
the custom order for the properties. -
m_PanelButtons
the panel for the buttons. -
m_ButtonLoad
the load props button. -
m_ButtonSave
the save props button. -
m_FileChooser
the filechooser for loading/saving properties.
-
-
Constructor Details
-
PropertiesParameterPanel
public PropertiesParameterPanel()
-
-
Method Details
-
initialize
protected void initialize()Initializes the members.- Overrides:
initializein classBasePanel
-
initGUI
protected void initGUI()For initializing the GUI. -
finishInit
protected void finishInit()finishes the initialization.- Overrides:
finishInitin classBasePanel
-
clearPropertyTypes
public void clearPropertyTypes()Removes all property/property type relations. -
clearProperties
protected void clearProperties()Removes all properties. -
addProperty
Adds a property.- Parameters:
identifier- the unique identifier of the propertylabel- the label to add, the mnemonic to use is preceded by "_"comp- the component to add- Throws:
IllegalArgumentException- if the identifier already exists
-
addProperty
Adds the chooser panel at the end.- Parameters:
identifier- the unique identifier of the propertylabel- the label to add, the mnemonic to use is preceded by "_"chooser- the chooser panel to add- Throws:
IllegalArgumentException- if the identifier already exists
-
getProperty
Returns the component at the specified location.- Parameters:
index- the index of the specified location- Returns:
- the component at the position
-
getProperty
Returns the component associated with the identifier.- Parameters:
identifier- the identifier of the property to return- Returns:
- the associated component, null if none found
-
getPropertyCount
public int getPropertyCount()Returns the number of properties currently displayed.- Returns:
- the number of properties
-
addPropertyType
Associates the property type with the specified property.- Parameters:
property- the property to associate a type withtype- the property type
-
hasPropertyType
Checks whether a property type has been specified for a particular property.- Parameters:
property- the property to associate a type with- Returns:
- true if a type has been specified
-
getPropertyType
Checks whether a property type has been specified for a particular property.- Parameters:
property- the property to associate a type with- Returns:
- true if a type has been specified
-
getActualPropertyType
Checks whether a property type has been specified for a particular property.- Parameters:
property- the property to associate a type with- Returns:
- true if a type has been specified
-
setPropertyOrder
Sets the order for the properties.- Parameters:
value- the ordered property names
-
setPropertyOrder
Sets the order for the properties.- Parameters:
value- the ordered property names
-
getPropertyOrder
Returns the order for the properties.- Returns:
- the ordered property names
-
hasChooser
Checks whether a chooser has been specified for a particular property.- Parameters:
property- the property check- Returns:
- true if a chooser has been specified
-
setChooser
Associates the chooser with a particular property.- Parameters:
property- the property to associate the chooser withvalue- the chooser to use
-
getChooser
Returns the chooser associated with a particular property.- Parameters:
property- the property to get the chooser for- Returns:
- the chooser, null if none available
-
hasComponent
Checks whether a custom component has been specified for a particular property.- Parameters:
property- the property check- Returns:
- true if a custom component has been specified
-
setComponent
Associates the custom component with a particular property.\ Must have setText(String) and getText() methods!- Parameters:
property- the property to associate the chooser withvalue- the custom component to use
-
getComponent
Returns the custom component associated with a particular property.- Parameters:
property- the property to get the chooser for- Returns:
- the custom component, null if none available
-
hasList
Checks whether a list has been specified for a particular property.- Parameters:
property- the property check- Returns:
- true if a list has been specified
-
setList
Associates the list with a particular property.- Parameters:
property- the property to associate the list withvalue- the list to use
-
getList
Returns the list associated with a particular property.- Parameters:
property- the property to get the list for- Returns:
- the list, null if none available
-
hasHelp
Checks whether a help has been specified for a particular property.- Parameters:
property- the property check- Returns:
- true if a help has been specified
-
setHelp
Associates the help with a particular property.- Parameters:
property- the property to associate the help withvalue- the help to use
-
getHelp
Returns the help associated with a particular property.- Parameters:
property- the property to get the help for- Returns:
- the help, null if none available
-
hasLabel
Checks whether a label has been specified for a particular property.- Parameters:
property- the property check- Returns:
- true if a label has been specified
-
setLabel
Associates the label with a particular property.- Parameters:
property- the property to associate the label withvalue- the label to use
-
getLabel
Returns the label associated with a particular property.- Parameters:
property- the property to get the label for- Returns:
- the label, null if none available
-
fixPropertyType
protected PropertiesParameterPanel.PropertyType fixPropertyType(String key, PropertiesParameterPanel.PropertyType type) Makes sure that the specified property type can be actually displayed.- Parameters:
key- the propertytype- the type- Returns:
- the (potentially) fixed type
-
updateToolTipText
Updates the tool tip.- Parameters:
comp- the component to updatehelp- the tip text to use
-
setText
Updates the text of the component.- Parameters:
comp- the component to updatetext- the text to set
-
getText
Returns the text from the component.- Parameters:
comp- the component to get the text from- Returns:
- the obtained text
-
setProperties
Sets the properties to base the properties on.- Parameters:
value- the properties to use
-
getProperties
Returns the currently display properties as a properties object.- Returns:
- the properties
-
getFileChooser
Returns the file chooser to use for loading/saving of props files.- Returns:
- the file chooser
-
loadProperties
protected void loadProperties()Loads properties from a file, prompts the user to select props file. -
saveProperties
protected void saveProperties()Saves properties to a file, prompts the user to select props file. -
setButtonPanelVisible
public void setButtonPanelVisible(boolean value) Sets the visibility state of the buttons panel (load/save).- Parameters:
value- true if to show buttons
-
isButtonPanelVisible
public boolean isButtonPanelVisible()Returns the visibility state of the buttons panel (load/save).- Returns:
- true if buttons displayed
-
addChangeListener
Adds the change listener.- Parameters:
l- the change listener
-
removeChangeListener
Removes the change listener.- Parameters:
l- the change listener
-