This commit is contained in:
jrandom
2005-09-16 04:34:59 +00:00
committed by zzz
parent d89f589f2b
commit 6ca3f01038
102 changed files with 9297 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,189 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sf.launch4j.binding.InvariantViolationException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Builder {
private final Log _log;
public Builder(Log log) {
_log = log;
}
/**
* @return Output file path.
*/
public File build() throws BuilderException {
final Config c = ConfigPersister.getInstance().getConfig();
try {
c.validate();
} catch (InvariantViolationException e) {
throw new BuilderException(e.getMessage());
}
File rc = null;
File ro = null;
File outfile = null;
FileInputStream is = null;
FileOutputStream os = null;
final RcBuilder rcb = new RcBuilder();
try {
String basedir = Util.getJarBasedir();
if (basedir == null) {
basedir = ".";
}
rc = rcb.build(c);
ro = File.createTempFile("launch4j", "o");
outfile = ConfigPersister.getInstance().getOutputFile();
Cmd resCmd = new Cmd(basedir);
resCmd.addExe("/bin/windres")
.add(Util.WINDOWS_OS ? "--preprocessor=type" : "--preprocessor=cat")
.add("-J rc -O coff -F pe-i386")
.add(rc.getPath())
.add(ro.getPath());
_log.append("Compiling resources");
Util.exec(resCmd.toString(), _log);
Cmd ldCmd = new Cmd(basedir);
ldCmd.addExe("/bin/ld")
.add("-mi386pe")
.add("--oformat pei-i386")
.add((c.getHeaderType() == Config.GUI_HEADER)
? "--subsystem windows" : "--subsystem console")
.add("-s") // strip symbols
.addFile("/w32api/crt2.o")
.addFile((c.getHeaderType() == Config.GUI_HEADER)
? "/head/guihead.o" : "/head/consolehead.o")
.addFile("/head/head.o")
.addAbsFile(ro.getPath())
.addFile("/w32api/libmingw32.a")
.addFile("/w32api/libgcc.a")
.addFile("/w32api/libmsvcrt.a")
.addFile("/w32api/libkernel32.a")
.addFile("/w32api/libuser32.a")
.addFile("/w32api/libadvapi32.a")
.addFile("/w32api/libshell32.a")
.add("-o")
.addAbsFile(outfile.getPath());
_log.append("Linking");
Util.exec(ldCmd.toString(), _log);
_log.append("Wrapping");
int len;
byte[] buffer = new byte[1024];
is = new FileInputStream(
Util.getAbsoluteFile(ConfigPersister.getInstance().getConfigPath(), c.getJar()));
os = new FileOutputStream(outfile, true);
while ((len = is.read(buffer)) > 0) {
os.write(buffer, 0, len);
}
_log.append("Successfully created " + outfile.getPath());
return outfile;
} catch (IOException e) {
Util.delete(outfile);
_log.append(e.getMessage());
throw new BuilderException(e);
} catch (ExecException e) {
Util.delete(outfile);
String msg = e.getMessage();
if (msg != null && msg.indexOf("windres") != -1) {
_log.append("Generated resource file...\n");
_log.append(rcb.getContent());
}
throw new BuilderException(e);
} finally {
Util.close(is);
Util.close(os);
Util.delete(rc);
Util.delete(ro);
}
}
}
class Cmd {
private final StringBuffer _sb = new StringBuffer();
private final String _basedir;
private final boolean _quote;
public Cmd(String basedir) {
_basedir = basedir;
_quote = basedir.indexOf(' ') != -1;
}
public Cmd add(String s) {
space();
_sb.append(s);
return this;
}
public Cmd addAbsFile(String file) {
space();
boolean quote = file.indexOf(' ') != -1;
if (quote) {
_sb.append('"');
}
_sb.append(file);
if (quote) {
_sb.append('"');
}
return this;
}
public Cmd addFile(String file) {
space();
if (_quote) {
_sb.append('"');
}
_sb.append(_basedir);
_sb.append(file);
if (_quote) {
_sb.append('"');
}
return this;
}
public Cmd addExe(String file) {
return addFile(Util.WINDOWS_OS ? file + ".exe" : file);
}
private void space() {
if (_sb.length() > 0) {
_sb.append(' ');
}
}
public String toString() {
return _sb.toString();
}
}

View File

@@ -0,0 +1,38 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 13, 2005
*/
package net.sf.launch4j;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class BuilderException extends Exception {
public BuilderException() {}
public BuilderException(Throwable t) {
super(t);
}
public BuilderException(String msg) {
super(msg);
}
}

View File

@@ -0,0 +1,38 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 14, 2005
*/
package net.sf.launch4j;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ExecException extends Exception {
public ExecException() {}
public ExecException(Throwable t) {
super(t);
}
public ExecException(String msg) {
super(msg);
}
}

View File

@@ -0,0 +1,62 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2004-01-15
*/
package net.sf.launch4j;
import java.io.File;
import javax.swing.filechooser.FileFilter;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public class FileChooserFilter extends FileFilter {
String _description;
String[] _extensions;
public FileChooserFilter(String description, String extension) {
_description = description;
_extensions = new String[] {extension};
}
public FileChooserFilter(String description, String[] extensions) {
_description = description;
_extensions = extensions;
}
public boolean accept(File f) {
if (f.isDirectory()) {
return true;
}
String ext = Util.getExtension(f);
for (int i = 0; i < _extensions.length; i++) {
if (ext.toLowerCase().equals(_extensions[i].toLowerCase())) {
return true;
}
}
return false;
}
public String getDescription() {
return _description;
}
}

View File

@@ -0,0 +1,21 @@
/*
* Created on Jun 4, 2005
*/
package net.sf.launch4j;
/**
* This class allows launch4j to act as a launcher instead of a wrapper.
* It's useful on Windows because an application cannot be a GUI and console one
* at the same time. So there are two launchers that start launch4j.jar: launch4j.exe
* for GUI mode and launch4jc.exe for console operation.
* The Launcher class is packed into an executable jar that contains nothing else but
* the manifest with Class-Path attribute defined as in the application jar. The jar
* is wrapped with launch4j.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Launcher {
public static void main(String[] args) {
Main.main(args);
}
}

View File

@@ -0,0 +1,91 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 12, 2005
*/
package net.sf.launch4j;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public abstract class Log {
private static final Log _consoleLog = new ConsoleLog();
private static final Log _antLog = new AntLog();
public abstract void clear();
public abstract void append(String line);
public static Log getConsoleLog() {
return _consoleLog;
}
public static Log getAntLog() {
return _antLog;
}
public static Log getSwingLog(JTextArea textArea) {
return new SwingLog(textArea);
}
}
class ConsoleLog extends Log {
public void clear() {
System.out.println("\n");
}
public void append(String line) {
System.out.println("launch4j: " + line);
}
}
class AntLog extends Log {
public void clear() {
System.out.println("\n");
}
public void append(String line) {
System.out.println(line);
}
}
class SwingLog extends Log {
private final JTextArea _textArea;
public SwingLog(JTextArea textArea) {
_textArea = textArea;
}
public void clear() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_textArea.setText("");
}});
}
public void append(final String line) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
_textArea.append(line + "\n");
}});
}
}

View File

@@ -0,0 +1,62 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 21, 2005
*/
package net.sf.launch4j;
import java.io.File;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.ConfigPersisterException;
import net.sf.launch4j.formimpl.MainFrame;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Main {
public static final String PROGRAM_NAME = "launch4j 2.0.RC3";
public static final String PROGRAM_DESCRIPTION = PROGRAM_NAME +
" :: Cross-platform Java application wrapper for creating Windows native executables\n" +
"Copyright (C) 2005 Grzegorz Kowal\n" +
"launch4j comes with ABSOLUTELY NO WARRANTY\n" +
"This is free software, licensed under the GNU General Public License.\n" +
"This product includes software developed by the Apache Software Foundation (http://www.apache.org/).\n\n";
public static void main(String[] args) {
try {
if (args.length == 0) {
ConfigPersister.getInstance().createBlank();
MainFrame.createInstance();
} else if (args.length == 1 && !args[0].startsWith("-")) {
ConfigPersister.getInstance().load(new File(args[0]));
Builder b = new Builder(Log.getConsoleLog());
b.build();
} else {
System.out.println(PROGRAM_DESCRIPTION + "usage: launch4j config.xml");
}
} catch (ConfigPersisterException e) {
Log.getConsoleLog().append(e.getMessage());
} catch (BuilderException e) {
Log.getConsoleLog().append(e.getMessage());
}
}
}

View File

@@ -0,0 +1,57 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
//import net.sf.launch4j.config.Config;
//import org.apache.commons.cli.CommandLine;
//import org.apache.commons.cli.CommandLineParser;
//import org.apache.commons.cli.HelpFormatter;
//import org.apache.commons.cli.Options;
//import org.apache.commons.cli.ParseException;
//import org.apache.commons.cli.PosixParser;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class OptionParser {
// private final Options _options;
//
// public OptionParser() {
// _options = new Options();
// _options.addOption("h", "header", true, "header");
// }
//
// public Config parse(Config c, String[] args) throws ParseException {
// CommandLineParser parser = new PosixParser();
// CommandLine cl = parser.parse(_options, args);
// c.setJar(getFile(props, Config.JAR));
// c.setOutfile(getFile(props, Config.OUTFILE));
// }
//
// public void printHelp() {
// HelpFormatter formatter = new HelpFormatter();
// formatter.printHelp("launch4j", _options);
// }
}

View File

