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

Class InstallCommander

app/src/processing/app/tools/InstallCommander.java:40–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40public class InstallCommander implements Tool {
41 Base base;
42
43
44 public String getMenuTitle() {
45 return Language.text("menu.tools.install_processing_java");
46 }
47
48
49 public void init(Base base) {
50 this.base = base;
51 }
52
53
54 public void run() {
55 try {
56 Editor editor = base.getActiveEditor();
57
58 final String primary =
59 "Install processing-java for all users?";
60 final String secondary =
61 "This will install the processing-java program, which is capable " +
62 "of building and running Java Mode sketches from the command line. " +
63 "Click “Yes” to install it for all users (an administrator password " +
64 "is required), or “No” to place the program in your home directory. " +
65 "If you rename or move Processing.app, " +
66 "you'll need to reinstall the tool.";
67
68 int result =
69 JOptionPane.showConfirmDialog(editor,
70 "<html> " +
71 "<head> <style type=\"text/css\">"+
72 "b { font: 13pt \"Lucida Grande\" }"+
73 "p { font: 11pt \"Lucida Grande\"; margin-top: 8px; width: 300px }"+
74 "</style> </head>" +
75 "<b>" + primary + "</b>" +
76 "<p>" + secondary + "</p>",
77 "Commander",
78 JOptionPane.YES_NO_CANCEL_OPTION,
79 JOptionPane.QUESTION_MESSAGE);
80
81 if (result == JOptionPane.CANCEL_OPTION) {
82 return;
83 }
84
85 File file = File.createTempFile("processing", "commander");
86 PrintWriter writer = PApplet.createWriter(file);
87 writer.print("#!/bin/sh\n\n");
88
89 writer.print("# Prevents processing-java from stealing focus, see:\n" +
90 "# https://github.com/processing/processing/issues/3996.\n" +
91 "OPTION_FOR_HEADLESS_RUN=\"\"\n" +
92 "for ARG in \"$@\"\n" +
93 "do\n" +
94 " if [ \"$ARG\" = \"--build\" ]; then\n" +
95 " OPTION_FOR_HEADLESS_RUN=\"-Djava.awt.headless=true\"\n" +
96 " fi\n" +
97 "done\n\n");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected