Class DataTypeSelectionEditor
- All Implemented Interfaces:
Serializable
,CellEditor
DropDownSelectionTextField
for the entering of
data types by name and offers the user of a completion window. This editor also provides a
browse button that when pressed will show a data type tree so that the user may browse a tree
of known data types.
The typical usage of this class is in conjunction with the DataTypeChooserDialog
. The
dialog uses this editor as part of its DataType selection process. Users seeking a dialog
that allows users to choose DataTypes are encouraged to use that dialog. If you wish to add
this editor to a widget directly, then see below.
Stand Alone Usage
In order to use this component directly you need to call getEditorComponent()
. This
will give you a Component for editing.
In order to know when changes are made to the component you need to add a DocumentListener
via the addDocumentListener(DocumentListener)
method. The added listener will be
notified as the user enters text into the editor's text field. Then, to determine when there
is as valid DataType in the field you may call validateUserSelection()
.
- See Also:
-
Field Summary
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList
-
Constructor Summary
ConstructorsConstructorDescriptionDataTypeSelectionEditor
(DataTypeManager dtm, DataTypeManagerService service, DataTypeParser.AllowedDataTypes allowedDataTypes) Creates a new instance.DataTypeSelectionEditor
(DataTypeManager dtm, ServiceProvider serviceProvider, DataTypeParser.AllowedDataTypes allowedDataTypes) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDocumentListener
(DocumentListener listener) Adds a document listener to the text field editing component of this editor so that users can be notified when the text contents of the editor change.void
addFocusListener
(FocusListener listener) boolean
protected DropDownSelectionTextField
<DataType> Returns the text value of the editor's text field.Returns the component that allows the user to edit.Returns the direction of the user triggered navigation; null if the user did not trigger navigation out of this component.void
removeDocumentListener
(DocumentListener listener) Removes a previously added document listener.void
removeFocusListener
(FocusListener listener) void
void
setCellEditorValue
(DataType dataType) Sets the value to be edited on this cell editor.void
void
setConsumeEnterKeyPress
(boolean consume) Sets whether this editor should consumer Enter key pressesvoid
Sets the initially selected node in the data type tree that the user can choose to show.void
setTabCommitsEdit
(boolean doesCommit) boolean
Returns true if the current value of the data type editor is a know data type.Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
-
Constructor Details
-
DataTypeSelectionEditor
public DataTypeSelectionEditor(DataTypeManager dtm, ServiceProvider serviceProvider, DataTypeParser.AllowedDataTypes allowedDataTypes) Creates a new instance.- Parameters:
dtm
- the preferredDataTypeManager
. Extra copies of data types that are already in the preferred DTM will be suppressed.serviceProvider
-ServiceProvider
allowedDataTypes
-DataTypeParser.AllowedDataTypes
option enum, controls what kind of data types that will be shown
-
DataTypeSelectionEditor
public DataTypeSelectionEditor(DataTypeManager dtm, DataTypeManagerService service, DataTypeParser.AllowedDataTypes allowedDataTypes) Creates a new instance.- Parameters:
dtm
- the preferredDataTypeManager
. Extra copies of data types that are already in the preferred DTM will be suppressed.service
-DataTypeManagerService
allowedDataTypes
-DataTypeParser.AllowedDataTypes
option enum, controls what kind of data types that will be shown
-
-
Method Details
-
setConsumeEnterKeyPress
public void setConsumeEnterKeyPress(boolean consume) Sets whether this editor should consumer Enter key presses- Parameters:
consume
- true to consume- See Also:
-
createDropDownSelectionTextField
protected DropDownSelectionTextField<DataType> createDropDownSelectionTextField(DataTypeDropDownSelectionDataModel model) -
getCellEditorValue
-
getCellEditorValueAsDataType
-
getCellEditorValueAsText
Returns the text value of the editor's text field.- Returns:
- the text value of the editor's text field.
-
getEditorComponent
Returns the component that allows the user to edit.- Returns:
- the component that allows the user to edit.
-
getDropDownTextField
-
getBrowseButton
-
setDefaultSelectedTreePath
Sets the initially selected node in the data type tree that the user can choose to show.- Parameters:
path
- The path to set
-
requestFocus
public void requestFocus() -
setCellEditorValue
Sets the value to be edited on this cell editor.- Parameters:
dataType
- The data type which is to be edited.
-
setCellEditorValueAsText
-
addDocumentListener
Adds a document listener to the text field editing component of this editor so that users can be notified when the text contents of the editor change. You may verify whether the text changes represent a valid DataType by callingvalidateUserSelection()
.- Parameters:
listener
- the listener to add.- See Also:
-
removeDocumentListener
Removes a previously added document listener.- Parameters:
listener
- the listener to remove.
-
addFocusListener
-
removeFocusListener
-
setTabCommitsEdit
public void setTabCommitsEdit(boolean doesCommit) -
validateUserSelection
Returns true if the current value of the data type editor is a know data type.- Returns:
- true if the current value of the data type editor is a know data type.
- Throws:
InvalidDataTypeException
- If the current text in the editor's text field could not be parsed into a valid DataType
-
containsValidDataType
public boolean containsValidDataType()
-