org.openbp.jaspira.propertybrowser.editor.standard
Class SelectionEditor

java.lang.Object
  extended by org.openbp.jaspira.propertybrowser.editor.AbstractPropertyEditor
      extended by org.openbp.jaspira.propertybrowser.editor.standard.SelectionEditor
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.KeyListener, java.lang.Cloneable, java.util.EventListener, javax.swing.event.DocumentListener, Copyable, PropertyEditor, PopupListener

public class SelectionEditor
extends AbstractPropertyEditor
implements java.awt.event.ActionListener, PopupListener, javax.swing.event.DocumentListener

A property editor for collection of strings, displayed in a combo box. The combo box by default is NOT editable, unless otherwise specified in the XML property file assigned to the specified object.

Author:
Erich Lauterbach

Field Summary
 
Fields inherited from class org.openbp.jaspira.propertybrowser.editor.AbstractPropertyEditor
component, listener, object, owner, parameterParser, params, propertyBrowser, propertyName, readonly, validator, value, valueChanged, valueLoaded
 
Fields inherited from interface org.openbp.common.generic.Copyable
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW
 
Constructor Summary
SelectionEditor()
          Default constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Action performed.
 void addSelectionValue(DescriptionObject selectionValue)
          Adds a selection value.
 void addSelectionValue(java.lang.String selectionName)
          Adds a selection value.
 void addSelectionValue(java.lang.String selectionName, java.lang.String selectionValue)
          Adds a selection value.
 void changedUpdate(javax.swing.event.DocumentEvent e)
          Gives notification that an attribute or set of attributes changed.
 void clearSelectionValues()
          Clears the list of combo box values.
 void createComponent()
          Creates the editor component of the property editor.
 java.lang.Object getComponentValue()
          Gets the current editor component value.
 int getNumberOfSelectionValues()
          Gets the number of selection values.
 DescriptionObject getSelectionValueAt(int index)
          Gets a selection value by its collection index.
 java.util.List getSelectionValueList()
          Gets the list of combo box values.
 java.util.Iterator getSelectionValues()
          Gets the list of combo box values.
 void highlight(boolean on)
          Highlights the content of the component.
 void insertUpdate(javax.swing.event.DocumentEvent e)
          Gives notification that there was an insert into the document.
 boolean isEditable()
          Gets the editable flag.
 void keyPressed(java.awt.event.KeyEvent e)
          Invoked when a key has been pressed.
protected  void parseParams(EditorParameterParser parser)
          Parses the editor parameters specified in the property descriptor.
 void popupStateChanged(PopupEvent e)
           
 void removeUpdate(javax.swing.event.DocumentEvent e)
          Gives notification that a portion of the document has been removed.
 void setComponentValue()
          Sets the display component value.
 void setEditable(boolean editable)
          Sets the editable flag.
 void setSelectionValueList(java.util.List selectionValueList)
          Sets the list of combo box values.
 
Methods inherited from class org.openbp.jaspira.propertybrowser.editor.AbstractPropertyEditor
clone, copyFrom, focusGained, focusLost, forwardKeyEvent, getComponent, getObject, getOwner, getParameterParser, getParams, getPropertyBrowser, getPropertyComponent, getPropertyName, getSafeString, getValidator, getValue, initialize, initializeComponent, isReadonly, keyReleased, keyTyped, loadProperty, propertyChanged, resetComponentDisplay, resetProperty, saveProperty, setObject, setOwner, setParams, setPropertyBrowser, setPropertyName, setReadonly, setValidator, setValue, validateProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectionEditor

public SelectionEditor()
Default constructor.

Method Detail

parseParams

protected void parseParams(EditorParameterParser parser)
Parses the editor parameters specified in the property descriptor.

Overrides:
parseParams in class AbstractPropertyEditor
Parameters:
parser - Editor parameter parser or null if there are no parameters defined

createComponent

public void createComponent()
Creates the editor component of the property editor.

Specified by:
createComponent in class AbstractPropertyEditor

setComponentValue

public void setComponentValue()
Sets the display component value.

Specified by:
setComponentValue in class AbstractPropertyEditor

getComponentValue

public java.lang.Object getComponentValue()
Gets the current editor component value.

Specified by:
getComponentValue in class AbstractPropertyEditor
Returns:
The current value of the component (can be null)
Note that this value might be different from the actual property value if the property hasn't been saved yet.

highlight

public void highlight(boolean on)
Highlights the content of the component.

Overrides:
highlight in class AbstractPropertyEditor
Parameters:
on - true Turns the highlight on if the component has the focus
false Turns the highlight off

isEditable

public boolean isEditable()
Gets the editable flag.


setEditable

public void setEditable(boolean editable)
Sets the editable flag.


getSelectionValues

public java.util.Iterator getSelectionValues()
Gets the list of combo box values.

Returns:
An iterator of DescriptionObject objects
The description member (or the name member if not present) is presented to the user, the name member will be stored in the property the editor operates on.

getNumberOfSelectionValues

public int getNumberOfSelectionValues()
Gets the number of selection values.

Returns:
The number of selection values in the collection

getSelectionValueAt

public DescriptionObject getSelectionValueAt(int index)
Gets a selection value by its collection index.

Parameters:
index - Collection index (must be in the range [0..getNumberOfSelectionValues()]
Returns:
The selection value
The description member (or the name member if not present) is presented to the user, the name member will be stored in the property the editor operates on.

addSelectionValue

public void addSelectionValue(java.lang.String selectionName,
                              java.lang.String selectionValue)
Adds a selection value.

Parameters:
selectionName - The name of the selection
selectionValue - The selection value to add

addSelectionValue

public void addSelectionValue(java.lang.String selectionName)
Adds a selection value.

Parameters:
selectionName - The name and value of the selection

addSelectionValue

public void addSelectionValue(DescriptionObject selectionValue)
Adds a selection value.

Parameters:
selectionValue - The selection value to add

clearSelectionValues

public void clearSelectionValues()
Clears the list of combo box values.


getSelectionValueList

public java.util.List getSelectionValueList()
Gets the list of combo box values.

Returns:
A list of DescriptionObject objects or null
The description member (or the name member if not present) is presented to the user, the name member will be stored in the property the editor operates on.

setSelectionValueList

public void setSelectionValueList(java.util.List selectionValueList)
Sets the list of combo box values.

Parameters:
selectionValueList - A list of DescriptionObject objects or null
The description member (or the name member if not present) is presented to the user, the name member will be stored in the property the editor operates on.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Action performed.

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

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent e)
Gives notification that there was an insert into the document. The range given by the DocumentEvent bounds the freshly inserted region.

Specified by:
insertUpdate in interface javax.swing.event.DocumentListener
Parameters:
e - Document event

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent e)
Gives notification that a portion of the document has been removed. The range is given in terms of what the view last saw (that is, before updating sticky positions).

Specified by:
removeUpdate in interface javax.swing.event.DocumentListener
Parameters:
e - Document event

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent e)
Gives notification that an attribute or set of attributes changed.

Specified by:
changedUpdate in interface javax.swing.event.DocumentListener
Parameters:
e - Document event

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Invoked when a key has been pressed.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Overrides:
keyPressed in class AbstractPropertyEditor

popupStateChanged

public void popupStateChanged(PopupEvent e)
Specified by:
popupStateChanged in interface PopupListener
See Also:
(PopupEvent)


Copyright © 2011. All Rights Reserved.