Package mars.venus
Class VenusUI
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
mars.venus.VenusUI
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,RootPaneContainer
,WindowConstants
,SimulatorListener
Top level container for the Venus GUI.
- Author:
- Sanderson and Team JSpim
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
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
FieldsModifier and TypeFieldDescriptionstatic final int
Width and height in user pixels of icons in the tool bar and menus.static final int
Time in milliseconds to show splash screen.static final String
Filename of the icon used in the window title bar and taskbar.Fields inherited from class javax.swing.JFrame
accessibleContext, rootPane, rootPaneCheckingEnabled
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
Fields inherited from class java.awt.Component
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
addRecentFile
(File file) Add a file to the "Recent Files" menu, or bring it to the top if it is already present.void
customizeScrollPane
(JScrollPane scrollPane) Get a reference to the text editor associated with this GUI.Get the current status of the file being edited in the Edit tab (orFileStatus.NO_FILE
if no files are being edited).Get a reference to the main pane associated with this GUI.Get a reference to the messages pane associated with this GUI.Get the current status of the overall program as it relates to the Execute tab.Get reference to registers pane associated with this GUI.Get a reference to the Run->Assemble action.static Icon
getSVGActionIcon
(String filename) Load an SVG action icon from the action icons folder (Application.ACTION_ICONS_PATH
).boolean
Determine whether calls tosaveWorkspaceState()
have any effect.void
Load the state of the previous workspace from permanent storage, which includes the paths of the files that were open.void
removeRecentFile
(File file) Remove a file from the "Recent Files" menu, if it exists in the menu.void
Save the state of the current workspace to permanent storage, which includes the paths of the files that are open.void
setFileStatus
(FileStatus status) Set the status of the file being edited, and update the menu state.void
setProgramStatus
(ProgramStatus status) Set the status of the overall program, and update the menu state.void
setTitleContent
(String content) Set the content to display as part of the window title, if any.void
setWorkspaceStateSavingEnabled
(boolean enabled) Set whether calls tosaveWorkspaceState()
have any effect.void
Called bySplashScreen
once it has displayed for the required duration, making this window visible.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
Automatically update whether the Undo and Redo actions are enabled or disabled based on the status of theUndoManager
.Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, 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 java.awt.MenuContainer
getFont, postEvent
Methods inherited from interface mars.simulator.SimulatorListener
simulatorStepped
-
Field Details
-
ICON_SIZE
public static final int ICON_SIZEWidth and height in user pixels of icons in the tool bar and menus.- See Also:
-
SPLASH_DURATION_MILLIS
public static final int SPLASH_DURATION_MILLISTime in milliseconds to show splash screen.- See Also:
-
WINDOW_ICON_NAME
Filename of the icon used in the window title bar and taskbar.- See Also:
-
-
Constructor Details
-
VenusUI
Create a new instance of the Venus GUI and show it once it is created.- Parameters:
title
- Name of the window to be created.
-
-
Method Details
-
showWindow
public void showWindow()Called bySplashScreen
once it has displayed for the required duration, making this window visible. -
getSVGActionIcon
Load an SVG action icon from the action icons folder (Application.ACTION_ICONS_PATH
).- Parameters:
filename
- Name of the SVG icon to load.- Returns:
- The loaded SVG icon, or null if the image does not exist.
-
customizeScrollPane
-
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.
-
updateUndoRedoActions
public void updateUndoRedoActions()Automatically update whether the Undo and Redo actions are enabled or disabled based on the status of theUndoManager
. -
setTitleContent
Set the content to display as part of the window title, if any. (Usually, this is a filename.) The resulting full title will look like "(content) - (base title)" if the content is not null, or simply the base title otherwise.- Parameters:
content
- The content to display before the base title.
-
isWorkspaceStateSavingEnabled
public boolean isWorkspaceStateSavingEnabled()Determine whether calls tosaveWorkspaceState()
have any effect. Workspace state saving is disabled during bulk open/close operations.- Returns:
true
if the workspace state can be saved, orfalse
otherwise.
-
setWorkspaceStateSavingEnabled
public void setWorkspaceStateSavingEnabled(boolean enabled) Set whether calls tosaveWorkspaceState()
have any effect. This is useful for when the state of the workspace needs to change without updating the saved workspace state (for example, when closing all files before the application exits).- Parameters:
enabled
- Whether to allow the workspace state to be saved.
-
saveWorkspaceState
public void saveWorkspaceState()Save the state of the current workspace to permanent storage, which includes the paths of the files that are open.Most file-related operations trigger this automatically unless the
workspaceStateSavingEnabled
flag is set tofalse
.- See Also:
-
loadWorkspaceState
public void loadWorkspaceState()Load the state of the previous workspace from permanent storage, which includes the paths of the files that were open. -
addRecentFile
Add a file to the "Recent Files" menu, or bring it to the top if it is already present. If the length of the menu is pushed past the limit specified in the settings, the least recent entry is removed from the list.- Parameters:
file
- The file which was just opened.
-
removeRecentFile
Remove a file from the "Recent Files" menu, if it exists in the menu.- Parameters:
file
- The file to remove from the "Recent Files" menu.
-
getFileStatus
Get the current status of the file being edited in the Edit tab (orFileStatus.NO_FILE
if no files are being edited).- Returns:
- The current file status.
-
setFileStatus
Set the status of the file being edited, and update the menu state.- Parameters:
status
- The new file status.
-
getProgramStatus
Get the current status of the overall program as it relates to the Execute tab.- Returns:
- The current program status.
-
setProgramStatus
Set the status of the overall program, and update the menu state.- Parameters:
status
- The new program status.
-
getSettings
-
getEditor
Get a reference to the text editor associated with this GUI.- Returns:
- Editor for the GUI.
-
getMainPane
Get a reference to the main pane associated with this GUI.- Returns:
- MainPane for the GUI.
-
getMessagesPane
Get a reference to the messages pane associated with this GUI.- Returns:
- MessagesPane for the GUI.
-
getRegistersPane
Get reference to registers pane associated with this GUI.- Returns:
- RegistersPane for the GUI.
-
getRunAssembleAction
Get a reference to the Run->Assemble action. Needed by File->Open in case the assemble-upon-open flag is set.- Returns:
- The object for the Run->Assemble operation.
-