From: <sh...@us...> - 2010-02-28 10:23:48
|
Revision: 17402 http://jedit.svn.sourceforge.net/jedit/?rev=17402&view=rev Author: shlomy Date: 2010-02-28 10:23:42 +0000 (Sun, 28 Feb 2010) Log Message: ----------- Added an option to automatically start jEdit when the installation is over. A start script can be specified using the options pane; by default it's a script named 'jedit' (on Windows, this meant it can be jedit.bat or jedit.cmd). Modified Paths: -------------- plugins/Updater/trunk/Updater.props plugins/Updater/trunk/src/updater/InstallLauncher.java plugins/Updater/trunk/src/updater/UpdaterOptions.java plugins/Updater/trunk/src/updater/UpdaterPlugin.java Modified: plugins/Updater/trunk/Updater.props =================================================================== --- plugins/Updater/trunk/Updater.props 2010-02-28 08:20:26 UTC (rev 17401) +++ plugins/Updater/trunk/Updater.props 2010-02-28 10:23:42 UTC (rev 17402) @@ -34,6 +34,7 @@ updater.options.updateEvery=Check for updates every: updater.options.updatePeriod=days updater.options.interactiveInstall=Interactive update (select components, install path) +updater.options.autoRestart=When installation is over, start jEdit using: updater.options.unixScriptDir=Unix script directory: updater.options.unixManDir=Unix man page directory: @@ -79,5 +80,7 @@ updater.msg.updateDialogCloseButton=Ok updater.msg.updateDialogCancelButton=Cancel updater.msg.waitForInstall=Please wait while the update is being installed... -updater.msg.installerDone=Installer done. You can now start jEdit if an update was installed. +updater.msg.installerDoneAutoStart=Installer done. jEdit will now be started using the start script. +updater.msg.installerDoneManualStart=Installer done. You can now start jEdit if an update was installed. updater.msg.updateErrorAbort=Encountered an unknown problem - aborting update. +updater.msg.startScriptDone=Start script done. Modified: plugins/Updater/trunk/src/updater/InstallLauncher.java =================================================================== --- plugins/Updater/trunk/src/updater/InstallLauncher.java 2010-02-28 08:20:26 UTC (rev 17401) +++ plugins/Updater/trunk/src/updater/InstallLauncher.java 2010-02-28 10:23:42 UTC (rev 17402) @@ -73,11 +73,13 @@ private static OutputStreamWriter out; private static ActionListener buttonActionListener; + // Program arguments (optional): logFile, startScript public static void main(String [] args) { String logFile = (args.length > 0) ? args[0] : null; if (logFile != null) startLogging(logFile); + String startScript = (args.length > 1) ? args[1] : null; props = new Properties(); try { @@ -135,7 +137,14 @@ cancel.setEnabled(false); appendText(props.getProperty("updater.msg.waitForInstall")); runInstaller(params); - text.append(props.getProperty("updater.msg.installerDone")); + if (startScript != null) + { + appendText(props.getProperty("updater.msg.installerDoneAutoStart")); + runStartScript(startScript); + appendText(props.getProperty("updater.msg.startScriptDone")); + } + else + appendText(props.getProperty("updater.msg.installerDoneManualStart")); ok.setEnabled(true); OutputStreamWriter bout = new OutputStreamWriter(System.out); try @@ -225,6 +234,25 @@ awaitingConfirmation = false; } + private static void runStartScript(String script) + { + if (script.contains(" ") && (! script.startsWith("\""))) + script = "\"" + script + "\""; + log("Running: " + script + "\n"); + try { + Process p = Runtime.getRuntime().exec(script); + StreamConsumer osc = new StreamConsumer(p.getInputStream()); + osc.start(); + StreamConsumer esc = new StreamConsumer(p.getErrorStream()); + esc.start(); + p.waitFor(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + private static void runInstaller(Vector<String> params) { String [] installerArgs = new String[2 + params.size()]; Modified: plugins/Updater/trunk/src/updater/UpdaterOptions.java =================================================================== --- plugins/Updater/trunk/src/updater/UpdaterOptions.java 2010-02-28 08:20:26 UTC (rev 17401) +++ plugins/Updater/trunk/src/updater/UpdaterOptions.java 2010-02-28 10:23:42 UTC (rev 17402) @@ -51,6 +51,8 @@ private static final String UPDATE_ON_STARTUP_PROP = "updater.values.updateOnStartup"; private static final String UPDATE_PERIOD_PROP = "updater.values.updatePeriod"; private static final String INTERACTIVE_INSTALL_PROP = "updater.values.interactiveInstall"; + private static final String AUTO_RESTART_PROP = "updater.values.autoRestart"; + private static final String START_SCRIPT_PROP = "updater.values.startScript"; private static final String UNIX_SCRIPT_DIR_PROP = "updater.values.unixScriptDir"; private static final String UNIX_MAN_DIR_PROP = "updater.values.unixManDir"; private FileTextField logFile; @@ -61,7 +63,9 @@ private JTextField unixScriptDir; private JTextField unixManDir; private JComboBox updateSources; - + private JCheckBox autoRestart; + private FileTextField startScript; + public UpdaterOptions() { super("updater"); @@ -121,6 +125,13 @@ interactiveInstall = new JCheckBox(jEdit.getProperty( "updater.options.interactiveInstall"), isInteractiveInstall()); addComponent(interactiveInstall); + + // auto-restart + autoRestart = new JCheckBox(jEdit.getProperty( + "updater.options.autoRestart")); + autoRestart.setSelected(isAutoRestart()); + startScript = new FileTextField(getStartScript(), false); + addComponent(autoRestart, startScript); // Unix-specific unixScriptDir = new JTextField(getUnixScriptDir()); @@ -145,6 +156,9 @@ Integer.valueOf(updatePeriod.getValue().toString())); jEdit.setBooleanProperty(INTERACTIVE_INSTALL_PROP, interactiveInstall.isSelected()); + jEdit.setBooleanProperty(AUTO_RESTART_PROP, autoRestart.isSelected()); + jEdit.setProperty(START_SCRIPT_PROP, + startScript.getTextField().getText()); jEdit.setProperty(UNIX_SCRIPT_DIR_PROP, unixScriptDir.getText()); jEdit.setProperty(UNIX_MAN_DIR_PROP, unixManDir.getText()); } @@ -179,6 +193,16 @@ return jEdit.getBooleanProperty(INTERACTIVE_INSTALL_PROP, false); } + public static boolean isAutoRestart() + { + return jEdit.getBooleanProperty(AUTO_RESTART_PROP); + } + public static String getStartScript() + { + return jEdit.getProperty(START_SCRIPT_PROP, getInstallDir() + + File.separator + "jedit"); + } + public static String getUnixScriptDir() { return jEdit.getProperty(UNIX_SCRIPT_DIR_PROP, ""); Modified: plugins/Updater/trunk/src/updater/UpdaterPlugin.java =================================================================== --- plugins/Updater/trunk/src/updater/UpdaterPlugin.java 2010-02-28 08:20:26 UTC (rev 17401) +++ plugins/Updater/trunk/src/updater/UpdaterPlugin.java 2010-02-28 10:23:42 UTC (rev 17402) @@ -120,7 +120,9 @@ //"-Xdebug", "-Xnoagent", "-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y", "-cp", getPluginJAR().getFile().getAbsolutePath(), InstallLauncher.class.getCanonicalName(), - UpdaterOptions.getUpdateLogFile() }; + UpdaterOptions.getUpdateLogFile(), + UpdaterOptions.isAutoRestart() ? UpdaterOptions.getStartScript() : "" + }; try { backgroundProcess = Runtime.getRuntime().exec(args); writer = new OutputStreamWriter(backgroundProcess.getOutputStream()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |