Package mars.venus

Class VenusUI

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants, SimulatorListener

public class VenusUI extends JFrame implements SimulatorListener
Top level container for the Venus GUI.
Author:
Sanderson and Team JSpim
See Also:
  • Field Details

    • ICON_SIZE

      public static final int ICON_SIZE
      Width and height in user pixels of icons in the tool bar and menus.
      See Also:
    • SPLASH_DURATION_MILLIS

      public static final int SPLASH_DURATION_MILLIS
      Time in milliseconds to show splash screen.
      See Also:
    • WINDOW_ICON_NAME

      public static final String WINDOW_ICON_NAME
      Filename of the icon used in the window title bar and taskbar.
      See Also:
  • Constructor Details

    • VenusUI

      public VenusUI(Settings settings, String title)
      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 by SplashScreen once it has displayed for the required duration, making this window visible.
    • getSVGActionIcon

      public static Icon getSVGActionIcon(String filename)
      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

      public void customizeScrollPane(JScrollPane scrollPane)
    • simulatorStarted

      public void simulatorStarted(SimulatorStartEvent event)
      Description copied from interface: SimulatorListener
      Called when the simulator begins execution of a program.
      Specified by:
      simulatorStarted in interface SimulatorListener
      Parameters:
      event - The event which occurred.
    • simulatorPaused

      public void simulatorPaused(SimulatorPauseEvent event)
      Description copied from interface: SimulatorListener
      Called when the simulator stops execution of a program due to pausing.
      Specified by:
      simulatorPaused in interface SimulatorListener
      Parameters:
      event - The event which occurred.
    • simulatorFinished

      public void simulatorFinished(SimulatorFinishEvent event)
      Description copied from interface: SimulatorListener
      Called when the simulator stops execution of a program due to termination or finishing.
      Specified by:
      simulatorFinished in interface SimulatorListener
      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 the UndoManager.
    • setTitleContent

      public void setTitleContent(String content)
      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 to saveWorkspaceState() have any effect. Workspace state saving is disabled during bulk open/close operations.
      Returns:
      true if the workspace state can be saved, or false otherwise.
    • setWorkspaceStateSavingEnabled

      public void setWorkspaceStateSavingEnabled(boolean enabled)
      Set whether calls to saveWorkspaceState() 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 to false.

      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

      public void addRecentFile(File file)
      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

      public void removeRecentFile(File file)
      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

      public FileStatus getFileStatus()
      Get the current status of the file being edited in the Edit tab (or FileStatus.NO_FILE if no files are being edited).
      Returns:
      The current file status.
    • setFileStatus

      public void setFileStatus(FileStatus status)
      Set the status of the file being edited, and update the menu state.
      Parameters:
      status - The new file status.
    • getProgramStatus

      public ProgramStatus getProgramStatus()
      Get the current status of the overall program as it relates to the Execute tab.
      Returns:
      The current program status.
    • setProgramStatus

      public void setProgramStatus(ProgramStatus status)
      Set the status of the overall program, and update the menu state.
      Parameters:
      status - The new program status.
    • getSettings

      public Settings getSettings()
    • getEditor

      public Editor getEditor()
      Get a reference to the text editor associated with this GUI.
      Returns:
      Editor for the GUI.
    • getMainPane

      public MainPane getMainPane()
      Get a reference to the main pane associated with this GUI.
      Returns:
      MainPane for the GUI.
    • getMessagesPane

      public MessagesPane getMessagesPane()
      Get a reference to the messages pane associated with this GUI.
      Returns:
      MessagesPane for the GUI.
    • getRegistersPane

      public RegistersPane getRegistersPane()
      Get reference to registers pane associated with this GUI.
      Returns:
      RegistersPane for the GUI.
    • getRunAssembleAction

      public RunAssembleAction 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.