Skip to content

Commit 729d315

Browse files
committed
Merge branch 'drscala' of github.com:DrJavaAtRice/drjava into drscala
This merge reconciles commits from two different platforms: my Linux laptop and my Chromebook (with Ubuntu 14.04 Linux loaded via crouton).
2 parents 50237ae + 60c36e2 commit 729d315

File tree

5 files changed

+48
-210
lines changed

5 files changed

+48
-210
lines changed

drjava/lib/platform.jar

-42 Bytes
Binary file not shown.

drjava/src/edu/rice/cs/drjava/ui/MainFrame.java

Lines changed: 38 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,6 @@ public class MainFrame extends SwingFrame implements ClipboardOwner, DropTargetL
138138
private static final int CONSOLE_TAB = 1;
139139
private static final String ICON_PATH = "/edu/rice/cs/drjava/ui/icons/";
140140

141-
/* Debugger deactivated in DrScala */
142-
// private static final String DEBUGGER_OUT_OF_SYNC =
143-
// " Current document is out of sync with the debugger and should be recompiled!";
144-
//
145-
// /** Number of milliseconds to wait before displaying "Stepping..." message after a step is requested in
146-
// * the debugger.
147-
// */
148-
// private static final int DEBUG_STEP_TIMER_VALUE = 3000;
149-
150141
// ------ Field Declarations -------
151142

