mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
line number tweaks, button tweaks, debugger startup, fixes #3096
This commit is contained in:
@@ -26,13 +26,13 @@ import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
abstract public class EditorButton extends JComponent
|
||||
abstract public class EditorButton extends JComponent
|
||||
implements MouseListener, MouseMotionListener, ActionListener {
|
||||
static public final int DIM = 35;
|
||||
|
||||
/** Button's description. */
|
||||
/** Button's description. */
|
||||
protected String title;
|
||||
/** Description of alternate behavior when shift is down. */
|
||||
/** Description of alternate behavior when shift is down. */
|
||||
protected String titleShift;
|
||||
|
||||
protected boolean pressed;
|
||||
@@ -40,36 +40,36 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
protected boolean rollover;
|
||||
protected JLabel rolloverLabel;
|
||||
protected boolean shift;
|
||||
|
||||
|
||||
protected Image enabledImage;
|
||||
protected Image disabledImage;
|
||||
protected Image selectedImage;
|
||||
protected Image rolloverImage;
|
||||
protected Image pressedImage;
|
||||
|
||||
|
||||
protected Image gradient;
|
||||
|
||||
|
||||
protected Mode mode;
|
||||
|
||||
|
||||
|
||||
|
||||
public EditorButton(Mode mode, String name, String title) {
|
||||
this(mode, name, title, title);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public EditorButton(Mode mode, String name, String title, String titleShift) {
|
||||
this.mode = mode;
|
||||
this.title = title;
|
||||
this.titleShift = titleShift;
|
||||
|
||||
|
||||
final int res = Toolkit.highResDisplay() ? 2 : 1;
|
||||
disabledImage = mode.loadImage(name + "-disabled-" + res + "x.png");
|
||||
enabledImage = mode.loadImage(name + "-enabled-" + res + "x.png");
|
||||
selectedImage = mode.loadImage(name + "-selected-" + res + "x.png");
|
||||
pressedImage = mode.loadImage(name + "-pressed-" + res + "x.png");
|
||||
rolloverImage = mode.loadImage(name + "-rollover-" + res + "x.png");
|
||||
|
||||
if (disabledImage == null) {
|
||||
|
||||
if (disabledImage == null) {
|
||||
disabledImage = enabledImage;
|
||||
}
|
||||
if (selectedImage == null) {
|
||||
@@ -84,8 +84,8 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
addMouseListener(this);
|
||||
addMouseMotionListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Image image = enabledImage;
|
||||
@@ -103,8 +103,8 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
}
|
||||
g.drawImage(image, 0, 0, DIM, DIM, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public String toString() {
|
||||
// switch (this) {
|
||||
// case DISABLED: return "disabled";
|
||||
@@ -112,30 +112,30 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
// case SELECTED: return "selected";
|
||||
// case ROLLOVER: return "rollover";
|
||||
// case PRESSED: return "pressed";
|
||||
//
|
||||
//
|
||||
//// for (State bs : State.values()) {
|
||||
//// Image image = mode.loadImage(bs.getFilename(name));
|
||||
//// if (image != null) {
|
||||
//// imageMap.put(bs, image);
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// enabled = true;
|
||||
//// //updateState();
|
||||
//// setState(State.ENABLED);
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public void setReverse() {
|
||||
gradient = mode.getGradient("reversed", DIM, DIM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public void setGradient(Image gradient) {
|
||||
// this.gradient = gradient;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public void setRolloverLabel(JLabel label) {
|
||||
rolloverLabel = label;
|
||||
}
|
||||
@@ -145,12 +145,12 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (isEnabled()) {
|
||||
shift = e.isShiftDown();
|
||||
actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
|
||||
actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED,
|
||||
null, e.getModifiers()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isShiftDown() {
|
||||
return shift;
|
||||
}
|
||||
@@ -166,8 +166,8 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
setPressed(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setPressed(boolean pressed) {
|
||||
if (isEnabled()) {
|
||||
this.pressed = pressed;
|
||||
@@ -176,6 +176,11 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
}
|
||||
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
rollover = true;
|
||||
@@ -205,41 +210,41 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
|
||||
|
||||
abstract public void actionPerformed(ActionEvent e);
|
||||
|
||||
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// // To be overridden by all subclasses
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(DIM, DIM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public Image getImage() {
|
||||
// return imageMap.get(state);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//// protected void updateState() {
|
||||
//// state = ButtonState.ENABLED;
|
||||
//// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// public void setEnabled(boolean enabled) {
|
||||
// this.enabled = enabled;
|
||||
// if (enabled) {
|
||||
@@ -252,8 +257,8 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// public void setState(State state) {
|
||||
// this.state = state;
|
||||
// }
|
||||
@@ -261,16 +266,16 @@ implements MouseListener, MouseMotionListener, ActionListener {
|
||||
|
||||
// public enum State {
|
||||
// DISABLED, ENABLED, SELECTED, ROLLOVER, PRESSED;
|
||||
//
|
||||
// /**
|
||||
// * @param name the root name
|
||||
//
|
||||
// /**
|
||||
// * @param name the root name
|
||||
// * @return
|
||||
// */
|
||||
// public String getFilename(String name) {
|
||||
// final int res = Toolkit.highResDisplay() ? 2 : 1;
|
||||
// return name + "-" + toString() + "-" + res + "x.png";
|
||||
// return name + "-" + toString() + "-" + res + "x.png";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public String toString() {
|
||||
// switch (this) {
|
||||
// case DISABLED: return "disabled";
|
||||
|
||||
@@ -36,14 +36,14 @@ import javax.swing.JPopupMenu;
|
||||
* Run/Stop button plus Mode selection
|
||||
*/
|
||||
abstract public class EditorToolbar extends JPanel {
|
||||
// haven't decided how to handle this/how to make public/consistency
|
||||
// haven't decided how to handle this/how to make public/consistency
|
||||
// for components/does it live in theme.txt
|
||||
static final int HIGH = 53;
|
||||
// horizontal gap between buttons
|
||||
static final int GAP = 9;
|
||||
// gap from the run button to the sketch label
|
||||
static final int LABEL_GAP = GAP;
|
||||
|
||||
|
||||
protected Editor editor;
|
||||
protected Base base;
|
||||
protected Mode mode;
|
||||
@@ -51,113 +51,113 @@ abstract public class EditorToolbar extends JPanel {
|
||||
protected EditorButton runButton;
|
||||
protected EditorButton stopButton;
|
||||
// protected EditorButton currentButton;
|
||||
|
||||
|
||||
protected Box box;
|
||||
protected JLabel label;
|
||||
|
||||
|
||||
// int GRADIENT_TOP = 192;
|
||||
// int GRADIENT_BOTTOM = 246;
|
||||
protected Image gradient;
|
||||
// protected Image reverseGradient;
|
||||
|
||||
|
||||
|
||||
|
||||
public EditorToolbar(Editor editor) {
|
||||
this.editor = editor;
|
||||
base = editor.getBase();
|
||||
mode = editor.getMode();
|
||||
|
||||
|
||||
//setOpaque(false);
|
||||
//gradient = createGradient();
|
||||
//System.out.println(gradient);
|
||||
|
||||
|
||||
gradient = mode.getGradient("toolbar", 400, HIGH);
|
||||
// reverseGradient = mode.getGradient("reversed", 100, EditorButton.DIM);
|
||||
|
||||
runButton = new EditorButton(mode,
|
||||
|
||||
runButton = new EditorButton(mode,
|
||||
"/lib/toolbar/run",
|
||||
Language.text("toolbar.run"),
|
||||
Language.text("toolbar.run"),
|
||||
Language.text("toolbar.present")) {
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleRun(e.getModifiers());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
stopButton = new EditorButton(mode,
|
||||
"/lib/toolbar/stop",
|
||||
Language.text("toolbar.stop")) {
|
||||
|
||||
Language.text("toolbar.stop")) {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
handleStop();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
box = Box.createHorizontalBox();
|
||||
box.add(Box.createHorizontalStrut(Editor.LEFT_GUTTER));
|
||||
|
||||
|
||||
box.add(runButton);
|
||||
box.add(Box.createHorizontalStrut(GAP));
|
||||
box.add(stopButton);
|
||||
|
||||
|
||||
box.add(Box.createHorizontalStrut(LABEL_GAP));
|
||||
label = new JLabel();
|
||||
label.setFont(mode.getFont("toolbar.rollover.font"));
|
||||
label.setForeground(mode.getColor("toolbar.rollover.color"));
|
||||
box.add(label);
|
||||
// currentButton = runButton;
|
||||
|
||||
|
||||
runButton.setRolloverLabel(label);
|
||||
stopButton.setRolloverLabel(label);
|
||||
|
||||
|
||||
box.add(Box.createHorizontalGlue());
|
||||
addModeButtons(box);
|
||||
// Component items = createModeButtons();
|
||||
// if (items != null) {
|
||||
// box.add(items);
|
||||
// }
|
||||
ModeSelector ms = new ModeSelector();
|
||||
ModeSelector ms = new ModeSelector();
|
||||
box.add(ms);
|
||||
box.add(Box.createHorizontalStrut(Editor.RIGHT_GUTTER));
|
||||
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(box, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public void setReverse(EditorButton button) {
|
||||
// button.setGradient(reverseGradient);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// public void setText(String text) {
|
||||
// label.setText(text);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
// label.setText(editor.getSketch().getName());
|
||||
// super.paintComponent(g);
|
||||
Dimension size = getSize();
|
||||
g.drawImage(gradient, 0, 0, size.width, size.height, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void addModeButtons(Box box) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void addGap(Box box) {
|
||||
box.add(Box.createHorizontalStrut(GAP));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public Component createModeSelector() {
|
||||
// return new ModeSelector();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// protected void swapButton(EditorButton replacement) {
|
||||
// if (currentButton != replacement) {
|
||||
// box.remove(currentButton);
|
||||
@@ -167,61 +167,63 @@ abstract public class EditorToolbar extends JPanel {
|
||||
// currentButton = replacement;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public void activateRun() {
|
||||
// //runButton.setPressed(true);
|
||||
//// Rectangle bounds = runButton.getBounds();
|
||||
//// remove(runButton);
|
||||
// swapButton(stopButton);
|
||||
|
||||
|
||||
public void activateRun() {
|
||||
runButton.setSelected(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void deactivateRun() {
|
||||
|
||||
|
||||
|
||||
public void deactivateRun() {
|
||||
runButton.setSelected(false);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public void activateStop() {
|
||||
|
||||
|
||||
public void activateStop() {
|
||||
stopButton.setSelected(true);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void deactivateStop() {
|
||||
// swapButton(runButton);
|
||||
stopButton.setSelected(false);
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
abstract public void handleRun(int modifiers);
|
||||
|
||||
|
||||
|
||||
|
||||
abstract public void handleStop();
|
||||
|
||||
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(super.getPreferredSize().width, HIGH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
return new Dimension(super.getMinimumSize().width, HIGH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Dimension getMaximumSize() {
|
||||
return new Dimension(super.getMaximumSize().width, HIGH);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
class ModeSelector extends JPanel {
|
||||
Image offscreen;
|
||||
int width, height;
|
||||
|
||||
String title;
|
||||
|
||||
String title;
|
||||
Font titleFont;
|
||||
Color titleColor;
|
||||
int titleAscent;
|
||||
int titleWidth;
|
||||
|
||||
|
||||
final int MODE_GAP_WIDTH = 13;
|
||||
final int ARROW_GAP_WIDTH = 6;
|
||||
final int ARROW_WIDTH = 6;
|
||||
@@ -230,31 +232,31 @@ abstract public class EditorToolbar extends JPanel {
|
||||
|
||||
int[] triangleX = new int[3];
|
||||
int[] triangleY = new int[] { ARROW_TOP, ARROW_TOP, ARROW_BOTTOM };
|
||||
|
||||
|
||||
// Image background;
|
||||
Color backgroundColor;
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ModeSelector() {
|
||||
title = mode.getTitle(); //.toUpperCase();
|
||||
titleFont = mode.getFont("mode.title.font");
|
||||
titleColor = mode.getColor("mode.title.color");
|
||||
|
||||
|
||||
// getGraphics() is null and no offscreen yet
|
||||
titleWidth = getToolkit().getFontMetrics(titleFont).stringWidth(title);
|
||||
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent event) {
|
||||
JPopupMenu popup = editor.getModeMenu().getPopupMenu();
|
||||
popup.show(ModeSelector.this, event.getX(), event.getY());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//background = mode.getGradient("reversed", 100, EditorButton.DIM);
|
||||
backgroundColor = mode.getColor("mode.background.color");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics screen) {
|
||||
// Toolkit.debugOpacity(this);
|
||||
@@ -270,52 +272,52 @@ abstract public class EditorToolbar extends JPanel {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
}
|
||||
|
||||
|
||||
Graphics g = offscreen.getGraphics();
|
||||
/*Graphics2D g2 =*/ Toolkit.prepareGraphics(g);
|
||||
//Toolkit.clearGraphics(g, width, height);
|
||||
// g.clearRect(0, 0, width, height);
|
||||
// g.setColor(Color.GREEN);
|
||||
// g.fillRect(0, 0, width, height);
|
||||
|
||||
|
||||
g.setFont(titleFont);
|
||||
if (titleAscent == 0) {
|
||||
titleAscent = (int) Toolkit.getAscent(g); //metrics.getAscent();
|
||||
}
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
titleWidth = metrics.stringWidth(title);
|
||||
|
||||
|
||||
//g.drawImage(background, 0, 0, width, height, this);
|
||||
g.setColor(backgroundColor);
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
|
||||
g.setColor(titleColor);
|
||||
g.drawString(title.toUpperCase(), MODE_GAP_WIDTH, (height + titleAscent) / 2);
|
||||
|
||||
|
||||
int x = MODE_GAP_WIDTH + titleWidth + ARROW_GAP_WIDTH;
|
||||
triangleX[0] = x;
|
||||
triangleX[1] = x + ARROW_WIDTH;
|
||||
triangleX[2] = x + ARROW_WIDTH/2;
|
||||
g.fillPolygon(triangleX, triangleY, 3);
|
||||
|
||||
|
||||
// screen.clearRect(0, 0, width, height);
|
||||
screen.drawImage(offscreen, 0, 0, width, height, this);
|
||||
// screen.setColor(Color.RED);
|
||||
// screen.drawRect(0, 0, width-1, height-1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(MODE_GAP_WIDTH + titleWidth +
|
||||
ARROW_GAP_WIDTH + ARROW_WIDTH + MODE_GAP_WIDTH,
|
||||
return new Dimension(MODE_GAP_WIDTH + titleWidth +
|
||||
ARROW_GAP_WIDTH + ARROW_WIDTH + MODE_GAP_WIDTH,
|
||||
EditorButton.DIM);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getMaximumSize() {
|
||||
return getPreferredSize();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,9 @@ editor.errormarkercolor = #ed2630
|
||||
editor.warningmarkercolor = #ffc30e
|
||||
|
||||
# ERROR BAR - error bar on the right that shows the markers
|
||||
errorbar.errorcolor = #ed2630
|
||||
# formerly #ed2630, tickmark on right-hand side in comp is #c20102
|
||||
errorbar.errorcolor = #c20102
|
||||
errorbar.warningcolor = #ffc30e
|
||||
errorbar.backgroundcolor = #2c343d
|
||||
# using gutter.bcolor in 3.0a6
|
||||
#errorbar.backgroundcolor = #2c343d
|
||||
|
||||
# color of error tickmark on right-hand side in comp: #c20102
|
||||
|
||||
@@ -25,8 +25,6 @@ X https://github.com/processing/processing/issues/3128
|
||||
|
||||
_ run button w/ debugger shouldn't require "continue" before actually starting
|
||||
_ https://github.com/processing/processing/issues/3096
|
||||
_ large window places the debugger window offscreen
|
||||
_ https://github.com/processing/processing/issues/3091
|
||||
|
||||
_ how are we going to handle fonts for other languages?
|
||||
_ two new fonts have been added, other languages will need more
|
||||
@@ -203,6 +201,8 @@ _ remove deprecated methods
|
||||
gui
|
||||
_ finish the gui
|
||||
_ https://github.com/processing/processing/issues/3072
|
||||
_ large window places the debugger window offscreen
|
||||
_ https://github.com/processing/processing/issues/3091
|
||||
_ need 'actively pressed' version of 'play' and 'stop'
|
||||
_ could do rollover as well, but do other apps use them?
|
||||
_ iTunes has no rollover state but has a 'down' state
|
||||
|
||||
Reference in New Issue
Block a user