Skip to content

Commit

Permalink
* New: Include fileInPatches when starting MetaEdit+
Browse files Browse the repository at this point in the history
  - after changing to correct working directory with currentDir:
* New: Recognize Mac OS X and Linux MetaEdit+ installations in program path setting in Launch Parameters
* Correction: Command line to start MetaEdit+ is now an array of Strings, rather than a string with spaces and double quotes
  - Java exec() does dumb tokenization that looks only at spaces, ignoring double quotes
* Correction: MetaEdit+ .app on Mac OS X does not accept arguments, so only Startup Launcher was opened. Call script inside .app instead.
  • Loading branch information
stevekmcc committed Oct 24, 2012
1 parent 810dc89 commit 54acd90
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
Expand Up @@ -5,10 +5,13 @@

package com.metacase.graphbrowser;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.ArrayList;

import javax.xml.rpc.ServiceException;
import com.metacase.API.*;

Expand Down Expand Up @@ -144,33 +147,39 @@ public static boolean launchMetaEdit(){
* opens one or more projects and starts API server.
* @return command that can be executed.
*/
private static String createLaunchParameters(){
String metaEditDir = "\"" + getSettings().getProgramPath() + "\"";
String workingDir = "\"" + getSettings().getWorkingDirectory() + "\"";
String db = "\"" + getSettings().getDatabase() + "\"";
String user = "\"" + getSettings().getUsername() + "\"";
String password = "\"" + getSettings().getPassword() + "\"";
int port = getSettings().getPort();
String hostname = getSettings().getHostname();
boolean logging = getSettings().isLogging();

String line = metaEditDir + " currentDir: " + workingDir + " " + "loginDB:user:password: " + db + " " +
user + " " + password;
private static String[] createLaunchParameters(){
ArrayList<String> cmdLine = new ArrayList<String>();
String executable = getSettings().getProgramPath();
if (System.getProperty("os.name").contains("OS X")) {
executable += File.separator + "Contents" + File.separator + "Resources" + File.separator + "script";
}
cmdLine.add(executable);

cmdLine.add("currentDir:");
cmdLine.add(getSettings().getWorkingDirectory());

// Any existing fileInPatches, e.g. in Linux & Mac OS X scripts, will be done in the wrong dir, so repeat
cmdLine.add("fileInPatches");

cmdLine.add("loginDB:user:password:");
cmdLine.add(getSettings().getDatabase());
cmdLine.add(getSettings().getUsername());
cmdLine.add(getSettings().getPassword());

String [] projects = getSettings().getProjects();
for (String s : projects) {
if (!s.equals("")) {
line += " setProject: " + "\"" + s + "\"";
cmdLine.add("setProject:");
cmdLine.add(s);
}
}

line += " startAPIHostname:port:logEvents: " + hostname + " " + port + " " + logging;
cmdLine.add("startAPIHostname:port:logEvents:");
cmdLine.add(getSettings().getHostname());
cmdLine.add(String.valueOf(getSettings().getPort()));
cmdLine.add(String.valueOf(getSettings().isLogging()));

if (System.getProperty("os.name").contains("OS X")) {
line = "open " + line;
}

return line;
return cmdLine.toArray(new String[0]);
}

/**
Expand Down
Expand Up @@ -678,7 +678,20 @@ public class ProgramDirectoryVerifier implements SettingsVerifier {
public int verify(final JComponent input) {
JTextField tf = (JTextField) input;
File file = new File(tf.getText());
if (file.exists() && file.getName().contains("mep") && file.getName().contains(".exe")) return 1;
String os = System.getProperty("os.name").toLowerCase();
if (file.exists()) {
String fn = file.getName();
if (os.indexOf("win") >= 0)
if (fn.contains("mep") && fn.endsWith(".exe"))
return 1;
if (os.contains("os x"))
if (fn.contains("MetaEdit+") && fn.endsWith(".app"))
return 1;
if (os.indexOf("nux") >= 0 || os.indexOf("nix") >= 0)
if (fn.contains("mep") && fn.endsWith("metaedit"))
return 1;
}

return -1;
}
}
Expand Down

0 comments on commit 54acd90

Please sign in to comment.