152143
/** The model which controls all logic in DrScala. */
@@ -3269,27 +3260,20 @@ public void setCurrentDirectory(File dir) {
32693260
_editMenu = _setUpEditMenu(mask, true);
32703261
_toolsMenu = _setUpToolsMenu(mask, true);
32713262
_projectMenu = _setUpProjectMenu(mask, true);
3272-
3273-
3274-
/* Debugger is deactivated in DrScala */
3275-
// _debugMenu = null;
3276-
// if (_showDebugger) _debugMenu = _setUpDebugMenu(mask, true);
3277-
32783263
_helpMenu = _setUpHelpMenu(mask, true);
32793264

32803265
// initialize menu bar and actions
32813266
_setUpActions();
32823267
/* Omit _debugMenu until debugging actions are implemented correctly */
3283-
_setUpMenuBar(_menuBar,
3284-
_fileMenu, _editMenu, _toolsMenu, _projectMenu, /* _debugMenu, */ _helpMenu);
3268+
_setUpMenuBar(_menuBar, _fileMenu, _editMenu, _toolsMenu, _projectMenu, _helpMenu);
32853269
setJMenuBar(_menuBar);
32863270

32873271
// _setUpDocumentSelector();
32883272
_setUpContextMenus();
32893273

32903274
// Create toolbar and buttons
3291-
_undoButton = _createManualToolbarButton(_undoAction);
3292-
_redoButton = _createManualToolbarButton(_redoAction);
3275+
_undoButton = _createManualToolBarButton(_undoAction);
3276+
_redoButton = _createManualToolBarButton(_redoAction);
32933277

32943278
// initialize _toolBar
32953279
_setUpToolBar();
@@ -3329,33 +3313,6 @@ public void windowClosing(WindowEvent we) {
33293313
// set up the menu bars on other frames
33303314
_tabbedPanesFrame.setUpMenuBar();
33313315

3332-
/* Debugger deactivated in DrScala */
3333-
// // Create detachable debug frame
3334-
// if (_debugPanel != null) { // using debugger
3335-
// _debugFrame = new DetachedFrame("Debugger", MainFrame.this, new Runnable1<DetachedFrame>() {
3336-
// public void run(DetachedFrame frame) {
3337-
// frame.getContentPane().add(_debugPanel);
3338-
// }
3339-
// }, new Runnable1<DetachedFrame>() {
3340-
// public void run(DetachedFrame frame) {
3341-
// _debugSplitPane.setTopComponent(_docSplitPane);
3342-
// _debugSplitPane.setBottomComponent(_debugPanel);
3343-
// _mainSplit.setTopComponent(_debugSplitPane);
3344-
// }
3345-
// });
3346-
// _debugFrame.addWindowListener(new WindowAdapter() {
3347-
// public void windowClosing(WindowEvent we) {
3348-
// if (_debugFrame == null) return; // debugger not used
3349-
// _detachDebugFrameMenuItem.setSelected(false);
3350-
// DrScala.getConfig().setSetting(DETACH_DEBUGGER, false);
3351-
// }
3352-
// });
3353-
// _debugFrame.setUpMenuBar();
3354-
// }
3355-
// else { // not using debugger
3356-
// _debugFrame = null;
3357-
// }
3358-
33593316
// Set frame icon
33603317
setIconImage(MainFrame.getIcon("drscala64.png").getImage());
33613318

@@ -3435,9 +3392,9 @@ public void windowOpened(WindowEvent e) {
34353392
config.addOptionListener(FONT_LINE_NUMBERS, new LineNumbersFontOptionListener());
34363393
config.addOptionListener(FONT_DOCLIST, new DoclistFontOptionListener());
34373394
config.addOptionListener(FONT_TOOLBAR, new ToolbarFontOptionListener());
3438-
config.addOptionListener(TOOLBAR_ICONS_ENABLED, new ToolbarOptionListener());
3439-
config.addOptionListener(TOOLBAR_TEXT_ENABLED, new ToolbarOptionListener());
3440-
config.addOptionListener(TOOLBAR_ENABLED, new ToolbarOptionListener());
3395+
config.addOptionListener(TOOLBAR_ICONS_ENABLED, new ToolBarOptionListener());
3396+
config.addOptionListener(TOOLBAR_TEXT_ENABLED, new ToolBarOptionListener());
3397+
config.addOptionListener(TOOLBAR_ENABLED, new ToolBarOptionListener());
34413398
config.addOptionListener(LINEENUM_ENABLED, new LineEnumOptionListener());
34423399
config.addOptionListener(DEFINITIONS_LINE_NUMBER_COLOR, new LineEnumColorOptionListener());
34433400
config.addOptionListener(DEFINITIONS_LINE_NUMBER_BACKGROUND_COLOR, new LineEnumColorOptionListener());
@@ -6267,12 +6224,26 @@ public static ImageIcon getIcon(String name) {
62676224
/** This allows us to intercept key events when compiling testing and turn them off when the glass pane is up. */
62686225
static class MenuBar extends JMenuBar {
62696226
private final MainFrame _mf;
6270-
public MenuBar(MainFrame mf) { _mf = mf; }
6227+
public MenuBar(MainFrame mf) {
6228+
_mf = mf;}
62716229
public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
62726230
if (_mf.getAllowKeyEvents()) return super.processKeyBinding(ks, e, condition, pressed);
62736231
return false;
62746232
}
62756233
}
6234+
6235+
/** Update the menubar's buttons, following any change to FONT_TOOLBAR (name, style, text) */
6236+
private void _updateMenuBarButtons() {
6237+
Component[] buttons = _menuBar.getComponents();
6238+
Font toolbarFont = DrScala.getConfig().getSetting(FONT_TOOLBAR);
6239+
6240+
for (int i = 0; i < buttons.length; i++) {
6241+
if (buttons[i] instanceof JButton) {
6242+
JButton b = (JButton) buttons[i];
6243+
b.setFont(toolbarFont);
6244+
}
6245+
}
6246+
}
62766247

62776248
public void addMenuBarInOtherFrame(JMenuBar menuBar) {
62786249
JMenu fileMenu = menuBar.getMenu(Utilities.getComponentIndex(_fileMenu));
@@ -6293,27 +6264,19 @@ public void removeMenuBarInOtherFrame(JMenuBar menuBar) {
62936264
*/
62946265
void _setUpMenuBar(JMenuBar menuBar) {
62956266
int mask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
6296-
_setUpMenuBar(menuBar,
6297-
_setUpFileMenu(mask, false), _setUpEditMenu(mask, false), _setUpToolsMenu(mask, false),
6298-
_setUpProjectMenu(mask, false), /* _showDebugger ? _setUpDebugMenu(mask, false) : null, */
6299-
_setUpHelpMenu(mask, false));
6267+
_setUpMenuBar(menuBar, _setUpFileMenu(mask, false), _setUpEditMenu(mask, false), _setUpToolsMenu(mask, false),
6268+
_setUpProjectMenu(mask, false), _setUpHelpMenu(mask, false));
63006269
}
63016270

63026271
/* Defining a method that takes an argument for each menu is very rigid! */
6303-
void _setUpMenuBar(JMenuBar menuBar,
6304-
JMenu fileMenu,
6305-
JMenu editMenu,
6306-
JMenu toolsMenu,
6307-
JMenu projectMenu,
6308-
/* JMenu debugMenu, */
6272+
void _setUpMenuBar(JMenuBar menuBar, JMenu fileMenu, JMenu editMenu, JMenu toolsMenu, JMenu projectMenu,
63096273
JMenu helpMenu) {
63106274
menuBar.add(fileMenu);
63116275
menuBar.add(editMenu);
63126276
menuBar.add(toolsMenu);
63136277
menuBar.add(projectMenu);
6314-
/* Omit until debugger is specified and implemented correctly. */
6315-
// if (_showDebugger && (debugMenu!=null)) menuBar.add(debugMenu);
63166278
menuBar.add(helpMenu);
6279+
63176280
// Plastic-specific style hints
63186281
if(Utilities.isPlasticLaf()) {
63196282
menuBar.putClientProperty(com.jgoodies.looks.Options.HEADER_STYLE_KEY, com.jgoodies.looks.HeaderStyle.BOTH);
@@ -6724,133 +6687,6 @@ private JMenu _setUpProjectMenu(int mask, boolean updateKeyboardManager) {
67246687
return projectMenu;
67256688
}
67266689

6727-
/* Debugger deactivated in DrScala */
6728-
// /** Creates and returns a debug menu.
6729-
// * @param mask the keystroke modifier to be used
6730-
// * @param updateKeyboardManager true if the keyboard manager should be updated; pass true only for MainFrame!
6731-
// */
6732-
// private JMenu _setUpDebugMenu(int mask, boolean updateKeyboardManager) {
6733-
// JMenu debugMenu = new JMenu("Debugger");
6734-
// PlatformFactory.ONLY.setMnemonic(debugMenu,KeyEvent.VK_D);
6735-
// // Enable debugging item
6736-
// JMenuItem tempDebuggerEnabledMenuItem = MainFrameStatics.newCheckBoxMenuItem(_toggleDebuggerAction);
6737-
// tempDebuggerEnabledMenuItem.setSelected(false);
6738-
// _setMenuShortcut(tempDebuggerEnabledMenuItem, _toggleDebuggerAction, KEY_DEBUG_MODE_TOGGLE, updateKeyboardManager);
6739-
// debugMenu.add(tempDebuggerEnabledMenuItem);
6740-
// if (_debuggerEnabledMenuItem == null) {
6741-
// // assign the first time
6742-
// _debuggerEnabledMenuItem = tempDebuggerEnabledMenuItem;
6743-
// }
6744-
// else {
6745-
// // otherwise link this item to the first item
6746-
// final WeakReference<JMenuItem> weakRef = new WeakReference<JMenuItem>(tempDebuggerEnabledMenuItem);
6747-
// _debuggerEnabledMenuItem.addItemListener(new ItemListener() {
6748-
// public void itemStateChanged(ItemEvent e) {
6749-
// JMenuItem temp = weakRef.get();
6750-
// if (temp!=null) {
6751-
// temp.setSelected(_debuggerEnabledMenuItem.isSelected());
6752-
// }
6753-
// else {
6754-
// // weak reference cleared, remove this listener
6755-
// _debuggerEnabledMenuItem.removeItemListener(this);
6756-
// }
6757-
// }
6758-
// });
6759-
// }
6760-
//
6761-
// debugMenu.addSeparator();
6762-
//
6763-
// _addMenuItem(debugMenu, _toggleBreakpointAction, KEY_DEBUG_BREAKPOINT_TOGGLE, updateKeyboardManager);
6764-
// //_printBreakpointsMenuItem = debugMenu.add(_printBreakpointsAction);
6765-
// //_clearAllBreakpointsMenuItem =
6766-
// _addMenuItem(debugMenu, _clearAllBreakpointsAction, KEY_DEBUG_CLEAR_ALL_BREAKPOINTS, updateKeyboardManager);
6767-
// _addMenuItem(debugMenu, _breakpointsPanelAction, KEY_DEBUG_BREAKPOINT_PANEL, updateKeyboardManager);
6768-
// debugMenu.addSeparator();
6769-
//
6770-
// //_addMenuItem(debugMenu, _suspendDebugAction, KEY_DEBUG_SUSPEND, updateKeyboardManager);
6771-
// _addMenuItem(debugMenu, _resumeDebugAction, KEY_DEBUG_RESUME, updateKeyboardManager);
6772-
// _addMenuItem(debugMenu, _stepIntoDebugAction, KEY_DEBUG_STEP_INTO, updateKeyboardManager);
6773-
// _addMenuItem(debugMenu, _stepOverDebugAction, KEY_DEBUG_STEP_OVER, updateKeyboardManager);
6774-
// _addMenuItem(debugMenu, _stepOutDebugAction, KEY_DEBUG_STEP_OUT, updateKeyboardManager);
6775-
//
6776-
// JMenuItem tempAutomaticTraceMenuItem = MainFrameStatics.newCheckBoxMenuItem(_automaticTraceDebugAction);
6777-
// _setMenuShortcut(tempAutomaticTraceMenuItem, _automaticTraceDebugAction, KEY_DEBUG_AUTOMATIC_TRACE,
6778-
// updateKeyboardManager);
6779-
// debugMenu.add(tempAutomaticTraceMenuItem);
6780-
// if (_automaticTraceMenuItem==null) {
6781-
// // assign the first time
6782-
// _automaticTraceMenuItem = tempAutomaticTraceMenuItem;
6783-
// }
6784-
// else {
6785-
// // otherwise link this item to the first item
6786-
// final WeakReference<JMenuItem> weakRef = new WeakReference<JMenuItem>(tempAutomaticTraceMenuItem);
6787-
// _automaticTraceMenuItem.addItemListener(new ItemListener() {
6788-
// public void itemStateChanged(ItemEvent e) {
6789-
// JMenuItem temp = weakRef.get();
6790-
// if (temp!=null) {
6791-
// temp.setSelected(_automaticTraceMenuItem.isSelected());
6792-
// }
6793-
// else {
6794-
// // weak reference cleared, remove this listener
6795-
// _automaticTraceMenuItem.removeItemListener(this);
6796-
// }
6797-
// }
6798-
// });
6799-
// }
6800-
//
6801-
// debugMenu.addSeparator();
6802-
// JMenuItem tempDetachDebugFrameMenuItem = MainFrameStatics.newCheckBoxMenuItem(_detachDebugFrameAction);
6803-
// tempDetachDebugFrameMenuItem.setSelected(DrScala.getConfig().getSetting(DETACH_DEBUGGER));
6804-
// _setMenuShortcut(tempDetachDebugFrameMenuItem, _detachDebugFrameAction, KEY_DETACH_DEBUGGER, updateKeyboardManager);
6805-
// debugMenu.add(tempDetachDebugFrameMenuItem);
6806-
// if (_detachDebugFrameMenuItem==null) {
6807-
// // assign the first time
6808-
// _detachDebugFrameMenuItem = tempDetachDebugFrameMenuItem;
6809-
// }
6810-
// else {
6811-
// // otherwise link this item to the first item
6812-
// final WeakReference<JMenuItem> weakRef = new WeakReference<JMenuItem>(tempDetachDebugFrameMenuItem);
6813-
// _detachDebugFrameMenuItem.addItemListener(new ItemListener() {
6814-
// public void itemStateChanged(ItemEvent e) {
6815-
// JMenuItem temp = weakRef.get();
6816-
// if (temp!=null) {
6817-
// temp.setSelected(_detachDebugFrameMenuItem.isSelected());
6818-
// }
6819-
// else {
6820-
// // weak reference cleared, remove this listener
6821-
// _detachDebugFrameMenuItem.removeItemListener(this);
6822-
// }
6823-
// }
6824-
// });
6825-
// }
6826-
//
6827-
// // Start off disabled
6828-
// _setDebugMenuItemsEnabled(false);
6829-
//
6830-
// // Add the menu to the menu bar
6831-
// return debugMenu;
6832-
// }
6833-
6834-
/* Debugger is deactivated in DrScala */
6835-
// /** Called every time the debug mode checkbox is toggled. The resume and step
6836-
// * functions should always be disabled.
6837-
// */
6838-
// private void _setDebugMenuItemsEnabled(boolean isEnabled) {
6839-
// _debuggerEnabledMenuItem.setSelected(isEnabled);
6840-
// _guiAvailabilityNotifier.ensureUnavailable(GUIAvailabilityListener.ComponentType.DEBUGGER_SUSPENDED);
6841-
// if (_showDebugger) { _debugPanel.setAutomaticTraceButtonText(); }
6842-
// }
6843-
//
6844-
// /** Enables and disables the appropriate menu items in the debug menu depending upon the state of the current thread.
6845-
// * @param isSuspended is true when the current thread has just been suspended
6846-
// * false if the current thread has just been resumed
6847-
// */
6848-
// private void _setThreadDependentDebugMenuItems(boolean isSuspended) {
6849-
// _guiAvailabilityNotifier.ensureAvailabilityIs(GUIAvailabilityListener.ComponentType.DEBUGGER_SUSPENDED,
6850-
// isSuspended);
6851-
// if (_showDebugger) { _debugPanel.setAutomaticTraceButtonText(); }
6852-
// }
6853-
68546690
/** Creates and returns a help menu.
68556691
* @param mask the keystroke modifier to be used
68566692
* @param updateKeyboardManager true if the keyboard manager should be updated; pass true only for MainFrame!
@@ -6871,9 +6707,9 @@ private JMenu _setUpHelpMenu(int mask, boolean updateKeyboardManager) {
68716707
// _addMenuItem(helpMenu, _exportProjectInOldFormatAction, KEY_EXPORT_OLD, updateKeyboardManager);
68726708
return helpMenu;
68736709
}
6874-
6710+
68756711
/** Creates a toolbar button for undo and redo, which behave differently. */
6876-
JButton _createManualToolbarButton(Action a) {
6712+
JButton _createManualToolBarButton(Action a) {
68776713
final JButton ret;
68786714
Font buttonFont = DrScala.getConfig().getSetting(FONT_TOOLBAR);
68796715

@@ -6905,7 +6741,7 @@ public void propertyChange(PropertyChangeEvent evt) {
69056741
return ret;
69066742
}
69076743

6908-
/** Sets up all buttons for the toolbar except for undo and redo, which use _createManualToolbarButton. */
6744+
/** Sets up all buttons for the toolbar except for undo and redo, which use _createManualToolBarButton. */
69096745
public JButton _createToolbarButton(Action a) {
69106746
boolean useText = DrScala.getConfig().getSetting(TOOLBAR_TEXT_ENABLED).booleanValue();
69116747
boolean useIcons = DrScala.getConfig().getSetting(TOOLBAR_ICONS_ENABLED).booleanValue();
@@ -7037,7 +6873,7 @@ private void _updateToolBarVisible() {
70376873
/** Update the toolbar's buttons, following any change to TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, or
70386874
* FONT_TOOLBAR (name, style, text)
70396875
*/
7040-
private void _updateToolbarButtons() {
6876+
private void _updateToolBarButtons() {
70416877
_updateToolBarVisible();
70426878
Component[] buttons = _toolBar.getComponents();
70436879

@@ -9898,7 +9734,10 @@ public void optionChanged(OptionEvent<Font> oce) {
98989734

98999735
/** The OptionListener for FONT_TOOLBAR */
99009736
private class ToolbarFontOptionListener implements OptionListener<Font> {
9901-
public void optionChanged(OptionEvent<Font> oce) { _updateToolbarButtons(); }
9737+
public void optionChanged(OptionEvent<Font> oce) {
9738+
_updateToolBarButtons();
9739+
_updateMenuBarButtons(); // Hack to support changing the MenuBar font
9740+
}
99029741
}
99039742

99049743
/** The OptionListener for DEFINITIONS_NORMAL_COLOR */
@@ -9912,8 +9751,11 @@ private class BackgroundColorOptionListener implements OptionListener<Color> {
99129751
}
99139752

99149753
/** The OptionListener for TOOLBAR options */
9915-
private class ToolbarOptionListener implements OptionListener<Boolean> {
9916-
public void optionChanged(OptionEvent<Boolean> oce) { _updateToolbarButtons(); }
9754+
private class ToolBarOptionListener implements OptionListener<Boolean> {
9755+
public void optionChanged(OptionEvent<Boolean> oce) {
9756+
_updateToolBarButtons();
9757+
_updateMenuBarButtons(); // Hack to support changing the MenuBar font
9758+
}
99179759
}
99189760

99199761
/** The OptionListener for LINEENUM_ENABLED. */

drjava/src/edu/rice/cs/drjava/ui/MainFrameTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ public void tearDown() throws Exception {
114114
}
115115

116116
JButton _but;
117-
/** Tests that the returned JButton of <code>createManualToolbarButton</code>:
117+
/** Tests that the returned JButton of <code>createManualToolBarButton</code>:
118118
* 1. Is disabled upon return.
119119
* 2. Inherits the tooltip of the Action parameter <code>a</code>.
120120
*/
121121
public void testCreateManualToolbarButton() {
122122
final Action a = new AbstractAction("Test Action") { public void actionPerformed(ActionEvent ae) { } };
123123

124124
a.putValue(Action.LONG_DESCRIPTION, "test tooltip");
125-
Utilities.invokeAndWait(new Runnable() { public void run() { _but = _frame._createManualToolbarButton(a); } });
125+
Utilities.invokeAndWait(new Runnable() { public void run() { _but = _frame._createManualToolBarButton(a); } });
126126

127127
assertTrue("Returned JButton is enabled.", ! _but.isEnabled());
128128
assertEquals("Tooltip text not set.", "test tooltip", _but.getToolTipText());

drjava/src/edu/rice/cs/drjava/ui/config/ConfigDescriptions.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ public static void add(Option<?> o, String s, String l) {
7171
add(LOOK_AND_FEEL, "Look and Feel", "Changes the general appearance of DrScala.");
7272
add(PLASTIC_THEMES, "Plastic Theme", "Pick the theme to be used by the Plastic family of Look and Feels");
7373

74-
//ToolbarOptionComponent is a degenerate option component
75-
// addOptionComponent(panel, new ToolbarOptionComponent("Toolbar Buttons"
76-
// "How to display the toolbar buttons."));
7774
add(LINEENUM_ENABLED, "Show All Line Numbers",
7875
"Whether to show line numbers on the left side of the Definitions Pane.");
7976

drjava/src/edu/rice/cs/drjava/ui/config/ToolbarOptionComponent.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,14 @@
4444
import edu.rice.cs.drjava.config.*;
4545
import edu.rice.cs.util.swing.SwingFrame;
4646

47-
/**
48-
* The special option component for the toolbar text and toolbar icon options.
49-
* Not a true OptionComponent, in that it actually represents and governs the
50-
* configuration of two BooleanOptions (i.e. those corresponding to TOOLBAR_TEXT_ENABLED
51-
* and TOOLBAR_ICONS_ENABLED) bypassing the the normal graphical representation
52-
* with JRadioButtons, in order to comply with the special circumstances regarding
53-
* their setting.
54-
* @version $Id: ToolbarOptionComponent.java 5594 2012-06-21 11:23:40Z rcartwright $
55-
*/
47+
/** The special option component for the toolbar text and toolbar icon options.
48+
* Not a true OptionComponent, in that it actually represents and governs the
49+
* configuration of two BooleanOptions (i.e. those corresponding to TOOLBAR_TEXT_ENABLED
50+
* and TOOLBAR_ICONS_ENABLED) bypassing the the normal graphical representation
51+
* with JRadioButtons, in order to comply with the special circumstances regarding
52+
* their setting.
53+
* @version $Id: ToolbarOptionComponent.java 5594 2012-06-21 11:23:40Z rcartwright $
54+
*/
5655
public class ToolbarOptionComponent extends OptionComponent<Boolean,JComponent> {
5756

5857
private JRadioButton _noneButton;

0 commit comments

Comments
 (0)