MCPcopy Index your code
hub / github.com/processing/processing / handleTweak

Method handleTweak

java/src/processing/mode/java/JavaMode.java:142–205  ·  view source on GitHub ↗

Start a sketch in tweak mode

(Sketch sketch,
                            RunnerListener listener, JavaEditor editor)

Source from the content-addressed store, hash-verified

140
141 /** Start a sketch in tweak mode */
142 public Runner handleTweak(Sketch sketch,
143 RunnerListener listener, JavaEditor editor) throws SketchException {
144
145 // first try to build the unmodified code
146 JavaBuild build = new JavaBuild(sketch);
147// String appletClassName = build.build(false);
148 String appletClassName = build.build(true);
149 if (appletClassName == null) {
150 // unmodified build failed, so fail
151 return null;
152 }
153
154 // if compilation passed, modify the code and build again
155 // save the original sketch code of the user
156 editor.initBaseCode();
157 // check for "// tweak" comment in the sketch
158 boolean requiresTweak = SketchParser.containsTweakComment(editor.baseCode);
159 // parse the saved sketch to get all (or only with "//tweak" comment) numbers
160 final SketchParser parser = new SketchParser(editor.baseCode, requiresTweak);
161
162 // add our code to the sketch
163 final boolean launchInteractive = editor.automateSketch(sketch, parser);
164
165 build = new JavaBuild(sketch);
166 appletClassName = build.build(false);
167
168 if (appletClassName != null) {
169 final Runner runtime = new Runner(build, listener);
170 new Thread(new Runnable() {
171 public void run() {
172 // these block until finished
173// if (present) {
174// runtime.present(null);
175// } else {
176 runtime.launch(null);
177// }
178 // next lines are executed when the sketch quits
179 if (launchInteractive) {
180 // fix swing deadlock issue: https://github.com/processing/processing/issues/3928
181 SwingUtilities.invokeLater(new Runnable() {
182 public void run() {
183 editor.initEditorCode(parser.allHandles, false);
184 editor.stopTweakMode(parser.allHandles);
185 }
186 });
187 }
188 }
189 }).start();
190
191 if (launchInteractive) {
192 // fix swing deadlock issue: https://github.com/processing/processing/issues/3928
193 SwingUtilities.invokeLater(new Runnable() {
194 public void run() {
195 // replace editor code with baseCode
196 editor.initEditorCode(parser.allHandles, false);
197 editor.updateInterface(parser.allHandles, parser.colorBoxes);
198 editor.startTweakMode();
199 }

Callers

nothing calls this directly

Calls 5

buildMethod · 0.95
containsTweakCommentMethod · 0.95
initBaseCodeMethod · 0.80
automateSketchMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected