Class AddressInput

All Implemented Interfaces:
FocusableEditor, ImageObserver, MenuContainer, Serializable, Accessible

public class AddressInput extends JPanel implements FocusableEditor
Input field for entering address or address expression. Handles multiple address spaces and supports both hex and decimal number modes for evaluating numbers.
See Also:
  • Field Details Link icon

  • Constructor Details Link icon

    • AddressInput Link icon

      public AddressInput()
      Constructs an AddressInput field with no specified program or address.
    • AddressInput Link icon

      public AddressInput(Consumer<Address> addressChangedConsumer)
      Constructs an AddressInput field with a consumer to be called when the address field's value changes.
      Parameters:
      addressChangedConsumer - the consumer to be called when the value in the address field changes
    • AddressInput Link icon

      public AddressInput(Program program)
      Constructs an AddressInput field and initialized with a program.
      Parameters:
      program - the program used to evaluate the entered address expression.
    • AddressInput Link icon

      public AddressInput(AddressFactory factory)
      Constructs an AddressInput field and initialized with an address factory.
      Parameters:
      factory - the address factory used to evaluate the entered address expression.
    • AddressInput Link icon

      public AddressInput(Program program, Consumer<Address> addressChangedConsumer)
      Constructs an AddressInput field with a consumer to be notified when the address field changes and initialized with a program.
      Parameters:
      program - the program used to evaluate the entered address expression.
      addressChangedConsumer - the consumer to be called when the value in the address field changes
    • AddressInput Link icon

      public AddressInput(AddressFactory factory, Consumer<Address> addressChangedConsumer)
      Constructs an AddressInput field with a consumer to be notified when the address field changes and initialized with an address factory.
      Parameters:
      factory - the address factory used to evaluate the entered address expression.
      addressChangedConsumer - the consumer to be called when the value in the address field changes
  • Method Details Link icon

    • setAddressSpaceFilter Link icon

      public void setAddressSpaceFilter(Predicate<AddressSpace> spaceFilter)
      Sets a filter predicate to determine which address spaces should be selectable by the user. If after filtering only one space is remaining, the address space portion of the address input field will not be shown.
      Parameters:
      spaceFilter - the predicate for filtering selectable address spaces.
    • setText Link icon

      public void setText(String text)
      Sets the text in the expression input textfield.
      Parameters:
      text - the text to initialize the input textfield
    • setComponentBorders Link icon

      public void setComponentBorders(Border border)
      Used to set the internal borders for use in specialized use cases such as a table field editor.
      Parameters:
      border - the border to use for the internal components that make up this input field
    • setAssumeHex Link icon

      public void setAssumeHex(boolean hexMode)
      Sets the hex/decimal mode for this field. When in hex mode, all numbers are assumed to be hexadecimal values. When in decimal mode, all numbers are assumed to be decimal numbers unless prefixed with "0x".
      Parameters:
      hexMode - true to assume numbers are hexadecimal.
    • setAddress Link icon

      public void setAddress(Address address)
      Set the field to display the given address
      Parameters:
      address - the new address to display
    • setAddressSpace Link icon

      public void setAddressSpace(AddressSpace addressSpace)
      Sets the selected AddressSpace to the given space.
      Parameters:
      addressSpace - the address space to set selected
    • getAddressWithExceptions Link icon

      public Address getAddressWithExceptions() throws ExpressionException
      Returns the address in the field or null if the address can't be parsed.
      Returns:
      The address for the current value in the text field
      Throws:
      ExpressionException - if expression can not be evaluated to a valid address.
      NullPointerException - if AddressFactory has not been set.
    • getAddress Link icon

      public Address getAddress()
      Gets the current address the field evaluates to or null if the text does not evaluate to a valid, unique address.
      Returns:
      the current address the field evalutes to or null if the text does not evalute to a valid unique address.
    • getAddressSpace Link icon

      public AddressSpace getAddressSpace()
      Returns the address space selected in the combobox the default address space if the comboBox is not being shown.
      Returns:
      the selected address space, or the default address space if no combo added, or null if no program is set.
    • hasInput Link icon

      public boolean hasInput()
      Returns true if the Address input field contains text. The getAddress() method will return null if text is not a valid address.
      Returns:
      true if the address field is not blank
    • getText Link icon

      public String getText()
      Returns the text in this field.
      Returns:
      the text in this field
    • setProgram Link icon

      public void setProgram(Program program)
      Set the program to be used to parse addresses and expressions and also to determine the list of valid address spaces. Only loaded memory spaces will be allowed (see AddressSpace.isLoadedMemorySpace()).
      Parameters:
      program - the program to use to resolve address expressions
    • setProgram Link icon

      public void setProgram(Program program, Predicate<AddressSpace> addessSpaceFilter)
      Sets the program and the address space filter at the same time. This avoid some weird intermediate results if the are set separately.
      Parameters:
      program - the program to use to parse addresses and expressions.
      addessSpaceFilter - the predicate to determine which address spaces are user selectable
    • setAddressFactory Link icon

      public void setAddressFactory(AddressFactory factory)
      Legacy method for setting the address factory to be used to parse address. Should only be used when a program is not readily available.
      Parameters:
      factory - the address factory to be used to parse addresses.
    • setAddressErrorConsumer Link icon

      public void setAddressErrorConsumer(Consumer<String> addressErrorConsumer)
      Sets a consumer to be notified when the address input field changes, but can't be parsed into a valid address.
      Parameters:
      addressErrorConsumer - the consumer to be notified for bad address input
    • clear Link icon

      public void clear()
      Clear the offset part of the address field.
    • select Link icon

      public void select()
      Select the text field that is the offset.
    • simulateAddressChanged Link icon

      public void simulateAddressChanged(Address addr)
      Set the address space and offset. NOTE: Unlike setAddress(Address) this method is intended for test use only and mimics user input with address changed notification
      Parameters:
      addr - the address value
    • isEnabled Link icon

      public boolean isEnabled()
      Overrides:
      isEnabled in class Component
    • containsAddressSpaces Link icon

      public boolean containsAddressSpaces()
    • setAddressSpaceEditable Link icon

      public void setAddressSpaceEditable(boolean state)
      Set the address space (if it is shown) such that it is not editable. If the combo box is shown for multiple address spaces, then the combo box is replaced with a fixed uneditable text field that shows the currently selected address space.
      Parameters:
      state - false means that the combo box should not be editable
    • addActionListener Link icon

      public void addActionListener(ActionListener listener)
      Add an action listener that will be notified anytime the user presses the return key while in the text field.
      Parameters:
      listener - the action listener to be notified.
    • removeActionListener Link icon

      public void removeActionListener(ActionListener listener)
      Removes the action listener from the list to be notified.
      Parameters:
      listener - the listener to be removed
    • setEnabled Link icon

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
    • setAccessibleName Link icon

      public void setAccessibleName(String name)
      Sets the accessible name for this address input field.
      Parameters:
      name - the accessible name for this address field
    • setEditable Link icon

      public void setEditable(boolean b)
      Set the text field to be editable or not.
      Parameters:
      b - true if the address input field can be edited
    • isEditable Link icon

      public boolean isEditable()
      Returns true if the address input field is editable.
      Returns:
      true if the address input field is editable.
    • focusEditor Link icon

      public void focusEditor()
      Description copied from interface: FocusableEditor
      Called with the editor should take focus.
      Specified by:
      focusEditor in interface FocusableEditor
    • requestFocus Link icon

      public void requestFocus()
      Overrides:
      requestFocus in class JComponent