Package ghidra.app.util
Class AddressInput
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
ghidra.app.util.AddressInput
- All Implemented Interfaces:
FocusableEditor
,ImageObserver
,MenuContainer
,Serializable
,Accessible
Panel for user input of addresses. Handles case with multiple address
spaces.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Predicate
<AddressSpace> Address Space predicate which includes all memory spaces, including theAddressSpace.OTHER_SPACE
and all overlay spaces.static final Predicate
<AddressSpace> Address Space predicate which includes all loaded memory spaces.Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorDescriptionConstructor for AddressInput.AddressInput
(Border border) Constructor for AddressInput. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addActionListener
(ActionListener listener) Add an action listener that will be notified anytime the user presses the return key while in the text field.void
addChangeListener
(ChangeListener listener) Adds a change listener that will be notified anytime this address value in this panel changesvoid
clear()
Clear the offset part of the address field.boolean
void
Called with the editor should take focus.Returns the address in the field or null if the address can't be parsed.Returns the address space selected in the combobox or in the input text itself if specified (eg: "register:1").protected JTextField
protected JTextField
getText()
Returns the text in this field.getValue()
Get the offset part of the address field.boolean
hasInput()
Returns true if the Address input field contains text.boolean
boolean
void
removeActionListener
(ActionListener listener) Removes the action listener from the list to be notified.void
void
select()
Select the text field that is the offset.void
Sets the selected combo box item to the default address space.void
setAccessibleName
(String name) Sets the accessible name for this address input field.void
setAddress
(Address addr) Set the field to display the given addressvoid
setAddressFactory
(AddressFactory factory) Set the address factory to be used to parse addresses.void
setAddressFactory
(AddressFactory factory, Predicate<AddressSpace> predicate) Set the address factory to be used to parse addresses.void
setAddressSpaceEditable
(boolean state) Set the address space (if it is shown) such that it is not editable.void
setEditable
(boolean state) Set the text field to be editable according to the state param.void
setEnabled
(boolean enabled) void
Set the address space and offset.void
Set the offset part of the address offset field without changing address space.void
showAddressSpaceCombo
(boolean showCombo) Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
INCLUDE_LOADED_MEMORY_SPACES
Address Space predicate which includes all loaded memory spaces. SeeAddressSpace.isLoadedMemorySpace()
. Intended for use withsetAddressFactory(AddressFactory, Predicate)
. -
INCLUDE_ALL_MEMORY_SPACES
Address Space predicate which includes all memory spaces, including theAddressSpace.OTHER_SPACE
and all overlay spaces. Intended for use withsetAddressFactory(AddressFactory, Predicate)
.
-
-
Constructor Details
-
AddressInput
Constructor for AddressInput.- Parameters:
border
- border around each subcomponent (combo/text fields).
-
AddressInput
public AddressInput()Constructor for AddressInput.
-
-
Method Details
-
setAddress
Set the field to display the given 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
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
Returns the text in this field.- Returns:
- the text in this field
-
getAddressFactory
-
setAddressFactory
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 (seeAddressSpace.isLoadedMemorySpace()
).- Parameters:
factory
- address factory to use
-
setAddressFactory
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 usepredicate
- 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
Get the offset part of the address field.- Returns:
- String
-
setValue
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
Set the address space and offset. NOTE: UnlikesetAddress(Address)
this method is intended for test use only and mimicks user input withstateChanged()
notification.- Parameters:
addr
- the address value
-
isEnabled
public boolean isEnabled() -
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
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
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
Removes the action listener from the list to be notified.- Parameters:
listener
-
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabled
in classJComponent
- See Also:
-
setAccessibleName
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 interfaceFocusableEditor
-
showAddressSpaceCombo
public void showAddressSpaceCombo(boolean showCombo) -
requestFocus
public void requestFocus()- Overrides:
requestFocus
in classJComponent
-
getAddressTextField
-
getAddressSpaceTextField
-