You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2006/05/07 16:55:29 UTC
svn commit: r404778 [4/7] - in
/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows: ./
launch4j-2.1.1/ launch4j-2.1.1/bin/ launch4j-2.1.1/demo/
launch4j-2.1.1/demo/ConsoleApp/ launch4j-2.1.1/demo/ConsoleApp/l4j/
launch4j-2.1.1/demo/ConsoleApp...
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Builder.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Builder.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Builder.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Builder.java Sun May 7 07:55:12 2006
@@ -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 {
+ File basedir = Util.getJarBasedir();
+ rc = rcb.build(c);
+ ro = File.createTempFile("launch4j", "o"); //$NON-NLS-1$ //$NON-NLS-2$
+ outfile = ConfigPersister.getInstance().getOutputFile();
+
+ Cmd resCmd = new Cmd(basedir);
+ resCmd.addExe("bin/windres") //$NON-NLS-1$
+ .add(Util.WINDOWS_OS ? "--preprocessor=type" : "--preprocessor=cat") //$NON-NLS-1$ //$NON-NLS-2$
+ .add("-J rc -O coff -F pe-i386") //$NON-NLS-1$
+ .addAbsFile(rc)
+ .addAbsFile(ro);
+ _log.append(Messages.getString("Builder.compiling.resources")); //$NON-NLS-1$
+ resCmd.exec(_log);
+
+ Cmd ldCmd = new Cmd(basedir);
+ ldCmd.addExe("bin/ld") //$NON-NLS-1$
+ .add("-mi386pe") //$NON-NLS-1$
+ .add("--oformat pei-i386") //$NON-NLS-1$
+ .add((c.getHeaderType() == Config.GUI_HEADER)
+ ? "--subsystem windows" : "--subsystem console") //$NON-NLS-1$ //$NON-NLS-2$
+ .add("-s") // strip symbols //$NON-NLS-1$
+ .addFiles(c.getHeaderObjects())
+ .addAbsFile(ro)
+ .addFiles(c.getLibs())
+ .add("-o") //$NON-NLS-1$
+ .addAbsFile(outfile);
+ _log.append(Messages.getString("Builder.linking")); //$NON-NLS-1$
+ ldCmd.exec(_log);
+
+ if (!c.isDontWrapJar()) {
+ _log.append(Messages.getString("Builder.wrapping")); //$NON-NLS-1$
+ 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(Messages.getString("Builder.success") + outfile.getPath()); //$NON-NLS-1$
+ 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) { //$NON-NLS-1$
+ _log.append(Messages.getString("Builder.generated.resource.file")); //$NON-NLS-1$
+ _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 File _basedir;
+ private final boolean _quote;
+
+ public Cmd(File basedir) {
+ _basedir = basedir;
+ _quote = basedir.getPath().indexOf(' ') != -1;
+ }
+
+ public Cmd add(String s) {
+ space();
+ _sb.append(s);
+ return this;
+ }
+
+ public Cmd addAbsFile(File file) {
+ space();
+ boolean quote = file.getPath().indexOf(' ') != -1;
+ if (quote) {
+ _sb.append('"');
+ }
+ _sb.append(file.getPath());
+ if (quote) {
+ _sb.append('"');
+ }
+ return this;
+ }
+
+ public Cmd addFile(String pathname) {
+ space();
+ if (_quote) {
+ _sb.append('"');
+ }
+ _sb.append(new File(_basedir, pathname).getPath());
+ if (_quote) {
+ _sb.append('"');
+ }
+ return this;
+ }
+
+ public Cmd addExe(String pathname) {
+ return addFile(Util.WINDOWS_OS ? pathname + ".exe" : pathname); //$NON-NLS-1$
+ }
+
+ public Cmd addFiles(String[] files) {
+ for (int i = 0; i < files.length; i++) {
+ addFile(files[i]);
+ }
+ return this;
+ }
+
+ private void space() {
+ if (_sb.length() > 0) {
+ _sb.append(' ');
+ }
+ }
+
+ public String toString() {
+ return _sb.toString();
+ }
+
+ public void exec(Log log) throws ExecException {
+ Util.exec(_sb.toString(), log);
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/BuilderException.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/BuilderException.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/BuilderException.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/BuilderException.java Sun May 7 07:55:12 2006
@@ -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);
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ExecException.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ExecException.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ExecException.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ExecException.java Sun May 7 07:55:12 2006
@@ -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);
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/FileChooserFilter.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/FileChooserFilter.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/FileChooserFilter.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/FileChooserFilter.java Sun May 7 07:55:12 2006
@@ -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;
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Log.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Log.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Log.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Log.java Sun May 7 07:55:12 2006
@@ -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");
+ }});
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Main.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Main.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Main.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Main.java Sun May 7 07:55:12 2006
@@ -0,0 +1,64 @@
+/*
+ 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.1.1";
+ 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
+ + Messages.getString("usage")
+ + ": launch4j config.xml");
+ }
+ } catch (ConfigPersisterException e) {
+ Log.getConsoleLog().append(e.getMessage());
+ } catch (BuilderException e) {
+ Log.getConsoleLog().append(e.getMessage());
+ }
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Messages.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Messages.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Messages.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Messages.java Sun May 7 07:55:12 2006
@@ -0,0 +1,23 @@
+package net.sf.launch4j;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "net.sf.launch4j.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ // TODO Auto-generated method stub
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/OptionParser.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/OptionParser.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/OptionParser.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/OptionParser.java Sun May 7 07:55:12 2006
@@ -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);
+// }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/RcBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/RcBuilder.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/RcBuilder.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/RcBuilder.java Sun May 7 07:55:12 2006
@@ -0,0 +1,234 @@
+/*
+ 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;
+ public static final int JAR = 14;
+
+ 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());
+ if (c.isDontWrapJar()) {
+ addWindowsPath(JAR, c.getJar().getPath());
+ }
+ 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.replaceAll("\"", "\"\""));
+ _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");
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Util.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Util.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Util.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/Util.java Sun May 7 07:55:12 2006
@@ -0,0 +1,153 @@
+/*
+ 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 File 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);
+ } else {
+ return new File(".");
+ }
+ }
+
+ 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 = Messages.getString("Util.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;
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/AntConfig.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/AntConfig.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/AntConfig.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/AntConfig.java Sun May 7 07:55:12 2006
@@ -0,0 +1,60 @@
+/*
+ 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"); //$NON-NLS-1$
+ setJre(jre);
+ }
+
+ public void addSplash(Splash splash) {
+ checkNull(getSplash(), "splash"); //$NON-NLS-1$
+ setSplash(splash);
+ }
+
+ public void addVersionInfo(VersionInfo versionInfo) {
+ checkNull(getVersionInfo(), "versionInfo"); //$NON-NLS-1$
+ setVersionInfo(versionInfo);
+ }
+
+ private void checkNull(Object o, String name) {
+ if (o != null) {
+ throw new BuildException(
+ Messages.getString("AntConfig.duplicate.element") //$NON-NLS-1$
+ + ": " //$NON-NLS-1$
+ + name);
+ }
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Launch4jTask.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Launch4jTask.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Launch4jTask.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Launch4jTask.java Sun May 7 07:55:12 2006
@@ -0,0 +1,137 @@
+/*
+ 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(
+ Messages.getString("Launch4jTask.specify.config")); //$NON-NLS-1$
+ } else if (_configFile != null) {
+ ConfigPersister.getInstance().load(_configFile);
+ Config c = ConfigPersister.getInstance().getConfig();
+ if (jar != null) {
+ c.setJar(jar);
+ fixRelativeJarPath(c);
+ }
+ 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) {
+ fixRelativeJarPath(_config);
+ ConfigPersister.getInstance().setAntConfig(_config,
+ getProject().getBaseDir());
+ } else {
+ throw new BuildException(
+ Messages.getString("Launch4jTask.specify.config")); //$NON-NLS-1$
+ }
+ final Builder b = new Builder(Log.getAntLog());
+ b.build();
+ } catch (ConfigPersisterException e) {
+ throw new BuildException(e);
+ } catch (BuilderException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ private void fixRelativeJarPath(Config c) {
+ if (c.isDontWrapJar() && c.getJar() != null) {
+ String basePath = getProject().getBaseDir().getPath() + File.separator;
+ String jarPath = c.getJar().getPath();
+ if (jarPath.startsWith(basePath)) {
+ c.setJar(new File(jarPath.substring(basePath.length())));
+ }
+ }
+ }
+
+ 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;
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Messages.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Messages.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Messages.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/Messages.java Sun May 7 07:55:12 2006
@@ -0,0 +1,23 @@
+package net.sf.launch4j.ant;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "net.sf.launch4j.ant.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ // TODO Auto-generated method stub
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages.properties
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages.properties?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages.properties (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages.properties Sun May 7 07:55:12 2006
@@ -0,0 +1,21 @@
+#
+# 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
+#
+
+Launch4jTask.specify.config=Specify configFile or config
+AntConfig.duplicate.element=Duplicate element
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages_es.properties
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages_es.properties?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages_es.properties (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/ant/messages_es.properties Sun May 7 07:55:12 2006
@@ -0,0 +1,21 @@
+#
+# 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
+#
+
+Launch4jTask.specify.config=Specify configFile or config
+AntConfig.duplicate.element=Duplicate element
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Binding.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Binding.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Binding.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Binding.java Sun May 7 07:55:12 2006
@@ -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(IValidatable bean);
+ /** 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);
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/BindingException.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/BindingException.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/BindingException.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/BindingException.java Sun May 7 07:55:12 2006
@@ -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);
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Bindings.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Bindings.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Bindings.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Bindings.java Sun May 7 07:55:12 2006
@@ -0,0 +1,255 @@
+/*
+ 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.JTextArea;
+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()) //$NON-NLS-1$
+ || "AccessibleText".equals(evt.getPropertyName())) { //$NON-NLS-1$
+ _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(IValidatable bean) {
+ for (Iterator iter = _optComponents.values().iterator(); iter.hasNext();) {
+ ((Binding) iter.next()).clear(bean);
+ }
+ for (Iterator iter = _bindings.values().iterator(); iter.hasNext();) {
+ ((Binding) iter.next()).clear(bean);
+ }
+ _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(null);
+ } 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(Messages.getString("Bindings.duplicate.binding")); //$NON-NLS-1$
+ }
+ _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(Messages.getString("Bindings.duplicate.binding")); //$NON-NLS-1$
+ }
+ _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, "")); //$NON-NLS-1$
+ }
+
+ /**
+ * 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));
+ }
+
+ public Bindings add(String property, String stateProperty,
+ JToggleButton button, JTextArea textArea) {
+ registerPropertyChangeListener(button);
+ registerPropertyChangeListener(textArea);
+ return add(new OptListBinding(property, stateProperty, button, textArea));
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/IValidatable.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/IValidatable.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/IValidatable.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/IValidatable.java Sun May 7 07:55:12 2006
@@ -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();
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/InvariantViolationException.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/InvariantViolationException.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/InvariantViolationException.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/InvariantViolationException.java Sun May 7 07:55:12 2006
@@ -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;
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JRadioButtonBinding.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JRadioButtonBinding.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JRadioButtonBinding.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JRadioButtonBinding.java Sun May 7 07:55:12 2006
@@ -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("") //$NON-NLS-1$
+ || 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(IValidatable bean) {
+ select(_defaultValue);
+ }
+
+ public void put(IValidatable bean) {
+ try {
+ Integer i = (Integer) PropertyUtils.getProperty(bean, _property);
+ if (i == null) {
+ throw new BindingException(Messages.getString("JRadioButtonBinding.property.null")); //$NON-NLS-1$
+ }
+ 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(Messages.getString("JRadioButtonBinding.nothing.selected")); //$NON-NLS-1$
+ } catch (Exception e) {
+ throw new BindingException(e);
+ }
+ }
+
+ private void select(int index) {
+ if (index < 0 || index >= _buttons.length) {
+ throw new BindingException(Messages.getString("JRadioButtonBinding.index.out.of.bounds")); //$NON-NLS-1$
+ }
+ _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(Messages.getString("JRadioButtonBinding.nothing.selected")); //$NON-NLS-1$
+ }
+
+ 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(Messages.getString("JRadioButtonBinding.nothing.selected")); //$NON-NLS-1$
+ }
+
+ public void setEnabled(boolean enabled) {
+ for (int i = 0; i < _buttons.length; i++) {
+ _buttons[i].setEnabled(enabled);
+ }
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JTextComponentBinding.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JTextComponentBinding.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JTextComponentBinding.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JTextComponentBinding.java Sun May 7 07:55:12 2006
@@ -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(IValidatable bean) {
+ _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);
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JToggleButtonBinding.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JToggleButtonBinding.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JToggleButtonBinding.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/JToggleButtonBinding.java Sun May 7 07:55:12 2006
@@ -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(IValidatable bean) {
+ _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);
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Messages.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Messages.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Messages.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Messages.java Sun May 7 07:55:12 2006
@@ -0,0 +1,47 @@
+package net.sf.launch4j.binding;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "net.sf.launch4j.binding.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+ private static final MessageFormat FORMATTER = new MessageFormat("");
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ // TODO Auto-generated method stub
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+
+ public static String getString(String key, String arg0) {
+ return getString(key, new Object[] {arg0});
+ }
+
+ public static String getString(String key, String arg0, String arg1) {
+ return getString(key, new Object[] {arg0, arg1});
+ }
+
+ public static String getString(String key, String arg0, String arg1, String arg2) {
+ return getString(key, new Object[] {arg0, arg1, arg2});
+ }
+
+ public static String getString(String key, Object[] args) {
+ // TODO Auto-generated method stub
+ try {
+ FORMATTER.applyPattern(RESOURCE_BUNDLE.getString(key));
+ return FORMATTER.format(args);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptComponentBinding.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptComponentBinding.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptComponentBinding.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptComponentBinding.java Sun May 7 07:55:12 2006
@@ -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("")) { //$NON-NLS-1$
+ throw new IllegalArgumentException();
+ }
+ if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
+ throw new IllegalArgumentException(Messages.getString("OptComponentBinding.must.implement") //$NON-NLS-1$
+ + IValidatable.class);
+ }
+ _bindings = bindings;
+ _property = property;
+ _clazz = clazz;
+ _button = button;
+ _button.addActionListener(this);
+ _enabledByDefault = enabledByDefault;
+ }
+
+ public String getProperty() {
+ return _property;
+ }
+
+ public void clear(IValidatable bean) {
+ _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());
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptListBinding.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptListBinding.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptListBinding.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/OptListBinding.java Sun May 7 07:55:12 2006
@@ -0,0 +1,94 @@
+/*
+ * Created on Sep 3, 2005
+ */
+package net.sf.launch4j.binding;
+
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JTextArea;
+import javax.swing.JToggleButton;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.beanutils.PropertyUtils;
+
+/**
+ * @author Copyright (C) 2005 Grzegorz Kowal
+ */
+public class OptListBinding implements Binding, ActionListener {
+ private final String _property;
+ private final String _stateProperty;
+ private final JToggleButton _button;
+ private final JTextArea _textArea;
+ private final Color _validColor;
+
+ public OptListBinding(String property, String stateProperty,
+ JToggleButton button, JTextArea textArea) {
+ if (property == null || button == null || textArea == null) {
+ throw new NullPointerException();
+ }
+ if (property.equals("")) {
+ throw new IllegalArgumentException();
+ }
+ _property = property;
+ _stateProperty = stateProperty;
+ _button = button;
+ _textArea = textArea;
+ _validColor = _textArea.getBackground();
+ button.addActionListener(this);
+ }
+
+ public String getProperty() {
+ return _property;
+ }
+
+ public void clear(IValidatable bean) {
+ put(bean);
+ }
+
+ public void put(IValidatable bean) {
+ try {
+ boolean selected = "true".equals(BeanUtils.getProperty(bean, _stateProperty));
+ _button.setSelected(selected);
+ _textArea.setEnabled(selected);
+ String[] items = (String[]) PropertyUtils.getProperty(bean, _property);
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < items.length; i++) {
+ sb.append(items[i]);
+ if (i < items.length - 1) {
+ sb.append("\n");
+ }
+ }
+ _textArea.setText(sb.toString());
+ } catch (Exception e) {
+ throw new BindingException(e);
+ }
+ }
+
+ public void get(IValidatable bean) {
+ try {
+ String[] items = _textArea.getText().split("\n");
+ PropertyUtils.setProperty(bean, _property, _button.isSelected() ? items : null);
+ } catch (Exception e) {
+ throw new BindingException(e);
+ }
+ }
+
+ public void markValid() {
+ _textArea.setBackground(_validColor);
+ _textArea.requestFocusInWindow();
+ }
+
+ public void markInvalid() {
+ _textArea.setBackground(Binding.INVALID_COLOR);
+ }
+
+ public void setEnabled(boolean enabled) {
+ _textArea.setEnabled(enabled);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ _textArea.setEnabled(_button.isSelected());
+ }
+}
Added: incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Validator.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Validator.java?rev=404778&view=auto
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Validator.java (added)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-ant/lib/windows/launch4j-2.1.1/src/net/sf/launch4j/binding/Validator.java Sun May 7 07:55:12 2006
@@ -0,0 +1,182 @@
+/*
+ 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]*?"; //$NON-NLS-1$
+ public static final String ALPHA_PATTERN = "[\\w&&\\D]*?"; //$NON-NLS-1$
+ public static final String NUMERIC_PATTERN = "[\\d]*?"; //$NON-NLS-1$
+ public static final String PATH_PATTERN = "[\\w|[ .,:\\-/\\\\]]*?"; //$NON-NLS-1$
+
+ private Validator() {}
+
+ public static boolean isEmpty(String s) {
+ return s == null || s.equals(""); //$NON-NLS-1$
+ }
+
+ public static void checkNotNull(Object o, String property, String name) {
+ if (o == null) {
+ signalViolation(property,
+ Messages.getString("Validator.empty.field", name)); //$NON-NLS-1$
+ }
+ }
+
+ public static void checkString(String s, int maxLength, String property, String name) {
+ if (s == null || s.length() == 0) {
+ signalViolation(property,
+ Messages.getString("Validator.empty.field", name)); //$NON-NLS-1$
+ }
+ 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,
+ Messages.getString("Validator.invalid.data", name)); //$NON-NLS-1$
+ }
+ }
+
+ 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,
+ Messages.getString("Validator.invalid.data", name)); //$NON-NLS-1$
+ }
+ }
+
+ public static void checkRange(int value, int min, int max,
+ String property, String name) {
+ if (value < min || value > max) {
+ signalViolation(property,
+ Messages.getString("ValidatocheckFiler.must.be.in.range", //$NON-NLS-1$
+ name, String.valueOf(min), String.valueOf(max)));
+ }
+ }
+
+ public static void checkRange(char value, char min, char max,
+ String property, String name) {
+ if (value < min || value > max) {
+ signalViolation(property,
+ Messages.getString("Validator.must.be.in.range", //$NON-NLS-1$
+ name, String.valueOf(min), String.valueOf(max)));
+ }
+ }
+
+ public static void checkMin(int value, int min, String property, String name) {
+ if (value < min) {
+ signalViolation(property,
+ Messages.getString("Validator.must.be.at.least", //$NON-NLS-1$
+ name, String.valueOf(min)));
+ }
+ }
+
+ 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,
+ Messages.getString("Validator.already.exists", msg)); //$NON-NLS-1$
+ }
+ }
+
+ public static void checkElementsUnique(Collection c, String property, String msg) {
+ if (new HashSet(c).size() != c.size()) {
+ signalViolation(property,
+ Messages.getString("Validator.already.exists", msg)); //$NON-NLS-1$
+ }
+ }
+
+ 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,
+ Messages.getString("Validator.doesnt.exist", fileDescription)); //$NON-NLS-1$
+ }
+ }
+
+ 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 == null
+ || path.equals("")
+ || path.startsWith("/") //$NON-NLS-1$
+ || path.startsWith("\\") //$NON-NLS-1$
+ || path.indexOf(':') != -1) {
+ signalViolation(property, msg);
+ }
+ }
+
+ public static void signalLengthViolation(String property, String name, int maxLength) {
+ signalViolation(property,
+ Messages.getString("Validator.exceeds.max.length", //$NON-NLS-1$
+ name, String.valueOf(maxLength)));
+ }
+
+ public static void signalViolation(String property, String msg) {
+ throw new InvariantViolationException(property, msg);
+ }
+}