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

Method run

app/src/processing/app/tools/InstallCommander.java:54–151  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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");
98
99 String javaRoot = Platform.getContentFile(".").getCanonicalPath();
100
101 StringList jarList = new StringList();
102 addJarList(jarList, new File(javaRoot));
103 addJarList(jarList, new File(javaRoot, "core/library"));
104 addJarList(jarList, new File(javaRoot, "modes/java/mode"));
105 String classPath = jarList.join(":").replaceAll(javaRoot + "\\/?", "");
106
107 writer.println("cd \"" + javaRoot + "\" && " +
108 Platform.getJavaPath().replaceAll(" ", "\\\\ ") +
109 " -Djna.nosys=true" +
110 " $OPTION_FOR_HEADLESS_RUN" +
111 " -cp \"" + classPath + "\"" +

Callers

nothing calls this directly

Calls 15

createWriterMethod · 0.95
getContentFileMethod · 0.95
addJarListMethod · 0.95
joinMethod · 0.95
getJavaPathMethod · 0.95
execMethod · 0.95
showWarningMethod · 0.95
statusNoticeMethod · 0.95
getActiveEditorMethod · 0.80
createTempFileMethod · 0.80
printMethod · 0.65
replaceAllMethod · 0.45

Tested by

no test coverage detected