Event handler called when switching between tabs. Loads all line background colors set for the tab. @param code tab to switch to
(SketchCode code)
| 2201 | * @param code tab to switch to |
| 2202 | */ |
| 2203 | @Override |
| 2204 | public void setCode(SketchCode code) { |
| 2205 | Document oldDoc = code.getDocument(); |
| 2206 | |
| 2207 | //System.out.println("tab switch: " + code.getFileName()); |
| 2208 | // set the new document in the textarea, etc. need to do this first |
| 2209 | super.setCode(code); |
| 2210 | |
| 2211 | Document newDoc = code.getDocument(); |
| 2212 | if (oldDoc != newDoc && pdex != null) { |
| 2213 | pdex.documentChanged(newDoc); |
| 2214 | } |
| 2215 | |
| 2216 | // set line background colors for tab |
| 2217 | final JavaTextArea ta = getJavaTextArea(); |
| 2218 | // can be null when setCode is called the first time (in constructor) |
| 2219 | if (ta != null) { |
| 2220 | // clear all gutter text |
| 2221 | ta.clearGutterText(); |
| 2222 | // first paint breakpoints |
| 2223 | if (breakpointedLines != null) { |
| 2224 | for (LineHighlight hl : breakpointedLines) { |
| 2225 | if (isInCurrentTab(hl.getLineID())) { |
| 2226 | hl.paint(); |
| 2227 | } |
| 2228 | } |
| 2229 | } |
| 2230 | // now paint current line (if any) |
| 2231 | if (currentLine != null) { |
| 2232 | if (isInCurrentTab(currentLine.getLineID())) { |
| 2233 | currentLine.paint(); |
| 2234 | } |
| 2235 | } |
| 2236 | } |
| 2237 | if (getDebugger() != null && getDebugger().isStarted()) { |
| 2238 | getDebugger().startTrackingLineChanges(); |
| 2239 | } |
| 2240 | if (errorColumn != null) { |
| 2241 | errorColumn.repaint(); |
| 2242 | } |
| 2243 | } |
| 2244 | |
| 2245 | |
| 2246 | /** |
no test coverage detected