Class DataTypeSelectionEditor
- java.lang.Object
-
- javax.swing.AbstractCellEditor
-
- ghidra.app.util.datatype.DataTypeSelectionEditor
-
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.CellEditor
public class DataTypeSelectionEditor extends javax.swing.AbstractCellEditor
An editor that is used to show theDropDownSelectionTextField
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 callgetEditorComponent()
. 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 callvalidateUserSelection()
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DataTypeSelectionEditor(DataTypeManagerService service, int maxSize, DataTypeParser.AllowedDataTypes allowedDataTypes)
DataTypeSelectionEditor(ServiceProvider serviceProvider, int maxSize, DataTypeParser.AllowedDataTypes allowedDataTypes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDocumentListener(javax.swing.event.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(java.awt.event.FocusListener listener)
boolean
containsValidDataType()
javax.swing.JButton
getBrowseButton()
java.lang.Object
getCellEditorValue()
DataType
getCellEditorValueAsDataType()
java.lang.String
getCellEditorValueAsText()
Returns the text value of the editor's text field.DropDownSelectionTextField<DataType>
getDropDownTextField()
javax.swing.JComponent
getEditorComponent()
Returns the component that allows the user to edit.NavigationDirection
getNavigationDirection()
Returns the direction of the user triggered navigation; null if the user did not trigger navigation out of this component.void
removeDocumentListener(javax.swing.event.DocumentListener listener)
Removes a previously added document listener.void
removeFocusListener(java.awt.event.FocusListener listener)
void
requestFocus()
void
setCellEditorValue(DataType dataType)
Sets the value to be edited on this cell editor.void
setCellEditorValueAsText(java.lang.String text)
void
setConsumeEnterKeyPress(boolean consume)
void
setDefaultSelectedTreePath(javax.swing.tree.TreePath path)
Sets the initially selected node in the data type tree that the user can choose to show.void
setPreferredDataTypeManager(DataTypeManager dataTypeManager)
Sets theDataTypeManager
to use when the chooser is forced to parse the given data type text to resolve the data type.void
setTabCommitsEdit(boolean doesCommit)
boolean
validateUserSelection()
Returns true if the current value of the data type editor is a know data type.
-
-
-
Constructor Detail
-
DataTypeSelectionEditor
public DataTypeSelectionEditor(ServiceProvider serviceProvider, int maxSize, DataTypeParser.AllowedDataTypes allowedDataTypes)
-
DataTypeSelectionEditor
public DataTypeSelectionEditor(DataTypeManagerService service, int maxSize, DataTypeParser.AllowedDataTypes allowedDataTypes)
-
-
Method Detail
-
setPreferredDataTypeManager
public void setPreferredDataTypeManager(DataTypeManager dataTypeManager)
Sets theDataTypeManager
to use when the chooser is forced to parse the given data type text to resolve the data type. If the users chooses a type, then this value is not used. Note that setting this value does not restrict the parser to just the given value, but rather the given value is the preferred manager and is thus searched first.- Parameters:
dataTypeManager
- the preferred data type manager
-
setConsumeEnterKeyPress
public void setConsumeEnterKeyPress(boolean consume)
-
getCellEditorValue
public java.lang.Object getCellEditorValue()
- See Also:
CellEditor.getCellEditorValue()
-
getCellEditorValueAsDataType
public DataType getCellEditorValueAsDataType()
-
getCellEditorValueAsText
public java.lang.String getCellEditorValueAsText()
Returns the text value of the editor's text field.- Returns:
- the text value of the editor's text field.
-
getEditorComponent
public javax.swing.JComponent getEditorComponent()
Returns the component that allows the user to edit.- Returns:
- the component that allows the user to edit.
-
getDropDownTextField
public DropDownSelectionTextField<DataType> getDropDownTextField()
-
getBrowseButton
public javax.swing.JButton getBrowseButton()
-
setDefaultSelectedTreePath
public void setDefaultSelectedTreePath(javax.swing.tree.TreePath path)
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
public void setCellEditorValue(DataType dataType)
Sets the value to be edited on this cell editor.- Parameters:
dataType
- The data type which is to be edited.
-
setCellEditorValueAsText
public void setCellEditorValueAsText(java.lang.String text)
-
addDocumentListener
public void addDocumentListener(javax.swing.event.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. You may verify whether the text changes represent a valid DataType by callingvalidateUserSelection()
.- Parameters:
listener
- the listener to add.- See Also:
validateUserSelection()
-
removeDocumentListener
public void removeDocumentListener(javax.swing.event.DocumentListener listener)
Removes a previously added document listener.- Parameters:
listener
- the listener to remove.s
-
addFocusListener
public void addFocusListener(java.awt.event.FocusListener listener)
-
removeFocusListener
public void removeFocusListener(java.awt.event.FocusListener listener)
-
setTabCommitsEdit
public void setTabCommitsEdit(boolean doesCommit)
-
getNavigationDirection
public NavigationDirection getNavigationDirection()
Returns the direction of the user triggered navigation; null if the user did not trigger navigation out of this component.
-
validateUserSelection
public boolean validateUserSelection() throws InvalidDataTypeException
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()
-
-