| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,9 @@ | |||
| 39 | 39 | ||
| 40 | 40 | ||
| 41 | 41 | /** | |
| 42 | - * Generic color selector frame, pulled from the Tool object. | ||
| 42 | + * Generic color selector frame, pulled from the Tool object. API not really | ||
| 43 | + * worked out here (what should the constructor be? how flexible?) So use with | ||
| 44 | + * caution and be ready for it to break in future releases. | ||
| 43 | 45 | */ | |
| 44 | 46 | public class ColorChooser { //extends JFrame implements DocumentListener { | |
| 45 | 47 | ||
@@ -60,14 +62,13 @@ public class ColorChooser { //extends JFrame implements DocumentListener { | |||
| 60 | 62 | JDialog window; | |
| 61 | 63 | ||
| 62 | 64 | ||
| 63 | - public String getMenuTitle() { | ||
| 64 | - return "Color Selector"; | ||
| 65 | - } | ||
| 65 | + // public String getMenuTitle() { | ||
| 66 | + // return "Color Selector"; | ||
| 67 | + // } | ||
| 66 | 68 | ||
| 67 | 69 | ||
| 68 | - public ColorChooser(Frame owner, boolean modal, | ||
| 69 | - String buttonName, ActionListener buttonListener) { | ||
| 70 | - //window = new jdi | ||
| 70 | + public ColorChooser(Frame owner, boolean modal, Color initialColor, | ||
| 71 | + String buttonName, ActionListener buttonListener) { | ||
| 71 | 72 | //super("Color Selector"); | |
| 72 | 73 | window = new JDialog(owner, "Color Selector", modal); | |
| 73 | 74 | window.getContentPane().setLayout(new BorderLayout()); | |
@@ -93,7 +94,7 @@ public ColorChooser(Frame owner, boolean modal, | |||
| 93 | 94 | box.add(sliderBox); | |
| 94 | 95 | box.add(Box.createHorizontalStrut(10)); | |
| 95 | 96 | ||
| 96 | - box.add(createColorFields()); | ||
| 97 | + box.add(createColorFields(buttonName, buttonListener)); | ||
| 97 | 98 | // System.out.println("1: " + hexField.getInsets()); | |
| 98 | 99 | ||
| 99 | 100 | box.add(Box.createHorizontalStrut(10)); | |
@@ -117,12 +118,12 @@ public ColorChooser(Frame owner, boolean modal, | |||
| 117 | 118 | window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); | |
| 118 | 119 | window.addWindowListener(new WindowAdapter() { | |
| 119 | 120 | public void windowClosing(WindowEvent e) { | |
| 120 | - hideSelector(); | ||
| 121 | + hide(); | ||
| 121 | 122 | } | |
| 122 | 123 | }); | |
| 123 | 124 | Toolkit.registerWindowCloseKeys(window.getRootPane(), new ActionListener() { | |
| 124 | 125 | public void actionPerformed(ActionEvent actionEvent) { | |
| 125 | - hideSelector(); | ||
| 126 | + hide(); | ||
| 126 | 127 | } | |
| 127 | 128 | }); | |
| 128 | 129 | ||
@@ -137,20 +138,21 @@ public void actionPerformed(ActionEvent actionEvent) { | |||
| 137 | 138 | blueField.getDocument().addDocumentListener(colorListener); | |
| 138 | 139 | hexField.getDocument().addDocumentListener(colorListener); | |
| 139 | 140 | ||
| 141 | + setColor(initialColor); | ||
| 140 | 142 | // System.out.println("4: " + hexField.getInsets()); | |
| 141 | 143 | } | |
| 142 | 144 | ||
| 143 | 145 | ||
| 144 | 146 | //hexField.setText("#FFFFFF"); | |
| 145 | 147 | ||
| 146 | 148 | ||
| 147 | - public void showSelector() { | ||
| 149 | + public void show() { | ||
| 148 | 150 | window.setVisible(true); | |
| 149 | 151 | window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); | |
| 150 | 152 | } | |
| 151 | 153 | ||
| 152 | 154 | ||
| 153 | - public void hideSelector() { | ||
| 155 | + public void hide() { | ||
| 154 | 156 | window.setVisible(false); | |
| 155 | 157 | } | |
| 156 | 158 | ||
@@ -160,6 +162,11 @@ public Color getColor() { | |||
| 160 | 162 | } | |
| 161 | 163 | ||
| 162 | 164 | ||
| 165 | + public void setColor(Color color) { | ||
| 166 | + updateRGB(color.getRGB()); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + | ||
| 163 | 170 | public String getHexColor() { | |
| 164 | 171 | return "#" + PApplet.hex(red, 2) + PApplet.hex(green, 2) + PApplet.hex(blue, 2); | |
| 165 | 172 | } | |
@@ -313,7 +320,7 @@ public void run() { | |||
| 313 | 320 | } | |
| 314 | 321 | ||
| 315 | 322 | ||
| 316 | - protected Container createColorFields() { | ||
| 323 | + protected Container createColorFields(String buttonName, ActionListener buttonListener) { | ||
| 317 | 324 | Box box = Box.createVerticalBox(); | |
| 318 | 325 | box.setAlignmentY(0); | |
| 319 | 326 | ||
@@ -403,7 +410,8 @@ public void paintComponent(Graphics g) { | |||
| 403 | 410 | row = Box.createHorizontalBox(); | |
| 404 | 411 | row.add(createFixedLabel("")); | |
| 405 | 412 | // Windows needs extra space, OS X and Linux do not | |
| 406 | - final int hexCount = Base.isWindows() ? 7 : 5; | ||
| 413 | + // Mac OS X needs 6 because #CCCCCC is quite wide | ||
| 414 | + final int hexCount = Base.isWindows() ? 7 : 6; | ||
| 407 | 415 | row.add(hexField = new NumberField(hexCount, true)); | |
| 408 | 416 | row.add(Box.createHorizontalGlue()); | |
| 409 | 417 | box.add(row); | |
@@ -421,19 +429,18 @@ public void paintComponent(Graphics g) { | |||
| 421 | 429 | ||
| 422 | 430 | // | |
| 423 | 431 | ||
| 424 | - /* | ||
| 425 | 432 | row = Box.createHorizontalBox(); | |
| 426 | 433 | if (Base.isMacOS()) { | |
| 427 | 434 | row.add(Box.createHorizontalStrut(11)); | |
| 428 | 435 | } else { | |
| 429 | 436 | row.add(createFixedLabel("")); | |
| 430 | 437 | } | |
| 431 | - JButton button = new JButton("Select"); | ||
| 438 | + JButton button = new JButton(buttonName); | ||
| 439 | + button.addActionListener(buttonListener); | ||
| 432 | 440 | //System.out.println("button: " + button.getInsets()); | |
| 433 | 441 | row.add(button); | |
| 434 | 442 | row.add(Box.createHorizontalGlue()); | |
| 435 | 443 | box.add(row); | |
| 436 | - */ | ||
| 437 | 444 | ||
| 438 | 445 | // | |
| 439 | 446 | ||
@@ -533,8 +540,7 @@ public Dimension getMaximumSize() { | |||
| 533 | 540 | ||
| 534 | 541 | public void keyPressed() { | |
| 535 | 542 | if (key == ESC) { | |
| 536 | - //ColorSelector.this.setVisible(false); | ||
| 537 | - hideSelector(); | ||
| 543 | + ColorChooser.this.hide(); | ||
| 538 | 544 | // don't quit out of processing | |
| 539 | 545 | // http://dev.processing.org/bugs/show_bug.cgi?id=1006 | |
| 540 | 546 | key = 0; | |
@@ -604,8 +610,7 @@ public Dimension getMaximumSize() { | |||
| 604 | 610 | ||
| 605 | 611 | public void keyPressed() { | |
| 606 | 612 | if (key == ESC) { | |
| 607 | - //ColorSelector.this.setVisible(false); | ||
| 608 | - hideSelector(); | ||
| 613 | + ColorChooser.this.hide(); | ||
| 609 | 614 | // don't quit out of processing | |
| 610 | 615 | // http://dev.processing.org/bugs/show_bug.cgi?id=1006 | |
| 611 | 616 | key = 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -430,8 +430,8 @@ public void actionPerformed(ActionEvent e) { | |||
| 430 | 430 | deletePreviousBox.setBounds(left, top, d.width + 10, d.height); | |
| 431 | 431 | right = Math.max(right, left + d.width); | |
| 432 | 432 | top += d.height + GUI_BETWEEN; | |
| 433 | - | ||
| 434 | - | ||
| 433 | + | ||
| 434 | + | ||
| 435 | 435 | // // [ ] Use external editor | |
| 436 | 436 | // | |
| 437 | 437 | // externalEditorBox = new JCheckBox("Use external editor"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -128,37 +128,19 @@ public ProcessResult execute(String outgoing) throws InterruptedException, IOExc | |||
| 128 | 128 | } | |
| 129 | 129 | ||
| 130 | 130 | ||
| 131 | - // static public ProcessResult execute(String exe, String[] args, File dir) | ||
| 132 | - // throws InterruptedException, IOException { | ||
| 133 | - // final StringWriter outWriter = new StringWriter(); | ||
| 134 | - // final StringWriter errWriter = new StringWriter(); | ||
| 135 | - // final long startTime = System.currentTimeMillis(); | ||
| 136 | - // | ||
| 137 | - // final String prettyCommand = exe + " " + PApplet.join(args, " "); | ||
| 138 | - // System.out.println("pretty cmd is " + prettyCommand); | ||
| 139 | - // final Process process = dir == null ? | ||
| 140 | - // Runtime.getRuntime().exec(exe, args) : | ||
| 141 | - // Runtime.getRuntime().exec(exe, args, dir); | ||
| 142 | - // ProcessRegistry.watch(process); | ||
| 143 | - // try { | ||
| 144 | - // String title = prettyCommand; | ||
| 145 | - // new StreamPump(process.getInputStream(), "out: " + title).addTarget(outWriter).start(); | ||
| 146 | - // new StreamPump(process.getErrorStream(), "err: " + title).addTarget(errWriter).start(); | ||
| 147 | - // try { | ||
| 148 | - // final int result = process.waitFor(); | ||
| 149 | - // final long time = System.currentTimeMillis() - startTime; | ||
| 150 | - // // System.err.println("ProcessHelper: <<<<< " | ||
| 151 | - // // + Thread.currentThread().getId() + " " + cmd[0] + " (" + time | ||
| 152 | - // // + "ms)"); | ||
| 153 | - // return new ProcessResult(prettyCommand, result, outWriter.toString(), | ||
| 154 | - // errWriter.toString(), time); | ||
| 155 | - // } catch (final InterruptedException e) { | ||
| 156 | - // System.err.println("Interrupted: " + prettyCommand); | ||
| 157 | - // throw e; | ||
| 158 | - // } | ||
| 159 | - // } finally { | ||
| 160 | - // process.destroy(); | ||
| 161 | - // ProcessRegistry.unwatch(process); | ||
| 162 | - // } | ||
| 163 | - // } | ||
| 131 | + static public boolean ffs(final String... cmd) { | ||
| 132 | + try { | ||
| 133 | + ProcessHelper helper = new ProcessHelper(cmd); | ||
| 134 | + ProcessResult result = helper.execute(); | ||
| 135 | + if (result.succeeded()) { | ||
| 136 | + return true; | ||
| 137 | + } | ||
| 138 | + System.out.println(result.getStdout()); | ||
| 139 | + System.err.println(result.getStderr()); | ||
| 140 | + | ||
| 141 | + } catch (Exception e) { | ||
| 142 | + e.printStackTrace(); | ||
| 143 | + } | ||
| 144 | + return false; | ||
| 145 | + } | ||
| 164 | 146 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | 24 | import processing.app.*; | |
| 25 | 25 | ||
| 26 | + import java.awt.Color; | ||
| 26 | 27 | import java.awt.datatransfer.Clipboard; | |
| 27 | 28 | import java.awt.datatransfer.StringSelection; | |
| 28 | 29 | import java.awt.event.*; | |
@@ -52,7 +53,8 @@ public String getMenuTitle() { | |||
| 52 | 53 | ||
| 53 | 54 | public void init(Editor editor) { | |
| 54 | 55 | if (selector == null) { | |
| 55 | - selector = new ColorChooser(editor, false, "Copy", new ActionListener() { | ||
| 56 | + selector = new ColorChooser(editor, false, Color.WHITE, | ||
| 57 | + "Copy", new ActionListener() { | ||
| 56 | 58 | ||
| 57 | 59 | @Override | |
| 58 | 60 | public void actionPerformed(ActionEvent e) { | |
@@ -65,6 +67,6 @@ public void actionPerformed(ActionEvent e) { | |||
| 65 | 67 | ||
| 66 | 68 | ||
| 67 | 69 | public void run() { | |
| 68 | - selector.showSelector(); | ||
| 70 | + selector.show(); | ||
| 69 | 71 | } | |
| 70 | 72 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,8 @@ | |||
| 32 | 32 | import org.apache.tools.ant.ProjectHelper; | |
| 33 | 33 | ||
| 34 | 34 | import processing.app.*; | |
| 35 | + import processing.app.exec.ProcessHelper; | ||
| 36 | + import processing.app.exec.ProcessResult; | ||
| 35 | 37 | import processing.core.*; | |
| 36 | 38 | import processing.data.XML; | |
| 37 | 39 | import processing.mode.java.preproc.*; | |
@@ -1109,32 +1111,36 @@ protected boolean exportApplication() throws IOException, SketchException { | |||
| 1109 | 1111 | return false; | |
| 1110 | 1112 | } | |
| 1111 | 1113 | ||
| 1112 | - /* | ||
| 1113 | 1114 | File folder = null; | |
| 1114 | 1115 | for (String platformName : PConstants.platformNames) { | |
| 1115 | 1116 | int platform = Base.getPlatformIndex(platformName); | |
| 1117 | + | ||
| 1118 | + // Can only embed Java on the native platform | ||
| 1119 | + boolean embedJava = (platform == PApplet.platform) && | ||
| 1120 | + Preferences.getBoolean("export.application.embed_java"); | ||
| 1121 | + | ||
| 1116 | 1122 | if (Preferences.getBoolean("export.application.platform." + platformName)) { | |
| 1117 | 1123 | if (Library.hasMultipleArch(platform, importedLibraries)) { | |
| 1118 | 1124 | // export the 32-bit version | |
| 1119 | 1125 | folder = new File(sketch.getFolder(), "application." + platformName + "32"); | |
| 1120 | - if (!exportApplication(folder, platform, 32)) { | ||
| 1126 | + if (!exportApplication(folder, platform, 32, embedJava && Base.getNativeBits() == 32)) { | ||
| 1121 | 1127 | return false; | |
| 1122 | 1128 | } | |
| 1123 | 1129 | // export the 64-bit version | |
| 1124 | 1130 | folder = new File(sketch.getFolder(), "application." + platformName + "64"); | |
| 1125 | - if (!exportApplication(folder, platform, 64)) { | ||
| 1131 | + if (!exportApplication(folder, platform, 64, embedJava && Base.getNativeBits() == 64)) { | ||
| 1126 | 1132 | return false; | |
| 1127 | 1133 | } | |
| 1128 | 1134 | } else { // just make a single one for this platform | |
| 1129 | 1135 | folder = new File(sketch.getFolder(), "application." + platformName); | |
| 1130 | - if (!exportApplication(folder, platform, 0)) { | ||
| 1136 | + if (!exportApplication(folder, platform, 0, embedJava)) { | ||
| 1131 | 1137 | return false; | |
| 1132 | 1138 | } | |
| 1133 | 1139 | } | |
| 1134 | 1140 | } | |
| 1135 | 1141 | } | |
| 1136 | - */ | ||
| 1137 | - | ||
| 1142 | + | ||
| 1143 | + /* | ||
| 1138 | 1144 | File folder = null; | |
| 1139 | 1145 | String platformName = Base.getPlatformName(); | |
| 1140 | 1146 | boolean embedJava = Preferences.getBoolean("export.application.embed_java"); | |
@@ -1158,6 +1164,7 @@ protected boolean exportApplication() throws IOException, SketchException { | |||
| 1158 | 1164 | return false; | |
| 1159 | 1165 | } | |
| 1160 | 1166 | } | |
| 1167 | + */ | ||
| 1161 | 1168 | return true; // all good | |
| 1162 | 1169 | } | |
| 1163 | 1170 | ||
@@ -1200,6 +1207,7 @@ protected boolean exportApplication(File destFolder, | |||
| 1200 | 1207 | /// also where the jar files will be placed | |
| 1201 | 1208 | File dotAppFolder = null; | |
| 1202 | 1209 | String jvmRuntime = ""; | |
| 1210 | + String jdkPath = null; | ||
| 1203 | 1211 | if (exportPlatform == PConstants.MACOSX) { | |
| 1204 | 1212 | dotAppFolder = new File(destFolder, sketch.getName() + ".app"); | |
| 1205 | 1213 | ||
@@ -1209,6 +1217,7 @@ protected boolean exportApplication(File destFolder, | |||
| 1209 | 1217 | File jdkFolder = new File(Base.getJavaHome(), "../../.."); | |
| 1210 | 1218 | String jdkFolderName = jdkFolder.getCanonicalFile().getName(); | |
| 1211 | 1219 | jvmRuntime = "<key>JVMRuntime</key>\n <string>" + jdkFolderName + "</string>"; | |
| 1220 | + jdkPath = new File(dotAppFolder, "Contents/PlugIns/" + jdkFolderName + ".jdk").getAbsolutePath(); | ||
| 1212 | 1221 | } | |
| 1213 | 1222 | ||
| 1214 | 1223 | File contentsFolder = new File(dotAppFolder, "Contents"); | |
@@ -1489,6 +1498,15 @@ protected boolean exportApplication(File destFolder, | |||
| 1489 | 1498 | pw.flush(); | |
| 1490 | 1499 | pw.close(); | |
| 1491 | 1500 | ||
| 1501 | + // attempt to code sign if the Xcode tools appear to be installed | ||
| 1502 | + if (Base.isMacOS() && new File("/usr/bin/codesign_allocate").exists()) { | ||
| 1503 | + if (embedJava) { | ||
| 1504 | + ProcessHelper.ffs("codesign", "--force", "--sign", "-", jdkPath); | ||
| 1505 | + } | ||
| 1506 | + String appPath = dotAppFolder.getAbsolutePath(); | ||
| 1507 | + ProcessHelper.ffs("codesign", "--force", "--sign", "-", appPath); | ||
| 1508 | + } | ||
| 1509 | + | ||
| 1492 | 1510 | } else if (exportPlatform == PConstants.WINDOWS) { | |
| 1493 | 1511 | File buildFile = new File(destFolder, "launch4j-build.xml"); | |
| 1494 | 1512 | File configFile = new File(destFolder, "launch4j-config.xml"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments