edu.rice.cs.drjava.ui
Class MainFrame

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--edu.rice.cs.drjava.ui.MainFrame
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, OptionConstants, RootPaneContainer, Serializable, WindowConstants

public class MainFrame
extends JFrame
implements OptionConstants

DrJava's main window.

Version:
$Id: MainFrame.java,v 1.226 2002/09/10 02:27:07 csreis Exp $
See Also:
Serialized Form

Inner Class Summary
private  class MainFrame.DocCellRenderer
          Prints a display label for each item in the document list.
private  class MainFrame.DoclistFontOptionListener
          The OptionListener for FONT_DOCLIST
private  class MainFrame.GlassPane
          Blocks access to DrJava while the hourglass cursor is on
private  class MainFrame.LineEnumOptionListener
          The OptionListener for LINEENUM_ENABLED
private  class MainFrame.MainFontOptionListener
          The OptionListener for FONT_MAIN
private  class MainFrame.ModelListener
          Inner class to listen to all events in the model.
private  class MainFrame.PositionListener
          Inner class to handle the updating of current position within the document.
private  class MainFrame.QuitPromptOptionListener
          The OptionListener for QUIT_PROMPT
private  class MainFrame.RecentFilesOptionListener
          The OptionListener for RECENT_FILES_MAX_SIZE
private  class MainFrame.ToolbarFontOptionListener
          The OptionListener for FONT_TOOLBAR
private  class MainFrame.ToolbarOptionListener
          The OptionListener for TOOLBAR options
private  class MainFrame.UIDebugListener
          Listens to events from the debugger.
private  class MainFrame.WorkingDirOptionListener
          The OptionListener for WORKING_DIRECTORY
 
Inner classes inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.AWTTreeLock
 
Field Summary
private  Action _aboutAction
          Pops up an info dialog.
private  AboutDialog _aboutDialog
           
private  gj.util.Hashtable _breakpointHighlights
          Table to map breakpoints to their corresponding highlight objects.
private  Action _clearAllBreakpointsAction
          Clears all breakpoints
private  JMenuItem _clearAllBreakpointsMenuItem
           
private  Action _clearHistoryAction
          Clears the commands in the interaction history
private  Action _clearOutputAction
          Clears DrJava's output console.
private  Action _closeAction
          Closes the current active document, prompting to save if necessary.
private  Action _closeAllAction
          Closes all open documents, prompting to save if necessary.
private  Action _compileAction
          Compiles the document in the definitions pane.
private  Action _compileAllAction
          Compiles all open documents.
private  JButton _compileButton
           
private  ConfigFrame _configFrame
           
private  DefinitionsPane _currentDefPane
          The currently displayed DefinitionsPane.
private  HighlightManager.HighlightInfo _currentThreadLocationHighlight
          The current highlight displaying the location of the debugger's thread, if there is one.
private  JLabel _currLocationField
           
private  Action _cutLineAction
          Cuts from the caret to the end of the line to the clipboard.
private  JMenuItem _debuggerEnabledMenuItem
           
private  JMenu _debugMenu
           
private  DebugPanel _debugPanel
           
private  JSplitPane _debugSplitPane
           
private  Timer _debugStepTimer
          Timer to display "Stepping..." message if a step takes longer than a certain amount of time.
private  Hashtable _defScrollPanes
          Maps an OpenDefDoc to its JScrollPane.
private  JList _docList
           
private  JSplitPane _docSplitPane
           
private  JMenu _editMenu
           
private  Action _editPreferencesAction
          Calls the ConfigFrame to edit preferences
private  CompilerErrorPanel _errorPanel
           
private  JMenu _fileMenu
           
private  JLabel _fileNameField
           
private  String _fileTitle
          The filename currently being displayed.
private  FindReplaceDialog _findReplace
           
private  Action _findReplaceAction
          Shows the find/replace tab.
private  Action _gotoLineAction
          Asks the user for a line number and goes there.
private  Action _helpAction
          Shows the user documentation.
private  HelpFrame _helpFrame
           
private  JMenu _helpMenu
           
private  InteractionsPane _interactionsPane
           
private  JPanel _interactionsWithSyncPanel
          Panel to hold both InteractionsPane and its sync message.
private  Action _junitAction
          Runs JUnit on the document in the definitions pane.
private  JButton _junitButton
           
private  JUnitPanel _junitPanel
           
private  Action _loadHistoryAction
          Interprets the commands in a file in the interactions window
private  JSplitPane _mainSplit
           
private  JMenuBar _menuBar
           
private  SingleDisplayModel _model
          The model which controls all logic in DrJava.
private  Action _newAction
          Resets the document in the definitions pane to a blank one.
private  Action _openAction
          Asks user for file name and and reads that file into the definitions pane.
private  JFileChooser _openChooser
          For opening files.
private  FileOpenSelector _openSelector
          Returns the files to open to the model (command pattern).
private  OutputPane _outputPane
           
private  Action _pageSetupAction
          Opens the page setup window.
private  MainFrame.PositionListener _posListener
           
private  Action _printAction
          Prints the current document.
private  JMenuItem _printBreakpointsMenuItem
           
private  Action _printPreviewAction
          Opens the print preview window
private  boolean _promptBeforeQuit
          Whether to display a prompt message before quitting.
private  Action _quitAction
          Quits DrJava.
private  RecentFileManager _recentFileManager
          Keeps track of the recent files list in the File menu.
private  DelegatingAction _redoAction
          Redoes the last undo to the active definitions document.
private  Action _resetInteractionsAction
          Resets the Interactions pane.
private  Action _resumeDebugAction
          Resumes debugging
private  JMenuItem _resumeDebugMenuItem
           
private  Action _revertAction
          Reverts the current document.
private  JMenuItem _runDebuggerMenuItem
           
private  Action _saveAction
          Saves the current document.
private  Action _saveAllAction
          Saves all documents, prompting for file names as necessary
private  Action _saveAsAction
          Asks the user for a file name and saves the document currently in the definitions pane to that file.
private  JButton _saveButton
           
private  JFileChooser _saveChooser
          For saving files.
private  Action _saveHistoryAction
          Save the commands in the interactions window's history to a file
private  FileSaveSelector _saveSelector
          Returns the file to save to the model (command pattern).
private  Action _selectAllAction
          Selects all text in window.
private  JPanel _statusBar
           
private  Action _stepIntoDebugAction
          Steps into the next method call
private  JMenuItem _stepIntoDebugMenuItem
           
private  Action _stepOutDebugAction
          Steps out of the next method call
private  JMenuItem _stepOutDebugMenuItem
           
private  Action _stepOverDebugAction
          Runs the next line, without stepping into methods
private  JMenuItem _stepOverDebugMenuItem
           
private  JMenuItem _suspendDebugMenuItem
           
private  Action _switchToNextAction
          Switches to next document.
private  Action _switchToPrevAction
          Switches to previous document.
private  JLabel _syncStatus
          Label to display message if Interactions are out of sync with Definitions.
private  JTabbedPane _tabbedPane
           
private  LinkedList _tabs
           
(package private)  Action _toggleBreakpointAction
          Toggles a breakpoint on the current line
private  JMenuItem _toggleBreakpointMenuItem
           
private  Action _toggleDebuggerAction
          Enables the debugger
private  JToolBar _toolBar
           
private  JMenu _toolsMenu
           
private  DelegatingAction _undoAction
          Undoes the last change to the active definitions document.
private  WindowListener _windowCloseListener
          How DrJava responds to window events.
(package private)  Action copyAction
          Default copy action.
(package private)  Action cutAction
          Default cut action.
private static int DEBUG_STEP_TIMER_VALUE
          Number of seconds to wait before displaying "Stepping..." message after a step is requested in the debugger.
private static String DEBUGGER_OUT_OF_SYNC
           
private static int DOC_LIST_WIDTH
           
private static int GUI_HEIGHT
           
private static int GUI_WIDTH
           
private static String ICON_PATH
           
private static int INTERACTIONS_TAB
           
(package private)  Action pasteAction
          Default paste action.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, defaultCloseOperation, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
base, CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, frameSerializedDataVersion, HAND_CURSOR, icon, ICONIFIED, mbManagement, menuBar, MOVE_CURSOR, N_RESIZE_CURSOR, nameCounter, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, ownedWindows, resizable, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, serialVersionUID, state, SW_RESIZE_CURSOR, TEXT_CURSOR, title, W_RESIZE_CURSOR, WAIT_CURSOR, weakThis
 
Fields inherited from class java.awt.Window
active, dbg, focusMgr, inputContext, inputContextLock, nativeActive, OPENED, ownedWindowList, warningString, windowListener, windowSerializedDataVersion
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, needsPaint, printing, printingThreads
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface edu.rice.cs.drjava.config.OptionConstants
COMPILER_ERROR_COLOR, DEBUG_BREAKPOINT_COLOR, DEBUG_SHOW_THREADS, DEBUG_SOURCEPATH, DEBUG_STEP_DRJAVA, DEBUG_STEP_INTERPRETER, DEBUG_STEP_JAVA, DEBUG_THREAD_COLOR, DEFINITIONS_BACKGROUND_COLOR, DEFINITIONS_COMMENT_COLOR, DEFINITIONS_DOUBLE_QUOTED_COLOR, DEFINITIONS_KEYWORD_COLOR, DEFINITIONS_MATCH_COLOR, DEFINITIONS_NORMAL_COLOR, DEFINITIONS_NUMBER_COLOR, DEFINITIONS_SINGLE_QUOTED_COLOR, DEFINITIONS_TYPE_COLOR, EXTRA_CLASSPATH, FONT_DOCLIST, FONT_MAIN, FONT_TOOLBAR, HISTORY_MAX_SIZE, INDENT_LEVEL, INTERACTIONS_EXIT_PROMPT, JAVAC_ALLOW_ASSERT, JAVAC_LOCATION, JSR14_COLLECTIONSPATH, JSR14_LOCATION, KEY_BACKWARD, KEY_BEGIN_DOCUMENT, KEY_BEGIN_LINE, KEY_CLOSE_FILE, KEY_COMPILE, KEY_COMPILE_ALL, KEY_COPY, KEY_CUT, KEY_CUT_LINE, KEY_DEBUG_BREAKPOINT_TOGGLE, KEY_DEBUG_MODE_TOGGLE, KEY_DEBUG_RESUME, KEY_DEBUG_STEP_INTO, KEY_DEBUG_STEP_OUT, KEY_DEBUG_STEP_OVER, KEY_DELETE_NEXT, KEY_DELETE_PREVIOUS, KEY_DOWN, KEY_END_DOCUMENT, KEY_END_LINE, KEY_FIND_NEXT, KEY_FIND_REPLACE, KEY_FORWARD, KEY_GOTO_LINE, KEY_NEW_FILE, KEY_NEXT_DOCUMENT, KEY_NEXT_WORD, KEY_OPEN_FILE, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_PASTE, KEY_PREVIOUS_DOCUMENT, KEY_PREVIOUS_WORD, KEY_PRINT, KEY_PRINT_PREVIEW, KEY_QUIT, KEY_REDO, KEY_SAVE_FILE, KEY_SAVE_FILE_AS, KEY_SELECT_ALL, KEY_UNDO, KEY_UP, LINEENUM_ENABLED, mask, QUIT_PROMPT, RECENT_FILES, RECENT_FILES_MAX_SIZE, TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, WORKING_DIRECTORY
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MainFrame()
          Creates the main window, and shows it.
MainFrame(int rmiPort)
          Creates the main window and shows it.
 
Method Summary
private  void _addMenuItem(JMenu menu, Action a, Option opt)
          Adds an Action as a menu item to the given menu, using the specified configurable keystroke.
private  void _close()
           
private  void _closeAll()
           
private  void _compile()
          private void _revertAll() { try { _model.revertAllFiles(); } catch (FileMovedException fme) { _showFileMovedError(fme); } catch (IOException ioe) { _showIOError(ioe); } }
private  void _compileAll()
           
private  JScrollPane _createDefScrollPane(OpenDefinitionsDocument doc)
          Create a new DefinitionsPane and JScrollPane for an open definitions document.
(package private)  JButton _createManualToolbarButton(Action a)
          Creates a toolbar button for undo and redo, which behave differently.
 JButton _createToolbarButton(Action a)
          Sets up all buttons for the toolbar except for undo and redo, which use _createManualToolbarButton.
private  void _disableStepTimer()
          Disable any step timer
private  ImageIcon _getIcon(String name)
          Returns the icon with the given name.
private  void _gotoLine()
          Ask the user what line they'd like to jump to, then go there.
private  void _hideDebuggerPanel()
           
private  void _installNewDocumentListener(Document d)
          Makes sure save and compile buttons and menu items are enabled and disabled appropriately after document modifications.
private  void _junit()
           
private  void _new()
           
private  JMenuItem _newCheckBoxMenuItem(Action action)
          Returns a JRadioButtonMenuItem that looks like a JCheckBoxMenuItem.
private  void _open()
           
private  void _pageSetup()
           
private  void _print()
           
private  void _printPreview()
          Opens a new PrintPreview frame.
private  void _reenableScrollBar()
          Addresses the Mac OS X bug where the scrollbars are disabled in one document after opening another document.
private  void _removeErrorListener(OpenDefinitionsDocument doc)
          Removes the CompilerErrorCaretListener corresponding to the given document, after that document has been closed.
private  void _removeThreadLocationHighlight()
          Removes the current highlight
private  void _revert()
           
private  void _save()
           
private  void _saveAll()
           
private  void _saveAs()
           
private  void _selectAll()
           
private  void _setCurrentDirectory(File file)
          Sets the current directory to be that of the given file.
private  void _setCurrentDirectory(OpenDefinitionsDocument doc)
          Sets the current directory to be that of document's file.
private  void _setDebugMenuItemsEnabled(boolean enabled)
          Called every time the debug mode checkbox is toggled.
private  void _setDividerLocation()
           
private  void _setMainFont()
          Sets the font of all panes and panels to the main font
private  void _setMenuShortcut(JMenuItem item, Action a, Option opt)
          Sets the given menu item to have the specified configurable keystroke.
private  void _setThreadDependentDebugMenuItems(boolean isSuspended)
          Enables and disables the appropriate menu items in the debug menu depending upon the state of the current thread
private  void _setUpAction(Action a, String icon, String shortDesc)
           
private  void _setUpAction(Action a, String name, String icon, String shortDesc)
           
private  void _setUpActions()
          Initializes all action objects.
private  JMenu _setUpDebugMenu(int mask)
          Creates and returns a debug menu.
private  void _setUpDocumentSelector()
          Configures the component used for selecting active documents.
private  JMenu _setUpEditMenu(int mask)
          Creates and returns a edit menu.
private  JMenu _setUpFileMenu(int mask)
          Creates and returns a file menu.
private  JMenu _setUpHelpMenu(int mask)
          Creates and returns a help menu.
private  void _setUpKeyBindingMaps()
          Builds the Hashtables in KeyBindingManager that are used to keep track of key-bindings and allows for live updating, conflict resolution, and intelligent error messages (the ActionToNameMap)
private  void _setUpMenuBar()
          Sets up the components of the menu bar and links them to the private fields within MainFrame.
private  void _setUpPanes()
           
private  void _setUpStatusBar()
          Sets up the status bar with the filename field.
private  void _setUpTabs()
           
private  void _setUpToolBar()
          Sets up the toolbar with several useful buttons.
private  JMenu _setUpToolsMenu(int mask)
          Creates and returns a tools menu.
(package private)  void _showClassNotFoundError(ClassNotFoundException cnfe)
           
private  void _showConfigException()
          Check if any errors occurred while parsing the config file, and display a message if necessary.
(package private)  void _showDebugError(DebugException de)
           
private  void _showDebuggerPanel()
           
private  void _showDebuggingModifiedFileWarning()
          Shows a brief warning to the user, to inform him/her that the file he/she is debugging has been modified since its last save and should probably be saved and recompiled.
private  void _showError(Throwable e, String title, String message)
           
(package private)  void _showFileMovedError(FileMovedException fme)
           
(package private)  void _showFileNotFoundError(FileNotFoundException fnf)
           
(package private)  void _showIOError(IOException ioe)
           
(package private)  void _showNoClassDefError(NoClassDefFoundError ncde)
           
private  void _switchDefScrollPane()
          Switch to the JScrollPane containing the DefinitionsPane for the current active document.
private  void _updateDebugStatus()
          Checks if debugPanel's status bar displays the DEBUGGER_OUT_OF_SYNC message but the current document is in sync.
private  void _updateDefScrollRowHeader()
          Update the row header (line number enumeration) for the definitions scroll pane
private  void _updateToolbarButtons()
          Update the toolbar's buttons, following any change to TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, or FONT_TOOLBAR (name, style, text)
private  boolean _verifyOverwrite()
           
private  void _warnFileOpen()
           
(package private)  void debuggerClearAllBreakpoints()
          Clears all breakpoints from the debugger
(package private)  void debuggerResume()
          Suspends the current execution of the debugger private void debuggerSuspend() throws DebugException { if (inDebugMode()) _model.getDebugManager().suspend(); }/ /** Resumes the debugger's current execution
(package private)  void debuggerStep(int flag)
          Steps in the debugger
 void debuggerToggle()
          Toggles whether the debugger is enabled or disabled, and updates the display accordingly.
(package private)  void debuggerToggleBreakpoint()
          Toggles a breakpoint on the current line
private  File getChosenFile(JFileChooser fc, int choice)
          Returns the File selected by the JFileChooser.
private  File[] getChosenFiles(JFileChooser fc, int choice)
          Returns the File selected by the JFileChooser.
 DefinitionsPane getCurrentDefPane()
          Returns the current DefinitionsPane.
 JViewport getDefViewport()
           
static ImageIcon getIcon(String name)
           
 SingleDisplayModel getModel()
           
 File[] getOpenFiles(JFileChooser jfc)
          Prompt the user to select a place to open a file from, then load it.
 File getSaveFile(JFileChooser jfc)
          Prompt the user to select a place to save the current document.
 void hideDebugger()
          Hide the debugger tab and update the Debug menu accordingly.
 void hourglassOff()
          Return the cursor to normal.
 void hourglassOn()
          Make the cursor an hourglass.
(package private)  boolean inDebugMode()
           
(package private)  void open(FileOpenSelector openSelector)
           
 void removeTab(Component c)
           
 void showDebugger()
          Display the debugger tab and update the Debug menu accordingly.
 void showTab(Component c)
          Shows the components passed in in the appropriate place in the tabbedPane depending on the position of the component in the _tabs list.
(package private)  void updateErrorListeners()
          Update all appropriate listeners that the CompilerErrorModels have changed.
 void updateFileTitle()
          Updates the title bar with the name of the active document.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, createRootPaneException, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
, addNotify, addToFrameList, constructComponentName, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, initIDs, isResizable, postProcessKeyEvent, readObject, remove, removeFromFrameList, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle, writeObject
 
Methods inherited from class java.awt.Window
addOwnedWindow, addWindowListener, adjustListeningChildren, applyResourceBundle, applyResourceBundle, connectOwnedWindow, dispatchEventImpl, dispose, eventEnabled, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postWindowEvent, preProcessKeyEvent, processEvent, removeOwnedWindow, removeWindowListener, resetGC, setCursor, setFocusOwner, setWarningString, show, toBack, toFront, transferFocus
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, numListening, paint, paintComponents, paintHeavyweightComponents, postsOldMouseEvents, preferredSize, print, printComponents, printHeavyweightComponents, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, 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, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

INTERACTIONS_TAB

private static final int INTERACTIONS_TAB

GUI_WIDTH

private static final int GUI_WIDTH

GUI_HEIGHT

private static final int GUI_HEIGHT

DOC_LIST_WIDTH

private static final int DOC_LIST_WIDTH

ICON_PATH

private static final String ICON_PATH

DEBUGGER_OUT_OF_SYNC

private static final String DEBUGGER_OUT_OF_SYNC

DEBUG_STEP_TIMER_VALUE

private static final int DEBUG_STEP_TIMER_VALUE
Number of seconds to wait before displaying "Stepping..." message after a step is requested in the debugger.

_model

private final SingleDisplayModel _model
The model which controls all logic in DrJava.

_defScrollPanes

private Hashtable _defScrollPanes
Maps an OpenDefDoc to its JScrollPane.

_currentDefPane

private DefinitionsPane _currentDefPane
The currently displayed DefinitionsPane.

_fileTitle

private String _fileTitle
The filename currently being displayed.

_tabbedPane

private JTabbedPane _tabbedPane

_errorPanel

private CompilerErrorPanel _errorPanel

_outputPane

private OutputPane _outputPane

_interactionsPane

private InteractionsPane _interactionsPane

_debugPanel

private DebugPanel _debugPanel

_junitPanel

private JUnitPanel _junitPanel

_findReplace

private FindReplaceDialog _findReplace

_tabs

private LinkedList _tabs

_interactionsWithSyncPanel

private JPanel _interactionsWithSyncPanel
Panel to hold both InteractionsPane and its sync message. TO DO: move sync message into the pane itself.

_syncStatus

private JLabel _syncStatus
Label to display message if Interactions are out of sync with Definitions.

_statusBar

private JPanel _statusBar

_fileNameField

private JLabel _fileNameField

_currLocationField

private JLabel _currLocationField

_posListener

private MainFrame.PositionListener _posListener

_docSplitPane

private JSplitPane _docSplitPane

_debugSplitPane

private JSplitPane _debugSplitPane

_mainSplit

private JSplitPane _mainSplit

_docList

private JList _docList

_saveButton

private JButton _saveButton

_compileButton

private JButton _compileButton

_junitButton

private JButton _junitButton

_toolBar

private JToolBar _toolBar

_menuBar

private JMenuBar _menuBar

_fileMenu

private JMenu _fileMenu

_editMenu

private JMenu _editMenu

_toolsMenu

private JMenu _toolsMenu

_debugMenu

private JMenu _debugMenu

_helpMenu

private JMenu _helpMenu

_debuggerEnabledMenuItem

private JMenuItem _debuggerEnabledMenuItem

_runDebuggerMenuItem

private JMenuItem _runDebuggerMenuItem

_resumeDebugMenuItem

private JMenuItem _resumeDebugMenuItem

_stepIntoDebugMenuItem

private JMenuItem _stepIntoDebugMenuItem

_stepOverDebugMenuItem

private JMenuItem _stepOverDebugMenuItem

_stepOutDebugMenuItem

private JMenuItem _stepOutDebugMenuItem

_suspendDebugMenuItem

private JMenuItem _suspendDebugMenuItem

_toggleBreakpointMenuItem

private JMenuItem _toggleBreakpointMenuItem

_printBreakpointsMenuItem

private JMenuItem _printBreakpointsMenuItem

_clearAllBreakpointsMenuItem

private JMenuItem _clearAllBreakpointsMenuItem

_configFrame

private ConfigFrame _configFrame

_helpFrame

private HelpFrame _helpFrame

_aboutDialog

private AboutDialog _aboutDialog

_recentFileManager

private RecentFileManager _recentFileManager
Keeps track of the recent files list in the File menu.

_debugStepTimer

private final Timer _debugStepTimer
Timer to display "Stepping..." message if a step takes longer than a certain amount of time. All accesses must be synchronized on it.

_currentThreadLocationHighlight

private HighlightManager.HighlightInfo _currentThreadLocationHighlight
The current highlight displaying the location of the debugger's thread, if there is one. If there is none, this is null.

_breakpointHighlights

private gj.util.Hashtable _breakpointHighlights
Table to map breakpoints to their corresponding highlight objects.

_promptBeforeQuit

private boolean _promptBeforeQuit
Whether to display a prompt message before quitting.

_openChooser

private JFileChooser _openChooser
For opening files. We have a persistent dialog to keep track of the last directory from which we opened.

_saveChooser

private JFileChooser _saveChooser
For saving files. We have a persistent dialog to keep track of the last directory from which we saved.

_openSelector

private FileOpenSelector _openSelector
Returns the files to open to the model (command pattern).

_saveSelector

private FileSaveSelector _saveSelector
Returns the file to save to the model (command pattern).

_newAction

private Action _newAction
Resets the document in the definitions pane to a blank one.

_openAction

private Action _openAction
Asks user for file name and and reads that file into the definitions pane.

_closeAction

private Action _closeAction
Closes the current active document, prompting to save if necessary.

_closeAllAction

private Action _closeAllAction
Closes all open documents, prompting to save if necessary.

_saveAction

private Action _saveAction
Saves the current document.

_saveAsAction

private Action _saveAsAction
Asks the user for a file name and saves the document currently in the definitions pane to that file.

_revertAction

private Action _revertAction
Reverts the current document.

_saveAllAction

private Action _saveAllAction
Saves all documents, prompting for file names as necessary

_printAction

private Action _printAction
Prints the current document.

_printPreviewAction

private Action _printPreviewAction
Opens the print preview window

_pageSetupAction

private Action _pageSetupAction
Opens the page setup window.

_compileAction

private Action _compileAction
Compiles the document in the definitions pane.

_compileAllAction

private Action _compileAllAction
Compiles all open documents.

_junitAction

private Action _junitAction
Runs JUnit on the document in the definitions pane.

cutAction

Action cutAction
Default cut action. Returns focus to the correct pane.

copyAction

Action copyAction
Default copy action. Returns focus to the correct pane.

pasteAction

Action pasteAction
Default paste action. Returns focus to the correct pane.

_undoAction

private DelegatingAction _undoAction
Undoes the last change to the active definitions document.

_redoAction

private DelegatingAction _redoAction
Redoes the last undo to the active definitions document.

_quitAction

private Action _quitAction
Quits DrJava. Optionally displays a prompt before quitting.

_selectAllAction

private Action _selectAllAction
Selects all text in window.

_findReplaceAction

private Action _findReplaceAction
Shows the find/replace tab.

_gotoLineAction

private Action _gotoLineAction
Asks the user for a line number and goes there.

_clearOutputAction

private Action _clearOutputAction
Clears DrJava's output console.

_resetInteractionsAction

private Action _resetInteractionsAction
Resets the Interactions pane.

_helpAction

private Action _helpAction
Shows the user documentation.

_aboutAction

private Action _aboutAction
Pops up an info dialog.

_switchToNextAction

private Action _switchToNextAction
Switches to next document.

_switchToPrevAction

private Action _switchToPrevAction
Switches to previous document.

_editPreferencesAction

private Action _editPreferencesAction
Calls the ConfigFrame to edit preferences

_toggleDebuggerAction

private Action _toggleDebuggerAction
Enables the debugger

_resumeDebugAction

private Action _resumeDebugAction
Resumes debugging

_stepIntoDebugAction

private Action _stepIntoDebugAction
Steps into the next method call

_stepOverDebugAction

private Action _stepOverDebugAction
Runs the next line, without stepping into methods

_stepOutDebugAction

private Action _stepOutDebugAction
Steps out of the next method call

_toggleBreakpointAction

Action _toggleBreakpointAction
Toggles a breakpoint on the current line

_clearAllBreakpointsAction

private Action _clearAllBreakpointsAction
Clears all breakpoints

_cutLineAction

private Action _cutLineAction
Cuts from the caret to the end of the line to the clipboard.

_loadHistoryAction

private Action _loadHistoryAction
Interprets the commands in a file in the interactions window

_saveHistoryAction

private Action _saveHistoryAction
Save the commands in the interactions window's history to a file

_clearHistoryAction

private Action _clearHistoryAction
Clears the commands in the interaction history

_windowCloseListener

private WindowListener _windowCloseListener
How DrJava responds to window events.
Constructor Detail

MainFrame

public MainFrame()
Creates the main window, and shows it.

MainFrame

public MainFrame(int rmiPort)
Creates the main window and shows it. The underlying model will be told to use the given port for the RMI registry. If the port is -1, it will use a unique port.
Method Detail

getModel

public SingleDisplayModel getModel()
Returns:
The model providing the logic for this view.

hourglassOn

public void hourglassOn()
Make the cursor an hourglass.

hourglassOff

public void hourglassOff()
Return the cursor to normal.

debuggerToggle

public void debuggerToggle()
Toggles whether the debugger is enabled or disabled, and updates the display accordingly.

showDebugger

public void showDebugger()
Display the debugger tab and update the Debug menu accordingly.

hideDebugger

public void hideDebugger()
Hide the debugger tab and update the Debug menu accordingly.

_showDebuggerPanel

private void _showDebuggerPanel()

_hideDebuggerPanel

private void _hideDebuggerPanel()

updateFileTitle

public void updateFileTitle()
Updates the title bar with the name of the active document.

getOpenFiles

public File[] getOpenFiles(JFileChooser jfc)
                    throws OperationCanceledException
Prompt the user to select a place to open a file from, then load it. Ask the user if they'd like to save previous changes (if the current document has been modified) before opening.

getSaveFile

public File getSaveFile(JFileChooser jfc)
                 throws OperationCanceledException
Prompt the user to select a place to save the current document.

getCurrentDefPane

public DefinitionsPane getCurrentDefPane()
Returns the current DefinitionsPane.

_installNewDocumentListener

private void _installNewDocumentListener(Document d)
Makes sure save and compile buttons and menu items are enabled and disabled appropriately after document modifications.

_new

private void _new()

_open

private void _open()

open

void open(FileOpenSelector openSelector)

_close

private void _close()

_print

private void _print()

_printPreview

private void _printPreview()
Opens a new PrintPreview frame.

_pageSetup

private void _pageSetup()

_closeAll

private void _closeAll()

_save

private void _save()

_saveAs

private void _saveAs()

_saveAll

private void _saveAll()

_revert

private void _revert()

_compile

private void _compile()
private void _revertAll() { try { _model.revertAllFiles(); } catch (FileMovedException fme) { _showFileMovedError(fme); } catch (IOException ioe) { _showIOError(ioe); } }

_compileAll

private void _compileAll()

_junit

private void _junit()

debuggerResume

void debuggerResume()
              throws DebugException
Suspends the current execution of the debugger private void debuggerSuspend() throws DebugException { if (inDebugMode()) _model.getDebugManager().suspend(); }/ /** Resumes the debugger's current execution

debuggerStep

void debuggerStep(int flag)
Steps in the debugger

debuggerToggleBreakpoint

void debuggerToggleBreakpoint()
Toggles a breakpoint on the current line

debuggerClearAllBreakpoints

void debuggerClearAllBreakpoints()
Clears all breakpoints from the debugger

_showFileMovedError

void _showFileMovedError(FileMovedException fme)

_showFileNotFoundError

void _showFileNotFoundError(FileNotFoundException fnf)

_showIOError

void _showIOError(IOException ioe)

_showClassNotFoundError

void _showClassNotFoundError(ClassNotFoundException cnfe)

_showNoClassDefError

void _showNoClassDefError(NoClassDefFoundError ncde)

_showDebugError

void _showDebugError(DebugException de)

_showError

private void _showError(Throwable e,
                        String title,
                        String message)

_showConfigException

private void _showConfigException()
Check if any errors occurred while parsing the config file, and display a message if necessary.

_showDebuggingModifiedFileWarning

private void _showDebuggingModifiedFileWarning()
Shows a brief warning to the user, to inform him/her that the file he/she is debugging has been modified since its last save and should probably be saved and recompiled. Does not actually save or recompile for the user.

getChosenFile

private File getChosenFile(JFileChooser fc,
                           int choice)
                    throws OperationCanceledException
Returns the File selected by the JFileChooser.
Parameters:
fc - File chooser presented to the user
choice - return value from fc
Returns:
Selected File
Throws:
OperationCanceledException - if file choice canceled
RuntimeException - if fc returns a bad file or choice

getChosenFiles

private File[] getChosenFiles(JFileChooser fc,
                              int choice)
                       throws OperationCanceledException
Returns the File selected by the JFileChooser.
Parameters:
fc - File chooser presented to the user
choice - return value from fc
Returns:
Selected File
Throws:
OperationCanceledException - if file choice canceled
RuntimeException - if fc returns a bad file or choice

_selectAll

private void _selectAll()

_gotoLine

private void _gotoLine()
Ask the user what line they'd like to jump to, then go there.

updateErrorListeners

void updateErrorListeners()
Update all appropriate listeners that the CompilerErrorModels have changed.

_removeErrorListener

private void _removeErrorListener(OpenDefinitionsDocument doc)
Removes the CompilerErrorCaretListener corresponding to the given document, after that document has been closed. (Allows pane and listener to be garbage collected...)

_setUpActions

private void _setUpActions()
Initializes all action objects. Adds icons and descriptions to several of the actions. Note: this initialization will later be done in the constructor of each action, which will subclass AbstractAction.

_setUpAction

private void _setUpAction(Action a,
                          String name,
                          String icon,
                          String shortDesc)

_setUpAction

private void _setUpAction(Action a,
                          String icon,
                          String shortDesc)

_getIcon

private ImageIcon _getIcon(String name)
Returns the icon with the given name. All icons are assumed to reside in the /edu/rice/cs/drjava/ui/icons directory.
Parameters:
name - Name of icon image file
Returns:
ImageIcon object constructed from the file

getIcon

public static ImageIcon getIcon(String name)

_setUpMenuBar

private void _setUpMenuBar()
Sets up the components of the menu bar and links them to the private fields within MainFrame. This method serves to make the code more legible on the higher calling level, i.e., the constructor.

_addMenuItem

private void _addMenuItem(JMenu menu,
                          Action a,
                          Option opt)
Adds an Action as a menu item to the given menu, using the specified configurable keystroke.
Parameters:
menu - Menu to add item to
a - Action for the menu item
opt - Configurable keystroke for the menu item

_setMenuShortcut

private void _setMenuShortcut(JMenuItem item,
                              Action a,
                              Option opt)
Sets the given menu item to have the specified configurable keystroke.
Parameters:
item - Menu item containing the action
a - Action for the menu item
opt - Configurable keystroke for the menu item

_setUpFileMenu

private JMenu _setUpFileMenu(int mask)
Creates and returns a file menu. Side effects: sets values for _saveMenuItem.

_setUpEditMenu

private JMenu _setUpEditMenu(int mask)
Creates and returns a edit menu.

_setUpToolsMenu

private JMenu _setUpToolsMenu(int mask)
Creates and returns a tools menu.

_setUpDebugMenu

private JMenu _setUpDebugMenu(int mask)
Creates and returns a debug menu.

_setDebugMenuItemsEnabled

private void _setDebugMenuItemsEnabled(boolean enabled)
Called every time the debug mode checkbox is toggled. The resume and step functions should always be disabled.

_setThreadDependentDebugMenuItems

private void _setThreadDependentDebugMenuItems(boolean isSuspended)
Enables and disables the appropriate menu items in the debug menu depending upon the state of the current thread
Parameters:
isSuspended - is true when the current thread has just been suspended false if the current thread has just been resumed

_setUpHelpMenu

private JMenu _setUpHelpMenu(int mask)
Creates and returns a help menu.

_createManualToolbarButton

JButton _createManualToolbarButton(Action a)
Creates a toolbar button for undo and redo, which behave differently.

_createToolbarButton

public JButton _createToolbarButton(Action a)
Sets up all buttons for the toolbar except for undo and redo, which use _createManualToolbarButton.

_setUpToolBar

private void _setUpToolBar()
Sets up the toolbar with several useful buttons. Most buttons are always enabled, but those that are not are maintained in fields to allow enabling and disabling.

_updateToolbarButtons

private void _updateToolbarButtons()
Update the toolbar's buttons, following any change to TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, or FONT_TOOLBAR (name, style, text)

_setUpStatusBar

private void _setUpStatusBar()
Sets up the status bar with the filename field.

_setUpTabs

private void _setUpTabs()

_setUpDocumentSelector

private void _setUpDocumentSelector()
Configures the component used for selecting active documents.

_createDefScrollPane

private JScrollPane _createDefScrollPane(OpenDefinitionsDocument doc)
Create a new DefinitionsPane and JScrollPane for an open definitions document.
Parameters:
doc - The open definitions document to wrap
Returns:
JScrollPane containing a DefinitionsPane for the given document.

_setUpPanes

private void _setUpPanes()

_switchDefScrollPane

private void _switchDefScrollPane()
Switch to the JScrollPane containing the DefinitionsPane for the current active document.

_reenableScrollBar

private void _reenableScrollBar()
Addresses the Mac OS X bug where the scrollbars are disabled in one document after opening another document.

_newCheckBoxMenuItem

private JMenuItem _newCheckBoxMenuItem(Action action)
Returns a JRadioButtonMenuItem that looks like a JCheckBoxMenuItem. This is a workaround for a known bug on OS X's version of Java. (See http://developer.apple.com/qa/qa2001/qa1154.html)
Parameters:
action - Action for the menu item
Returns:
JRadioButtonMenuItem with a checkbox icon

_setCurrentDirectory

private void _setCurrentDirectory(File file)
Sets the current directory to be that of the given file.

_setCurrentDirectory

private void _setCurrentDirectory(OpenDefinitionsDocument doc)
Sets the current directory to be that of document's file.

_setMainFont

private void _setMainFont()
Sets the font of all panes and panels to the main font
Parameters:
f - is a Font object

_updateDefScrollRowHeader

private void _updateDefScrollRowHeader()
Update the row header (line number enumeration) for the definitions scroll pane

_removeThreadLocationHighlight

private void _removeThreadLocationHighlight()
Removes the current highlight

_disableStepTimer

private void _disableStepTimer()
Disable any step timer

_updateDebugStatus

private void _updateDebugStatus()
Checks if debugPanel's status bar displays the DEBUGGER_OUT_OF_SYNC message but the current document is in sync. Clears the debugPanel's status bar in this case.

getDefViewport

public JViewport getDefViewport()

removeTab

public void removeTab(Component c)

showTab

public void showTab(Component c)
Shows the components passed in in the appropriate place in the tabbedPane depending on the position of the component in the _tabs list.
Parameters:
c - the component to show in the tabbedPane

_setDividerLocation

private void _setDividerLocation()

_warnFileOpen

private void _warnFileOpen()

_verifyOverwrite

private boolean _verifyOverwrite()

inDebugMode

boolean inDebugMode()

_setUpKeyBindingMaps

private void _setUpKeyBindingMaps()
Builds the Hashtables in KeyBindingManager that are used to keep track of key-bindings and allows for live updating, conflict resolution, and intelligent error messages (the ActionToNameMap)