Package mars.venus.execute
Class TextSegmentWindow
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JInternalFrame
mars.venus.execute.TextSegmentWindow
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,RootPaneContainer
,WindowConstants
,Memory.Listener
,SimulatorListener
Creates the Text Segment window in the Execute tab of the UI.
- Author:
- Team JSpim
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIcon
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
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
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
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Allow the user to enter program arguments in a panel at the bottom of the text segment window.void
Clears all breakpoints that have been set since last assemble, and updates the display of the breakpoint column.void
Remove all components.int
findRowForAddress
(int address) Helper method to find the table row corresponding to the given text segment address.int
Returns number of breakpoints currently set.Get program arguments from text field at the bottom of the text segment window.int[]
Returns array of current breakpoints, each represented by a MIPS program counter address.void
memoryWritten
(int address, int length, int value, int wordAddress, int wordValue) Invoked upon any write operation which is relevant to this listener's active range.void
registerTableModelListener
(TableModelListener listener) Assign listener to Table model.void
Hide the panel for entering program arguments.void
Called by RunResetAction to restore display of any table rows that were overwritten due to self-modifying code feature.void
scrollToRow
(int row) void
selectStepAtAddress
(int address) Scroll the viewport so the step (table row) at the given text segment address is visible, vertically centered if possible, and selected.void
Method to be called once the user compiles the program.void
Called when the simulator stops execution of a program due to termination or finishing.void
Called when the simulator stops execution of a program due to pausing.void
Called when the simulator begins execution of a program.void
Called when the simulator has finished executing an instruction, but only if the run speed is not unlimited.void
Convenience method to add this as a listener of the text segment in memory.void
Convenience method to remove this as a listener of memory.void
Enable or disable all items in the Breakpoints column.void
Redisplay the basic statements.void
Redisplay the addresses.void
Highlights the source code line whose address matches the current program counter value.void
Convenience method to remove this as a listener of memory, then add again if the self-modifying code feature is enabled in the settings.void
updateUI()
For whatever reason, FlatLaf seems to forget what the frame icon is set to after this method is called.Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront
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, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, 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, isEnabled, 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, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface mars.mips.hardware.Memory.Listener
memoryRead, memoryReset
-
Constructor Details
-
TextSegmentWindow
Constructor, sets up a new JInternalFrame.
-
-
Method Details
-
setupTable
public void setupTable()Method to be called once the user compiles the program. Should convert the lines of code over to the table rows and columns. -
getProgramArguments
Get program arguments from text field at the bottom of the text segment window.- Returns:
- The list of program arguments.
-
addProgramArgumentsPanel
public void addProgramArgumentsPanel()Allow the user to enter program arguments in a panel at the bottom of the text segment window. -
removeProgramArgumentsPanel
public void removeProgramArgumentsPanel()Hide the panel for entering program arguments. -
clearWindow
public void clearWindow()Remove all components. -
registerTableModelListener
Assign listener to Table model. Used for breakpoints, since that is the only editable column in the table. Since table model objects are transient (get a new one with each successful assemble), this method will simply keep the identity of the listener then add it as a listener each time a new table model object is created. Limit 1 listener. -
updateCodeAddresses
public void updateCodeAddresses()Redisplay the addresses. This should only be done when address display base is modified (e.g. between base 16 hex and base 10 dec). -
updateBasicStatements
public void updateBasicStatements()Redisplay the basic statements. This should only be done when address or value display base is modified (e.g. between base 16 hex and base 10 dec). -
memoryWritten
public void memoryWritten(int address, int length, int value, int wordAddress, int wordValue) Description copied from interface:Memory.Listener
Invoked upon any write operation which is relevant to this listener's active range. Does nothing by default.- Specified by:
memoryWritten
in interfaceMemory.Listener
- Parameters:
address
- The address which was written to.length
- The number of bytes written. Will always be 1 (single byte),Memory.BYTES_PER_HALFWORD
, orMemory.BYTES_PER_WORD
.value
- The value which was written.wordAddress
- The address of the word affected by the operation.wordValue
- The resulting value of the word.
-
simulatorStarted
Description copied from interface:SimulatorListener
Called when the simulator begins execution of a program.- Specified by:
simulatorStarted
in interfaceSimulatorListener
- Parameters:
event
- The event which occurred.
-
simulatorPaused
Description copied from interface:SimulatorListener
Called when the simulator stops execution of a program due to pausing.- Specified by:
simulatorPaused
in interfaceSimulatorListener
- Parameters:
event
- The event which occurred.
-
simulatorFinished
Description copied from interface:SimulatorListener
Called when the simulator stops execution of a program due to termination or finishing.- Specified by:
simulatorFinished
in interfaceSimulatorListener
- Parameters:
event
- The event which occurred.
-
simulatorStepped
public void simulatorStepped()Description copied from interface:SimulatorListener
Called when the simulator has finished executing an instruction, but only if the run speed is not unlimited.Note: For very fast run speeds, GUI listeners may not receive all step events. This is an intentional feature to prevent overloading of the GUI event queue.
- Specified by:
simulatorStepped
in interfaceSimulatorListener
-
resetModifiedSourceCode
public void resetModifiedSourceCode()Called by RunResetAction to restore display of any table rows that were overwritten due to self-modifying code feature. -
getBreakpointCount
public int getBreakpointCount()Returns number of breakpoints currently set.- Returns:
- number of current breakpoints
-
getSortedBreakPointsArray
public int[] getSortedBreakPointsArray()Returns array of current breakpoints, each represented by a MIPS program counter address. These are stored in the BREAK_COLUMN of the table model.- Returns:
- int array of breakpoints, sorted by PC address, or null if there are none.
-
clearAllBreakpoints
public void clearAllBreakpoints()Clears all breakpoints that have been set since last assemble, and updates the display of the breakpoint column. -
scrollToRow
public void scrollToRow(int row) -
updateHighlighting
public void updateHighlighting()Highlights the source code line whose address matches the current program counter value. This is used for stepping through code execution and when reaching breakpoints. -
selectStepAtAddress
public void selectStepAtAddress(int address) Scroll the viewport so the step (table row) at the given text segment address is visible, vertically centered if possible, and selected. Developed July 2007 for new feature that shows source code step where label is defined when that label is clicked on in the Label Window.- Parameters:
address
- text segment address of source code step.
-
toggleBreakpoints
public void toggleBreakpoints()Enable or disable all items in the Breakpoints column. -
startObservingMemory
public void startObservingMemory()Convenience method to add this as a listener of the text segment in memory. -
stopObservingMemory
public void stopObservingMemory()Convenience method to remove this as a listener of memory. -
updateListeningStatus
public void updateListeningStatus()Convenience method to remove this as a listener of memory, then add again if the self-modifying code feature is enabled in the settings. -
findRowForAddress
Helper method to find the table row corresponding to the given text segment address. This method is called by a couple different public methods.- Parameters:
address
- The address to find the row for.- Returns:
- The table row corresponding to this address.
- Throws:
IndexOutOfBoundsException
- Thrown if the address does not correspond to any row in the table.
-
updateUI
public void updateUI()For whatever reason, FlatLaf seems to forget what the frame icon is set to after this method is called. So, this method has been overwritten to set the frame icon back tonull
as desired.- Overrides:
updateUI
in classJInternalFrame
-