@@ -0,0 +1,230 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.Jre;
import net.sf.launch4j.config.Splash;
import net.sf.launch4j.config.VersionInfo;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class RcBuilder {
// winnt.h
public static final int LANG_NEUTRAL = 0;
public static final int SUBLANG_NEUTRAL = 0;
public static final int SUBLANG_DEFAULT = 1;
public static final int SUBLANG_SYS_DEFAULT = 2;
// ICON
public static final int APP_ICON = 1;
// BITMAP
public static final int SPLASH_BITMAP = 1;
// RCDATA
public static final int JRE_PATH = 1;
public static final int JAVA_MIN_VER = 2;
public static final int JAVA_MAX_VER = 3;
public static final int SHOW_SPLASH = 4;
public static final int SPLASH_WAITS_FOR_WINDOW = 5;
public static final int SPLASH_TIMEOUT = 6;
public static final int SPLASH_TIMEOUT_ERR = 7;
public static final int CHDIR = 8;
public static final int SET_PROC_NAME = 9;
public static final int ERR_TITLE = 10;
public static final int GUI_HEADER_STAYS_ALIVE = 11;
public static final int JVM_ARGS = 12;
public static final int JAR_ARGS = 13;
private final StringBuffer _sb = new StringBuffer();
public String getContent() {
return _sb.toString();
}
public File build(Config c) throws IOException {
_sb.append("LANGUAGE ");
_sb.append(LANG_NEUTRAL);
_sb.append(", ");
_sb.append(SUBLANG_DEFAULT);
_sb.append('\n');
addVersionInfo(c.getVersionInfo());
addJre(c.getJre());
addIcon(APP_ICON, c.getIcon());
addText(ERR_TITLE, c.getErrTitle());
addText(JAR_ARGS, c.getJarArgs());
addWindowsPath(CHDIR, c.getChdir());
addTrue(SET_PROC_NAME, c.isCustomProcName());
addTrue(GUI_HEADER_STAYS_ALIVE, c.isStayAlive());
addSplash(c.getSplash());
File f = File.createTempFile("launch4j", "rc");
BufferedWriter w = new BufferedWriter(new FileWriter(f));
w.write(_sb.toString());
w.close();
return f;
}
private void addVersionInfo(VersionInfo v) {
if (v == null) {
return;
}
_sb.append("1 VERSIONINFO\n");
_sb.append("FILEVERSION ");
_sb.append(v.getFileVersion().replaceAll("\\.", ", "));
_sb.append("\nPRODUCTVERSION ");
_sb.append(v.getProductVersion().replaceAll("\\.", ", "));
_sb.append("\nFILEFLAGSMASK 0\n" +
"FILEOS 0x40000\n" +
"FILETYPE 1\n" +
"{\n" +
" BLOCK \"StringFileInfo\"\n" +
" {\n" +
" BLOCK \"040904E4\"\n" + // English
" {\n");
addVerBlockValue("CompanyName", v.getCompanyName());
addVerBlockValue("FileDescription", v.getFileDescription());
addVerBlockValue("FileVersion", v.getTxtFileVersion());
addVerBlockValue("InternalName", v.getInternalName());
addVerBlockValue("LegalCopyright", v.getCopyright());
addVerBlockValue("OriginalFilename", v.getOriginalFilename());
addVerBlockValue("ProductName", v.getProductName());
addVerBlockValue("ProductVersion", v.getTxtProductVersion());
_sb.append(" }\n }\n}\n");
}
private void addJre(Jre jre) {
addWindowsPath(JRE_PATH, jre.getPath());
addText(JAVA_MIN_VER, jre.getMinVersion());
addText(JAVA_MAX_VER, jre.getMaxVersion());
StringBuffer jvmArgs = new StringBuffer();
if (jre.getInitialHeapSize() > 0) {
jvmArgs.append("-Xms");
jvmArgs.append(jre.getInitialHeapSize());
jvmArgs.append('m');
}
if (jre.getMaxHeapSize() > 0) {
addSpace(jvmArgs);
jvmArgs.append("-Xmx");
jvmArgs.append(jre.getMaxHeapSize());
jvmArgs.append('m');
}
if (jre.getArgs() != null && jre.getArgs().length() > 0) {
addSpace(jvmArgs);
jvmArgs.append(jre.getArgs().replaceAll("\n", " "));
}
addText(JVM_ARGS, jvmArgs.toString());
}
private void addSplash(Splash splash) {
if (splash == null) {
return;
}
addTrue(SHOW_SPLASH, true);
addTrue(SPLASH_WAITS_FOR_WINDOW, splash.getWaitForWindow());
addText(SPLASH_TIMEOUT, String.valueOf(splash.getTimeout()));
addTrue(SPLASH_TIMEOUT_ERR, splash.isTimeoutErr());
addBitmap(SPLASH_BITMAP, splash.getFile());
}
private void addText(int id, String text) {
if (text == null || text.length() == 0) {
return;
}
_sb.append(id);
_sb.append(" RCDATA BEGIN \"");
_sb.append(text);
_sb.append("\\0\" END\n");
}
/**
* Stores path in Windows format with '\' separators.
*/
private void addWindowsPath(int id, String path) {
if (path == null || path.equals("")) {
return;
}
_sb.append(id);
_sb.append(" RCDATA BEGIN \"");
_sb.append(path.replaceAll("\\\\", "\\\\\\\\")
.replaceAll("/", "\\\\\\\\"));
_sb.append("\\0\" END\n");
}
private void addTrue(int id, boolean value) {
if (value) {
addText(id, "true");
}
}
private void addIcon(int id, File icon) {
if (icon == null || icon.getPath().equals("")) {
return;
}
_sb.append(id);
_sb.append(" ICON DISCARDABLE \"");
_sb.append(getPath(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), icon)));
_sb.append("\"\n");
}
private void addBitmap(int id, File bitmap) {
if (bitmap == null) {
return;
}
_sb.append(id);
_sb.append(" BITMAP \"");
_sb.append(getPath(Util.getAbsoluteFile(
ConfigPersister.getInstance().getConfigPath(), bitmap)));
_sb.append("\"\n");
}
private String getPath(File f) {
return f.getPath().replaceAll("\\\\", "\\\\\\\\");
}
private void addSpace(StringBuffer sb) {
int len = sb.length();
if (len-- > 0 && sb.charAt(len) != ' ') {
sb.append(' ');
}
}
private void addVerBlockValue(String key, String value) {
_sb.append(" VALUE \"");
_sb.append(key);
_sb.append("\", \"");
if (value != null) {
_sb.append(value);
}
_sb.append("\"\n");
}
}

View File

@@ -0,0 +1,152 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-04-24
*/
package net.sf.launch4j;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Util {
public static final boolean WINDOWS_OS = System.getProperty("os.name")
.toLowerCase().startsWith("windows");
private Util() {}
/**
* Returns the base directory of a jar file or null if the class is a standalone file.
* @return System specific path
*
* Based on a patch submitted by Josh Elsasser
*/
public static String getJarBasedir() {
String url = Util.class.getClassLoader()
.getResource(Util.class.getName().replace('.', '/') + ".class")
.getFile()
.replaceAll("%20", " ");
if (url.startsWith("file:")) {
String jar = url.substring(5, url.lastIndexOf('!'));
int x = jar.lastIndexOf('/');
if (x == -1) {
x = jar.lastIndexOf('\\');
}
String basedir = jar.substring(0, x + 1);
return new File(basedir).getPath();
} else {
return null;
}
}
public static File getAbsoluteFile(File basepath, File f) {
return f.isAbsolute() ? f : new File(basepath, f.getPath());
}
public static String getExtension(File f) {
String name = f.getName();
int x = name.lastIndexOf('.');
if (x != -1) {
return name.substring(x);
} else {
return "";
}
}
public static void exec(String cmd, Log log) throws ExecException {
BufferedReader is = null;
try {
if (WINDOWS_OS) {
cmd = cmd.replaceAll("/", "\\\\");
}
Process p = Runtime.getRuntime().exec(cmd);
is = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
while ((line = is.readLine()) != null) {
log.append(line);
}
is.close();
p.waitFor();
if (p.exitValue() != 0) {
String msg = "Exec failed (" + p.exitValue() + "): " + cmd;
log.append(msg);
throw new ExecException(msg);
}
} catch (IOException e) {
close(is);
throw new ExecException(e);
} catch (InterruptedException e) {
close(is);
throw new ExecException(e);
}
}
public static void close(final InputStream o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final OutputStream o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final Reader o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static void close(final Writer o) {
if (o != null) {
try {
o.close();
} catch (IOException e) {
System.err.println(e); // XXX log
}
}
}
public static boolean delete(File f) {
return (f != null) ? f.delete() : false;
}
}

View File

@@ -0,0 +1,57 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 24, 2005
*/
package net.sf.launch4j.ant;
import org.apache.tools.ant.BuildException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.Jre;
import net.sf.launch4j.config.Splash;
import net.sf.launch4j.config.VersionInfo;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class AntConfig extends Config {
public void addJre(Jre jre) {
checkNull(getJre(), "jre");
setJre(jre);
}
public void addSplash(Splash splash) {
checkNull(getSplash(), "splash");
setSplash(splash);
}
public void addVersionInfo(VersionInfo versionInfo) {
checkNull(getVersionInfo(), "versionInfo");
setVersionInfo(versionInfo);
}
private void checkNull(Object o, String name) {
if (o != null) {
throw new BuildException("Duplicate element: " + name);
}
}
}

View File

@@ -0,0 +1,122 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 24, 2005
*/
package net.sf.launch4j.ant;
import java.io.File;
import net.sf.launch4j.Builder;
import net.sf.launch4j.BuilderException;
import net.sf.launch4j.Log;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.ConfigPersisterException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Launch4jTask extends Task {
private File _configFile;
private AntConfig _config;
// Override configFile settings
private File jar;
private File outfile;
private String fileVersion;
private String txtFileVersion;
private String productVersion;
private String txtProductVersion;
public void execute() throws BuildException {
try {
if (_configFile != null && _config != null) {
throw new BuildException("Specify configFile or config");
} else if (_configFile != null) {
ConfigPersister.getInstance().load(_configFile);
Config c = ConfigPersister.getInstance().getConfig();
if (jar != null) {
c.setJar(jar);
}
if (outfile != null) {
c.setOutfile(outfile);
}
if (fileVersion != null) {
c.getVersionInfo().setFileVersion(fileVersion);
}
if (txtFileVersion != null) {
c.getVersionInfo().setTxtFileVersion(txtFileVersion);
}
if (productVersion != null) {
c.getVersionInfo().setProductVersion(productVersion);
}
if (txtProductVersion != null) {
c.getVersionInfo().setTxtProductVersion(txtProductVersion);
}
} else if (_config != null) {
ConfigPersister.getInstance().setAntConfig(_config, getProject().getBaseDir());
} else {
throw new BuildException("Specify configFile or config");
}
final Builder b = new Builder(Log.getAntLog());
b.build();
} catch (ConfigPersisterException e) {
throw new BuildException(e);
} catch (BuilderException e) {
throw new BuildException(e);
}
}
public void setConfigFile(File configFile) {
_configFile = configFile;
}
public void addConfig(AntConfig config) {
_config = config;
}
public void setFileVersion(String fileVersion) {
this.fileVersion = fileVersion;
}
public void setJar(File jar) {
this.jar = jar;
}
public void setOutfile(File outfile) {
this.outfile = outfile;
}
public void setProductVersion(String productVersion) {
this.productVersion = productVersion;
}
public void setTxtFileVersion(String txtFileVersion) {
this.txtFileVersion = txtFileVersion;
}
public void setTxtProductVersion(String txtProductVersion) {
this.txtProductVersion = txtProductVersion;
}
}

View File

@@ -0,0 +1,48 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public interface Binding {
/** Used to mark components with invalid data. */
public final static Color INVALID_COLOR = Color.PINK;
/** Java Bean property bound to a component */
public String getProperty();
/** Clear component, set it to the default value. */
public void clear();
/** Java Bean property -> Component */
public void put(IValidatable bean);
/** Component -> Java Bean property */
public void get(IValidatable bean);
/** Mark component as valid */
public void markValid();
/** Mark component as invalid */
public void markInvalid();
/** Enable or disable the component */
public void setEnabled(boolean enabled);
}

View File

@@ -0,0 +1,38 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
/**
* Signals a runtime error, a missing property in a Java Bean for example.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class BindingException extends RuntimeException {
public BindingException(Throwable t) {
super(t);
}
public BindingException(String msg) {
super(msg);
}
}

View File

@@ -0,0 +1,247 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JComponent;
import javax.swing.JRadioButton;
import javax.swing.JToggleButton;
import javax.swing.text.JTextComponent;
import org.apache.commons.beanutils.PropertyUtils;
/**
* Creates and handles bindings.
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Bindings implements PropertyChangeListener {
private final Map _bindings = new HashMap();
private final Map _optComponents = new HashMap();
private boolean _modified = false;
/**
* Used to track component modifications.
*/
public void propertyChange(PropertyChangeEvent evt) {
if ("AccessibleValue".equals(evt.getPropertyName())
|| "AccessibleText".equals(evt.getPropertyName())) {
_modified = true;
}
}
/**
* Any of the components modified?
*/
public boolean isModified() {
return _modified;
}
public Binding getBinding(String property) {
return (Binding) _bindings.get(property);
}
private void registerPropertyChangeListener(JComponent c) {
c.getAccessibleContext().addPropertyChangeListener(this);
}
private void registerPropertyChangeListener(JComponent[] cs) {
for (int i = 0; i < cs.length; i++) {
cs[i].getAccessibleContext().addPropertyChangeListener(this);
}
}
private boolean isPropertyNull(IValidatable bean, Binding b) {
try {
for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) {
String property = (String) iter.next();
if (b.getProperty().startsWith(property)) {
return PropertyUtils.getProperty(bean, property) == null;
}
}
return false;
} catch (Exception e) {
throw new BindingException(e);
}
}
/**
* Enables or disables all components bound to properties that begin with given prefix.
*/
public void setComponentsEnabled(String prefix, boolean enabled) {
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (b.getProperty().startsWith(prefix)) {
b.setEnabled(enabled);
}
}
}
/**
* Clear all components, set them to their default values.
* Clears the _modified flag.
*/
public void clear() {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).clear();
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).clear();
}
_modified = false;
}
/**
* Copies data from the Java Bean to the UI components.
* Clears the _modified flag.
*/
public void put(IValidatable bean) {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).put(bean);
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (isPropertyNull(bean, b)) {
b.clear();
} else {
b.put(bean);
}
}
_modified = false;
}
/**
* Copies data from UI components to the Java Bean and checks it's class invariants.
* Clears the _modified flag.
* @throws InvariantViolationException
* @throws BindingException
*/
public void get(IValidatable bean) {
try {
for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
((Binding) iter.next()).get(bean);
}
for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
Binding b = (Binding) iter.next();
if (!isPropertyNull(bean, b)) {
b.get(bean);
}
}
bean.checkInvariants();
for (Iterator iter = _optComponents.keySet().iterator(); iter.hasNext();) {
String property = (String) iter.next();
IValidatable component = (IValidatable) PropertyUtils.getProperty(bean, property);
if (component != null) {
component.checkInvariants();
}
}
_modified = false; // XXX
} catch (InvariantViolationException e) {
e.setBinding(getBinding(e.getProperty()));
throw e;
} catch (Exception e) {
throw new BindingException(e);
}
}
private Bindings add(Binding b) {
if (_bindings.containsKey(b.getProperty())) {
throw new BindingException("Duplicate binding");
}
_bindings.put(b.getProperty(), b);
return this;
}
/**
* Add an optional (nullable) Java Bean component of type clazz.
*/
public Bindings addOptComponent(String property, Class clazz, JToggleButton c,
boolean enabledByDefault) {
Binding b = new OptComponentBinding(this, property, clazz, c, enabledByDefault);
if (_optComponents.containsKey(property)) {
throw new BindingException("Duplicate binding");
}
_optComponents.put(property, b);
return this;
}
/**
* Add an optional (nullable) Java Bean component of type clazz.
*/
public Bindings addOptComponent(String property, Class clazz, JToggleButton c) {
return addOptComponent(property, clazz, c, false);
}
/**
* Handles JEditorPane, JTextArea, JTextField
*/
public Bindings add(String property, JTextComponent c, String defaultValue) {
registerPropertyChangeListener(c);
return add(new JTextComponentBinding(property, c, defaultValue));
}
/**
* Handles JEditorPane, JTextArea, JTextField
*/
public Bindings add(String property, JTextComponent c) {
registerPropertyChangeListener(c);
return add(new JTextComponentBinding(property, c, ""));
}
/**
* Handles JToggleButton, JCheckBox
*/
public Bindings add(String property, JToggleButton c, boolean defaultValue) {
registerPropertyChangeListener(c);
return add(new JToggleButtonBinding(property, c, defaultValue));
}
/**
* Handles JToggleButton, JCheckBox
*/
public Bindings add(String property, JToggleButton c) {
registerPropertyChangeListener(c);
return add(new JToggleButtonBinding(property, c, false));
}
/**
* Handles JRadioButton
*/
public Bindings add(String property, JRadioButton[] cs, int defaultValue) {
registerPropertyChangeListener(cs);
return add(new JRadioButtonBinding(property, cs, defaultValue));
}
/**
* Handles JRadioButton
*/
public Bindings add(String property, JRadioButton[] cs) {
registerPropertyChangeListener(cs);
return add(new JRadioButtonBinding(property, cs, 0));
}
}

