Skip to content

Commit 64b7bf6

Browse files
committed
Notify ECS that sketch changed on adding/removing tab
1 parent 4bba6d7 commit 64b7bf6

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

app/src/processing/app/Sketch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,12 @@ public void handleDeleteCode() {
673673
// remove code from the list
674674
removeCode(current);
675675

676+
// update the tabs
677+
editor.rebuildHeader();
678+
676679
// just set current tab to the main tab
677680
setCurrentCode(0);
678681

679-
// update the tabs
680-
editor.rebuildHeader();
681682
}
682683
}
683684
}

java/src/processing/mode/java/JavaEditor.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.beans.*;
66
import java.io.*;
77
import java.util.ArrayList;
8+
import java.util.Collections;
89
import java.util.Iterator;
910
import java.util.List;
1011
import java.util.Map;
@@ -130,9 +131,6 @@ public void actionPerformed(ActionEvent e) {
130131
getSketch().setModified(false);
131132

132133
hasJavaTabs = checkForJavaTabs();
133-
//initializeErrorChecker();
134-
135-
initErrorChecker();
136134

137135
// hack to add a JPanel to the right-hand side of the text area
138136
JPanel textAndError = new JPanel();
@@ -150,6 +148,8 @@ public void actionPerformed(ActionEvent e) {
150148

151149
getJavaTextArea().setMode(jmode);
152150

151+
initErrorChecker();
152+
153153
// ensure completion is hidden when editor loses focus
154154
addWindowFocusListener(new WindowFocusListener() {
155155
public void windowLostFocus(WindowEvent e) {
@@ -195,6 +195,8 @@ public EditorToolbar createToolbar() {
195195
}
196196

197197

198+
private int previousTabCount = 1;
199+
198200
// Override the parent call to add hook to the rebuild() method
199201
public EditorHeader createHeader() {
200202
return new EditorHeader(this) {
@@ -203,6 +205,14 @@ public void rebuild() {
203205

204206
// after Rename and New Tab, we may have new .java tabs
205207
hasJavaTabs = checkForJavaTabs();
208+
209+
if (errorCheckerService != null) {
210+
int currentTabCount = sketch.getCodeCount();
211+
if (currentTabCount != previousTabCount) {
212+
previousTabCount = currentTabCount;
213+
errorCheckerService.notifySketchChanged();
214+
}
215+
}
206216
}
207217
};
208218
}

0 commit comments

Comments
 (0)