MCPcopy Index your code
hub / github.com/benfry/processing4 / setCode

Method setCode

java/src/processing/mode/java/JavaEditor.java:1593–1633  ·  view source on GitHub ↗

Event handler called when switching between tabs. Loads all line background colors set for the tab. @param code tab to switch to

(SketchCode code)

Source from the content-addressed store, hash-verified

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 /**

Callers 4

setTabContentsMethod · 0.95
stopTweakModeMethod · 0.95
initEditorCodeMethod · 0.95
loadSavedCodeMethod · 0.95

Calls 11

addDocumentListenerMethod · 0.95
getJavaTextAreaMethod · 0.95
isInCurrentTabMethod · 0.95
getDebuggerMethod · 0.95
clearGutterTextMethod · 0.80
getLineIDMethod · 0.80
isStartedMethod · 0.80
repaintMethod · 0.80
getDocumentMethod · 0.45
paintMethod · 0.45

Tested by

no test coverage detected