Skip to content

Commit b939982

Browse files
committed
finish redoing Export to Application for macOS
1 parent 42439dc commit b939982

File tree

4 files changed

+47
-105
lines changed

4 files changed

+47
-105
lines changed

app/src/processing/app/Platform.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ static public String getName() {
260260
}
261261

262262

263+
static public String getPrettyName() {
264+
return supportedVariants.get(getVariant());
265+
}
266+
267+
263268
// /**
264269
// * Map a platform constant to its name.
265270
// * @param which PConstants.WINDOWS, PConstants.MACOSX, PConstants.LINUX

java/src/processing/mode/java/ExportPrompt.java

Lines changed: 28 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,26 @@
3333
import processing.data.StringList;
3434

3535
import javax.swing.*;
36-
import javax.swing.border.BevelBorder;
3736
import javax.swing.border.EmptyBorder;
3837
import javax.swing.border.TitledBorder;
3938
import java.awt.*;
4039
import java.awt.event.ActionEvent;
4140
import java.awt.event.ActionListener;
4241
import java.awt.event.MouseAdapter;
4342
import java.awt.event.MouseEvent;
44-
import java.io.File;
4543
import java.io.IOException;
4644
import java.util.ArrayList;
4745
import java.util.List;
4846

4947

5048
public 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 \u201CGatekeeper\u201D system, " +
311-
"which makes it more difficult to run applications like those exported from Processing. ";
260+
"Applications on macOS must be \u201Csigned\u201D and \u201Cnotarized,\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 \u201Cself-signed\u201D which means that Finder may report that the " +
316-
"application is from an \u201Cunidentified 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 \u201Cself-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 \u201Csigned\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
}

java/src/processing/mode/java/JavaBuild.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ static public String[] getArgsJavaFX(String modulePath) {
10891089

10901090
static protected boolean isXcodeInstalled() {
10911091
if (xcodeInstalled == null) {
1092-
// Note that this is *not* an xcrun tool, because it's part of the OS.
1092+
// Note that xcode-select is *not* an xcrun tool: it's part of the OS.
10931093
// pkgutil --file-info /usr/bin/xcode-select
10941094
// https://stackoverflow.com/a/32752859/18247494
10951095
StringList stdout = new StringList();

todo.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ X working on an updated welcome screen
1818
X fix usages of .array() method in PDE code
1919
X get code signing to work again on macOS for exported applications
2020
X absolutely floored that it was broken this long
21+
X new docs added, window text redone
2122

2223
docs
2324
X update theme instructions
2425
X https://github.com/processing/processing4/wiki/Themes
2526
X update the platforms page
2627
X https://github.com/processing/processing4/wiki/Supported-Platforms
2728
o rename to 'platforms'?
29+
X rewrote Exporting Applications wiki page
30+
X include more details about Gatekeeper et al
2831

2932
temp
3033
X temp folders (particularly on Windows)
@@ -270,10 +273,6 @@ _ also use id/ask for login to help understand community?
270273
_ tell users about JavaFX, Movie Maker install, changing themes
271274
_ final call on the About screen
272275

273-
274-
_ make sure mono font is coming from languages file when first setting editor pref
275-
_ add wiki page for customization
276-
277276
new things
278277
+ themes
279278
+ naming
@@ -287,6 +286,14 @@ old things
287286
+ Examples window (Casey will pick 3-4)
288287

289288

289+
_ make sure mono font is coming from languages file when first setting editor pref
290+
_ naming selection not being set in prefs window
291+
_ add wiki page for customization
292+
_ "include Java for macOS" only relevant for current macOS platform
293+
_ better to fix that, or make it possible to download both?
294+
295+
296+
290297
4.0 / in the queue
291298
_ examples still coming from processing-docs repo
292299
_ https://github.com/processing/processing-examples
@@ -301,8 +308,8 @@ _ update license info to state gplv2 not v3
301308
_ run through that online license checker
302309
_ Export to Application on Apple Silicon is including a broken "Universal" appbundler
303310
_ need to lipo a new appbundler, or have it export one of the two files
304-
_ “Array_Test.app” is damaged and can’t be opened. You should move it to the Trash.
305-
_ https://github.com/processing/processing/issues/4214 (closed)
311+
X “Array_Test.app” is damaged and can’t be opened. You should move it to the Trash.
312+
X https://github.com/processing/processing/issues/4214 (closed)
306313
_ figure out if we can do anything with signing applications
307314
_ https://developer.apple.com/forums/thread/128166
308315
_ https://developer.apple.com/forums/thread/701514#701514021

0 commit comments

Comments
 (0)