Class DataTypeSelectionEditor

java.lang.Object
javax.swing.AbstractCellEditor
ghidra.app.util.datatype.DataTypeSelectionEditor
All Implemented Interfaces:
Serializable, CellEditor

public class DataTypeSelectionEditor extends AbstractCellEditor
An editor that is used to show the 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:
  • Constructor Details

  • Method Details

    • setPreferredDataTypeManager

      public void setPreferredDataTypeManager(DataTypeManager dataTypeManager)
      Sets the DataTypeManager 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)
      Sets whether this editor should consumer Enter key presses
      Parameters:
      consume - true to consume
      See Also:
    • createDropDownSelectionTextField

      protected DropDownSelectionTextField<DataType> createDropDownSelectionTextField(DataTypeDropDownSelectionDataModel model)
    • getCellEditorValue

      public Object getCellEditorValue()
    • getCellEditorValueAsDataType

      public DataType getCellEditorValueAsDataType()
    • getCellEditorValueAsText

      public String getCellEditorValueAsText()
      Returns the text value of the editor's text field.
      Returns:
      the text value of the editor's text field.
    • getEditorComponent

      public 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 JButton getBrowseButton()
    • setDefaultSelectedTreePath

      public void setDefaultSelectedTreePath(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(String text)
    • addDocumentListener

      public void 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. You may verify whether the text changes represent a valid DataType by calling validateUserSelection().
      Parameters:
      listener - the listener to add.
      See Also:
    • removeDocumentListener

      public void removeDocumentListener(DocumentListener listener)
      Removes a previously added document listener.
      Parameters:
      listener - the listener to remove.
    • addFocusListener

      public void addFocusListener(FocusListener listener)
    • removeFocusListener

      public void removeFocusListener(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.
      Returns:
      the direction
    • 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()