From f21a192d78d47fb74dfec7bf5cf8143914c90766 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Mon, 12 May 2014 17:38:15 -0400 Subject: [PATCH] fix code signing, color checking, other misc for export --- app/src/processing/app/ColorChooser.java | 47 +-- app/src/processing/app/Preferences.java | 4 +- .../processing/app/exec/ProcessHelper.java | 48 +-- .../processing/app/tools/ColorSelector.java | 6 +- app/src/processing/mode/java/JavaBuild.java | 30 +- app/src/processing/mode/java/JavaEditor.java | 305 +++++++++++++++--- todo.txt | 26 +- 7 files changed, 354 insertions(+), 112 deletions(-) diff --git a/app/src/processing/app/ColorChooser.java b/app/src/processing/app/ColorChooser.java index 4d191bb02..b4a6ccac8 100644 --- a/app/src/processing/app/ColorChooser.java +++ b/app/src/processing/app/ColorChooser.java @@ -39,7 +39,9 @@ import javax.swing.text.*; /** - * Generic color selector frame, pulled from the Tool object. + * Generic color selector frame, pulled from the Tool object. API not really + * worked out here (what should the constructor be? how flexible?) So use with + * caution and be ready for it to break in future releases. */ public class ColorChooser { //extends JFrame implements DocumentListener { @@ -60,14 +62,13 @@ public class ColorChooser { //extends JFrame implements DocumentListener { JDialog window; - public String getMenuTitle() { - return "Color Selector"; - } +// public String getMenuTitle() { +// return "Color Selector"; +// } - public ColorChooser(Frame owner, boolean modal, - String buttonName, ActionListener buttonListener) { - //window = new jdi + public ColorChooser(Frame owner, boolean modal, Color initialColor, + String buttonName, ActionListener buttonListener) { //super("Color Selector"); window = new JDialog(owner, "Color Selector", modal); window.getContentPane().setLayout(new BorderLayout()); @@ -93,7 +94,7 @@ public class ColorChooser { //extends JFrame implements DocumentListener { box.add(sliderBox); box.add(Box.createHorizontalStrut(10)); - box.add(createColorFields()); + box.add(createColorFields(buttonName, buttonListener)); // System.out.println("1: " + hexField.getInsets()); box.add(Box.createHorizontalStrut(10)); @@ -117,12 +118,12 @@ public class ColorChooser { //extends JFrame implements DocumentListener { window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); window.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { - hideSelector(); + hide(); } }); Toolkit.registerWindowCloseKeys(window.getRootPane(), new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { - hideSelector(); + hide(); } }); @@ -137,6 +138,7 @@ public class ColorChooser { //extends JFrame implements DocumentListener { blueField.getDocument().addDocumentListener(colorListener); hexField.getDocument().addDocumentListener(colorListener); + setColor(initialColor); // System.out.println("4: " + hexField.getInsets()); } @@ -144,13 +146,13 @@ public class ColorChooser { //extends JFrame implements DocumentListener { //hexField.setText("#FFFFFF"); - public void showSelector() { + public void show() { window.setVisible(true); window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } - public void hideSelector() { + public void hide() { window.setVisible(false); } @@ -160,6 +162,11 @@ public class ColorChooser { //extends JFrame implements DocumentListener { } + public void setColor(Color color) { + updateRGB(color.getRGB()); + } + + public String getHexColor() { return "#" + PApplet.hex(red, 2) + PApplet.hex(green, 2) + PApplet.hex(blue, 2); } @@ -313,7 +320,7 @@ public class ColorChooser { //extends JFrame implements DocumentListener { } - protected Container createColorFields() { + protected Container createColorFields(String buttonName, ActionListener buttonListener) { Box box = Box.createVerticalBox(); box.setAlignmentY(0); @@ -403,7 +410,8 @@ public class ColorChooser { //extends JFrame implements DocumentListener { row = Box.createHorizontalBox(); row.add(createFixedLabel("")); // Windows needs extra space, OS X and Linux do not - final int hexCount = Base.isWindows() ? 7 : 5; + // Mac OS X needs 6 because #CCCCCC is quite wide + final int hexCount = Base.isWindows() ? 7 : 6; row.add(hexField = new NumberField(hexCount, true)); row.add(Box.createHorizontalGlue()); box.add(row); @@ -421,19 +429,18 @@ public class ColorChooser { //extends JFrame implements DocumentListener { // - /* row = Box.createHorizontalBox(); if (Base.isMacOS()) { row.add(Box.createHorizontalStrut(11)); } else { row.add(createFixedLabel("")); } - JButton button = new JButton("Select"); + JButton button = new JButton(buttonName); + button.addActionListener(buttonListener); //System.out.println("button: " + button.getInsets()); row.add(button); row.add(Box.createHorizontalGlue()); box.add(row); - */ // @@ -533,8 +540,7 @@ public class ColorChooser { //extends JFrame implements DocumentListener { public void keyPressed() { if (key == ESC) { - //ColorSelector.this.setVisible(false); - hideSelector(); + ColorChooser.this.hide(); // don't quit out of processing // http://dev.processing.org/bugs/show_bug.cgi?id=1006 key = 0; @@ -604,8 +610,7 @@ public class ColorChooser { //extends JFrame implements DocumentListener { public void keyPressed() { if (key == ESC) { - //ColorSelector.this.setVisible(false); - hideSelector(); + ColorChooser.this.hide(); // don't quit out of processing // http://dev.processing.org/bugs/show_bug.cgi?id=1006 key = 0; diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 8c5d6dcde..68f94d44b 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -430,8 +430,8 @@ public class Preferences { deletePreviousBox.setBounds(left, top, d.width + 10, d.height); right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN; - - + + // // [ ] Use external editor // // externalEditorBox = new JCheckBox("Use external editor"); diff --git a/app/src/processing/app/exec/ProcessHelper.java b/app/src/processing/app/exec/ProcessHelper.java index 66e9d331f..0bbd2aa97 100644 --- a/app/src/processing/app/exec/ProcessHelper.java +++ b/app/src/processing/app/exec/ProcessHelper.java @@ -128,37 +128,19 @@ public class ProcessHelper { } -// static public ProcessResult execute(String exe, String[] args, File dir) -// throws InterruptedException, IOException { -// final StringWriter outWriter = new StringWriter(); -// final StringWriter errWriter = new StringWriter(); -// final long startTime = System.currentTimeMillis(); -// -// final String prettyCommand = exe + " " + PApplet.join(args, " "); -// System.out.println("pretty cmd is " + prettyCommand); -// final Process process = dir == null ? -// Runtime.getRuntime().exec(exe, args) : -// Runtime.getRuntime().exec(exe, args, dir); -// ProcessRegistry.watch(process); -// try { -// String title = prettyCommand; -// new StreamPump(process.getInputStream(), "out: " + title).addTarget(outWriter).start(); -// new StreamPump(process.getErrorStream(), "err: " + title).addTarget(errWriter).start(); -// try { -// final int result = process.waitFor(); -// final long time = System.currentTimeMillis() - startTime; -// // System.err.println("ProcessHelper: <<<<< " -// // + Thread.currentThread().getId() + " " + cmd[0] + " (" + time -// // + "ms)"); -// return new ProcessResult(prettyCommand, result, outWriter.toString(), -// errWriter.toString(), time); -// } catch (final InterruptedException e) { -// System.err.println("Interrupted: " + prettyCommand); -// throw e; -// } -// } finally { -// process.destroy(); -// ProcessRegistry.unwatch(process); -// } -// } + static public boolean ffs(final String... cmd) { + try { + ProcessHelper helper = new ProcessHelper(cmd); + ProcessResult result = helper.execute(); + if (result.succeeded()) { + return true; + } + System.out.println(result.getStdout()); + System.err.println(result.getStderr()); + + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } } \ No newline at end of file diff --git a/app/src/processing/app/tools/ColorSelector.java b/app/src/processing/app/tools/ColorSelector.java index 600854cfc..68bc92b68 100644 --- a/app/src/processing/app/tools/ColorSelector.java +++ b/app/src/processing/app/tools/ColorSelector.java @@ -23,6 +23,7 @@ package processing.app.tools; import processing.app.*; +import java.awt.Color; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.awt.event.*; @@ -52,7 +53,8 @@ public class ColorSelector implements Tool { public void init(Editor editor) { if (selector == null) { - selector = new ColorChooser(editor, false, "Copy", new ActionListener() { + selector = new ColorChooser(editor, false, Color.WHITE, + "Copy", new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -65,6 +67,6 @@ public class ColorSelector implements Tool { public void run() { - selector.showSelector(); + selector.show(); } } diff --git a/app/src/processing/mode/java/JavaBuild.java b/app/src/processing/mode/java/JavaBuild.java index d515e611f..b9c3877da 100644 --- a/app/src/processing/mode/java/JavaBuild.java +++ b/app/src/processing/mode/java/JavaBuild.java @@ -32,6 +32,8 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectHelper; import processing.app.*; +import processing.app.exec.ProcessHelper; +import processing.app.exec.ProcessResult; import processing.core.*; import processing.data.XML; import processing.mode.java.preproc.*; @@ -1109,32 +1111,36 @@ public class JavaBuild { return false; } - /* File folder = null; for (String platformName : PConstants.platformNames) { int platform = Base.getPlatformIndex(platformName); + + // Can only embed Java on the native platform + boolean embedJava = (platform == PApplet.platform) && + Preferences.getBoolean("export.application.embed_java"); + if (Preferences.getBoolean("export.application.platform." + platformName)) { if (Library.hasMultipleArch(platform, importedLibraries)) { // export the 32-bit version folder = new File(sketch.getFolder(), "application." + platformName + "32"); - if (!exportApplication(folder, platform, 32)) { + if (!exportApplication(folder, platform, 32, embedJava && Base.getNativeBits() == 32)) { return false; } // export the 64-bit version folder = new File(sketch.getFolder(), "application." + platformName + "64"); - if (!exportApplication(folder, platform, 64)) { + if (!exportApplication(folder, platform, 64, embedJava && Base.getNativeBits() == 64)) { return false; } } else { // just make a single one for this platform folder = new File(sketch.getFolder(), "application." + platformName); - if (!exportApplication(folder, platform, 0)) { + if (!exportApplication(folder, platform, 0, embedJava)) { return false; } } } } - */ - + + /* File folder = null; String platformName = Base.getPlatformName(); boolean embedJava = Preferences.getBoolean("export.application.embed_java"); @@ -1158,6 +1164,7 @@ public class JavaBuild { return false; } } + */ return true; // all good } @@ -1200,6 +1207,7 @@ public class JavaBuild { /// also where the jar files will be placed File dotAppFolder = null; String jvmRuntime = ""; + String jdkPath = null; if (exportPlatform == PConstants.MACOSX) { dotAppFolder = new File(destFolder, sketch.getName() + ".app"); @@ -1209,6 +1217,7 @@ public class JavaBuild { File jdkFolder = new File(Base.getJavaHome(), "../../.."); String jdkFolderName = jdkFolder.getCanonicalFile().getName(); jvmRuntime = "JVMRuntime\n " + jdkFolderName + ""; + jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName + ".jdk").getAbsolutePath(); } File contentsFolder = new File(dotAppFolder, "Contents"); @@ -1489,6 +1498,15 @@ public class JavaBuild { pw.flush(); pw.close(); + // attempt to code sign if the Xcode tools appear to be installed + if (Base.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) { + if (embedJava) { + ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath); + } + String appPath = dotAppFolder.getAbsolutePath(); + ProcessHelper.ffs("codesign", "--force", "--sign", "-", appPath); + } + } else if (exportPlatform == PConstants.WINDOWS) { File buildFile = new File(destFolder, "launch4j-build.xml"); File configFile = new File(destFolder, "launch4j-config.xml"); diff --git a/app/src/processing/mode/java/JavaEditor.java b/app/src/processing/mode/java/JavaEditor.java index 676db1272..681bde70f 100644 --- a/app/src/processing/mode/java/JavaEditor.java +++ b/app/src/processing/mode/java/JavaEditor.java @@ -251,15 +251,18 @@ 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)); String line1 = "Export to Application creates double-clickable,"; - //String line2 = "standalone applications for the selected plaforms."; - String line2 = "standalone application for the current plaform."; + String line2 = "standalone applications for the selected plaforms."; + //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); @@ -267,11 +270,10 @@ public class JavaEditor extends Editor { panel.add(label1); panel.add(label2); // The longer line is different between Windows and OS X. - int wide = Math.max(label1.getPreferredSize().width, - label2.getPreferredSize().width); +// int wide = Math.max(label1.getPreferredSize().width, +// label2.getPreferredSize().width); panel.add(Box.createVerticalStrut(12)); - /* final JCheckBox windowsButton = new JCheckBox("Windows"); //windowsButton.setMnemonic(KeyEvent.VK_W); windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows")); @@ -282,7 +284,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) { @@ -309,11 +310,13 @@ public class JavaEditor extends Editor { platformPanel.setBorder(new TitledBorder("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); - */ + int divWidth = platformPanel.getPreferredSize().width; + // + //int indent = new JCheckBox().getPreferredSize().width; int indent = 0; @@ -338,13 +341,101 @@ public class JavaEditor extends Editor { }); fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13)); - boolean embed = Preferences.getBoolean("export.application.embed_java"); - final String embedWarning = "Embedding Java makes larger applications"; - final String nopeWarning = "Users will have to install the latest Java 7"; - final JLabel warningLabel = new JLabel(embed ? embedWarning : nopeWarning); - warningLabel.setBorder(new EmptyBorder(3, 13 + indent, 3, 13)); + JPanel presentPanel = new JPanel(); + presentPanel.setLayout(new BoxLayout(presentPanel, BoxLayout.Y_AXIS)); + Box fullScreenBox = Box.createHorizontalBox(); + fullScreenBox.add(fullScreenButton); - final JCheckBox embedJavaButton = new JCheckBox("Embed Java"); + /* + //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()); + + presentPanel.add(fullScreenBox); + +// presentColorPanel.addMouseListener(new MouseAdapter() { +// public void mousePressed(MouseEvent e) { +// new ColorListener("run.present.bgcolor"); +// } +// }); + + 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 = + "
" + +// "" + + "Embedding Java will make the " + platformName + " application " + + "larger, but it will be far more likely to work. " + + "Users on other platforms will need to install Java 7."; + final String nopeWarning = + "
" + +// "" + + "Users on all platforms will have to install the latest " + + "version of Java 7 from http://java.com/download. " + + "
 "; + //"from java.com/download."; + 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) { @@ -359,27 +450,76 @@ public class JavaEditor extends Editor { }); embedJavaButton.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(embedJavaButton); - optionPanel.add(warningLabel); - optionPanel.setBorder(new TitledBorder("Options")); -// wide = Math.max(wide, platformPanel.getPreferredSize().width); - optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - panel.add(optionPanel); - - 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); + 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 = + //"" + + "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: https://developer.apple.com/developer-id/"; + + // 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("
" + thePain + "
"); + + 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 = { "Export", "Cancel" }; final JOptionPane optionPane = new JOptionPane(panel, @@ -391,7 +531,8 @@ public class JavaEditor extends Editor { final JDialog dialog = new JDialog(this, "Export Application", true); dialog.setContentPane(optionPane); - +// System.out.println(optionPane.getLayout()); + optionPane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { String prop = e.getPropertyName(); @@ -406,12 +547,17 @@ public class JavaEditor extends Editor { } }); 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])) { @@ -423,7 +569,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 mousePressed(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. diff --git a/todo.txt b/todo.txt index 35066da9c..8e3c87fa7 100644 --- a/todo.txt +++ b/todo.txt @@ -77,23 +77,29 @@ X make sure Windows export includes library DLLs X remove build/windows/export from repo o make sure launch4j export isn't printing to console unless trouble X OS X is doing this, though Windows is pushing some stuff through -_ exported apps reporting as "damaged" on OS X -_ https://github.com/processing/processing/issues/2095 -_ implement a call to codesign, and a message box re: installing Xcode -_ bring back multi-platform export? -_ OS X applications can only be exported from OS X -_ embed Java only works for the current platform +X bring back multi-platform export? +X embed Java only works for the current platform +o OS X applications can only be exported from OS X +X actually it's just the embedding, which is a problem on any platform +X add all sorts of language to the export dialog +X make available the background colors for present mode, stop button color +X isolate color chooser into a simpler/smaller class outside tools +X then can also use from inside processing applications as well +X http://code.google.com/p/processing/issues/detail?id=30 +X https://github.com/processing/processing/issues/69 +X exported apps reporting as "damaged" on OS X +X https://github.com/processing/processing/issues/2095 +X implement a call to codesign, and a message box re: installing Xcode +_ possible to open a sketch multiple times +_ by double-clicking one of its files instead of the main pde file +_ https://github.com/processing/processing/issues/2506 _ closing the color selector makes things freeze _ https://github.com/processing/processing/issues/2381 medium -_ make available the background colors for present mode, stop button color -_ isolate color chooser into a simpler/smaller class outside tools -_ then can also use from inside processing applications as well -_ http://code.google.com/p/processing/issues/detail?id=30 _ check on why 2x core.jar inside the Java folder _ maybe OS X Java can't look in subfolders? (just auto-adds things) _ display "1" is not correct in 2.1.2