Skip to content

Commit 579a4d8

Browse files
author
mgricken
committed
Fixes a Retroweaver error in DrJavaErrorWindow.
Changes menu text for making auxiliary files external files to "Do not include with project" to mirror the menu item going the other way. Fixes bug [ 1471788 ] Can't run without tools.jar Fixes bug [ 1471896 ] Project/Save As Saves Even When Cancelled M src/edu/rice/cs/drjava/model/debug/NoDebuggerAvailable.java M src/edu/rice/cs/drjava/ui/MainFrame.java M src/edu/rice/cs/drjava/ui/DrJavaErrorWindow.java git-svn-id: file:///tmp/test-svn/trunk@3796 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent dd87e87 commit 579a4d8

3 files changed

Lines changed: 68 additions & 52 deletions

File tree

drjava/src/edu/rice/cs/drjava/model/debug/NoDebuggerAvailable.java

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,85 +56,86 @@ private NoDebuggerAvailable() { }
5656

5757
/** Attaches the debugger to the Interactions JVM to prepare for debugging. */
5858
public void startup() throws DebugException {
59-
throw new IllegalStateException("No debugger is available");
59+
//throw new IllegalStateException("No debugger is available");
6060
}
6161

6262
/** Disconnects the debugger from the Interactions JVM and cleans up any state. */
6363
public void shutdown() {
64-
throw new IllegalStateException("No debugger is available");
64+
//throw new IllegalStateException("No debugger is available");
6565
}
6666

6767
/** Returns the status of the debugger. */
6868
public boolean isReady() {
69-
throw new IllegalStateException("No debugger is available");
69+
return false;
70+
//throw new IllegalStateException("No debugger is available");
7071
}
7172

7273
public boolean inDebugMode() { return false; }
7374

7475
/** Suspends execution of the currently. */
7576
public void suspend(DebugThreadData d) {
76-
throw new IllegalStateException("No debugger is available");
77+
//throw new IllegalStateException("No debugger is available");
7778
}
7879

7980
/** Suspends all the threads. */
8081
public void suspendAll() {
81-
throw new IllegalStateException("No debugger is available");
82+
//throw new IllegalStateException("No debugger is available");
8283
}
8384

8485
/** Sets the current thread which is being debugged to the thread referenced by d. */
8586
public void setCurrentThread(DebugThreadData d) {
86-
throw new IllegalStateException("No debugger is available");
87+
//throw new IllegalStateException("No debugger is available");
8788
}
8889

8990
/** Resumes execution of the currently loaded document. */
9091
public void resume() {
91-
throw new IllegalStateException("No debugger is available");
92+
//throw new IllegalStateException("No debugger is available");
9293
}
9394

9495
/** Resumes execution of the given thread.
9596
* @param data the DebugThreadData representing the thread to resume
9697
*/
9798
public void resume(DebugThreadData data) {
98-
throw new IllegalStateException("No debugger is available");
99+
//throw new IllegalStateException("No debugger is available");
99100
}
100101

101102
/** Steps into the execution of the currently loaded document.
102103
* @param flag The flag denotes what kind of step to take. The following mark valid options:
103104
* StepRequest.STEP_INTO, StepRequest.STEP_OVER, StepRequest.STEP_OUT
104105
*/
105106
public void step(int flag) throws DebugException {
106-
throw new IllegalStateException("No debugger is available");
107+
//throw new IllegalStateException("No debugger is available");
107108
}
108109

109110
/** Called from interactionsEnded in MainFrame in order to clear any current StepRequests that remain. */
110111
public void clearCurrentStepRequest() {
111-
throw new IllegalStateException("No debugger is available");
112+
//throw new IllegalStateException("No debugger is available");
112113
}
113114

114115
/** Adds a watch on the given field or variable.
115116
* @param field the name of the field we will watch
116117
*/
117118
public void addWatch(String field) {
118-
throw new IllegalStateException("No debugger is available");
119+
//throw new IllegalStateException("No debugger is available");
119120
}
120121

121122
/** Removes any watches on the given field or variable.
122123
* @param field the name of the field we will watch
123124
*/
124125
public void removeWatch(String field) {
125-
throw new IllegalStateException("No debugger is available");
126+
//throw new IllegalStateException("No debugger is available");
126127
}
127128

128129
/** Removes the watch at the given index.
129130
* @param index Index of the watch to remove
130131
*/
131132
public void removeWatch(int index) {
132-
throw new IllegalStateException("No debugger is available");
133+
//throw new IllegalStateException("No debugger is available");
133134
}
134135

135136
/** Removes all watches on existing fields and variables. */
136137
public void removeAllWatches() {
137-
throw new IllegalStateException("No debugger is available");
138+
//throw new IllegalStateException("No debugger is available");
138139
}
139140

