From d9d21cc417919ee6e8e6cfaff9485f9efea0e1c3 Mon Sep 17 00:00:00 2001 From: benfry Date: Sat, 20 Oct 2012 22:23:09 +0000 Subject: [PATCH] more work on command line.. adding tool for OS X install --- app/src/processing/app/Editor.java | 9 ++- .../app/tools/InstallCommander.java | 71 +++++++++++++++++++ app/src/processing/mode/java/Commander.java | 2 + build/build.xml | 1 - 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 app/src/processing/app/tools/InstallCommander.java diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 588675d47..a34296421 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1017,7 +1017,14 @@ public abstract class Editor extends JFrame implements RunnerListener { addToolMenuItem(menu, "processing.app.tools.CreateFont"); addToolMenuItem(menu, "processing.app.tools.ColorSelector"); addToolMenuItem(menu, "processing.app.tools.Archiver"); - addToolMenuItem(menu, "processing.app.tools.FixEncoding"); + + if (Base.isMacOS()) { + addToolMenuItem(menu, "processing.app.tools.InstallCommander"); + } + + // I think this is no longer needed... It was Mac OS X specific, + // and they gave up on MacRoman a long time ago. +// addToolMenuItem(menu, "processing.app.tools.FixEncoding"); if (Base.DEBUG) { addToolMenuItem(menu, "processing.app.tools.ExportExamples"); diff --git a/app/src/processing/app/tools/InstallCommander.java b/app/src/processing/app/tools/InstallCommander.java new file mode 100644 index 000000000..ad06864db --- /dev/null +++ b/app/src/processing/app/tools/InstallCommander.java @@ -0,0 +1,71 @@ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + +/* + Part of the Processing project - http://processing.org + + Copyright (c) 2012 The Processing Foundation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 2. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package processing.app.tools; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; + +import processing.app.Base; +import processing.app.Editor; +import processing.core.PApplet; + + +public class InstallCommander implements Tool { + Editor editor; + + + public String getMenuTitle() { + return "Install Command Line Tool"; + } + + + public void init(Editor editor) { + this.editor = editor; + } + + + public void run() { + try { + File file = File.createTempFile("processing", "commander"); + PrintWriter writer = PApplet.createWriter(file); + writer.println("#!/bin/sh"); + writer.println("echo 'bag of awesome'"); + writer.flush(); + writer.close(); + file.setExecutable(true); + + System.out.println(System.getProperty("javaroot")); + if (true) return; + + String sourcePath = file.getAbsolutePath(); + String targetPath = "/usr/bin/processing-java"; + String shellScript = "/bin/mv " + sourcePath + " " + targetPath; + String appleScript = + "do shell script \"" + shellScript + "\" with administrator privileges"; + PApplet.exec(new String[] { "osascript", "-e", appleScript }); + } catch (IOException e) { + Base.showWarning("Error while installing", + "An error occurred and the tools were not installed.", e); + } + } +} \ No newline at end of file diff --git a/app/src/processing/mode/java/Commander.java b/app/src/processing/mode/java/Commander.java index 9696bf164..91365e45d 100644 --- a/app/src/processing/mode/java/Commander.java +++ b/app/src/processing/mode/java/Commander.java @@ -67,6 +67,7 @@ public class Commander implements RunnerListener { static public void main(String[] args) { + /* if (args == null || args.length == 0) { // System.out.println(System.getProperty("user.dir")); args = new String[] { @@ -82,6 +83,7 @@ public class Commander implements RunnerListener { "--output=/Users/fry/Desktop/test-build" }; } + */ // Do this early so that error messages go to the console Base.setCommandLine(); diff --git a/build/build.xml b/build/build.xml index 2a14eb539..fe8bd1585 100644 --- a/build/build.xml +++ b/build/build.xml @@ -35,7 +35,6 @@ -