Class SwingGui

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants, GuiCallback

public class SwingGui extends JFrame implements GuiCallback
GUI for the Rhino debugger.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serializable magic number.
      See Also:
    • dim

      Dim dim
      The debugger.
    • exitAction

      private Runnable exitAction
      The action to run when the 'Exit' menu item is chosen or the frame is closed.
    • desk

      private JDesktopPane desk
      The JDesktopPane that holds the script windows.
    • context

      private ContextWindow context
      The JPanel that shows information about the context.
    • toolBar

      private JToolBar toolBar
      The tool bar.
    • console

      private JSInternalConsole console
      The console that displays I/O from the script.
    • split1

      private JSplitPane split1
      The JSplitPane that separates desk from Context.
    • statusBar

      private JLabel statusBar
      The status bar.
    • toplevels

      private final Map<String,JFrame> toplevels
      Hash table of internal frame names to the internal frames themselves.
    • fileWindows

      private final Map<String,FileWindow> fileWindows
      Hash table of script URLs to their internal frames.
    • currentWindow

      private FileWindow currentWindow
      The FileWindow that last had the focus.
    • dlg

      File choose dialog for loading a script.
    • awtEventQueue

      private EventQueue awtEventQueue
      The AWT EventQueue. Used for manually pumping AWT events from dispatchNextGuiEvent().
  • Constructor Details

    • SwingGui

      public SwingGui(Dim dim, String title)
      Creates a new SwingGui.
  • Method Details

    • getMenubar

      public Menubar getMenubar()
      Returns the Menubar of this debugger frame.
    • setExitAction

      public void setExitAction(Runnable r)
      Sets the Runnable that will be run when the "Exit" menu item is chosen.
    • getConsole

      public JSInternalConsole getConsole()
      Returns the debugger console component.
    • setVisible

      public void setVisible(boolean b)
      Sets the visibility of the debugger GUI.
      Overrides:
      setVisible in class Window
    • addTopLevel

      void addTopLevel(String key, JFrame frame)
      Records a new internal frame.
    • init

      private void init()
      Constructs the debugger GUI.
    • exit

      private void exit()
      Runs the exitAction.
    • getFileWindow

      FileWindow getFileWindow(String url)
      Returns the FileWindow for the given URL.
    • getShortName

      static String getShortName(String url)
      Returns a short version of the given URL.
    • removeWindow

      void removeWindow(FileWindow w)
      Closes the given FileWindow.
    • showStopLine

      void showStopLine(Dim.StackFrame frame)
      Shows the line at which execution in the given stack frame just stopped.
    • showFileWindow

      protected void showFileWindow(String sourceUrl, int lineNumber)
      Shows a FileWindow for the given source, creating it if it doesn't exist yet. if lineNumber is greater than -1, it indicates the line number to select and display.
      Parameters:
      sourceUrl - the source URL
      lineNumber - the line number to select, or -1
    • createFileWindow

      protected void createFileWindow(Dim.SourceInfo sourceInfo, int line)
      Creates and shows a new FileWindow for the given source.
    • updateFileWindow

      protected boolean updateFileWindow(Dim.SourceInfo sourceInfo)
      Update the source text for sourceInfo. This returns true if a FileWindow for the given source exists and could be updated. Otherwise, this does nothing and returns false.
      Parameters:
      sourceInfo - the source info
      Returns:
      true if a FileWindow for the given source exists and could be updated, false otherwise.
    • setFilePosition

      private void setFilePosition(FileWindow w, int line)
      Moves the current position in the given FileWindow to the given line.
    • enterInterruptImpl

      void enterInterruptImpl(Dim.StackFrame lastFrame, String threadTitle, String alertMessage)
      Handles script interruption.
    • getWindowMenu

      private JMenu getWindowMenu()
      Returns the 'Window' menu.
    • chooseFile

      private String chooseFile(String title)
      Displays a JFileChooser and returns the selected filename.
    • getSelectedFrame

      private JInternalFrame getSelectedFrame()
      Returns the current selected internal frame.
    • updateEnabled

      private void updateEnabled(boolean interrupted)
      Enables or disables the menu and tool bars with respect to the state of script execution.
    • setResizeWeight

      static void setResizeWeight(JSplitPane pane, double weight)
      Calls JSplitPane.setResizeWeight(double) via reflection. For compatibility, since JDK < 1.3 does not have this method.
    • readFile

      private String readFile(String fileName)
      Reads the file with the given name and returns its contents as a String.
    • updateSourceText

      public void updateSourceText(Dim.SourceInfo sourceInfo)
      Called when the source text for a script has been updated.
      Specified by:
      updateSourceText in interface GuiCallback
    • enterInterrupt

      public void enterInterrupt(Dim.StackFrame lastFrame, String threadTitle, String alertMessage)
      Called when the interrupt loop has been entered.
      Specified by:
      enterInterrupt in interface GuiCallback
    • isGuiEventThread

      public boolean isGuiEventThread()
      Returns whether the current thread is the GUI event thread.
      Specified by:
      isGuiEventThread in interface GuiCallback
    • dispatchNextGuiEvent

      public void dispatchNextGuiEvent() throws InterruptedException
      Processes the next GUI event.
      Specified by:
      dispatchNextGuiEvent in interface GuiCallback
      Throws:
      InterruptedException
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      Performs an action from the menu or toolbar.