View File

@@ -0,0 +1,30 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2004-01-30
*/
package net.sf.launch4j.binding;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public interface IValidatable {
public void checkInvariants();
}

View File

@@ -0,0 +1,53 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Jun 23, 2003
*/
package net.sf.launch4j.binding;
/**
* @author Copyright (C) 2003 Grzegorz Kowal
*/
public class InvariantViolationException extends RuntimeException {
private final String _property;
private Binding _binding;
public InvariantViolationException(String msg) {
super(msg);
_property = null;
}
public InvariantViolationException(String property, String msg) {
super(msg);
_property = property;
}
public String getProperty() {
return _property;
}
public Binding getBinding() {
return _binding;
}
public void setBinding(Binding binding) {
_binding = binding;
}
}

View File

@@ -0,0 +1,127 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 10, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.JRadioButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JRadioButtonBinding implements Binding {
private final String _property;
private final JRadioButton[] _buttons;
private final int _defaultValue;
private final Color _validColor;
public JRadioButtonBinding(String property, JRadioButton[] buttons, int defaultValue) {
if (property == null || buttons == null) {
throw new NullPointerException();
}
for (int i = 0; i < buttons.length; i++) {
if (buttons[i] == null) {
throw new NullPointerException();
}
}
if (property.equals("")
|| buttons.length == 0
|| defaultValue < 0 || defaultValue >= buttons.length) {
throw new IllegalArgumentException();
}
_property = property;
_buttons = buttons;
_defaultValue = defaultValue;
_validColor = buttons[0].getBackground();
}
public String getProperty() {
return _property;
}
public void clear() {
select(_defaultValue);
}
public void put(IValidatable bean) {
try {
Integer i = (Integer) PropertyUtils.getProperty(bean, _property);
if (i == null) {
throw new BindingException("Property is null");
}
select(i.intValue());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
PropertyUtils.setProperty(bean, _property, new Integer(i));
return;
}
}
throw new BindingException("Nothing selected");
} catch (Exception e) {
throw new BindingException(e);
}
}
private void select(int index) {
if (index < 0 || index >= _buttons.length) {
throw new BindingException("Button index out of bounds");
}
_buttons[index].setSelected(true);
}
public void markValid() {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
_buttons[i].setBackground(_validColor);
_buttons[i].requestFocusInWindow();
return;
}
}
throw new BindingException("Nothing selected");
}
public void markInvalid() {
for (int i = 0; i < _buttons.length; i++) {
if (_buttons[i].isSelected()) {
_buttons[i].setBackground(Binding.INVALID_COLOR);
return;
}
}
throw new BindingException("Nothing selected");
}
public void setEnabled(boolean enabled) {
for (int i = 0; i < _buttons.length; i++) {
_buttons[i].setEnabled(enabled);
}
}
}

View File

