From 59b4fb2b7f5e8b2a8e98c87a142a122416e2614e Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Sat, 30 Apr 2016 17:08:37 +0200 Subject: [PATCH] Notify ECS that sketch changed on adding/removing tab --- app/src/processing/app/Sketch.java | 5 +++-- java/src/processing/mode/java/JavaEditor.java | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index c3d6382f5..d44e3bffc 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -673,11 +673,12 @@ public class Sketch { // remove code from the list removeCode(current); + // update the tabs + editor.rebuildHeader(); + // just set current tab to the main tab setCurrentCode(0); - // update the tabs - editor.rebuildHeader(); } } } diff --git a/java/src/processing/mode/java/JavaEditor.java b/java/src/processing/mode/java/JavaEditor.java index 735db8df5..7d84d45f6 100644 --- a/java/src/processing/mode/java/JavaEditor.java +++ b/java/src/processing/mode/java/JavaEditor.java @@ -5,6 +5,7 @@ import java.awt.event.*; import java.beans.*; import java.io.*; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -130,9 +131,6 @@ public class JavaEditor extends Editor { getSketch().setModified(false); hasJavaTabs = checkForJavaTabs(); - //initializeErrorChecker(); - - initErrorChecker(); // hack to add a JPanel to the right-hand side of the text area JPanel textAndError = new JPanel(); @@ -150,6 +148,8 @@ public class JavaEditor extends Editor { getJavaTextArea().setMode(jmode); + initErrorChecker(); + // ensure completion is hidden when editor loses focus addWindowFocusListener(new WindowFocusListener() { public void windowLostFocus(WindowEvent e) { @@ -195,6 +195,8 @@ public class JavaEditor extends Editor { } + private int previousTabCount = 1; + // Override the parent call to add hook to the rebuild() method public EditorHeader createHeader() { return new EditorHeader(this) { @@ -203,6 +205,14 @@ public class JavaEditor extends Editor { // after Rename and New Tab, we may have new .java tabs hasJavaTabs = checkForJavaTabs(); + + if (errorCheckerService != null) { + int currentTabCount = sketch.getCodeCount(); + if (currentTabCount != previousTabCount) { + previousTabCount = currentTabCount; + errorCheckerService.notifySketchChanged(); + } + } } }; }