3333import processing .data .StringList ;
3434
3535import javax .swing .*;
36- import javax .swing .border .BevelBorder ;
3736import javax .swing .border .EmptyBorder ;
3837import javax .swing .border .TitledBorder ;
3938import java .awt .*;
4039import java .awt .event .ActionEvent ;
4140import java .awt .event .ActionListener ;
4241import java .awt .event .MouseAdapter ;
4342import java .awt .event .MouseEvent ;
44- import java .io .File ;
4543import java .io .IOException ;
4644import java .util .ArrayList ;
4745import java .util .List ;
4846
4947
5048public class ExportPrompt {
51- // Can't be .windows because that'll be stripped off as a per-platform pref
49+ static final String MACOS_EXPORT_WIKI =
50+ "https://github.com/processing/processing4/wiki/Exporting-Applications#macos" ;
5251 static final String EXPORT_VARIANTS = "export.application.variants" ;
53- /*
54- static final String EXPORT_PREFIX = "export.application.platform_";
55- static final String EXPORT_MACOSX = EXPORT_PREFIX + "macosx";
56- static final String EXPORT_WINDOWS = EXPORT_PREFIX + "windows";
57- static final String EXPORT_LINUX = EXPORT_PREFIX + "linux";
58- */
5952
6053 final JButton exportButton = new JButton (Language .text ("prompt.export" ));
6154 final JButton cancelButton = new JButton (Language .text ("prompt.cancel" ));
6255
63- /*
64- final JCheckBox windowsButton = new JCheckBox("Windows");
65- final JCheckBox macosButton = new JCheckBox("Mac OS X");
66- final JCheckBox linuxButton = new JCheckBox("Linux");
67- */
6856 List <JCheckBox > variantButtons ;
6957
7058 final JavaEditor editor ;
@@ -94,16 +82,6 @@ private ExportPrompt(JavaEditor editor) {
9482 button .setActionCommand (variant );
9583 button .addActionListener (e -> updateVariants ());
9684 variantButtons .add (button );
97- /*
98- final String variant = entry.key;
99- button.addActionListener(new ActionListener() {
100- @Override
101- public void actionPerformed(ActionEvent e) {
102- e.getActionCommand();
103- toggleVariant(variant);
104- }
105- });
106- */
10785 }
10886 }
10987
@@ -120,26 +98,6 @@ protected void updateVariants() {
12098 }
12199
122100
123- /*
124- protected void toggleVariant(String variant) {
125- String pref = Preferences.get(EXPORT_VARIANTS);
126- StringList list = new StringList(pref.split(","));
127- if (list.hasValue(variant)) {
128- list.removeValue(variant);
129- } else {
130- list.append(variant);
131- }
132- pref = list.join(",");
133- Preferences.set(EXPORT_VARIANTS, pref);
134- }
135-
136-
137- protected void updateExportButton() {
138- exportButton.setEnabled(anyExportButton());
139- }
140- */
141-
142-
143101 protected boolean anyExportButton () {
144102 for (JCheckBox button : variantButtons ) {
145103 if (button .isSelected ()) {
@@ -192,11 +150,6 @@ protected boolean trigger() throws IOException, SketchException {
192150
193151 int divWidth = platformPanel .getPreferredSize ().width ;
194152
195- // Dimension labelDim = new Dimension(divWidth, label.getPreferredSize().height);
196- // label.setPreferredSize(labelDim);
197- // label.setMinimumSize(labelDim);
198- // label.setMaximumSize(labelDim);
199-
200153 final JCheckBox showStopButton = new JCheckBox (Language .text ("export.options.show_stop_button" ));
201154 showStopButton .setSelected (Preferences .getBoolean ("export.application.stop" ));
202155 showStopButton .addItemListener (e -> Preferences .setBoolean ("export.application.stop" , showStopButton .isSelected ()));
@@ -251,7 +204,7 @@ protected boolean trigger() throws IOException, SketchException {
251204 final boolean embed =
252205 Preferences .getBoolean ("export.application.embed_java" );
253206 final String warning1 =
254- "<html><div width=\" " + divWidth + "\" >" ; //<font size=\"2\">";
207+ "<html><div width=\" " + divWidth + "\" >" ;
255208 final String warning2a =
256209 "Embedding Java will make the " + platformName + " application " +
257210 "larger, but it will be far more likely to work. " +
@@ -276,7 +229,8 @@ public void mousePressed(MouseEvent event) {
276229 warningLabel .putClientProperty ("FlatLaf.styleClass" , "medium" );
277230
278231 final JCheckBox embedJavaButton =
279- new JCheckBox (Language .interpolate ("export.include_java" , platformName ));
232+ new JCheckBox (Language .interpolate ("export.include_java" , Platform .getPrettyName ()));
233+ //new JCheckBox(Language.interpolate("export.include_java", platformName));
280234 embedJavaButton .setSelected (embed );
281235 embedJavaButton .addItemListener (e -> {
282236 boolean selected = embedJavaButton .isSelected ();
@@ -302,40 +256,24 @@ public void mousePressed(MouseEvent event) {
302256 signPanel .setLayout (new BoxLayout (signPanel , BoxLayout .Y_AXIS ));
303257 signPanel .setBorder (new TitledBorder (Language .text ("export.code_signing" )));
304258
305- // gatekeeper: http://support.apple.com/kb/ht5290
306- // for developers: https://developer.apple.com/developer-id/
307- final String APPLE_URL = "https://developer.apple.com/developer-id/" ;
308259 String thePain =
309- //"<html><body><font size=2>" +
310- "In recent versions of macOS, Apple has introduced the \u201C Gatekeeper\u201D system, " +
311- "which makes it more difficult to run applications like those exported from Processing. " ;
260+ "Applications on macOS must be \u201C signed\u201D and \u201C notarized,\u201D " +
261+ "or they will be reported as damaged or unsafe. " ;
312262
313- if (new File ("/usr/bin/codesign_allocate" ).exists ()) {
263+ //if (false && new File("/usr/bin/codesign_allocate").exists()) {
264+ if (JavaBuild .isXcodeInstalled ()) {
314265 thePain +=
315- "This application will be \u201C self-signed\u201D which means that Finder may report that the " +
316- "application is from an \u201C unidentified developer\u201D . If the application will not " +
317- "run, try right-clicking the app and selecting Open from the pop-up menu. Or you can visit " +
318- "System Preferences \u2192 Security & Privacy and select Allow apps downloaded from: anywhere. " ;
266+ "This application will be \u201C self-signed\u201D which means that " +
267+ "macOS may complain that is from an unidentified developer. " +
268+ "If the application will not run, try right-clicking the app and " +
269+ "selecting Open from the pop-up menu. " +
270+ "More details at the <a href=\" \" >Exporting Applications</a> wiki page." ;
319271 } else {
320272 thePain +=
321- "Gatekeeper requires applications to be \u201C signed \u201D , or they will be reported as damaged. " +
322- "To prevent this message, install Xcode (and the Command Line Tools) from the App Store . " ;
273+ "To sign the app, <a href= \" \" >click here</a> to begin " +
274+ "installing the Command Line Tools from Apple . " ;
323275 }
324- thePain +=
325- "To avoid the messages entirely, manually code sign your app. " +
326- "For more information: <a href=\" \" >" + APPLE_URL + "</a>" ;
327276
328- // xattr -d com.apple.quarantine thesketch.app
329-
330- //signPanel.add(new JLabel(thePain));
331- //JEditorPane area = new JEditorPane("text/html", thePain);
332- //JTextPane area = new JEditorPane("text/html", thePain);
333-
334- // JTextArea area = new JTextArea(thePain);
335- // area.setBackground(null);
336- // area.setFont(new Font("Dialog", Font.PLAIN, 10));
337- // area.setLineWrap(true);
338- // area.setWrapStyleWord(true);
339277 // Are you f-king serious, Java API developers?
340278 // (Unless it's an HTML component, even with line wrap turned on,
341279 // getPreferredSize() will return the size for just a single line.)
@@ -344,15 +282,23 @@ public void mousePressed(MouseEvent event) {
344282 area .putClientProperty ("FlatLaf.styleClass" , "medium" );
345283
346284 area .setBorder (new EmptyBorder (3 , 13 , 3 , 13 ));
347- // area.setPreferredSize(new Dimension(embedPanel.getPreferredSize().width, 100));
348- // area.setPreferredSize(new Dimension(300, 200));
285+ // Using area.setPreferredSize() here doesn't help,
286+ // but setting the div width in CSS above worked.
349287 signPanel .add (area );
350- // signPanel.add(Box.createHorizontalGlue());
351288 signPanel .setAlignmentX (Component .LEFT_ALIGNMENT );
352289
353290 area .addMouseListener (new MouseAdapter () {
354291 public void mousePressed (MouseEvent event ) {
355- Platform .openURL ("https://developer.apple.com/developer-id/" );
292+ if (JavaBuild .isXcodeInstalled ()) {
293+ Platform .openURL (MACOS_EXPORT_WIKI );
294+
295+ } else {
296+ // Launch the process asynchronously
297+ PApplet .exec ("xcode-select" , "--install" );
298+ // Close the window so that we can rebuild it with different text
299+ // once they've finished installing the Command Line Tools.
300+ dialog .setVisible (false );
301+ }
356302 }
357303 });
358304
@@ -361,7 +307,6 @@ public void mousePressed(MouseEvent event) {
361307
362308 //
363309
364- //String[] options = { Language.text("prompt.export"), Language.text("prompt.cancel") };
365310 final JButton [] options = { exportButton , cancelButton };
366311
367312 final JOptionPane optionPane = new JOptionPane (panel ,
@@ -388,8 +333,6 @@ public void mousePressed(MouseEvent event) {
388333 }
389334 });
390335 dialog .pack ();
391- // System.out.println("after pack: " + panel.getPreferredSize());
392- // dialog.setSize(optionPane.getPreferredSize());
393336 dialog .setResizable (false );
394337
395338 // Center the window in the middle of the editor
@@ -446,17 +389,4 @@ public void actionPerformed(ActionEvent e) {
446389 chooser .hide ();
447390 }
448391 }
449-
450-
451- // protected void selectColor(String prefName) {
452- // Color color = Preferences.getColor(prefName);
453- // final ColorChooser chooser = new ColorChooser(JavaEditor.this, true, color,
454- // "Select", new ActionListener() {
455- //
456- // @Override
457- // public void actionPerformed(ActionEvent e) {
458- // Preferences.setColor(prefName, c.getColor());
459- // }
460- // });
461- // }
462392}
0 commit comments