@@ -0,0 +1,92 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.text.JTextComponent;
import org.apache.commons.beanutils.BeanUtils;
/**
* Handles JEditorPane, JTextArea, JTextField
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JTextComponentBinding implements Binding {
private final String _property;
private final JTextComponent _textComponent;
private final String _defaultValue;
private final Color _validColor;
public JTextComponentBinding(String property, JTextComponent textComponent, String defaultValue) {
if (property == null || textComponent == null || defaultValue == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_textComponent = textComponent;
_defaultValue = defaultValue;
_validColor = _textComponent.getBackground();
}
public String getProperty() {
return _property;
}
public void clear() {
_textComponent.setText(_defaultValue);
}
public void put(IValidatable bean) {
try {
String s = BeanUtils.getProperty(bean, _property);
_textComponent.setText(s != null && !s.equals("0") ? s : ""); // XXX displays zeros as blank
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
BeanUtils.setProperty(bean, _property, _textComponent.getText());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_textComponent.setBackground(_validColor);
_textComponent.requestFocusInWindow();
}
public void markInvalid() {
_textComponent.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_textComponent.setEnabled(enabled);
}
}

View File

@@ -0,0 +1,94 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 30, 2005
*/
package net.sf.launch4j.binding;
import java.awt.Color;
import javax.swing.JToggleButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* Handles JToggleButton, JCheckBox
*
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class JToggleButtonBinding implements Binding {
private final String _property;
private final JToggleButton _button;
private final boolean _defaultValue;
private final Color _validColor;
public JToggleButtonBinding(String property, JToggleButton button, boolean defaultValue) {
if (property == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
_property = property;
_button = button;
_defaultValue = defaultValue;
_validColor = _button.getBackground();
}
public String getProperty() {
return _property;
}
public void clear() {
_button.setSelected(_defaultValue);
}
public void put(IValidatable bean) {
try {
// String s = BeanUtils.getProperty(o, _property);
// _checkBox.setSelected("true".equals(s));
Boolean b = (Boolean) PropertyUtils.getProperty(bean, _property);
_button.setSelected(b != null && b.booleanValue());
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
PropertyUtils.setProperty(bean, _property, Boolean.valueOf(_button.isSelected()));
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {
_button.setBackground(_validColor);
_button.requestFocusInWindow();
}
public void markInvalid() {
_button.setBackground(Binding.INVALID_COLOR);
}
public void setEnabled(boolean enabled) {
_button.setEnabled(enabled);
}
}

View File

@@ -0,0 +1,104 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 11, 2005
*/
package net.sf.launch4j.binding;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import javax.swing.JToggleButton;
import org.apache.commons.beanutils.PropertyUtils;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class OptComponentBinding implements Binding, ActionListener {
private final Bindings _bindings;
private final String _property;
private final Class _clazz;
private final JToggleButton _button;
private final boolean _enabledByDefault;
public OptComponentBinding(Bindings bindings, String property, Class clazz,
JToggleButton button, boolean enabledByDefault) {
if (property == null || clazz == null || button == null) {
throw new NullPointerException();
}
if (property.equals("")) {
throw new IllegalArgumentException();
}
if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
throw new IllegalArgumentException("Optional component must implement "
+ IValidatable.class);
}
_bindings = bindings;
_property = property;
_clazz = clazz;
_button = button;
_button.addActionListener(this);
_enabledByDefault = enabledByDefault;
}
public String getProperty() {
return _property;
}
public void clear() {
_button.setSelected(_enabledByDefault);
updateComponents();
}
public void put(IValidatable bean) {
try {
Object component = PropertyUtils.getProperty(bean, _property);
_button.setSelected(component != null);
updateComponents();
} catch (Exception e) {
throw new BindingException(e);
}
}
public void get(IValidatable bean) {
try {
PropertyUtils.setProperty(bean, _property, _button.isSelected()
? _clazz.newInstance() : null);
} catch (Exception e) {
throw new BindingException(e);
}
}
public void markValid() {}
public void markInvalid() {}
public void setEnabled(boolean enabled) {} // XXX implement?
public void actionPerformed(ActionEvent e) {
updateComponents();
}
private void updateComponents() {
_bindings.setComponentsEnabled(_property, _button.isSelected());
}
}

View File

@@ -0,0 +1,190 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2004-01-30
*/
package net.sf.launch4j.binding;
import java.io.File;
import java.util.Collection;
import java.util.HashSet;
import net.sf.launch4j.Util;
import net.sf.launch4j.config.ConfigPersister;
/**
* @author Copyright (C) 2004 Grzegorz Kowal
*/
public class Validator {
public static final String ALPHANUMERIC_PATTERN = "[\\w]*?";
public static final String ALPHA_PATTERN = "[\\w&&\\D]*?";
public static final String NUMERIC_PATTERN = "[\\d]*?";
public static final String PATH_PATTERN = "[\\w|[ .,:\\-/\\\\]]*?";
private static final String EMPTY_FIELD = "Enter: ";
private static final String FIELD_ERROR = "Invalid data: ";
private static final String RANGE_ERROR = " must be in range [";
private static final String MINIMUM = " must be at least ";
private static final String DUPLICATE = " already exists.";
private Validator() {}
public static boolean isEmpty(String s) {
return s == null || s.equals("");
}
public static void checkNotNull(Object o, String property, String name) {
if (o == null) {
signalViolation(property, EMPTY_FIELD + name);
}
}
public static void checkString(String s, int maxLength, String property, String name) {
if (s == null || s.length() == 0) {
signalViolation(property, EMPTY_FIELD + name);
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
}
public static void checkString(String s, int maxLength, String pattern,
String property, String name) {
checkString(s, maxLength, property, name);
if (!s.matches(pattern)) {
signalViolation(property, FIELD_ERROR + name);
}
}
public static void checkOptString(String s, int maxLength, String property, String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
}
public static void checkOptString(String s, int maxLength, String pattern,
String property, String name) {
if (s == null || s.length() == 0) {
return;
}
if (s.length() > maxLength) {
signalLengthViolation(property, name, maxLength);
}
if (!s.matches(pattern)) {
signalViolation(property, FIELD_ERROR + name);
}
}
public static void checkRange(int value, int min, int max,
String property, String name) {
if (value < min || value > max) {
StringBuffer sb = new StringBuffer(name);
sb.append(RANGE_ERROR);
sb.append(min);
sb.append('-');
sb.append(max);
sb.append(']');
signalViolation(property, sb.toString());
}
}
public static void checkRange(char value, char min, char max,
String property, String name) {
if (value < min || value > max) {
StringBuffer sb = new StringBuffer(name);
sb.append(RANGE_ERROR);
sb.append(min);
sb.append('-');
sb.append(max);
sb.append(']');
signalViolation(property, sb.toString());
}
}
public static void checkMin(int value, int min, String property, String name) {
if (value < min) {
StringBuffer sb = new StringBuffer(name);
sb.append(MINIMUM);
sb.append(min);
signalViolation(property, sb.toString());
}
}
public static void checkTrue(boolean condition, String property, String msg) {
if (!condition) {
signalViolation(property, msg);
}
}
public static void checkFalse(boolean condition, String property, String msg) {
if (condition) {
signalViolation(property, msg);
}
}
public static void checkElementsNotNullUnique(Collection c, String property, String msg) {
if (c.contains(null)
|| new HashSet(c).size() != c.size()) {
signalViolation(property, msg + DUPLICATE);
}
}
public static void checkElementsUnique(Collection c, String property, String msg) {
if (new HashSet(c).size() != c.size()) {
signalViolation(property, msg + DUPLICATE);
}
}
public static void checkFile(File f, String property, String fileDescription) {
File cfgPath = ConfigPersister.getInstance().getConfigPath();
if (f == null || (!f.exists() && !Util.getAbsoluteFile(cfgPath, f).exists())) {
signalViolation(property, fileDescription + " doesn't exist.");
}
}
public static void checkOptFile(File f, String property, String fileDescription) {
if (f != null && f.getPath().length() > 0) {
checkFile(f, property, fileDescription);
}
}
public static void checkRelativeWinPath(String path, String property, String msg) {
if (path.startsWith("/")
|| path.startsWith("\\")
|| path.indexOf(':') != -1) {
signalViolation(property, msg);
}
}
public static void signalLengthViolation(String property, String name, int maxLength) {
final StringBuffer sb = new StringBuffer(name);
sb.append(" exceeds the maximum length of ");
sb.append(maxLength);
sb.append(" characters.");
throw new InvariantViolationException(property, sb.toString());
}
public static void signalViolation(String property, String msg) {
throw new InvariantViolationException(property, msg);
}
}

View File

@@ -0,0 +1,228 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 21, 2005
*/
package net.sf.launch4j.config;
import java.io.File;
import java.util.List;
import net.sf.launch4j.binding.IValidatable;
import net.sf.launch4j.binding.Validator;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Config implements IValidatable {
public static final String HEADER = "header";
public static final String JAR = "jar";
public static final String OUTFILE = "outfile";
public static final String ERR_TITLE = "errTitle";
public static final String JAR_ARGS = "jarArgs";
public static final String CHDIR = "chdir";
public static final String CUSTOM_PROC_NAME = "customProcName";
public static final String STAY_ALIVE = "stayAlive";
public static final String ICON = "icon";
public static final int GUI_HEADER = 0;
public static final int CONSOLE_HEADER = 1;
public static final int CUSTOM_HEADER = 2;
private int headerType;
private List headerObjects;
private List libs;
private File jar;
private File outfile;
// runtime configuration
private String errTitle;
private String jarArgs;
private String chdir;
private boolean customProcName = false;
private boolean stayAlive = false;
private File icon;
private Jre jre;
private Splash splash;
private VersionInfo versionInfo;
public void checkInvariants() {
Validator.checkTrue(outfile != null && outfile.getPath().endsWith(".exe"),
"outfile", "Specify output file with .exe extension.");
Validator.checkFile(jar, "jar", "Application jar");
if (!Validator.isEmpty(chdir)) {
Validator.checkRelativeWinPath(chdir,
"chdir", "'chdir' must be a path relative to the executable.");
Validator.checkFalse(chdir.toLowerCase().equals("true")
|| chdir.toLowerCase().equals("false"),
"chdir", "'chdir' is now a path instead of a boolean, please check the docs.");
}
Validator.checkOptFile(icon, "icon", "Icon");
Validator.checkOptString(jarArgs, 128, "jarArgs", "Jar arguments");
Validator.checkOptString(errTitle, 128, "errTitle", "Error title");
Validator.checkRange(headerType, GUI_HEADER, CONSOLE_HEADER,
"headerType", "Invalid header type"); // TODO add custom header check
Validator.checkTrue(headerType != CONSOLE_HEADER || splash == null,
"headerType", "Splash screen is not implemented by console header.");
// TODO libs
jre.checkInvariants();
}
public void validate() {
checkInvariants();
if (splash != null) {
splash.checkInvariants();
}
if (versionInfo != null) {
versionInfo.checkInvariants();
}
}
/** Change current directory to EXE location. */
public String getChdir() {
return chdir;
}
public void setChdir(String chdir) {
this.chdir = chdir;
}
/** Constant command line arguments passed to application jar. */
public String getJarArgs() {
return jarArgs;
}
public void setJarArgs(String jarArgs) {
this.jarArgs = jarArgs;
}
/** Optional, error message box title. */
public String getErrTitle() {
return errTitle;
}
public void setErrTitle(String errTitle) {
this.errTitle = errTitle;
}
/** launch4j header file. */
public int getHeaderType() {
return headerType;
}
public void setHeaderType(int headerType) {
this.headerType = headerType;
}
public List getHeaderObjects() {
// switch (_headerType) {
// case GUI_HEADER:
// return
// case CONSOLE_HEADER:
// FIXME
// default:
return headerObjects;
}
public void setHeaderObject(List headerObjects) {
this.headerObjects = headerObjects;
}
public List getLibs() {
return libs;
// FIXME default libs if null or empty
}
public void setLibs(List libs) {
this.libs = libs;
}
/** ICO file. */
public File getIcon() {
return icon;
}
public void setIcon(File icon) {
this.icon = icon;
}
/** Jar to wrap. */
public File getJar() {
return jar;
}
public void setJar(File jar) {
this.jar = jar;
}
/** JRE configuration */
public Jre getJre() {
return jre;
}
public void setJre(Jre jre) {
this.jre = jre;
}
/** Output EXE file. */
public File getOutfile() {
return outfile;
}
public void setOutfile(File outfile) {
this.outfile = outfile;
}
/** Custom process name as the output EXE file name. */
public boolean isCustomProcName() {
return customProcName;
}
public void setCustomProcName(boolean customProcName) {
this.customProcName = customProcName;
}
/** Splash screen configuration. */
public Splash getSplash() {
return splash;
}
public void setSplash(Splash splash) {
this.splash = splash;
}
/** Stay alive after launching the application. */
public boolean isStayAlive() {
return stayAlive;
}
public void setStayAlive(boolean stayAlive) {
this.stayAlive = stayAlive;
}
public VersionInfo getVersionInfo() {
return versionInfo;
}
public void setVersionInfo(VersionInfo versionInfo) {
this.versionInfo = versionInfo;
}
}

View File

@@ -0,0 +1,202 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 22, 2005
*/
package net.sf.launch4j.config;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import net.sf.launch4j.Util;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ConfigPersister {
private static final ConfigPersister _instance = new ConfigPersister();
private final XStream _xstream;
private Config _config;
private File _configPath;
private ConfigPersister() {
_xstream = new XStream(new DomDriver());
_xstream.alias("launch4jConfig", Config.class);
_xstream.alias("jre", Jre.class);
_xstream.alias("splash", Splash.class);
_xstream.alias("versionInfo", VersionInfo.class);
}
public static ConfigPersister getInstance() {
return _instance;
}
public Config getConfig() {
return _config;
}
public File getConfigPath() {
return _configPath;
}
public File getOutputPath() throws IOException {
if (_config.getOutfile().isAbsolute()) {
return _config.getOutfile().getParentFile();
}
File parent = _config.getOutfile().getParentFile();
return (parent != null) ? new File(_configPath, parent.getPath()) : _configPath;
}
public File getOutputFile() throws IOException {
return _config.getOutfile().isAbsolute()
? _config.getOutfile()
: new File(getOutputPath(), _config.getOutfile().getName());
}
public void createBlank() {
_config = new Config();
_config.setJre(new Jre());
_configPath = null;
}
public void setAntConfig(Config c, File basedir) {
_config = c;
_configPath = basedir;
}
public void load(File f) throws ConfigPersisterException {
try {
BufferedReader r = new BufferedReader(new FileReader(f));
_config = (Config) _xstream.fromXML(r);
r.close();
setConfigPath(f);
} catch (Exception e) {
throw new ConfigPersisterException(e);
}
}
/**
* Imports launch4j 1.x.x config file.
*/
public void loadVersion1(File f) throws ConfigPersisterException {
try {
Props props = new Props(f);
_config = new Config();
String header = props.getProperty(Config.HEADER);
_config.setHeaderType(header == null
|| header.toLowerCase().equals("guihead.bin") ? 0 : 1);
_config.setJar(props.getFile(Config.JAR));
_config.setOutfile(props.getFile(Config.OUTFILE));
_config.setJre(new Jre());
_config.getJre().setPath(props.getProperty(Jre.PATH));
_config.getJre().setMinVersion(props.getProperty(Jre.MIN_VERSION));
_config.getJre().setMaxVersion(props.getProperty(Jre.MAX_VERSION));
_config.getJre().setArgs(props.getProperty(Jre.ARGS));
_config.setJarArgs(props.getProperty(Config.JAR_ARGS));
_config.setChdir("true".equals(props.getProperty(Config.CHDIR)) ? "." : null);
_config.setCustomProcName("true".equals(
props.getProperty("setProcName"))); // 1.x
_config.setStayAlive("true".equals(props.getProperty(Config.STAY_ALIVE)));
_config.setErrTitle(props.getProperty(Config.ERR_TITLE));
_config.setIcon(props.getFile(Config.ICON));
File splashFile = props.getFile(Splash.SPLASH_FILE);
if (splashFile != null) {
_config.setSplash(new Splash());
_config.getSplash().setFile(splashFile);
String waitfor = props.getProperty("waitfor"); // 1.x
_config.getSplash().setWaitForWindow(waitfor != null && !waitfor.equals(""));
String splashTimeout = props.getProperty(Splash.TIMEOUT);
if (splashTimeout != null) {
_config.getSplash().setTimeout(Integer.parseInt(splashTimeout));
}
_config.getSplash().setTimeoutErr("true".equals(
props.getProperty(Splash.TIMEOUT_ERR)));
} else {
_config.setSplash(null);
}
setConfigPath(f);
} catch (IOException e) {
throw new ConfigPersisterException(e);
}
}
public void save(File f) throws ConfigPersisterException {
try {
BufferedWriter w = new BufferedWriter(new FileWriter(f));
_xstream.toXML(_config, w);
w.close();
setConfigPath(f);
} catch (Exception e) {
throw new ConfigPersisterException(e);
}
}
private void setConfigPath(File configFile) {
_configPath = configFile.getAbsoluteFile().getParentFile();
}
private class Props {
final Properties _properties = new Properties();
public Props(File f) throws IOException {
FileInputStream is = null;
try {
is = new FileInputStream(f);
_properties.load(is);
} finally {
Util.close(is);
}
}
/**
* Get property and remove trailing # comments.
*/
public String getProperty(String key) {
String p = _properties.getProperty(key);
if (p == null) {
return null;
}
int x = p.indexOf('#');
if (x == -1) {
return p;
}
do {
x--;
} while (x > 0 && (p.charAt(x) == ' ' || p.charAt(x) == '\t'));
return (x == 0) ? "" : p.substring(0, x + 1);
}
public File getFile(String key) {
String value = getProperty(key);
return value != null ? new File(value) : null;
}
}
}

View File

@@ -0,0 +1,37 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 22, 2005
*/
package net.sf.launch4j.config;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ConfigPersisterException extends Exception {
public ConfigPersisterException(String msg, Throwable t) {
super(msg, t);
}
public ConfigPersisterException(Throwable t) {
super(t);
}
}

View File

@@ -0,0 +1,125 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 21, 2005
*/
package net.sf.launch4j.config;
import net.sf.launch4j.binding.IValidatable;
import net.sf.launch4j.binding.Validator;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Jre implements IValidatable {
public static final String VERSION_PATTERN = "(\\d\\.){2}\\d(_\\d+)?";
public static final String PATH = "jrepath";
public static final String MIN_VERSION = "javamin";
public static final String MAX_VERSION = "javamax";
public static final String ARGS = "jvmArgs";
private String path;
private String minVersion;
private String maxVersion;
private int initialHeapSize;
private int maxHeapSize;
private String args;
public void checkInvariants() {
Validator.checkOptString(minVersion, 10, VERSION_PATTERN,
"jre.minVersion", "Minimum JRE version should be x.x.x[_xx]");
Validator.checkOptString(maxVersion, 10, VERSION_PATTERN,
"jre.maxVersion", "Maximum JRE version should be x.x.x[_xx]");
if (Validator.isEmpty(path)) {
Validator.checkFalse(Validator.isEmpty(minVersion),
"jre.path", "Specify embedded JRE path or/and minimum JRE version.");
} else {
Validator.checkRelativeWinPath(path,
"jre.path", "Embedded JRE path must be a path relative to the executable.");
}
if (!Validator.isEmpty(maxVersion)) {
Validator.checkFalse(Validator.isEmpty(minVersion),
"jre.minVersion", "Specify minimum JRE version.");
Validator.checkTrue(minVersion.compareTo(maxVersion) <= 0,
"jre.minVersion", "Minimum JRE version is greater than the maximum.");
}
Validator.checkTrue(initialHeapSize >= 0, "jre.initialHeapSize",
"Initial heap size cannot be negative," +
" specify 0 or leave the field blank to use the JVM default.");
Validator.checkTrue(maxHeapSize == 0 || initialHeapSize <= maxHeapSize,
"jre.maxHeapSize", "Maximum heap size cannot be less than the initial" +
" size, specify 0 or leave the field blank to use the JVM default.");
Validator.checkOptString(args, 512, "jre.args", "JVM arguments");
}
/** JVM arguments: XOptions, system properties. */
public String getArgs() {
return args;
}
public void setArgs(String args) {
this.args = args;
}
/** Max Java version (x.x.x) */
public String getMaxVersion() {
return maxVersion;
}
public void setMaxVersion(String maxVersion) {
this.maxVersion = maxVersion;
}
/** Min Java version (x.x.x) */
public String getMinVersion() {
return minVersion;
}
public void setMinVersion(String minVersion) {
this.minVersion = minVersion;
}
/** JRE path */
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
/** Initial heap size in MB */
public int getInitialHeapSize() {
return initialHeapSize;
}
public void setInitialHeapSize(int initialHeapSize) {
this.initialHeapSize = initialHeapSize;
}
/** Max heap size in MB */
public int getMaxHeapSize() {
return maxHeapSize;
}
public void setMaxHeapSize(int maxHeapSize) {
this.maxHeapSize = maxHeapSize;
}
}

View File

@@ -0,0 +1,84 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on Apr 21, 2005
*/
package net.sf.launch4j.config;
import java.io.File;
import net.sf.launch4j.binding.IValidatable;
import net.sf.launch4j.binding.Validator;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class Splash implements IValidatable {
public static final String SPLASH_FILE = "splash";
public static final String WAIT_FOR_TITLE = "waitForTitle";
public static final String TIMEOUT = "splashTimeout";
public static final String TIMEOUT_ERR = "splashTimeoutErr";
private File file;
private boolean waitForWindow = true;
private int timeout = 60;
private boolean timeoutErr = true;
public void checkInvariants() {
Validator.checkFile(file, "splash.file", "Splash file");
Validator.checkRange(timeout, 1, 60 * 15, "splash.timeout", "Splash timeout");
}
/** Splash screen in BMP format. */
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
/** Splash timeout in seconds. */
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
/** Signal error on splash timeout. */
public boolean isTimeoutErr() {
return timeoutErr;
}
public void setTimeoutErr(boolean timeoutErr) {
this.timeoutErr = timeoutErr;
}
/** Hide splash screen when the child process displayes the first window. */
public boolean getWaitForWindow() {
return waitForWindow;
}
public void setWaitForWindow(boolean waitForWindow) {
this.waitForWindow = waitForWindow;
}
}

View File

@@ -0,0 +1,135 @@
/*
* Created on May 21, 2005
*/
package net.sf.launch4j.config;
import net.sf.launch4j.binding.IValidatable;
import net.sf.launch4j.binding.Validator;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class VersionInfo implements IValidatable {
public static final String VERSION_PATTERN = "(\\d+\\.){3}\\d+";
private static final int MAX_LEN = 150;
private String fileVersion;
private String txtFileVersion;
private String fileDescription;
private String copyright;
private String productVersion;
private String txtProductVersion;
private String productName;
private String companyName;
private String internalName;
private String originalFilename;
public void checkInvariants() {
Validator.checkString(fileVersion, 20, VERSION_PATTERN,
"versionInfo.fileVersion", "File version, should be 'x.x.x.x'");
Validator.checkString(txtFileVersion, 50,
"versionInfo.txtFileVersion", "Free form file version");
Validator.checkString(fileDescription, MAX_LEN,
"versionInfo.fileDescription", "File description");
Validator.checkString(copyright, MAX_LEN,
"versionInfo.copyright", "Copyright");
Validator.checkString(productVersion, 20, VERSION_PATTERN,
"versionInfo.productVersion", "Product version, should be 'x.x.x.x'");
Validator.checkString(txtProductVersion, 50,
"versionInfo.txtProductVersion", "Free from product version");
Validator.checkString(productName, MAX_LEN,
"versionInfo.productName", "Product name");
Validator.checkOptString(companyName, MAX_LEN,
"versionInfo.companyName", "Company name");
Validator.checkString(internalName, 50,
"versionInfo.internalName", "Internal name");
Validator.checkTrue(!internalName.endsWith(".exe"),
"versionInfo.internalName",
"Internal name shouldn't have the .exe extension.");
Validator.checkString(originalFilename, 50,
"versionInfo.originalFilename", "Original filename");
Validator.checkTrue(originalFilename.endsWith(".exe"),
"versionInfo.originalFilename",
"Original filename should end with the .exe extension.");
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public String getCopyright() {
return copyright;
}
public void setCopyright(String copyright) {
this.copyright = copyright;
}
public String getFileDescription() {
return fileDescription;
}
public void setFileDescription(String fileDescription) {
this.fileDescription = fileDescription;
}
public String getFileVersion() {
return fileVersion;
}
public void setFileVersion(String fileVersion) {
this.fileVersion = fileVersion;
}
public String getInternalName() {
return internalName;
}
public void setInternalName(String internalName) {
this.internalName = internalName;
}
public String getOriginalFilename() {
return originalFilename;
}
public void setOriginalFilename(String originalFilename) {
this.originalFilename = originalFilename;
}
public String getProductName() {
return productName;
}
public void setProductName(String productName) {
this.productName = productName;
}
public String getProductVersion() {
return productVersion;
}
public void setProductVersion(String productVersion) {
this.productVersion = productVersion;
}
public String getTxtFileVersion() {
return txtFileVersion;
}
public void setTxtFileVersion(String txtFileVersion) {
this.txtFileVersion = txtFileVersion;
}
public String getTxtProductVersion() {
return txtProductVersion;
}
public void setTxtProductVersion(String txtProductVersion) {
this.txtProductVersion = txtProductVersion;
}
}

View File

@@ -0,0 +1,534 @@
package net.sf.launch4j.form;
import com.jeta.forms.components.separator.TitledSeparator;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public abstract class ConfigForm extends JPanel
{
protected final JTabbedPane _tab = new JTabbedPane();
protected final JButton _outfileButton = new JButton();
protected final JTextField _outfileField = new JTextField();
protected final JTextField _errorTitleField = new JTextField();
protected final JCheckBox _customProcNameCheck = new JCheckBox();
protected final JCheckBox _stayAliveCheck = new JCheckBox();
protected final JTextField _iconField = new JTextField();
protected final JTextField _jarField = new JTextField();
protected final JButton _jarButton = new JButton();
protected final JButton _iconButton = new JButton();
protected final JTextField _jarArgsField = new JTextField();
protected final JTextField _chdirField = new JTextField();
protected final JRadioButton _guiHeaderRadio = new JRadioButton();
protected final ButtonGroup _headerButtonGroup = new ButtonGroup();
protected final JRadioButton _consoleHeaderRadio = new JRadioButton();
protected final JList _objectFileList = new JList();
protected final JList _w32apiList = new JList();
protected final JTextField _jrePathField = new JTextField();
protected final JTextField _jreMinField = new JTextField();
protected final JTextField _jreMaxField = new JTextField();
protected final JTextArea _jvmArgsTextArea = new JTextArea();
protected final JTextField _initialHeapSizeField = new JTextField();
protected final JTextField _maxHeapSizeField = new JTextField();
protected final JCheckBox _timeoutErrCheck = new JCheckBox();
protected final JTextField _splashFileField = new JTextField();
protected final JTextField _timeoutField = new JTextField();
protected final JButton _splashFileButton = new JButton();
protected final JCheckBox _splashCheck = new JCheckBox();
protected final JCheckBox _waitForWindowCheck = new JCheckBox();
protected final JCheckBox _versionInfoCheck = new JCheckBox();
protected final JTextField _fileVersionField = new JTextField();
protected final JTextField _productVersionField = new JTextField();
protected final JTextField _fileDescriptionField = new JTextField();
protected final JTextField _copyrightField = new JTextField();
protected final JTextField _txtFileVersionField = new JTextField();
protected final JTextField _txtProductVersionField = new JTextField();
protected final JTextField _productNameField = new JTextField();
protected final JTextField _originalFilenameField = new JTextField();
protected final JTextField _internalNameField = new JTextField();
protected final JTextField _companyNameField = new JTextField();
protected final JTextArea _logTextArea = new JTextArea();
/**
* Default constructor
*/
public ConfigForm()
{
initializePanel();
}
/**
* Adds fill components to empty cells in the first row and first column of the grid.
* This ensures that the grid spacing will be the same as shown in the designer.
* @param cols an array of column indices in the first row where fill components should be added.
* @param rows an array of row indices in the first column where fill components should be added.
*/
void addFillComponents( Container panel, int[] cols, int[] rows )
{
Dimension filler = new Dimension(10,10);
boolean filled_cell_11 = false;
CellConstraints cc = new CellConstraints();
if ( cols.length > 0 && rows.length > 0 )
{
if ( cols[0] == 1 && rows[0] == 1 )
{
/** add a rigid area */
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
filled_cell_11 = true;
}
}
for( int index = 0; index < cols.length; index++ )
{
if ( cols[index] == 1 && filled_cell_11 )
{
continue;
}
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
}
for( int index = 0; index < rows.length; index++ )
{
if ( rows[index] == 1 && filled_cell_11 )
{
continue;
}
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
}
}
/**
* Helper method to load an image file from the CLASSPATH
* @param imageName the package and name of the file to load relative to the CLASSPATH
* @return an ImageIcon instance with the specified image file
* @throws IllegalArgumentException if the image resource cannot be loaded.
*/
public ImageIcon loadImage( String imageName )
{
try
{
ClassLoader classloader = getClass().getClassLoader();
java.net.URL url = classloader.getResource( imageName );
if ( url != null )
{
ImageIcon icon = new ImageIcon( url );
return icon;
}
}
catch( Exception e )
{
e.printStackTrace();
}
throw new IllegalArgumentException( "Unable to load image: " + imageName );
}
public JPanel createPanel()
{
JPanel jpanel1 = new JPanel();
FormLayout formlayout1 = new FormLayout("FILL:3DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:3DLU:NONE","CENTER:3DLU:NONE,FILL:DEFAULT:NONE,CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:3DLU:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
_tab.setName("tab");
_tab.addTab("Basic",null,createPanel1());
_tab.addTab("Header",null,createPanel2());
_tab.addTab("JRE",null,createPanel3());
_tab.addTab("Splash",null,createPanel4());
_tab.addTab("Version Info",null,createPanel5());
jpanel1.add(_tab,cc.xy(2,2));
_logTextArea.setName("logTextArea");
JScrollPane jscrollpane1 = new JScrollPane();
jscrollpane1.setViewportView(_logTextArea);
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jpanel1.add(jscrollpane1,cc.xy(2,6));
TitledSeparator titledseparator1 = new TitledSeparator();
titledseparator1.setText("Log");
jpanel1.add(titledseparator1,cc.xy(2,4));
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7 });
return jpanel1;
}
public JPanel createPanel1()
{
JPanel jpanel1 = new JPanel();
FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(55DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:3DLU:NONE,FILL:26PX:NONE,FILL:7DLU:NONE","CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
_outfileButton.setIcon(loadImage("images/open16.png"));
_outfileButton.setName("outfileButton");
jpanel1.add(_outfileButton,cc.xy(6,2));
JLabel jlabel1 = new JLabel();
jlabel1.setText("<html><b>Output file</b></html>");
jpanel1.add(jlabel1,cc.xy(2,2));
JLabel jlabel2 = new JLabel();
jlabel2.setText("Error title");
jpanel1.add(jlabel2,cc.xy(2,12));
_outfileField.setName("outfileField");
_outfileField.setToolTipText("Output executable file.");
jpanel1.add(_outfileField,cc.xy(4,2));
_errorTitleField.setName("errorTitleField");
_errorTitleField.setToolTipText("Launch4j signals errors using a message box, you can set it's title to the application's name.");
jpanel1.add(_errorTitleField,cc.xy(4,12));
_customProcNameCheck.setActionCommand("Custom process name");
_customProcNameCheck.setName("customProcNameCheck");
_customProcNameCheck.setText("Custom process name");
jpanel1.add(_customProcNameCheck,cc.xy(4,14));
_stayAliveCheck.setActionCommand("Stay alive after launching a GUI application");
_stayAliveCheck.setName("stayAliveCheck");
_stayAliveCheck.setText("Stay alive after launching a GUI application");
jpanel1.add(_stayAliveCheck,cc.xy(4,16));
JLabel jlabel3 = new JLabel();
jlabel3.setText("Icon");
jpanel1.add(jlabel3,cc.xy(2,6));
_iconField.setName("iconField");
_iconField.setToolTipText("Application icon.");
jpanel1.add(_iconField,cc.xy(4,6));
_jarField.setName("jarField");
_jarField.setToolTipText("Application jar.");
jpanel1.add(_jarField,cc.xy(4,4));
JLabel jlabel4 = new JLabel();
jlabel4.setText("<html><b>Jar</b></html>");
jpanel1.add(jlabel4,cc.xy(2,4));
_jarButton.setIcon(loadImage("images/open16.png"));
_jarButton.setName("jarButton");
jpanel1.add(_jarButton,cc.xy(6,4));
_iconButton.setIcon(loadImage("images/open16.png"));
_iconButton.setName("iconButton");
jpanel1.add(_iconButton,cc.xy(6,6));
JLabel jlabel5 = new JLabel();
jlabel5.setText("Jar arguments");
jpanel1.add(jlabel5,cc.xy(2,10));
_jarArgsField.setName("jarArgsField");
_jarArgsField.setToolTipText("Constant command line arguments passed to the application.");
jpanel1.add(_jarArgsField,cc.xy(4,10));
JLabel jlabel6 = new JLabel();
jlabel6.setText("Options");
jpanel1.add(jlabel6,cc.xy(2,14));
JLabel jlabel7 = new JLabel();
jlabel7.setText("Change dir");
jpanel1.add(jlabel7,cc.xy(2,8));
_chdirField.setName("chdirField");
_chdirField.setToolTipText("Change current directory to a location relative to the executable. Empty field has no effect, . - changes directory to the exe location.");
jpanel1.add(_chdirField,cc.xy(4,8));
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 });
return jpanel1;
}
public JPanel createPanel2()
{
JPanel jpanel1 = new JPanel();
FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(55DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:7DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:7DLU:NONE","CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,FILL:DEFAULT:GROW(0.2),CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:9DLU:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
JLabel jlabel1 = new JLabel();
jlabel1.setText("Header type");
jpanel1.add(jlabel1,cc.xy(2,2));
_guiHeaderRadio.setActionCommand("GUI");
_guiHeaderRadio.setName("guiHeaderRadio");
_guiHeaderRadio.setText("GUI");
_headerButtonGroup.add(_guiHeaderRadio);
jpanel1.add(_guiHeaderRadio,cc.xy(4,2));
_consoleHeaderRadio.setActionCommand("Console");
_consoleHeaderRadio.setName("consoleHeaderRadio");
_consoleHeaderRadio.setText("Console");
_headerButtonGroup.add(_consoleHeaderRadio);
jpanel1.add(_consoleHeaderRadio,cc.xy(6,2));
JLabel jlabel2 = new JLabel();
jlabel2.setText("Object files");
jpanel1.add(jlabel2,new CellConstraints(2,4,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
_objectFileList.setName("objectFileList");
_objectFileList.setToolTipText("Compiled header files.");
JScrollPane jscrollpane1 = new JScrollPane();
jscrollpane1.setViewportView(_objectFileList);
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jpanel1.add(jscrollpane1,cc.xywh(4,4,4,1));
JLabel jlabel3 = new JLabel();
jlabel3.setText("w32api");
jpanel1.add(jlabel3,new CellConstraints(2,6,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
_w32apiList.setName("w32apiList");
_w32apiList.setToolTipText("DLLs required by header.");
JScrollPane jscrollpane2 = new JScrollPane();
jscrollpane2.setViewportView(_w32apiList);
jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jpanel1.add(jscrollpane2,cc.xywh(4,6,4,1));
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7 });
return jpanel1;
}
public JPanel createPanel3()
{
JPanel jpanel1 = new JPanel();
FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(55DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:60DLU:NONE,FILL:3DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:7DLU:NONE","CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:9DLU:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
JLabel jlabel1 = new JLabel();
jlabel1.setText("<html><b>Emb. JRE path</b></html>");
jpanel1.add(jlabel1,cc.xy(2,2));
JLabel jlabel2 = new JLabel();
jlabel2.setText("<html><b>Min JRE version</b></html>");
jpanel1.add(jlabel2,cc.xy(2,4));
JLabel jlabel3 = new JLabel();
jlabel3.setText("Max JRE version");
jpanel1.add(jlabel3,cc.xy(2,6));
JLabel jlabel4 = new JLabel();
jlabel4.setText("JVM arguments");
jpanel1.add(jlabel4,new CellConstraints(2,12,1,1,CellConstraints.DEFAULT,CellConstraints.TOP));
_jrePathField.setName("jrePathField");
_jrePathField.setToolTipText("Embedded JRE path relative to the executable.");
jpanel1.add(_jrePathField,cc.xywh(4,2,4,1));
_jreMinField.setName("jreMinField");
jpanel1.add(_jreMinField,cc.xy(4,4));
_jreMaxField.setName("jreMaxField");
jpanel1.add(_jreMaxField,cc.xy(4,6));
_jvmArgsTextArea.setName("jvmArgsTextArea");
_jvmArgsTextArea.setToolTipText("Accepts everything you would normally pass to java/javaw launcher: assertion options, system properties and X options.");
JScrollPane jscrollpane1 = new JScrollPane();
jscrollpane1.setViewportView(_jvmArgsTextArea);
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jpanel1.add(jscrollpane1,cc.xywh(4,12,4,1));
JLabel jlabel5 = new JLabel();
jlabel5.setText("Initial heap size");
jpanel1.add(jlabel5,cc.xy(2,8));
JLabel jlabel6 = new JLabel();
jlabel6.setText("Max heap size");
jpanel1.add(jlabel6,cc.xy(2,10));
JLabel jlabel7 = new JLabel();
jlabel7.setText("MB");
jpanel1.add(jlabel7,cc.xy(6,8));
JLabel jlabel8 = new JLabel();
jlabel8.setText("MB");
jpanel1.add(jlabel8,cc.xy(6,10));
_initialHeapSizeField.setName("initialHeapSizeField");
jpanel1.add(_initialHeapSizeField,cc.xy(4,8));
_maxHeapSizeField.setName("maxHeapSizeField");
jpanel1.add(_maxHeapSizeField,cc.xy(4,10));
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 });
return jpanel1;
}
public JPanel createPanel4()
{
JPanel jpanel1 = new JPanel();
FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(55DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:60DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:3DLU:NONE,FILL:26PX:NONE,FILL:7DLU:NONE","CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
JLabel jlabel1 = new JLabel();
jlabel1.setText("Splash file");
jpanel1.add(jlabel1,cc.xy(2,4));
JLabel jlabel2 = new JLabel();
jlabel2.setText("Wait for window");
jpanel1.add(jlabel2,cc.xy(2,6));
JLabel jlabel3 = new JLabel();
jlabel3.setText("Timeout [s]");
jpanel1.add(jlabel3,cc.xy(2,8));
_timeoutErrCheck.setActionCommand("Signal error on timeout");
_timeoutErrCheck.setName("timeoutErrCheck");
_timeoutErrCheck.setText("Signal error on timeout");
_timeoutErrCheck.setToolTipText("True signals an error on splash timeout, false closes the splash screen quietly.");
jpanel1.add(_timeoutErrCheck,cc.xywh(4,10,2,1));
_splashFileField.setName("splashFileField");
_splashFileField.setToolTipText("Splash screen file in BMP format.");
jpanel1.add(_splashFileField,cc.xywh(4,4,2,1));
_timeoutField.setName("timeoutField");
_timeoutField.setToolTipText("Number of seconds after which the splash screen must close. Splash timeout may cause an error depending on splashTimeoutErr property.");
jpanel1.add(_timeoutField,cc.xy(4,8));
_splashFileButton.setIcon(loadImage("images/open16.png"));
_splashFileButton.setName("splashFileButton");
jpanel1.add(_splashFileButton,cc.xy(7,4));
_splashCheck.setActionCommand("Enable splash screen");
_splashCheck.setName("splashCheck");
_splashCheck.setText("Enable splash screen");
jpanel1.add(_splashCheck,cc.xywh(4,2,2,1));
_waitForWindowCheck.setActionCommand("Close splash screen when an application window appears");
_waitForWindowCheck.setName("waitForWindowCheck");
_waitForWindowCheck.setText("Close splash screen when an application window appears");
jpanel1.add(_waitForWindowCheck,cc.xywh(4,6,2,1));
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11 });
return jpanel1;
}
public JPanel createPanel5()
{
JPanel jpanel1 = new JPanel();
FormLayout formlayout1 = new FormLayout("FILL:7DLU:NONE,RIGHT:MAX(55DLU;DEFAULT):NONE,FILL:3DLU:NONE,FILL:60DLU:NONE,FILL:7DLU:NONE,RIGHT:DEFAULT:NONE,FILL:3DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:7DLU:NONE","CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:3DLU:NONE,CENTER:DEFAULT:NONE,CENTER:9DLU:NONE");
CellConstraints cc = new CellConstraints();
jpanel1.setLayout(formlayout1);
_versionInfoCheck.setActionCommand("Add version information");
_versionInfoCheck.setName("versionInfoCheck");
_versionInfoCheck.setText("Add version information");
jpanel1.add(_versionInfoCheck,cc.xywh(4,2,5,1));
JLabel jlabel1 = new JLabel();
jlabel1.setText("File version");
jpanel1.add(jlabel1,cc.xy(2,4));
_fileVersionField.setName("fileVersionField");
_fileVersionField.setToolTipText("Version number 'x.x.x.x'");
jpanel1.add(_fileVersionField,cc.xy(4,4));
TitledSeparator titledseparator1 = new TitledSeparator();
titledseparator1.setText("Additional information");
jpanel1.add(titledseparator1,cc.xywh(2,10,7,1));
JLabel jlabel2 = new JLabel();
jlabel2.setText("Product version");
jpanel1.add(jlabel2,cc.xy(2,12));
_productVersionField.setName("productVersionField");
_productVersionField.setToolTipText("Version number 'x.x.x.x'");
jpanel1.add(_productVersionField,cc.xy(4,12));
JLabel jlabel3 = new JLabel();
jlabel3.setText("File description");
jpanel1.add(jlabel3,cc.xy(2,6));
_fileDescriptionField.setName("fileDescriptionField");
_fileDescriptionField.setToolTipText("File description presented to the user.");
jpanel1.add(_fileDescriptionField,cc.xywh(4,6,5,1));
JLabel jlabel4 = new JLabel();
jlabel4.setText("Copyright");
jpanel1.add(jlabel4,cc.xy(2,8));
_copyrightField.setName("copyrightField");
jpanel1.add(_copyrightField,cc.xywh(4,8,5,1));
JLabel jlabel5 = new JLabel();
jlabel5.setText("Free form");
jpanel1.add(jlabel5,cc.xy(6,4));
_txtFileVersionField.setName("txtFileVersionField");
_txtFileVersionField.setToolTipText("Free form file version, for example '1.20.RC1'.");
jpanel1.add(_txtFileVersionField,cc.xy(8,4));
JLabel jlabel6 = new JLabel();
jlabel6.setText("Free form");
jpanel1.add(jlabel6,cc.xy(6,12));
_txtProductVersionField.setName("txtProductVersionField");
_txtProductVersionField.setToolTipText("Free form product version, for example '1.20.RC1'.");
jpanel1.add(_txtProductVersionField,cc.xy(8,12));
JLabel jlabel7 = new JLabel();
jlabel7.setText("Product name");
jpanel1.add(jlabel7,cc.xy(2,14));
_productNameField.setName("productNameField");
jpanel1.add(_productNameField,cc.xywh(4,14,5,1));
JLabel jlabel8 = new JLabel();
jlabel8.setText("Original filename");
jpanel1.add(jlabel8,cc.xy(2,20));
_originalFilenameField.setName("originalFilenameField");
_originalFilenameField.setToolTipText("Original name of the file without the path. Allows to determine whether a file has been renamed by a user.");
jpanel1.add(_originalFilenameField,cc.xywh(4,20,5,1));
JLabel jlabel9 = new JLabel();
jlabel9.setText("Internal name");
jpanel1.add(jlabel9,cc.xy(2,18));
_internalNameField.setName("internalNameField");
_internalNameField.setToolTipText("Internal name without extension, original filename or module name for example.");
jpanel1.add(_internalNameField,cc.xywh(4,18,5,1));
JLabel jlabel10 = new JLabel();
jlabel10.setText("Company name");
jpanel1.add(jlabel10,cc.xy(2,16));
_companyNameField.setName("companyNameField");
jpanel1.add(_companyNameField,cc.xywh(4,16,5,1));
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 });
return jpanel1;
}
/**
* Initializer
*/
protected void initializePanel()
{
setLayout(new BorderLayout());
add(createPanel(), BorderLayout.CENTER);
}
}

View File

@@ -0,0 +1,141 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on May 10, 2005
*/
package net.sf.launch4j.formimpl;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import net.sf.launch4j.FileChooserFilter;
import net.sf.launch4j.binding.Binding;
import net.sf.launch4j.binding.Bindings;
import net.sf.launch4j.binding.IValidatable;
import net.sf.launch4j.config.Splash;
import net.sf.launch4j.config.VersionInfo;
import net.sf.launch4j.form.ConfigForm;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class ConfigFormImpl extends ConfigForm {
private final JFileChooser _fileChooser = new JFileChooser();
private final Bindings _bindings = new Bindings();
public ConfigFormImpl() {
_outfileButton.addActionListener(new BrowseActionListener(
_outfileField, new FileChooserFilter("Windows executables (.exe)", ".exe")));
_jarButton.addActionListener(new BrowseActionListener(
_jarField, new FileChooserFilter("Jar files", ".jar")));
_iconButton.addActionListener(new BrowseActionListener(
_iconField, new FileChooserFilter("Icon files (.ico)", ".ico")));
_splashFileButton.addActionListener(new BrowseActionListener(
_splashFileField, new FileChooserFilter("Bitmap files (.bmp)", ".bmp")));
_bindings.add("outfile", _outfileField)
.add("jar", _jarField)
.add("icon", _iconField)
.add("jarArgs", _jarArgsField)
.add("errTitle", _errorTitleField)
.add("chdir", _chdirField)
.add("customProcName", _customProcNameCheck)
.add("stayAlive", _stayAliveCheck)
.add("headerType", new JRadioButton[] {_guiHeaderRadio, _consoleHeaderRadio})
// TODO header object files
// TODO w32api
.add("jre.path", _jrePathField)
.add("jre.minVersion", _jreMinField)
.add("jre.maxVersion", _jreMaxField)
.add("jre.initialHeapSize", _initialHeapSizeField)
.add("jre.maxHeapSize", _maxHeapSizeField)
.add("jre.args", _jvmArgsTextArea)
.addOptComponent("splash", Splash.class, _splashCheck)
.add("splash.file", _splashFileField)
.add("splash.waitForWindow", _waitForWindowCheck, true)
.add("splash.timeout", _timeoutField, "60")
.add("splash.timeoutErr", _timeoutErrCheck, true)
.addOptComponent("versionInfo", VersionInfo.class, _versionInfoCheck)
.add("versionInfo.fileVersion", _fileVersionField)
.add("versionInfo.productVersion", _productVersionField)
.add("versionInfo.fileDescription", _fileDescriptionField)
.add("versionInfo.internalName", _internalNameField)
.add("versionInfo.originalFilename", _originalFilenameField)
.add("versionInfo.productName", _productNameField)
.add("versionInfo.txtFileVersion", _txtFileVersionField)
.add("versionInfo.txtProductVersion", _txtProductVersionField)
.add("versionInfo.companyName", _companyNameField)
.add("versionInfo.copyright", _copyrightField);
}
private class BrowseActionListener implements ActionListener {
private final JTextField _field;
private final FileChooserFilter _filter;
public BrowseActionListener(JTextField field, FileChooserFilter filter) {
_field = field;
_filter = filter;
}
public void actionPerformed(ActionEvent e) {
if (!_field.isEnabled()) {
return;
}
_fileChooser.setFileFilter(_filter);
_fileChooser.setSelectedFile(new File(""));
int result = _field.equals(_outfileField)
? _fileChooser.showSaveDialog(MainFrame.getInstance())
: _fileChooser.showOpenDialog(MainFrame.getInstance());
if (result == JFileChooser.APPROVE_OPTION) {
_field.setText(_fileChooser.getSelectedFile().getPath());
}
}
}
public void clear() {
_bindings.clear();
}
public void put(IValidatable bean) {
_bindings.put(bean);
}
public void get(IValidatable bean) {
_bindings.get(bean);
}
public boolean isModified() {
return _bindings.isModified();
}
public JTextArea getLogTextArea() {
return _logTextArea;
}
public Binding getBinding(String property) {
return _bindings.getBinding(property);
}
}

View File

@@ -0,0 +1,67 @@
package net.sf.launch4j.formimpl;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.AWTEventListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
/**
* This is the glass pane class that intercepts screen interactions during
* system busy states.
*
* Based on JavaWorld article by Yexin Chen.
*/
public class GlassPane extends JComponent implements AWTEventListener {
private final Window _window;
public GlassPane(Window w) {
_window = w;
addMouseListener(new MouseAdapter() {});
addKeyListener(new KeyAdapter() {});
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
/**
* Receives all key events in the AWT and processes the ones that originated
* from the current window with the glass pane.
*
* @param event
* the AWTEvent that was fired
*/
public void eventDispatched(AWTEvent event) {
Object source = event.getSource();
if (event instanceof KeyEvent
&& source instanceof Component) {
/*
* If the event originated from the window w/glass pane,
* consume the event.
*/
if ((SwingUtilities.windowForComponent((Component) source) == _window)) {
((KeyEvent) event).consume();
}
}
}
/**
* Sets the glass pane as visible or invisible. The mouse cursor will be set
* accordingly.
*/
public void setVisible(boolean visible) {
if (visible) {
// Start receiving all events and consume them if necessary
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
} else {
// Stop receiving all events
Toolkit.getDefaultToolkit().removeAWTEventListener(this);
}
super.setVisible(visible);
}
}

View File

@@ -0,0 +1,319 @@
/*
launch4j :: Cross-platform Java application wrapper for creating Windows native executables
Copyright (C) 2005 Grzegorz Kowal
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; either version 2 of the License, or
(at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* Created on 2005-05-09
*/
package net.sf.launch4j.formimpl;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JToolBar;
import javax.swing.UIManager;
import com.jgoodies.plaf.Options;
import com.jgoodies.plaf.plastic.PlasticXPLookAndFeel;
import foxtrot.Task;
import foxtrot.Worker;
import net.sf.launch4j.Builder;
import net.sf.launch4j.BuilderException;
import net.sf.launch4j.ExecException;
import net.sf.launch4j.FileChooserFilter;
import net.sf.launch4j.Log;
import net.sf.launch4j.Main;
import net.sf.launch4j.Util;
import net.sf.launch4j.binding.BindingException;
import net.sf.launch4j.binding.InvariantViolationException;
import net.sf.launch4j.config.Config;
import net.sf.launch4j.config.ConfigPersister;
import net.sf.launch4j.config.ConfigPersisterException;
/**
* @author Copyright (C) 2005 Grzegorz Kowal
*/
public class MainFrame extends JFrame {
private static MainFrame _instance;
private final JToolBar _toolBar;
private final JButton _runButton;
private final ConfigFormImpl _configForm;
private final JFileChooser _fileChooser = new JFileChooser();
private File _outfile;
private boolean _saved = false;
public static void createInstance() {
try {
Toolkit.getDefaultToolkit().setDynamicLayout(true);
System.setProperty("sun.awt.noerasebackground","true");
// JGoodies
Options.setDefaultIconSize(new Dimension(16, 16)); // menu icons
Options.setUseNarrowButtons(false);
Options.setPopupDropShadowEnabled(true);
UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
_instance = new MainFrame();
} catch (Exception e) {
System.err.println(e);
}
}
public static MainFrame getInstance() {
return _instance;
}
public MainFrame() {
showConfigName(null);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new ExitWindowListener());
setGlassPane(new GlassPane(this));
_fileChooser.setFileFilter(new FileChooserFilter("launch4j config files (.xml, .cfg)",
new String[] {".xml", ".cfg"}));
_toolBar = new JToolBar();
_toolBar.setFloatable(false);
_toolBar.setRollover(true);
addButton("images/new.png", "New configuration", new NewActionListener());
addButton("images/open.png", "Open configuration or import 1.x", new OpenActionListener());
addButton("images/save.png", "Save configuration", new SaveActionListener());
_toolBar.addSeparator();
addButton("images/build.png", "Build wrapper", new BuildActionListener());
_runButton = addButton("images/run.png", "Test wrapper", new RunActionListener());
setRunEnabled(false);
_toolBar.addSeparator();
addButton("images/info.png", "About launch4j", new AboutActionListener());
_configForm = new ConfigFormImpl();
getContentPane().setLayout(new BorderLayout());
getContentPane().add(_toolBar, BorderLayout.NORTH);
getContentPane().add(_configForm, BorderLayout.CENTER);
_configForm.clear();
pack();
Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
Dimension fr = getSize();
fr.height += 100;
setBounds((scr.width - fr.width) / 2, (scr.height - fr.height) / 2, fr.width, fr.height);
setVisible(true);
}
private JButton addButton(String iconPath, String tooltip, ActionListener l) {
ImageIcon icon = new ImageIcon(MainFrame.class.getClassLoader().getResource(iconPath));
JButton b = new JButton(icon);
b.setToolTipText(tooltip);
b.addActionListener(l);
_toolBar.add(b);
return b;
}
public void info(String text) {
JOptionPane.showMessageDialog(this,
text,
Main.PROGRAM_NAME,
JOptionPane.INFORMATION_MESSAGE);
}
public void warn(String text) {
JOptionPane.showMessageDialog(this,
text,
Main.PROGRAM_NAME,
JOptionPane.WARNING_MESSAGE);
}
public void warn(InvariantViolationException e) {
e.getBinding().markInvalid();
warn(e.getMessage());
e.getBinding().markValid();
}
private boolean isModified() {
return (!_configForm.isModified())
|| JOptionPane.showConfirmDialog(MainFrame.this,
"Discard changes?",
"Confirm",
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
}
private boolean save() {
// XXX
try {
_configForm.get(ConfigPersister.getInstance().getConfig());
if (_fileChooser.showSaveDialog(MainFrame.this) == JOptionPane.YES_OPTION) {
File f = _fileChooser.getSelectedFile();
if (!f.getPath().endsWith(".xml")) {
f = new File(f.getPath() + ".xml");
}
ConfigPersister.getInstance().save(f);
_saved = true;
showConfigName(f);
return true;
}
return false;
} catch (InvariantViolationException ex) {
warn(ex);
return false;
} catch (BindingException ex) {
warn(ex.getMessage());
return false;
} catch (ConfigPersisterException ex) {
warn(ex.getMessage());
return false;
}
}
private void showConfigName(File config) {
setTitle(Main.PROGRAM_NAME + " - " + (config != null ? config.getName() : "untitled"));
}
private void setRunEnabled(boolean enabled) {
if (!enabled) {
_outfile = null;
}
_runButton.setEnabled(enabled);
}
private class ExitWindowListener extends WindowAdapter {
public void windowClosing(WindowEvent e) {
if (isModified()) {
System.exit(0);
}
}
}
private class NewActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (isModified()) {
ConfigPersister.getInstance().createBlank();
_configForm.put(ConfigPersister.getInstance().getConfig());
}
_saved = false;
showConfigName(null);
setRunEnabled(false);
}
}
private class OpenActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
try {
if (isModified()
&& _fileChooser.showOpenDialog(MainFrame.this) == JOptionPane.YES_OPTION) {
final File f = _fileChooser.getSelectedFile();
if (f.getPath().endsWith(".xml")) {
ConfigPersister.getInstance().load(f);
_saved = true;
} else {
ConfigPersister.getInstance().loadVersion1(f);
_saved = false;
}
_configForm.put(ConfigPersister.getInstance().getConfig());
showConfigName(f);
setRunEnabled(false);
}
} catch (ConfigPersisterException ex) {
warn(ex.getMessage());
}
}
}
private class SaveActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
save();
}
}
private class BuildActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
final Log log = Log.getSwingLog(_configForm.getLogTextArea());
try {
if ((!_saved || _configForm.isModified())
&& !save()) {
return;
}
log.clear();
ConfigPersister.getInstance().getConfig().checkInvariants();
Builder b = new Builder(log);
_outfile = b.build();
setRunEnabled(ConfigPersister.getInstance().getConfig().getHeaderType()
== Config.GUI_HEADER); // TODO fix console app test
} catch (InvariantViolationException ex) {
setRunEnabled(false);
ex.setBinding(_configForm.getBinding(ex.getProperty())); // XXX
warn(ex);
} catch (BuilderException ex) {
setRunEnabled(false);
log.append(ex.getMessage());
}
}
}
private class RunActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
try {
getGlassPane().setVisible(true);
Worker.post(new Task() {
public Object run() throws ExecException {
Log log = Log.getSwingLog(_configForm.getLogTextArea());
log.clear();
String path = _outfile.getPath();
if (Util.WINDOWS_OS) {
log.append("Executing: " + path);
Util.exec(path, log);
} else {
log.append("Jar integrity test, executing: " + path);
Util.exec("java -jar " + path, log);
}
return null;
}
});
} catch (Exception ex) {
// XXX errors logged by exec
} finally {
getGlassPane().setVisible(false);
}
};
}
private class AboutActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
info(Main.PROGRAM_DESCRIPTION
+ "The following projects are used by launch4j...\n\n"
+ "MinGW binutils (http://www.mingw.org/)\n"
+ "Commons BeanUtils (http://jakarta.apache.org/commons/beanutils/)\n"
+ "Commons Logging (http://jakarta.apache.org/commons/logging/)\n"
+ "XStream (http://xstream.codehaus.org/)\n"
+ "JGoodies Forms (http://www.jgoodies.com/freeware/forms/)\n"
+ "JGoodies Looks (http://www.jgoodies.com/freeware/looks/)\n"
+ "Foxtrot (http://foxtrot.sourceforge.net/)\n"
+ "Nuvola Icon Theme (http://www.icon-king.com)");
}
}
}