Event handler called when switching between tabs. Loads all line background colors set for the tab. @param code tab to switch to
(SketchCode code)
| 1591 | * @param code tab to switch to |
| 1592 | */ |
| 1593 | @Override |
| 1594 | public void setCode(SketchCode code) { |
| 1595 | Document oldDoc = code.getDocument(); |
| 1596 | |
| 1597 | //System.out.println("tab switch: " + code.getFileName()); |
| 1598 | // set the new document in the textarea, etc. need to do this first |
| 1599 | super.setCode(code); |
| 1600 | |
| 1601 | Document newDoc = code.getDocument(); |
| 1602 | if (oldDoc != newDoc) { |
| 1603 | addDocumentListener(newDoc); |
| 1604 | } |
| 1605 | |
| 1606 | // set line background colors for tab |
| 1607 | final JavaTextArea ta = getJavaTextArea(); |
| 1608 | // can be null when setCode is called the first time (in constructor) |
| 1609 | if (ta != null) { |
| 1610 | // clear all gutter text |
| 1611 | ta.clearGutterText(); |
| 1612 | // first paint breakpoints |
| 1613 | if (breakpointedLines != null) { |
| 1614 | for (LineHighlight hl : breakpointedLines) { |
| 1615 | if (isInCurrentTab(hl.getLineID())) { |
| 1616 | hl.paint(); |
| 1617 | } |
| 1618 | } |
| 1619 | } |
| 1620 | // now paint current line (if any) |
| 1621 | if (currentLine != null) { |
| 1622 | if (isInCurrentTab(currentLine.getLineID())) { |
| 1623 | currentLine.paint(); |
| 1624 | } |
| 1625 | } |
| 1626 | } |
| 1627 | if (getDebugger() != null && getDebugger().isStarted()) { |
| 1628 | getDebugger().startTrackingLineChanges(); |
| 1629 | } |
| 1630 | if (errorColumn != null) { |
| 1631 | errorColumn.repaint(); |
| 1632 | } |
| 1633 | } |
| 1634 | |
| 1635 | |
| 1636 | /** |
no test coverage detected