mirror of
https://github.com/processing/processing4.git
synced 2026-02-16 11:55:38 +01:00
updated for processing 2.1.2
This commit is contained in:
@@ -251,31 +251,33 @@ public class JavaEditor extends Editor {
|
||||
toolbar.deactivate(JavaToolbar.EXPORT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// JPanel presentColorPanel;
|
||||
// JTextField presentColorPanel;
|
||||
|
||||
protected boolean exportApplicationPrompt() throws IOException, SketchException {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
panel.add(Box.createVerticalStrut(6));
|
||||
|
||||
//Box panel = Box.createVerticalBox();
|
||||
|
||||
//Box labelBox = Box.createHorizontalBox();
|
||||
// Box panel = Box.createVerticalBox();
|
||||
// Box labelBox = Box.createHorizontalBox();
|
||||
// String msg = "<html>Click Export to Application to create a standalone, " +
|
||||
// "double-clickable application for the selected plaforms.";
|
||||
|
||||
// String msg = "Export to Application creates a standalone, \n" +
|
||||
// "double-clickable application for the selected plaforms.";
|
||||
String line1 = Language.text("export.description.line1");
|
||||
String line2 = Language.text("export.description.line2");
|
||||
//String line2 = "standalone application for the current plaform.";
|
||||
JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
|
||||
JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
|
||||
label1.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
label2.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
// label1.setAlignmentX();
|
||||
// label2.setAlignmentX(0);
|
||||
panel.add(label1);
|
||||
panel.add(label2);
|
||||
int wide = label2.getPreferredSize().width;
|
||||
// The longer line is different between Windows and OS X.
|
||||
// int wide = Math.max(label1.getPreferredSize().width,
|
||||
// label2.getPreferredSize().width);
|
||||
panel.add(Box.createVerticalStrut(12));
|
||||
|
||||
final JCheckBox windowsButton = new JCheckBox("Windows");
|
||||
@@ -288,7 +290,6 @@ public class JavaEditor extends Editor {
|
||||
});
|
||||
|
||||
final JCheckBox macosxButton = new JCheckBox("Mac OS X");
|
||||
//macosxButton.setMnemonic(KeyEvent.VK_M);
|
||||
macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
|
||||
macosxButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
@@ -315,14 +316,15 @@ public class JavaEditor extends Editor {
|
||||
platformPanel.setBorder(new TitledBorder(Language.text("export.platforms")));
|
||||
//Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height);
|
||||
//platformPanel.setMaximumSize(goodIdea);
|
||||
wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
// wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
panel.add(platformPanel);
|
||||
|
||||
// Box indentPanel = Box.createHorizontalBox();
|
||||
// indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
|
||||
int divWidth = platformPanel.getPreferredSize().width;
|
||||
|
||||
//int indent = new JCheckBox().getPreferredSize().width;
|
||||
int indent = 0;
|
||||
|
||||
final JCheckBox showStopButton = new JCheckBox(Language.text("export.options.show_stop_button"));
|
||||
//showStopButton.setMnemonic(KeyEvent.VK_S);
|
||||
showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
|
||||
showStopButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
@@ -330,9 +332,7 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
});
|
||||
showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
|
||||
showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
|
||||
// indentPanel.add(showStopButton);
|
||||
// indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
showStopButton.setBorder(new EmptyBorder(3, 13 + indent, 6, 13));
|
||||
|
||||
final JCheckBox fullScreenButton = new JCheckBox(Language.text("export.options.fullscreen"));
|
||||
//fullscreenButton.setMnemonic(KeyEvent.VK_F);
|
||||
@@ -346,63 +346,200 @@ public class JavaEditor extends Editor {
|
||||
});
|
||||
fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
|
||||
JPanel optionPanel = new JPanel();
|
||||
optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
|
||||
optionPanel.add(fullScreenButton);
|
||||
optionPanel.add(showStopButton);
|
||||
// optionPanel.add(indentPanel);
|
||||
optionPanel.setBorder(new TitledBorder(Language.text("export.options")));
|
||||
wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
//goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
|
||||
optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
//optionPanel.setMaximumSize(goodIdea);
|
||||
panel.add(optionPanel);
|
||||
JPanel presentPanel = new JPanel();
|
||||
presentPanel.setLayout(new BoxLayout(presentPanel, BoxLayout.Y_AXIS));
|
||||
Box fullScreenBox = Box.createHorizontalBox();
|
||||
fullScreenBox.add(fullScreenButton);
|
||||
|
||||
/*
|
||||
//run.present.stop.color
|
||||
// presentColorPanel = new JTextField();
|
||||
// presentColorPanel.setFocusable(false);
|
||||
// presentColorPanel.setEnabled(false);
|
||||
presentColorPanel = new JPanel() {
|
||||
public void paintComponent(Graphics g) {
|
||||
g.setColor(Preferences.getColor("run.present.bgcolor"));
|
||||
Dimension size = getSize();
|
||||
g.fillRect(0, 0, size.width, size.height);
|
||||
}
|
||||
};
|
||||
presentColorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
||||
// presentColorPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
presentColorPanel.setMaximumSize(new Dimension(30, 20));
|
||||
fullScreenBox.add(presentColorPanel);
|
||||
*/
|
||||
fullScreenBox.add(new ColorPreference("run.present.bgcolor"));
|
||||
//presentPanel.add(fullScreenButton);
|
||||
fullScreenBox.add(Box.createHorizontalStrut(10));
|
||||
fullScreenBox.add(Box.createHorizontalGlue());
|
||||
|
||||
Dimension good;
|
||||
//label1, label2, platformPanel, optionPanel
|
||||
good = new Dimension(wide, label1.getPreferredSize().height);
|
||||
label1.setMaximumSize(good);
|
||||
good = new Dimension(wide, label2.getPreferredSize().height);
|
||||
label2.setMaximumSize(good);
|
||||
good = new Dimension(wide, platformPanel.getPreferredSize().height);
|
||||
platformPanel.setMaximumSize(good);
|
||||
good = new Dimension(wide, optionPanel.getPreferredSize().height);
|
||||
optionPanel.setMaximumSize(good);
|
||||
|
||||
// JPanel actionPanel = new JPanel();
|
||||
// optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
|
||||
// optionPanel.add(Box.createHorizontalGlue());
|
||||
|
||||
// final JDialog frame = new JDialog(editor, "Export to Application");
|
||||
|
||||
// JButton cancelButton = new JButton("Cancel");
|
||||
// cancelButton.addActionListener(new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// frame.dispose();
|
||||
// return false;
|
||||
presentPanel.add(fullScreenBox);
|
||||
|
||||
// presentColorPanel.addMouseListener(new MouseAdapter() {
|
||||
// public void mousePressed(MouseEvent e) {
|
||||
// new ColorListener("run.present.bgcolor");
|
||||
// }
|
||||
// });
|
||||
|
||||
// Add the buttons in platform-specific order
|
||||
// if (PApplet.platform == PConstants.MACOSX) {
|
||||
// optionPanel.add(cancelButton);
|
||||
// optionPanel.add(exportButton);
|
||||
// } else {
|
||||
// optionPanel.add(exportButton);
|
||||
// optionPanel.add(cancelButton);
|
||||
// }
|
||||
Box showStopBox = Box.createHorizontalBox();
|
||||
showStopBox.add(showStopButton);
|
||||
showStopBox.add(new ColorPreference("run.present.stop.color"));
|
||||
showStopBox.add(Box.createHorizontalStrut(10));
|
||||
showStopBox.add(Box.createHorizontalGlue());
|
||||
presentPanel.add(showStopBox);
|
||||
|
||||
//presentPanel.add(showStopButton);
|
||||
// presentPanel.add(Box.createHorizontalStrut(10));
|
||||
// presentPanel.add(Box.createHorizontalGlue());
|
||||
presentPanel.setBorder(new TitledBorder("Full Screen"));
|
||||
// wide = Math.max(wide, platformPanel.getPreferredSize().width);
|
||||
presentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
panel.add(presentPanel);
|
||||
|
||||
// Dimension good;
|
||||
// good = new Dimension(wide, label1.getPreferredSize().height);
|
||||
// label1.setMaximumSize(good);
|
||||
// good = new Dimension(wide, label2.getPreferredSize().height);
|
||||
// label2.setMaximumSize(good);
|
||||
// good = new Dimension(wide, presentPanel.getPreferredSize().height);
|
||||
|
||||
//
|
||||
|
||||
JPanel embedPanel = new JPanel();
|
||||
embedPanel.setLayout(new BoxLayout(embedPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
String platformName = null;
|
||||
if (Base.isMacOS()) {
|
||||
platformName = "Mac OS X";
|
||||
} else if (Base.isWindows()) {
|
||||
platformName = "Windows (" + Base.getNativeBits() + "-bit)";
|
||||
} else if (Base.isLinux()) {
|
||||
platformName = "Linux (" + Base.getNativeBits() + "-bit)";
|
||||
}
|
||||
|
||||
boolean embed = Preferences.getBoolean("export.application.embed_java");
|
||||
final String embedWarning =
|
||||
"<html><div width=\"" + divWidth + "\"><font size=\"2\">" +
|
||||
// "<html><body><font size=2>" +
|
||||
"Embedding Java will make the " + platformName + " application " +
|
||||
"larger, but it will be far more likely to work. " +
|
||||
"Users on other platforms will need to <a href=\"\">install Java 7</a>.";
|
||||
final String nopeWarning =
|
||||
"<html><div width=\"" + divWidth + "\"><font size=\"2\">" +
|
||||
// "<html><body><font size=2>" +
|
||||
"Users on all platforms will have to install the latest " +
|
||||
"version of Java 7 from <a href=\"\">http://java.com/download</a>. " +
|
||||
"<br/> ";
|
||||
//"from <a href=\"http://java.com/download\">java.com/download</a>.";
|
||||
final JLabel warningLabel = new JLabel(embed ? embedWarning : nopeWarning);
|
||||
warningLabel.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent event) {
|
||||
Base.openURL("http://java.com/download");
|
||||
}
|
||||
});
|
||||
warningLabel.setBorder(new EmptyBorder(3, 13 + indent, 3, 13));
|
||||
|
||||
final JCheckBox embedJavaButton =
|
||||
new JCheckBox("Embed Java for " + platformName);
|
||||
embedJavaButton.setSelected(embed);
|
||||
embedJavaButton.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
boolean selected = embedJavaButton.isSelected();
|
||||
Preferences.setBoolean("export.application.embed_java", selected);
|
||||
if (selected) {
|
||||
warningLabel.setText(embedWarning);
|
||||
} else {
|
||||
warningLabel.setText(nopeWarning);
|
||||
}
|
||||
}
|
||||
});
|
||||
embedJavaButton.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
|
||||
embedPanel.add(embedJavaButton);
|
||||
embedPanel.add(warningLabel);
|
||||
embedPanel.setBorder(new TitledBorder("Embed Java"));
|
||||
panel.add(embedPanel);
|
||||
|
||||
//
|
||||
|
||||
if (Base.isMacOS()) {
|
||||
JPanel signPanel = new JPanel();
|
||||
signPanel.setLayout(new BoxLayout(signPanel, BoxLayout.Y_AXIS));
|
||||
signPanel.setBorder(new TitledBorder("Code Signing"));
|
||||
|
||||
// gatekeeper: http://support.apple.com/kb/ht5290
|
||||
// for developers: https://developer.apple.com/developer-id/
|
||||
String thePain =
|
||||
//"<html><body><font size=2>" +
|
||||
"In recent versions of OS X, Apple has introduced the \u201CGatekeeper\u201D system, " +
|
||||
"which makes it more difficult to run applications like those exported from Processing. ";
|
||||
|
||||
if (new File("/usr/bin/codesign_allocate").exists()) {
|
||||
thePain +=
|
||||
"This application will be \u201Cself-signed\u201D which means that Finder may report that the " +
|
||||
"application is from an \u201Cunidentified developer\u201D. If the application will not " +
|
||||
"run, try right-clicking the app and selecting Open from the pop-up menu. Or you can visit " +
|
||||
"System Preferences \u2192 Security & Privacy and select Allow apps downloaded from: anywhere. ";
|
||||
} else {
|
||||
thePain +=
|
||||
"Gatekeeper requires applications to be \u201Csigned\u201D, or they will be reported as damaged. " +
|
||||
"To prevent this message, install Xcode (and the Command Line Tools) from the App Store, or visit " +
|
||||
"System Preferences \u2192 Security & Privacy and select Allow apps downloaded from: anywhere. ";
|
||||
}
|
||||
thePain +=
|
||||
"To avoid the messages entirely, manually code sign your app. " +
|
||||
"For more information: <a href=\"\">https://developer.apple.com/developer-id/</a>";
|
||||
|
||||
// xattr -d com.apple.quarantine thesketch.app
|
||||
|
||||
//signPanel.add(new JLabel(thePain));
|
||||
//JEditorPane area = new JEditorPane("text/html", thePain);
|
||||
//JTextPane area = new JEditorPane("text/html", thePain);
|
||||
|
||||
// JTextArea area = new JTextArea(thePain);
|
||||
// area.setBackground(null);
|
||||
// area.setFont(new Font("Dialog", Font.PLAIN, 10));
|
||||
// area.setLineWrap(true);
|
||||
// area.setWrapStyleWord(true);
|
||||
// Are you f-king serious, Java API developers?
|
||||
JLabel area = new JLabel("<html><div width=\"" + divWidth + "\"><font size=\"2\">" + thePain + "</div></html>");
|
||||
|
||||
area.setBorder(new EmptyBorder(3, 13, 3, 13));
|
||||
// area.setPreferredSize(new Dimension(embedPanel.getPreferredSize().width, 100));
|
||||
// area.setPreferredSize(new Dimension(300, 200));
|
||||
signPanel.add(area);
|
||||
// signPanel.add(Box.createHorizontalGlue());
|
||||
signPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
|
||||
area.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent event) {
|
||||
Base.openURL("https://developer.apple.com/developer-id/");
|
||||
}
|
||||
});
|
||||
|
||||
panel.add(signPanel);
|
||||
}
|
||||
//System.out.println(panel.getPreferredSize());
|
||||
// panel.setMinimumSize(new Dimension(316, 461));
|
||||
// panel.setPreferredSize(new Dimension(316, 461));
|
||||
// panel.setMaximumSize(new Dimension(316, 461));
|
||||
|
||||
//
|
||||
|
||||
String[] options = { Language.text("prompt.export"), Language.text("prompt.cancel") };
|
||||
|
||||
final JOptionPane optionPane = new JOptionPane(panel,
|
||||
JOptionPane.PLAIN_MESSAGE,
|
||||
//JOptionPane.QUESTION_MESSAGE,
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
|
||||
|
||||
final JDialog dialog = new JDialog(this, Language.text("export"), true);
|
||||
dialog.setContentPane(optionPane);
|
||||
|
||||
// System.out.println(optionPane.getLayout());
|
||||
|
||||
optionPane.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
String prop = e.getPropertyName();
|
||||
@@ -410,20 +547,24 @@ public class JavaEditor extends Editor {
|
||||
if (dialog.isVisible() &&
|
||||
(e.getSource() == optionPane) &&
|
||||
(prop.equals(JOptionPane.VALUE_PROPERTY))) {
|
||||
//If you were going to check something
|
||||
//before closing the window, you'd do
|
||||
//it here.
|
||||
// If you were going to check something before
|
||||
// closing the window, you'd do it here.
|
||||
dialog.setVisible(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.pack();
|
||||
// System.out.println("after pack: " + panel.getPreferredSize());
|
||||
// dialog.setSize(optionPane.getPreferredSize());
|
||||
dialog.setResizable(false);
|
||||
|
||||
|
||||
// Center the window in the middle of the editor
|
||||
Rectangle bounds = getBounds();
|
||||
dialog.setLocation(bounds.x + (bounds.width - dialog.getSize().width) / 2,
|
||||
bounds.y + (bounds.height - dialog.getSize().height) / 2);
|
||||
dialog.setVisible(true);
|
||||
|
||||
//System.out.println(panel.getSize());
|
||||
|
||||
Object value = optionPane.getValue();
|
||||
if (value.equals(options[0])) {
|
||||
@@ -435,7 +576,90 @@ public class JavaEditor extends Editor {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Color bgcolor = Preferences.getColor("run.present.bgcolor");
|
||||
final ColorChooser c = new ColorChooser(JavaEditor.this, true, bgcolor,
|
||||
"Select", new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Preferences.setColor("run.present.bgcolor", c.getColor());
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
/*
|
||||
class ColorListener implements ActionListener {
|
||||
ColorChooser chooser;
|
||||
String prefName;
|
||||
|
||||
public ColorListener(String prefName) {
|
||||
this.prefName = prefName;
|
||||
Color color = Preferences.getColor(prefName);
|
||||
chooser = new ColorChooser(JavaEditor.this, true, color, "Select", this);
|
||||
chooser.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Color color = chooser.getColor();
|
||||
Preferences.setColor(prefName, color);
|
||||
// presentColorPanel.setBackground(color);
|
||||
presentColorPanel.repaint();
|
||||
chooser.hide();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
class ColorPreference extends JPanel implements ActionListener {
|
||||
ColorChooser chooser;
|
||||
String prefName;
|
||||
|
||||
public ColorPreference(String pref) {
|
||||
prefName = pref;
|
||||
|
||||
setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
||||
setPreferredSize(new Dimension(30, 20));
|
||||
setMaximumSize(new Dimension(30, 20));
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
Color color = Preferences.getColor(prefName);
|
||||
chooser = new ColorChooser(JavaEditor.this, true, color, "Select", ColorPreference.this);
|
||||
chooser.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
g.setColor(Preferences.getColor(prefName));
|
||||
Dimension size = getSize();
|
||||
g.fillRect(0, 0, size.width, size.height);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Color color = chooser.getColor();
|
||||
Preferences.setColor(prefName, color);
|
||||
//presentColorPanel.repaint();
|
||||
repaint();
|
||||
chooser.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// protected void selectColor(String prefName) {
|
||||
// Color color = Preferences.getColor(prefName);
|
||||
// final ColorChooser chooser = new ColorChooser(JavaEditor.this, true, color,
|
||||
// "Select", new ActionListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// Preferences.setColor(prefName, c.getColor());
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Checks to see if the sketch has been modified, and if so,
|
||||
* asks the user to save the sketch or cancel the export.
|
||||
|
||||
Reference in New Issue
Block a user