140141
/** Toggles whether a breakpoint is set at the given line in the given document.
@@ -143,11 +144,8 @@ public void removeAllWatches() {
143144
* @param lineNum Line on which to set or remove the breakpoint
144145
* @param enabled true if this breakpoint should be enabled
145146
*/
146-
public void toggleBreakpoint(OpenDefinitionsDocument doc,
147-
int offset, int lineNum, boolean isEnabled)
148-
throws DebugException
149-
{
150-
throw new IllegalStateException("No debugger is available");
147+
public void toggleBreakpoint(OpenDefinitionsDocument doc, int offset, int lineNum, boolean isEnabled) throws DebugException {
148+
// throw new IllegalStateException("No debugger is available");
151149
}
152150

153151
/**
@@ -156,7 +154,7 @@ public void toggleBreakpoint(OpenDefinitionsDocument doc,
156154
* @param breakpoint The new breakpoint to set
157155
*/
158156
public void setBreakpoint(Breakpoint breakpoint) {
159-
throw new IllegalStateException("No debugger is available");
157+
//throw new IllegalStateException("No debugger is available");
160158
}
161159

162160
/**
@@ -165,106 +163,113 @@ public void setBreakpoint(Breakpoint breakpoint) {
165163
* @param breakpoint The breakpoint to remove.
166164
*/
167165
public void removeBreakpoint(Breakpoint breakpoint) {
168-
throw new IllegalStateException("No debugger is available");
166+
//throw new IllegalStateException("No debugger is available");
169167
}
170168

171169
/**
172170
* Removes all the breakpoints from the manager's vector of breakpoints.
173171
*/
174172
public void removeAllBreakpoints() {
175-
throw new IllegalStateException("No debugger is available");
173+
//throw new IllegalStateException("No debugger is available");
176174
}
177175

178176
/**
179177
* Returns a Vector<Breakpoint> that contains all of the Breakpoint objects that
180178
* all open documents contain.
181179
*/
182180
public Vector<Breakpoint> getBreakpoints() {
183-
throw new IllegalStateException("No debugger is available");
181+
return new Vector<Breakpoint>();
182+
//throw new IllegalStateException("No debugger is available");
184183
}
185184

186185
/**
187186
* Prints the list of breakpoints in the current session of DrJava, both pending
188187
* resolved Breakpoints are listed
189188
*/
190189
public void printBreakpoints() {
191-
throw new IllegalStateException("No debugger is available");
190+
//throw new IllegalStateException("No debugger is available");
192191
}
193192

194193
/**
195194
* Returns all currently watched fields and variables.
196195
*/
197196
public Vector<DebugWatchData> getWatches() {
198-
throw new IllegalStateException("No debugger is available");
197+
return new Vector<DebugWatchData>();
198+
//throw new IllegalStateException("No debugger is available");
199199
}
200200

201201
/**
202202
* Returns a Vector of ThreadData or null if the vm is null
203203
*/
204204
public Vector<DebugThreadData> getCurrentThreadData() {
205-
throw new IllegalStateException("No debugger is available");
205+
return new Vector<DebugThreadData>();
206+
//throw new IllegalStateException("No debugger is available");
206207
}
207208

208209
/**
209210
* Returns a Vector of StackData for the current thread or null if the
210211
* current thread is null.
211212
*/
212213
public Vector<DebugStackData> getCurrentStackFrameData() {
213-
throw new IllegalStateException("No debugger is available");
214+
return new Vector<DebugStackData>();
215+
//throw new IllegalStateException("No debugger is available");
214216
}
215217

216218
/**
217219
* Adds a listener to this JPDADebugger.
218220
* @param listener a listener that reacts on events generated by the JPDADebugger
219221
*/
220222
public void addListener(DebugListener listener) {
221-
throw new IllegalStateException("No debugger is available");
223+
//throw new IllegalStateException("No debugger is available");
222224
}
223225

224226
/**
225227
* Removes a listener to this JPDADebugger.
226228
* @param listener listener to remove
227229
*/
228230
public void removeListener(DebugListener listener) {
229-
throw new IllegalStateException("No debugger is available");
231+
//throw new IllegalStateException("No debugger is available");
230232
}
231233

232234
/**
233235
* @return true if there are any threads in the program currently being
234236
* debugged which have been suspended (by the user or by hitting a breakpoint).
235237
*/
236238
public boolean hasSuspendedThreads() {
237-
throw new IllegalStateException("No debugger is available");
239+
return false;
240+
//throw new IllegalStateException("No debugger is available");
238241
}
239242

240243
/**
241244
* Returns whether the thread the debugger is tracking is now running.
242245
*/
243246
public boolean hasRunningThread() {
244-
throw new IllegalStateException("No Debugger is available");
247+
return false;
248+
//throw new IllegalStateException("No Debugger is available");
245249
}
246250

247251
/**
248252
* Returns whether the debugger's current thread is suspended.
249253
*/
250254
public boolean isCurrentThreadSuspended() {
251-
throw new IllegalStateException("No debugger is available");
255+
return false;
256+
//throw new IllegalStateException("No debugger is available");
252257
}
253258

254259
/**
255260
* scrolls to the source indicated by the given DebugStackData
256261
* @param data the DebugStackData representing the source location
257262
*/
258263
public void scrollToSource(DebugStackData data) {
259-
throw new IllegalStateException("No debugger is available");
264+
//throw new IllegalStateException("No debugger is available");
260265
}
261266

262267
/**
263268
* scrolls to the source indicated by the given Breakpoint
264269
* @param bp the Breakpoint representing the source location
265270
*/
266271
public void scrollToSource(Breakpoint bp) {
267-
throw new IllegalStateException("No debugger is available");
272+
//throw new IllegalStateException("No debugger is available");
268273
}
269274

270275
/**
@@ -276,6 +281,7 @@ public void scrollToSource(Breakpoint bp) {
276281
* there is no such breakpoint.
277282
*/
278283
public Breakpoint getBreakpoint(int line, String className) {
279-
throw new IllegalStateException("No debugger is available");
284+
return null;
285+
//throw new IllegalStateException("No debugger is available");
280286
}
281287
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ private void updateErrorInfo() {
207207
}
208208

209209
b.append("\n\nSystem Properties:\n");
210+
b.append("DrJava Version ");
211+
b.append(edu.rice.cs.drjava.Version.getBuildTimeString());
212+
b.append("\n");
210213
java.util.Properties props = System.getProperties();
211214
int size = props.size();
212215
java.util.Iterator entries = props.entrySet().iterator();
@@ -220,7 +223,8 @@ private void updateErrorInfo() {
220223
for(int i=0; i<ls.length(); ++i) {
221224
int ch = ls.charAt(i);
222225
b.append("\\u");
223-
b.append(String.format("%04x", ch));
226+
String hexString = "0000"+Integer.toHexString(ch);
227+
b.append(hexString.substring(hexString.length()-4));
224228
}
225229
b.append("\"");
226230
}

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

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ public boolean shouldSaveAfterFileMoved(OpenDefinitionsDocument doc, File oldFil
332332
}
333333
public void actionPerformed(ActionEvent ae) { _moveToAuxiliary(); }
334334
};
335-
private Action _removeAuxiliaryAction = new AbstractAction("Convert to External") {
335+
private Action _removeAuxiliaryAction = new AbstractAction("Do Not Include With Project") {
336336
{
337337
putValue(Action.SHORT_DESCRIPTION, "Do not open this document next time this project is opened.");
338338
}
@@ -548,8 +548,9 @@ public void actionPerformed(ActionEvent ae) {
548548

549549
private Action _saveProjectAsAction = new AbstractAction("Save As...") {
550550
public void actionPerformed(ActionEvent ae) {
551-
_saveProjectAs(); // asks the user for a new project file name; sets _projectFile in global model to this value
552-
_saveAll(); // performs a save all operation using this new project file name
551+
if (_saveProjectAs()) { // asks the user for a new project file name; sets _projectFile in global model to this value
552+
_saveAll(); // performs a save all operation using this new project file name, but ONLY if the "Save as" was not cancelled
553+
}
553554
}
554555
};
555556

@@ -1545,9 +1546,9 @@ public void actionPerformed(ActionEvent ae) {
15451546
private Action _gotoOpeningBraceAction = new AbstractAction("Go to Opening Brace") {
15461547
public void actionPerformed(ActionEvent ae) {
15471548
OpenDefinitionsDocument odd = getCurrentDefPane().getOpenDefDocument();
1549+
if (true) throw new RuntimeException("booh");
15481550
odd.readLock();
15491551
try {
1550-
DrJavaErrorHandler.log("woof!");
15511552
int pos = odd.findPrevEnclosingBrace(getCurrentDefPane().getCaretPosition(), '{', '}');
15521553
if (pos!=AbstractDJDocument.ERROR_INDEX) { getCurrentDefPane().setCaretPosition(pos); }
15531554
}
@@ -2514,7 +2515,7 @@ public void run() {
25142515
public void debuggerToggle() {
25152516
// Make sure the debugger is available
25162517
Debugger debugger = _model.getDebugger();
2517-
// if (!debugger.isAvailable()) return; // Redundant! This test is the first check made by inDebugMode()
2518+
if (!debugger.isAvailable()) return;
25182519

25192520
try {
25202521
if (inDebugMode()) debugger.shutdown();
@@ -3256,8 +3257,9 @@ private void _newProject() {
32563257
}
32573258

32583259
/** Pops up the _saveChooser dialog, asks the user for a new project file name, and sets the project file to the
3259-
* specified file. Nothing is written in the file system; this action is performed by a subsequent _saveAll(). */
3260-
private void _saveProjectAs() {
3260+
* specified file. Nothing is written in the file system; this action is performed by a subsequent _saveAll().
3261+
* @return false if the user canceled the action */
3262+
private boolean _saveProjectAs() {
32613263

32623264
// // This redundant-looking hack is necessary for JDK 1.3.1 on Mac OS X!
32633265
_saveChooser.removeChoosableFileFilter(_projectFilter);
@@ -3280,6 +3282,8 @@ private void _saveProjectAs() {
32803282
_currentProjFile = file;
32813283
}
32823284
}
3285+
3286+
return (rc == JFileChooser.APPROVE_OPTION);
32833287
}
32843288

32853289
void _saveProjectHelper(File file) {
@@ -4293,13 +4297,15 @@ private void _setUpActions() {
42934297
_setUpAction(_showDebugConsoleAction, "Show DrJava Debug Console", "<html>Show a console for debugging DrJava<br>" +
42944298
"(with \"mainFrame\", \"model\", and \"config\" variables defined)</html>");
42954299

4296-
_setUpAction(_toggleDebuggerAction, "Debug Mode", "Enable or disable DrJava's debugger");
4297-
_setUpAction(_toggleBreakpointAction, "Toggle Breakpoint", "Set or clear a breakpoint on the current line");
4298-
_setUpAction(_clearAllBreakpointsAction, "Clear Breakpoints", "Clear all breakpoints in all classes");
4299-
_setUpAction(_resumeDebugAction, "Resume", "Resume the current suspended thread");
4300-
_setUpAction(_stepIntoDebugAction, "Step Into", "Step into the current line or method call");
4301-
_setUpAction(_stepOverDebugAction, "Step Over", "Step over the current line or method call");
4302-
_setUpAction(_stepOutDebugAction, "Step Out", "Step out of the current method");
4300+
if (_model.getDebugger().isAvailable()) {
4301+
_setUpAction(_toggleDebuggerAction, "Debug Mode", "Enable or disable DrJava's debugger");
4302+
_setUpAction(_toggleBreakpointAction, "Toggle Breakpoint", "Set or clear a breakpoint on the current line");
4303+
_setUpAction(_clearAllBreakpointsAction, "Clear Breakpoints", "Clear all breakpoints in all classes");
4304+
_setUpAction(_resumeDebugAction, "Resume", "Resume the current suspended thread");
4305+
_setUpAction(_stepIntoDebugAction, "Step Into", "Step into the current line or method call");
4306+
_setUpAction(_stepOverDebugAction, "Step Over", "Step over the current line or method call");
4307+
_setUpAction(_stepOutDebugAction, "Step Out", "Step out of the current method");
4308+
}
43034309

43044310
_setUpAction(_helpAction, "Help", "Show documentation on how to use DrJava");
43054311
_setUpAction(_quickStartAction, "Help", "View Quick Start Guide for DrJava");
@@ -5020,7 +5026,7 @@ private void _setUpTabs() {
50205026

50215027
_junitErrorPanel = new JUnitPanel(_model, this);
50225028
_javadocErrorPanel = new JavadocErrorPanel(_model, this);
5023-
_breakpointsPanel = new BreakpointsPanel(this);
5029+
if (_model.getDebugger().isAvailable()) { _breakpointsPanel = new BreakpointsPanel(this); }
50245030

50255031
_tabbedPane = new JTabbedPane();
50265032
_tabbedPane.addChangeListener(new ChangeListener () {
@@ -5055,7 +5061,7 @@ public void stateChanged(ChangeEvent e) {
50555061
_tabs.addLast(_junitErrorPanel);
50565062
_tabs.addLast(_javadocErrorPanel);
50575063
_tabs.addLast(_findReplace);
5058-
_tabs.addLast(_breakpointsPanel);
5064+
if (_model.getDebugger().isAvailable()) { _tabs.addLast(_breakpointsPanel); }
50595065

50605066
_interactionsPane.addFocusListener(new FocusAdapter() {
50615067
public void focusGained(FocusEvent e) { _lastFocusOwner = _interactionsContainer; }

0 commit comments

Comments
 (0)