line number tweaks, button tweaks, debugger startup, fixes #3096

This commit is contained in:
Ben Fry
2015-04-02 10:38:55 -04:00
parent 6c8a0fe08c
commit 40e808acf1
8 changed files with 197 additions and 188 deletions

View File

@@ -103,7 +103,7 @@ public class Debugger implements VMEventListener {
public VirtualMachine vm() {
if (runtime != null) {
return runtime.vm();
}
}
return null;
}
@@ -121,7 +121,7 @@ public class Debugger implements VMEventListener {
public ReferenceType getMainClass() {
if (isStarted()) {
return mainClass;
}
}
return null;
}
@@ -191,7 +191,7 @@ public class Debugger implements VMEventListener {
editor.prepareRun();
// after prepareRun, since this removes highlights
editor.activateDebug();
editor.activateDebug();
try {
Sketch sketch = editor.getSketch();
@@ -250,11 +250,11 @@ public class Debugger implements VMEventListener {
}
stopTrackingLineChanges();
started = false;
editor.deactivateDebug();
editor.deactivateContinue();
editor.deactivateStep();
editor.statusEmpty();
}
@@ -336,7 +336,7 @@ public class Debugger implements VMEventListener {
/**
* Print fields of current {@code this}-object.
* Print fields of current {@code this}-object.
* Outputs type, name and value of each field.
*/
public synchronized void printThis() {
@@ -387,7 +387,7 @@ public class Debugger implements VMEventListener {
log(Level.INFO, "set breakpoint on line {0}", line);
}
/**
* Remove a breakpoint from the current line (if set).
*/
@@ -915,7 +915,7 @@ public class Debugger implements VMEventListener {
return "";
}
return t.frame(0).thisObject().referenceType().name();
} catch (IncompatibleThreadStateException ex) {
log(Level.SEVERE, null, ex);
return "";
@@ -1379,13 +1379,13 @@ public class Debugger implements VMEventListener {
runtimeLineChanges.clear();
runtimeTabsTracked.clear();
}
static private void log(Level level, String msg) {
Logger.getLogger(Debugger.class.getName()).log(level, msg);
}
static private void log(Level level, String msg, Object obj) {
Logger.getLogger(Debugger.class.getName()).log(level, msg, obj);
}

View File

@@ -49,9 +49,9 @@ import processing.mode.java.pdex.Problem;
* scrolls to the tab and location. Error messages displayed on hover. Markers
* are not in sync with the error line. Similar to eclipse's right error bar
* which displays the overall errors in a document
*
*
* @author Manindra Moharana <me@mkmoharana.com>
*
*
*/
public class ErrorBar extends JPanel {
/**
@@ -121,32 +121,33 @@ public class ErrorBar extends JPanel {
}
}
public Dimension getPreferredSize() {
return new Dimension(preferredWidth, preferredHeight);
}
public Dimension getMinimumSize() {
return getPreferredSize();
}
public ErrorBar(JavaEditor editor, int height, JavaMode mode) {
this.editor = editor;
this.preferredHeight = height;
this.errorCheckerService = editor.errorCheckerService;
errorColor = mode.getColor("errorbar.errorcolor"); //, errorColor);
warningColor = mode.getColor("errorbar.warningcolor"); //, warningColor);
backgroundColor = mode.getColor("errorbar.backgroundcolor"); //, backgroundColor);
//backgroundColor = mode.getColor("errorbar.backgroundcolor"); //, backgroundColor);
backgroundColor = mode.getColor("gutter.bgcolor");
addListeners();
}
/**
* Update error markers in the error bar.
*
*
* @param problems
* - List of problems.
*/
@@ -154,7 +155,7 @@ public class ErrorBar extends JPanel {
// NOTE TO SELF: ErrorMarkers are calculated for the present tab only
// Error Marker index in the arraylist is LOCALIZED for current tab.
// Also, need to do the update in the UI thread via SwingWorker to prevent
// concurrency issues.
// concurrency issues.
final int fheight = this.getHeight();
SwingWorker<Object, Object> worker = new SwingWorker<Object, Object>() {
@@ -175,7 +176,7 @@ public class ErrorBar extends JPanel {
errorPointsOld.add(marker);
}
errorPoints.clear();
// Each problem.getSourceLine() will have an extra line added
// because of
// class declaration in the beginning as well as default imports
@@ -215,7 +216,7 @@ public class ErrorBar extends JPanel {
/**
* Check if new errors have popped up in the sketch since the last check
*
*
* @return true - if errors have changed
*/
public boolean errorPointsChanged() {
@@ -283,7 +284,7 @@ public class ErrorBar extends JPanel {
protected Object doInBackground() throws Exception {
for (ErrorMarker eMarker : errorPoints) {
if (evt.getY() >= eMarker.getY() - 2 &&
if (evt.getY() >= eMarker.getY() - 2 &&
evt.getY() <= eMarker.getY() + 2 + errorMarkerHeight) {
Problem p = eMarker.getProblem();
String msg = (p.isError() ? "Error: " : "Warning: ") + p.getMessage();

View File

@@ -195,12 +195,7 @@ public class JavaEditor extends Editor {
JMenuItem runItem = Toolkit.newJMenuItem(Language.text("toolbar.run"), 'R');
runItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (isDebuggerEnabled()) {
Logger.getLogger(JavaEditor.class.getName()).log(Level.INFO, "Invoked 'Debug' menu item");
debugger.startDebug();
} else {
handleRun();
}
handleRun();
}
});
@@ -1017,19 +1012,24 @@ public class JavaEditor extends Editor {
public void handleRun() {
new Thread(new Runnable() {
public void run() {
prepareRun();
try {
// toolbar.activate(JavaToolbar.RUN);
toolbar.activateRun();
runtime = jmode.handleRun(sketch, JavaEditor.this);
// System.out.println("runtime now " + runtime);
} catch (Exception e) {
statusError(e);
if (isDebuggerEnabled()) {
// Don't start the sketch paused, continue until a breakpoint or error
// https://github.com/processing/processing/issues/3096
debugger.continueDebug();
} else {
new Thread(new Runnable() {
public void run() {
prepareRun();
try {
toolbar.activateRun();
runtime = jmode.handleRun(sketch, JavaEditor.this);
} catch (Exception e) {
statusError(e);
}
}
}
}).start();
}).start();
}
}

View File

@@ -69,10 +69,10 @@ public class JavaTextAreaPainter extends TextAreaPainter
public Color warningColor; // = new Color(0xFFC30E);
public Color errorMarkerColor; // = new Color(0xED2630);
public Color warningMarkerColor; // = new Color(0xFFC30E);
protected Font gutterTextFont;
protected Color gutterTextColor;
protected Color gutterTempColor;
// protected Color gutterTempColor;
// static int ctrlMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
@@ -225,7 +225,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
gfx.setFont(gutterTextFont);
FontMetrics gm = getFontMetrics();
//int tx = Editor.GUTTER_MARGIN + ;
int tx = Editor.LEFT_GUTTER - Editor.GUTTER_MARGIN -
int tx = Editor.LEFT_GUTTER - Editor.GUTTER_MARGIN -
gm.charsWidth(txt, 0, txt.length);
// Color textColor = getTextArea().getGutterTextColor(line);
// if (textColor == null) {
@@ -236,10 +236,10 @@ public class JavaTextAreaPainter extends TextAreaPainter
gfx.setColor(gutterTextColor);
int ty = textArea.lineToY(line) + fm.getHeight();
Utilities.drawTabbedText(new Segment(txt, 0, text.length()),
tx, ty, gfx, this, 0);
tx, ty, gfx, this, 0);
}
// /**
// * Paint the gutter background (solid color).
// *
@@ -490,8 +490,8 @@ public class JavaTextAreaPainter extends TextAreaPainter
warningColor = mode.getColor("editor.warningcolor"); //, warningColor);
errorMarkerColor = mode.getColor("editor.errormarkercolor"); //, errorMarkerColor);
warningMarkerColor = mode.getColor("editor.warningmarkercolor"); //, warningMarkerColor);
gutterTextFont = mode.getFont("editor.gutter.text.font");
gutterTextFont = mode.getFont("editor.gutter.text.font");
gutterTextColor = mode.getColor("editor.gutter.text.color");
}