Class AddressInput

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

public class AddressInput extends JPanel implements FocusableEditor
Panel for user input of addresses. Handles case with multiple address spaces.
See Also:
  • Field Details

  • Constructor Details

    • AddressInput

      public AddressInput(Border border)
      Constructor for AddressInput.
      Parameters:
      border - border around each subcomponent (combo/text fields).
    • AddressInput

      public AddressInput()
      Constructor for AddressInput.
  • Method Details

    • setAddress

      public void setAddress(Address addr)
      Set the field to display the given address
    • getAddress

      public Address getAddress()
      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:
      NullPointerException - if AddressFactory has not been set.
    • getAddressSpace

      public AddressSpace getAddressSpace()
      Returns the address space selected in the combobox or in the input text itself if specified (eg: "register:1"). If the address space is not specified; returns the default space.
      Throws:
      NullPointerException - if AddressFactory has not been set.
    • hasInput

      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.
    • getText

      public String getText()
      Returns the text in this field.
      Returns:
      the text in this field
    • getAddressFactory

      public AddressFactory getAddressFactory()
    • setAddressFactory

      public void setAddressFactory(AddressFactory factory)
      Set the address factory to be used to parse addresses. Also used to set the combo box with the list of valid address spaces if there is more than one space. Only loaded memory spaces will be allowed (see AddressSpace.isLoadedMemorySpace()).
      Parameters:
      factory - address factory to use
    • setAddressFactory

      public void setAddressFactory(AddressFactory factory, Predicate<AddressSpace> predicate)
      Set the address factory to be used to parse addresses. Also used to set the combo box with the list of valid address spaces if there is more than one space. The specified predicate will be used to determine if an address space should be included.
      Parameters:
      factory - address factory to use
      predicate - callback used to determine if an address space should be included for selection
    • selectDefaultAddressSpace

      public void selectDefaultAddressSpace()
      Sets the selected combo box item to the default address space.
    • clear

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

      public void select()
      Select the text field that is the offset.
    • getValue

      public String getValue()
      Get the offset part of the address field.
      Returns:
      String
    • setValue

      public void setValue(String value)
      Set the offset part of the address offset field without changing address space. NOTE: This method is intended for test use only and mimicks user input.
      Parameters:
      value - the offset value string
    • setValue

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

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

      public boolean containsAddressSpaces()
    • setAddressSpaceEditable

      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
    • addChangeListener

      public void addChangeListener(ChangeListener listener)
      Adds a change listener that will be notified anytime this address value in this panel changes
      Parameters:
      listener - the change listener to be notified.
    • addActionListener

      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

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

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class JComponent
      See Also:
    • setAccessibleName

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

      public void setEditable(boolean state)
      Set the text field to be editable according to the state param.
    • isEditable

      public boolean isEditable()
    • focusEditor

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

      public void showAddressSpaceCombo(boolean showCombo)
    • requestFocus

      public void requestFocus()
      Overrides:
      requestFocus in class JComponent
    • getAddressTextField

      protected JTextField getAddressTextField()
    • getAddressSpaceTextField

      protected JTextField getAddressSpaceTextField()