From b2783d80722a982fdbd8e38c3a47159c088488b0 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Mon, 18 May 2015 20:02:41 -0400 Subject: [PATCH] fix up Java tab checking, making EditorStatus into the divider --- app/src/processing/app/Editor.java | 29 +++--- app/src/processing/app/EditorStatus.java | 13 ++- core/todo.txt | 13 ++- java/src/processing/mode/java/JavaEditor.java | 94 ++++++++++--------- todo.txt | 4 +- 5 files changed, 84 insertions(+), 69 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 89768a6e0..9445b0ef7 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -29,16 +29,12 @@ import processing.app.tools.*; import processing.core.*; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Frame; -import java.awt.Graphics; -import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; -import java.awt.RenderingHints; import java.awt.datatransfer.*; import java.awt.event.*; import java.awt.print.*; @@ -253,8 +249,8 @@ public abstract class Editor extends JFrame implements RunnerListener { consolePanel = new JPanel(); consolePanel.setLayout(new BorderLayout()); - status = new EditorStatus(this); - consolePanel.add(status, BorderLayout.NORTH); +// status = new EditorStatus(this); +// consolePanel.add(status, BorderLayout.NORTH); console = new EditorConsole(this); // windows puts an ugly border on this guy @@ -279,16 +275,20 @@ public abstract class Editor extends JFrame implements RunnerListener { // if window increases in size, give all of increase to // the textarea in the upper pane splitPane.setResizeWeight(1D); - // remove any ugly borders added by PLAFs + // remove any ugly borders added by PLAFs (doesn't fix everything) splitPane.setBorder(null); - // necessary to let the gradient show through -// splitPane.setOpaque(false); - // remove an ugly border around anything in a SplitPane !$*&!% UIManager.getDefaults().put("SplitPane.border", BorderFactory.createEmptyBorder()); + // set the height per our gui design + //splitPane.setDividerSize(mode.getInteger("divider.height")); + splitPane.setDividerSize(EditorStatus.HIGH); + // override the look of the SplitPane so that it's identical across OSes splitPane.setUI(new BasicSplitPaneUI() { public BasicSplitPaneDivider createDefaultDivider() { + status = new EditorStatus(this, Editor.this); + return status; + /* return new BasicSplitPaneDivider(this) { final Color dividerColor = mode.getColor("divider.color"); //new Color(204, 204, 204); final Color dotColor = mode.getColor("divider.dot.color"); //new Color(80, 80, 80); @@ -311,17 +311,10 @@ public abstract class Editor extends JFrame implements RunnerListener { g.fillOval(x, y, dotSize, dotSize); } }; + */ } }); -// EditorConsole.systemOut.println("divider default size is " + splitPane.getDividerSize()); -// // the default size on windows is too small and kinda ugly -// int dividerSize = Preferences.getInteger("editor.divider.size"); -// if (dividerSize != 0) { -// splitPane.setDividerSize(dividerSize); -// } - splitPane.setDividerSize(mode.getInteger("divider.height")); - box.add(splitPane); contentPain.add(box); diff --git a/app/src/processing/app/EditorStatus.java b/app/src/processing/app/EditorStatus.java index fbfde0275..14efc7cdd 100644 --- a/app/src/processing/app/EditorStatus.java +++ b/app/src/processing/app/EditorStatus.java @@ -25,13 +25,14 @@ package processing.app; import java.awt.*; -import javax.swing.*; +import javax.swing.plaf.basic.BasicSplitPaneDivider; +import javax.swing.plaf.basic.BasicSplitPaneUI; /** * Panel just below the editing area that contains status messages. */ -public class EditorStatus extends JPanel { +public class EditorStatus extends BasicSplitPaneDivider { //JPanel { static final int HIGH = 28; Color[] bgcolor; @@ -70,8 +71,9 @@ public class EditorStatus extends JPanel { Thread thread; - - public EditorStatus(Editor editor) { + //public EditorStatus(Editor editor) { + public EditorStatus(BasicSplitPaneUI ui, Editor editor) { + super(ui); this.editor = editor; empty(); updateMode(); @@ -172,7 +174,8 @@ public class EditorStatus extends JPanel { } - public void paintComponent(Graphics screen) { + //public void paintComponent(Graphics screen) { + public void paint(Graphics screen) { // if (okButton == null) setup(); Dimension size = getSize(); diff --git a/core/todo.txt b/core/todo.txt index 2771e29bf..e2fa2961b 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,5 +1,9 @@ 0236 (3.0a9) +fixed in 3.0a8 +X Full screen window on second monitor without using present mode +X https://github.com/processing/processing/issues/3271 + andres X Offscreen rendering broken in OpenGL renderers X https://github.com/processing/processing/issues/3292 @@ -8,6 +12,11 @@ X https://github.com/processing/processing/issues/2981 high priority +_ displayWidth and displayHeight are zero +_ https://github.com/processing/processing/issues/3295 +_ need a better option for using full screen +_ maybe we use the AWT screen sizes first, then match the others w/ em? +_ https://docs.oracle.com/javafx/2/api/javafx/stage/Screen.html _ instead of all these sketchXxxx() methods, should we have sketchSetting() _ and an internal dictionary that stores them all? _ or sketchInt() or settingsInt()? @@ -77,12 +86,12 @@ _ probably from the material stuff, but we need to fix that full screen +_ do we need to change up the api? +_ https://github.com/processing/processing/issues/3296 _ present window draws in stages (OS X) _ split 'present' and 'full screen'? _ --full-screen causes considerable flicker at this point _ or split them when sketchWidth/Height are implemented? -_ Full screen window on second monitor without using present mode -_ https://github.com/processing/processing/issues/3271 _ "run sketches on display" not working in 3.0a7 _ https://github.com/processing/processing/issues/3264 _ full screen doesn't work on second window w/o present mode diff --git a/java/src/processing/mode/java/JavaEditor.java b/java/src/processing/mode/java/JavaEditor.java index 92ad5d27e..cea1411fc 100644 --- a/java/src/processing/mode/java/JavaEditor.java +++ b/java/src/processing/mode/java/JavaEditor.java @@ -57,13 +57,14 @@ public class JavaEditor extends Editor { // Need to sort through the rest of these additions... - protected Color breakpointColor; // = new Color(240, 240, 240); // the background color for highlighting lines - protected Color currentLineColor; // = new Color(255, 255, 150); // the background color for highlighting lines - protected Color breakpointMarkerColor; // = new Color(74, 84, 94); // the color of breakpoint gutter markers - protected Color currentLineMarkerColor; // = new Color(226, 117, 0); // the color of current line gutter markers - protected List breakpointedLines = new ArrayList(); // breakpointed lines - protected LineHighlight currentLine; // line the debugger is currently suspended at - protected final String breakpointMarkerComment = " //<>//"; // breakpoint marker comment + protected Color breakpointColor; + protected Color currentLineColor; + protected Color breakpointMarkerColor; + protected Color currentLineMarkerColor; + protected List breakpointedLines = + new ArrayList(); + protected LineHighlight currentLine; // where the debugger is suspended + protected final String breakpointMarkerComment = " //<>//"; protected JMenu debugMenu; // JCheckBoxMenuItem enableDebug; @@ -91,6 +92,8 @@ public class JavaEditor extends Editor { private boolean hasJavaTabs; private boolean javaTabWarned; + protected ErrorCheckerService errorCheckerService; + protected JavaEditor(Base base, String path, EditorState state, Mode mode) { super(base, path, state, mode); @@ -134,33 +137,37 @@ public class JavaEditor extends Editor { Toolkit.setMenuMnemonics(textarea.getRightClickPopup()); // load settings from theme.txt - breakpointColor = mode.getColor("breakpoint.bgcolor"); //, breakpointColor); - breakpointMarkerColor = mode.getColor("breakpoint.marker.color"); //, breakpointMarkerColor); - currentLineColor = mode.getColor("currentline.bgcolor"); //, currentLineColor); - currentLineMarkerColor = mode.getColor("currentline.marker.color"); //, currentLineMarkerColor); + breakpointColor = mode.getColor("breakpoint.bgcolor"); + breakpointMarkerColor = mode.getColor("breakpoint.marker.color"); + currentLineColor = mode.getColor("currentline.bgcolor"); + currentLineMarkerColor = mode.getColor("currentline.marker.color"); // set breakpoints from marker comments for (LineID lineID : stripBreakpointComments()) { //System.out.println("setting: " + lineID); debugger.setBreakpoint(lineID); } - getSketch().setModified(false); // setting breakpoints will flag sketch as modified, so override this here + // setting breakpoints will flag sketch as modified, so override this here + getSketch().setModified(false); hasJavaTabs = checkForJavaTabs(); - initializeErrorChecker(); + //initializeErrorChecker(); + + errorCheckerService = new ErrorCheckerService(this); + new Thread(errorCheckerService).start(); getJavaTextArea().setECSandThemeforTextArea(errorCheckerService, jmode); // Adding ErrorBar JPanel textAndError = new JPanel(); - Box box = (Box) textarea.getParent(); - box.remove(2); // Remove textArea from it's container, i.e Box +// Box box = (Box) textarea.getParent(); +// box.remove(2); // Remove textArea from it's container, i.e Box textAndError.setLayout(new BorderLayout()); errorBar = new ErrorBar(this, textarea.getMinimumSize().height, jmode); textAndError.add(errorBar, BorderLayout.EAST); textarea.setBounds(0, 0, errorBar.getX() - 1, textarea.getHeight()); textAndError.add(textarea); - box.add(textAndError); +// box.add(textAndError); // Adding Error Table in a scroll pane errorTableScrollPane = new JScrollPane(); @@ -170,7 +177,7 @@ public class JavaEditor extends Editor { errorTableScrollPane.setViewportView(errorTable); // Adding toggle console button - consolePanel.remove(2); +// consolePanel.remove(2); JPanel lineStatusPanel = new JPanel(); lineStatusPanel.setLayout(new BorderLayout()); btnShowConsole = new XQConsoleToggle(this, Language.text("editor.footer.console"), lineStatus.getHeight()); @@ -185,15 +192,15 @@ public class JavaEditor extends Editor { lineStatus.setBounds(0, 0, toggleButtonPanel.getX() - 1, toggleButtonPanel.getHeight()); lineStatusPanel.add(lineStatus); - consolePanel.add(lineStatusPanel, BorderLayout.SOUTH); +// consolePanel.add(lineStatusPanel, BorderLayout.SOUTH); lineStatusPanel.repaint(); // Adding JPanel with CardLayout for Console/Problems Toggle - consolePanel.remove(1); +// consolePanel.remove(1); consoleProblemsPane = new JPanel(new CardLayout()); consoleProblemsPane.add(errorTableScrollPane, Language.text("editor.footer.errors")); consoleProblemsPane.add(console, Language.text("editor.footer.console")); - consolePanel.add(consoleProblemsPane, BorderLayout.CENTER); +// consolePanel.add(consoleProblemsPane, BorderLayout.CENTER); // ensure completion gets hidden on editor losing focus addWindowFocusListener(new WindowFocusListener() { @@ -220,7 +227,8 @@ public class JavaEditor extends Editor { return new EditorHeader(this) { public void rebuild() { super.rebuild(); - System.out.println("checking for Java tabs"); + + // after Rename and New Tab, we may have new .java tabs hasJavaTabs = checkForJavaTabs(); } }; @@ -1288,11 +1296,13 @@ public class JavaEditor extends Editor { public void dispose() { //System.out.println("window dispose"); // quit running debug session - debugger.stopDebug(); - // remove var.inspector - inspector.dispose(); + if (debugEnabled) { + debugger.stopDebug(); + } + if (inspector != null) { + inspector.dispose(); + } errorCheckerService.stopThread(); - // original dispose super.dispose(); } @@ -2508,24 +2518,22 @@ public class JavaEditor extends Editor { } - public ErrorCheckerService errorCheckerService; - - /** - * Initializes and starts Error Checker Service - */ - private void initializeErrorChecker() { - Thread errorCheckerThread = null; - - if (errorCheckerThread == null) { - errorCheckerService = new ErrorCheckerService(this); - errorCheckerThread = new Thread(errorCheckerService); - try { - errorCheckerThread.start(); - } catch (Exception e) { - Base.loge("Error Checker Service not initialized", e); - } - } - } +// /** +// * Initializes and starts Error Checker Service +// */ +// private void initializeErrorChecker() { +// Thread errorCheckerThread = null; +// +// if (errorCheckerThread == null) { +// errorCheckerService = new ErrorCheckerService(this); +// errorCheckerThread = new Thread(errorCheckerService); +// try { +// errorCheckerThread.start(); +// } catch (Exception e) { +// Base.loge("Error Checker Service not initialized", e); +// } +// } +// } public void updateErrorBar(List problems) { diff --git a/todo.txt b/todo.txt index 144956eba..a4787c551 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,5 @@ 0236 (3.0a9) +X show screen dimensions in the Preferences window pdex/debugger X remove "Experimental Mode: Yikes!" messages @@ -49,13 +50,14 @@ _ move Library to LibraryContribution and into contrib? gui +_ need active state for the butterfly _ finish the gui _ https://github.com/processing/processing/issues/3072 _ implement the bottom half of the editor window _ editor window draws in stages (at least on OS X) on first view _ the console/bottom area stays white until an additional repaint? _ remove EditorLineStatus (we have line numbers) -_ need active state for the butterfly +_ add a "what's new" window to promote features in 3? gui (lower, not blocking for beta)