[izpack-changes] r1527 - in izpack-frontend/trunk/src: . documentation izpack/frontend/actions izpack/frontend/controller/validators izpack/frontend/model izpack/frontend/model/files izpack/frontend/model/stages izpack/frontend/view/components izpack/frontend/view/components/table izpack/frontend/view/mode izpack/frontend/view/stages izpack/frontend/view/stages/compile izpack/frontend/view/stages/configure izpack/frontend/view/stages/geninfo izpack/frontend/view/stages/packs izpack/frontend/view/stages/packs/editors izpack/frontend/view/stages/panelselect lib res/i18n utils
noreply at berlios.de
noreply at berlios.de
Fri Aug 11 17:52:27 CEST 2006
Author: gumbo
Date: 2006-08-11 17:52:24 +0200 (Fri, 11 Aug 2006)
New Revision: 1527
Added:
izpack-frontend/trunk/src/documentation/
izpack-frontend/trunk/src/documentation/DocumentationGenerator.java
izpack-frontend/trunk/src/izpack/frontend/model/OS.java
izpack-frontend/trunk/src/izpack/frontend/view/components/OSSelector.java
izpack-frontend/trunk/src/lib/validation-1.3.0.jar
Modified:
izpack-frontend/trunk/src/izpack/frontend/actions/ActionHandler.java
izpack-frontend/trunk/src/izpack/frontend/controller/validators/PanelSelectionValidator.java
izpack-frontend/trunk/src/izpack/frontend/controller/validators/StageValidator.java
izpack-frontend/trunk/src/izpack/frontend/model/PackModel.java
izpack-frontend/trunk/src/izpack/frontend/model/files/DirectoryModel.java
izpack-frontend/trunk/src/izpack/frontend/model/files/Executable.java
izpack-frontend/trunk/src/izpack/frontend/model/files/FileModel.java
izpack-frontend/trunk/src/izpack/frontend/model/files/FileSet.java
izpack-frontend/trunk/src/izpack/frontend/model/files/PackFileModel.java
izpack-frontend/trunk/src/izpack/frontend/model/files/Parsable.java
izpack-frontend/trunk/src/izpack/frontend/model/stages/ConfigurationStageModel.java
izpack-frontend/trunk/src/izpack/frontend/model/stages/GeneralInformationModel.java
izpack-frontend/trunk/src/izpack/frontend/model/stages/PackStageModel.java
izpack-frontend/trunk/src/izpack/frontend/model/stages/PanelModel.java
izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellRenderer.java
izpack-frontend/trunk/src/izpack/frontend/view/components/table/TableEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/mode/WizardMode.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/IzPackStage.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/compile/Compile.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/configure/PanelConfigurator.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInfoPanel.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInformation.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/UIConfig.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/ListTable.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/Pack.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/DirectoryEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ExecutableEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileSetEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/PackEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ParsableEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/SetEditor.java
izpack-frontend/trunk/src/izpack/frontend/view/stages/panelselect/PanelSelection.java
izpack-frontend/trunk/src/res/i18n/LangResources_en.properties
izpack-frontend/trunk/src/utils/XML.java
Log:
Updated validation
Added: izpack-frontend/trunk/src/documentation/DocumentationGenerator.java
===================================================================
--- izpack-frontend/trunk/src/documentation/DocumentationGenerator.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/documentation/DocumentationGenerator.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -0,0 +1,71 @@
+/*
+ * Created on May 4, 2006
+ *
+ * $Id: DocumentationGenerator.java Feb 8, 2004 izpack-frontend
+ * Copyright (C) 2005 Andy Gombos
+ *
+ * File : DocumentationGenerator.java
+ * Description : TODO Add description
+ * Author's email : gumbo at users.berlios.de
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package documentation;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+import au.id.jericho.lib.html.Element;
+import au.id.jericho.lib.html.Segment;
+import au.id.jericho.lib.html.Source;
+import au.id.jericho.lib.html.StartTag;
+
+public class DocumentationGenerator
+{
+
+ /**
+ * @param args
+ * @throws IOException
+ * @throws FileNotFoundException
+ */
+ public static void main(String[] args) throws FileNotFoundException, IOException
+ {
+ Source src = new Source(new FileInputStream(new File("H:\\izpack-src\\src\\doc-ng\\XHTML\\node4.html")));
+ src.setLogWriter(new PrintWriter(System.err));
+
+ List<Element> tags = src.findAllElements("h2");
+
+ for (Element tag : tags)
+ {
+ String text = tag.extractText();
+
+ if (text.endsWith("Panel"))
+ {
+ System.out.println(text);
+
+ StartTag t = src.findNextStartTag(tag.getEnd(), "h2");
+
+ if (t == null)
+ t = src.findNextStartTag(tag.getEnd(), "hr");
+
+ System.out.println("\t" + new Segment(src, tag.getEnd(), t.getBegin()).extractText());
+ }
+ }
+ }
+
+}
Modified: izpack-frontend/trunk/src/izpack/frontend/actions/ActionHandler.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/actions/ActionHandler.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/actions/ActionHandler.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -108,6 +108,10 @@
if (installerUI != null)
{
welcomeUI.setVisible(false);
+
+ System.out.println("Creating new installer");
+
+ installerUI.resetState();
installerUI.setVisible(true);
}
}
Modified: izpack-frontend/trunk/src/izpack/frontend/controller/validators/PanelSelectionValidator.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/controller/validators/PanelSelectionValidator.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/controller/validators/PanelSelectionValidator.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,6 +23,8 @@
package izpack.frontend.controller.validators;
+import izpack.frontend.model.PanelInfo;
+import izpack.frontend.model.stages.PanelModel;
import izpack.frontend.model.stages.PanelSelectionModel;
import com.jgoodies.validation.Severity;
@@ -55,10 +57,48 @@
"Panels",
"dest"
));
+ }
+
+ tmp.configData = new PanelInfo("", "", "Install Panel", "", "", null, null);
+
+ if (!model.contains(tmp))
+ {
+ vr.add(new PropertyValidationMessage(
+ Severity.ERROR,
+ "must have an installation panel to perform the install",
+ model,
+ "Panels",
+ "dest"));
}
+ tmp.configData = new PanelInfo("", "", "Welcome Panel", "", "", null, null);
+
+ if (!model.contains(tmp))
+ {
+ vr.add(new PropertyValidationMessage(
+ Severity.WARNING,
+ "should have a welcome panel",
+ model,
+ "Panels",
+ "dest"));
+ }
+
+ tmp.configData = new PanelInfo("", "", "Finish Panel", "", "", null, null);
+ tmp2.configData = new PanelInfo("", "", "Simple Finish Panel", "", "", null, null);
+
+ if (! (model.contains(tmp) || model.contains(tmp2)) )
+ {
+ vr.add(new PropertyValidationMessage(
+ Severity.WARNING,
+ "should have a finishing panel",
+ model,
+ "Panels",
+ "dest"));
+ }
+
return vr;
}
+ private PanelModel tmp = new PanelModel(), tmp2 = new PanelModel();
PanelSelectionModel model;
}
Modified: izpack-frontend/trunk/src/izpack/frontend/controller/validators/StageValidator.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/controller/validators/StageValidator.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/controller/validators/StageValidator.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,12 +23,13 @@
package izpack.frontend.controller.validators;
-import com.jgoodies.validation.ValidationCapable;
+import com.jgoodies.validation.Validator;
+
/**
* @author Andy Gombos
*/
-public interface StageValidator extends ValidationCapable
+public interface StageValidator extends Validator
{
}
Added: izpack-frontend/trunk/src/izpack/frontend/model/OS.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/OS.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/OS.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -0,0 +1,141 @@
+/*
+ * Created on Aug 9, 2006
+ *
+ * $Id: OS.java Feb 8, 2004 izpack-frontend
+ * Copyright (C) 2005 Andy Gombos
+ *
+ * File : OS.java
+ * Description : TODO Add description
+ * Author's email : gumbo at users.berlios.de
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package izpack.frontend.model;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import utils.XML;
+
+import com.jgoodies.binding.beans.Model;
+
+public class OS extends Model
+{
+ boolean windows, unix, mac;
+
+ public boolean isMac()
+ {
+ return mac;
+ }
+
+ public boolean isUnix()
+ {
+ return unix;
+ }
+
+ public boolean isWindows()
+ {
+ return windows;
+ }
+
+ public void setMac(boolean mac)
+ {
+ this.mac = mac;
+ firePropertyChange("mac", false, mac);
+ }
+
+ public void setUnix(boolean unix)
+ {
+ this.unix = unix;
+ firePropertyChange("unix", false, unix);
+ }
+
+ public void setWindows(boolean windows)
+ {
+ this.windows = windows;
+ firePropertyChange("windows", false, windows);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Windows: " + windows + " Unix: " + unix + " Mac: " + mac;
+ }
+
+ public void createXML(Document doc, Element packElement)
+ {
+ if (windows)
+ {
+ createOSElement(doc, packElement, "windows");
+ }
+ if (unix)
+ {
+ createOSElement(doc, packElement, "unix");
+ }
+ if (mac)
+ {
+ createOSElement(doc, packElement, "mac");
+ }
+ }
+
+ private void createOSElement(Document doc, Element packElement, String osFamily)
+ {
+ Element root = XML.createElement("os", doc);
+ root.setAttribute("family", osFamily);
+
+ packElement.appendChild(root);
+ }
+
+ public void initFromXML(Node node)
+ {
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ try
+ {
+ initFromXML((NodeList) xpath.evaluate("os", node, XPathConstants.NODESET));
+ }
+ catch (XPathExpressionException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void initFromXML(NodeList os)
+ {
+ for (int i = 0; i < os.getLength(); i++)
+ {
+ NamedNodeMap attrs = os.item(i).getAttributes();
+
+ if (attrs.getNamedItem("family") != null)
+ {
+ String family = attrs.getNamedItem("family").getNodeValue();
+
+ if (family.equalsIgnoreCase("windows"))
+ windows = true;
+ else if (family.equalsIgnoreCase("unix"))
+ unix = true;
+ else if (family.equalsIgnoreCase("mac"))
+ mac = true;
+ }
+ }
+ }
+}
Modified: izpack-frontend/trunk/src/izpack/frontend/model/PackModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/PackModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/PackModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -62,7 +62,8 @@
model = new DefaultTableModel(15, 1);
}
- private String name = "", desc = "", id = "", os = "";
+ private String name = "", desc = "", id = "";
+ private OS oses = new OS();
private boolean required = true, preselected = true, loose = false;
/**
@@ -96,9 +97,9 @@
/**
* @return Returns the os.
*/
- public String getOS()
- {
- return os;
+ public OS getOS()
+ {
+ return oses;
}
/**
* @return Returns the preselected.
@@ -145,10 +146,11 @@
/**
* @param os The os to set.
*/
- public void setOS(String os)
- {
- this.os = os;
+ public void setOSes(OS os)
+ {
+ this.oses = os;
}
+
/**
* @param preselected The preselected to set.
*/
@@ -171,18 +173,17 @@
pack.setAttribute("name", name);
pack.setAttribute("required", required ? "yes" : "no");
pack.setAttribute("preselected", preselected ? "yes" : "no");
- pack.setAttribute("loose", loose ? "true" : "false");
-
- if (!os.equals(""))
- pack.setAttribute("os", os);
-
+ pack.setAttribute("loose", loose ? "true" : "false");
+
if (!id.equals(""))
pack.setAttribute("id", id);
Element descElem = XML.createElement("description", doc);
descElem.setTextContent(desc);
- pack.appendChild(descElem);
+ pack.appendChild(descElem);
+
+ oses.createXML(doc, pack);
//Convert the model into a list so it can be sorted
ArrayList elements = new ArrayList();
@@ -226,10 +227,6 @@
setLoose(stringToBoolean(getAttribute(attributes, "loose")));
- String os = getAttribute(attributes, "os");
- if (os != null && !os.equals(""))
- setOS(os);
-
String id = getAttribute(attributes, "id");
if (id != null && !id.equals(""))
setId(id);
@@ -243,12 +240,15 @@
{
String packLoc = "//pack[" + (packIndex + 1) + "]/";
+ NodeList os = (NodeList) xpath.evaluate(packLoc + "os", packNode, XPathConstants.NODESET);
+
NodeList dirs = (NodeList) xpath.evaluate(packLoc + "file", packNode, XPathConstants.NODESET);
NodeList fileset = (NodeList) xpath.evaluate(packLoc + "fileset", packNode, XPathConstants.NODESET);
NodeList files = (NodeList) xpath.evaluate(packLoc + "singlefile", packNode, XPathConstants.NODESET);
NodeList execs = (NodeList) xpath.evaluate(packLoc + "executable", packNode, XPathConstants.NODESET);
NodeList parsables = (NodeList) xpath.evaluate(packLoc + "parsable", packNode, XPathConstants.NODESET);
+ oses.initFromXML(os);
createChildParts(dirs, DirectoryModel.class);
createChildParts(files, FileModel.class);
createChildParts(fileset, FileSet.class);
Modified: izpack-frontend/trunk/src/izpack/frontend/model/files/DirectoryModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/files/DirectoryModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/files/DirectoryModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,6 +23,8 @@
package izpack.frontend.model.files;
+import izpack.frontend.model.OS;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -45,12 +47,11 @@
dir.setAttribute("src", source);
dir.setAttribute("targetdir", target);
- if (!os.equals(""))
- dir.setAttribute("os", os);
-
if (!override.equals(""))
dir.setAttribute("override", override);
+ os.createXML(doc, dir);
+
return dir;
}
@@ -62,8 +63,8 @@
target = attributes.getNamedItem("targetdir").getNodeValue();
- if (attributes.getNamedItem("os") != null)
- os = attributes.getNamedItem("os").getNodeValue();
+ os = new OS();
+ os.initFromXML(elementNode);
if (attributes.getNamedItem("override") != null)
override = attributes.getNamedItem("override").getNodeValue();
Modified: izpack-frontend/trunk/src/izpack/frontend/model/files/Executable.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/files/Executable.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/files/Executable.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,8 +23,11 @@
package izpack.frontend.model.files;
+import izpack.frontend.model.OS;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import utils.XML;
@@ -37,6 +40,7 @@
public class Executable implements PackElement
{
public String target = "", execClass = "", type = "", stage = "", failure = "", keep = "", args = "";
+ public OS os;
/* (non-Javadoc)
* @see izpack.frontend.model.files.ElementModel#writeXML()
@@ -53,6 +57,8 @@
setOptionalAttribute(executable, "failure", failure);
setOptionalAttribute(executable, "keep", keep);
+ os.createXML(doc, executable);
+
Element argsElem = XML.createElement("args", doc);
Element arg = XML.createElement("arg", doc);
arg.setAttribute("value", args);
@@ -67,11 +73,30 @@
{
if ((value != null) && !value.equals(""))
elem.setAttribute(attrName, value);
- }
+ }
public void initFromXML(Node elementNode)
{
- // TODO Auto-generated method stub
+ NamedNodeMap attributes = elementNode.getAttributes();
+ if (attributes.getNamedItem("targetfile") != null)
+ target = attributes.getNamedItem("targetfile").getNodeValue();
+ if (attributes.getNamedItem("class") != null)
+ execClass = attributes.getNamedItem("class").getNodeValue();
+ if (attributes.getNamedItem("type") != null)
+ type = attributes.getNamedItem("type").getNodeValue();
+ if (attributes.getNamedItem("stage") != null)
+ stage = attributes.getNamedItem("stage").getNodeValue();
+ if (attributes.getNamedItem("failure") != null)
+ failure = attributes.getNamedItem("failure").getNodeValue();
+ if (attributes.getNamedItem("keep") != null)
+ keep = attributes.getNamedItem("keep").getNodeValue();
+
+
+ //TODO handle args
+ //args = attributes.getNamedItem("src").getNodeValue();
+
+ os = new OS();
+ os.initFromXML(elementNode);
}
}
Modified: izpack-frontend/trunk/src/izpack/frontend/model/files/FileModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/files/FileModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/files/FileModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,6 +23,8 @@
package izpack.frontend.model.files;
+import izpack.frontend.model.OS;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -45,12 +47,11 @@
file.setAttribute("src", source);
file.setAttribute("target", target);
- if (!os.equals(""))
- file.setAttribute("os", os);
-
if (!override.equals(""))
file.setAttribute("override", override);
+ os.createXML(doc, file);
+
return file;
}
@@ -62,8 +63,8 @@
target = attributes.getNamedItem("target").getNodeValue();
- if (attributes.getNamedItem("os") != null)
- os = attributes.getNamedItem("os").getNodeValue();
+ os = new OS();
+ os.initFromXML(elementNode);
if (attributes.getNamedItem("override") != null)
override = attributes.getNamedItem("override").getNodeValue();
Modified: izpack-frontend/trunk/src/izpack/frontend/model/files/FileSet.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/files/FileSet.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/files/FileSet.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,6 +23,8 @@
package izpack.frontend.model.files;
+import izpack.frontend.model.OS;
+
import java.util.ArrayList;
import java.util.Iterator;
@@ -53,17 +55,16 @@
{
Element fset = XML.createElement("fileset", doc);
fset.setAttribute("dir", source);
- fset.setAttribute("targetdir", target);
+ fset.setAttribute("targetdir", target);
- if (!os.equals(""))
- fset.setAttribute("os", os);
-
if (!override.equals(""))
fset.setAttribute("override", override);
fset.setAttribute("casesensitive", yesNoBoolean(caseSensitive));
fset.setAttribute("defaultexcludes", yesNoBoolean(defaultExcludes));
+ os.createXML(doc, fset);
+
for (Iterator iter = files.iterator(); iter.hasNext();)
{
Set element = (Set) iter.next();
@@ -83,8 +84,8 @@
target = attributes.getNamedItem("targetdir").getNodeValue();
- if (attributes.getNamedItem("os") != null)
- os = attributes.getNamedItem("os").getNodeValue();
+ os = new OS();
+ os.initFromXML(elementNode);
if (attributes.getNamedItem("override") != null)
override = attributes.getNamedItem("override").getNodeValue();
Modified: izpack-frontend/trunk/src/izpack/frontend/model/files/PackFileModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/files/PackFileModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/files/PackFileModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,10 +23,13 @@
package izpack.frontend.model.files;
+import izpack.frontend.model.OS;
+
/**
* @author Andy Gombos
*/
public abstract class PackFileModel implements PackElement
{
- public String target = "", source = "", os = "", override = "";
+ public String target = "", source = "", override = "";
+ public OS os;
}
Modified: izpack-frontend/trunk/src/izpack/frontend/model/files/Parsable.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/files/Parsable.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/files/Parsable.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,8 +23,11 @@
package izpack.frontend.model.files;
+import izpack.frontend.model.OS;
+
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import utils.XML;
@@ -34,7 +37,8 @@
*/
public class Parsable implements PackElement
{
- public String targetfile, type = "plain", encoding, os;
+ public String targetfile, type = "plain", encoding;
+ public OS os;
/* (non-Javadoc)
* @see izpack.frontend.model.files.PackElement#writeXML()
@@ -48,15 +52,22 @@
if (encoding != null && !encoding.equals(""))
parsable.setAttribute("encoding", encoding);
- if (os != null && !os.equals(""))
- parsable.setAttribute("os", os);
+ os.createXML(doc, parsable);
return parsable;
}
public void initFromXML(Node elementNode)
{
- // TODO Auto-generated method stub
+ NamedNodeMap attributes = elementNode.getAttributes();
+ //TODO handle error about missing required attributes
+ targetfile = attributes.getNamedItem("targetfile").getNodeValue();
+
+ if (attributes.getNamedItem("encoding") != null)
+ encoding = attributes.getNamedItem("encoding").getNodeValue();
+
+ os = new OS();
+ os.initFromXML(elementNode);
}
}
Modified: izpack-frontend/trunk/src/izpack/frontend/model/stages/ConfigurationStageModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/stages/ConfigurationStageModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/stages/ConfigurationStageModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -123,4 +123,11 @@
{
return editors;
}
+
+ public void reset()
+ {
+ editors.clear();
+
+ currentlyActivePanel = 0;
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/model/stages/GeneralInformationModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/stages/GeneralInformationModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/stages/GeneralInformationModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -23,12 +23,13 @@
package izpack.frontend.model.stages;
+import izpack.frontend.controller.AuthorManager;
import izpack.frontend.model.Author;
import izpack.frontend.model.SelectListModel;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Iterator;
import javax.swing.ListModel;
import javax.xml.xpath.XPath;
@@ -173,6 +174,30 @@
//GUI Prefs
boolean resizable;
int width, height;
+
+ public void resetModel()
+ {
+ setAppName("");
+ setHeight(0);
+ setWidth(0);
+ setHomepage("");
+ setResizable(true);
+ setVersion("");
+
+ authors.clear();
+
+
+ ArrayList authorListData = AuthorManager.loadAuthors();
+ if (authorListData != null)
+ {
+ for (Iterator iter = authorListData.iterator(); iter.hasNext(); )
+ {
+ authors.add(iter.next());
+ }
+ }
+
+ langCodes.clear();
+ }
/* (non-Javadoc)
* @see izpack.frontend.model.stages.StageDataModel#writeToXML()
Modified: izpack-frontend/trunk/src/izpack/frontend/model/stages/PackStageModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/stages/PackStageModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/stages/PackStageModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -73,21 +73,24 @@
*/
public void initFromXML(Document doc)
{
- XPath xpath = XPathFactory.newInstance().newXPath();
+ XPath xpath = XPathFactory.newInstance().newXPath();
+
+ //Remove the spacer rows
+ for (int i = getRowCount() - 1; i >= 0; i--)
+ removeRow(i);
+
try
{
NodeList packs = (NodeList) xpath.evaluate("//packs/pack", doc, XPathConstants.NODESET);
- NodeList desc = (NodeList) xpath.evaluate("//packs/pack/description", doc, XPathConstants.NODESET);
+ NodeList desc = (NodeList) xpath.evaluate("//packs/pack/description", doc, XPathConstants.NODESET);
for (int i = 0; i < packs.getLength(); i++)
- {
+ {
PackModel pack = new PackModel();
pack.initFromXML(i, packs.item(i), desc.item(i));
- //Insert a row, but remove the empty one that was present originally
- insertRow(i, new Object[]{pack});
- removeRow(getRowCount() - i - 1);
+ insertRow(i, new Object[]{pack});
}
}
catch (XPathExpressionException e)
Modified: izpack-frontend/trunk/src/izpack/frontend/model/stages/PanelModel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/model/stages/PanelModel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/model/stages/PanelModel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -32,6 +32,15 @@
public boolean valid;
@Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof PanelModel)
+ return configData.getName().equals(( (PanelModel) obj).configData.getName());
+ else
+ return false;
+ }
+
+ @Override
public String toString()
{
return configData.getName();
Added: izpack-frontend/trunk/src/izpack/frontend/view/components/OSSelector.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/components/OSSelector.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/components/OSSelector.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -0,0 +1,95 @@
+/*
+ * Created on Apr 7, 2005
+ *
+ * $Id: OSComboBox.java Feb 8, 2004 izpack-frontend
+ * Copyright (C) 2005 Andy Gombos
+ *
+ * File : OSComboBox.java
+ * Description : TODO Add description
+ * Author's email : gumbo at users.berlios.de
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package izpack.frontend.view.components;
+
+import izpack.frontend.model.OS;
+
+import java.awt.FlowLayout;
+
+import javax.swing.JCheckBox;
+import javax.swing.JPanel;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import utils.XML;
+
+import com.jgoodies.binding.PresentationModel;
+import com.jgoodies.binding.adapter.Bindings;
+import com.jgoodies.binding.beans.PropertyAdapter;
+
+/**
+ * @author Andy Gombos
+ */
+public class OSSelector extends JPanel
+{
+ public OSSelector()
+ {
+ windows = new JCheckBox("Windows");
+ unix = new JCheckBox("Unix");
+ mac = new JCheckBox("Mac");
+
+ model = new PresentationModel(osModel);
+
+ Bindings.bind(windows, model.getModel("windows"));
+ Bindings.bind(unix, model.getModel("unix"));
+ Bindings.bind(mac, model.getModel("mac"));
+
+ FlowLayout layout = new FlowLayout();
+ layout.setAlignment(FlowLayout.LEFT);
+ setLayout(layout);
+ add(windows);
+ add(unix);
+ add(mac);
+ }
+
+ public OS getOsModel()
+ {
+ return osModel;
+ }
+
+ public void setOsModel(OS osModel)
+ {
+ this.osModel = osModel;
+
+ model = new PresentationModel(osModel);
+
+ Bindings.bind(windows, model.getModel("windows"));
+ Bindings.bind(unix, model.getModel("unix"));
+ Bindings.bind(mac, model.getModel("mac"));
+ }
+
+ public void setNoneSelected()
+ {
+ osModel.setMac(false);
+ osModel.setWindows(false);
+ osModel.setUnix(false);
+ }
+
+ private JCheckBox windows, unix, mac;
+
+ //TODO the pack stuff should bind to the model, not create a new instance
+ private OS osModel = new OS();
+ private PresentationModel model;
+}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -25,6 +25,7 @@
import izpack.frontend.model.PackModel;
+import java.awt.Color;
import java.awt.Component;
import javax.swing.AbstractCellEditor;
@@ -77,7 +78,7 @@
editingValue = pm;
- if (isSelected)
+ if (isSelected)
panel.setBorder(selected);
else
panel.setBorder(null);
Modified: izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellRenderer.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellRenderer.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/components/table/PackCellRenderer.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -24,6 +24,7 @@
import izpack.frontend.model.PackModel;
+import java.awt.Color;
import java.awt.Component;
import javax.swing.JCheckBox;
@@ -76,7 +77,7 @@
desc.setText(pm.getDesc());
required.setSelected(pm.isRequired());
- if (isSelected)
+ if (isSelected)
panel.setBorder(selected);
else
panel.setBorder(null);
Modified: izpack-frontend/trunk/src/izpack/frontend/view/components/table/TableEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/components/table/TableEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/components/table/TableEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -33,12 +33,16 @@
import javax.swing.JButton;
import javax.swing.JDialog;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import com.jgoodies.validation.ValidationResult;
+
/**
* @author Andy Gombos
*/
-public abstract class TableEditor extends JDialog implements ActionListener
-{
+public abstract class TableEditor extends JDialog implements ActionListener, DocumentListener
+{
public TableEditor(Frame parent)
{
super(parent);
@@ -57,7 +61,23 @@
public abstract void configureClean();
public abstract ElementModel getModel();
+
+ public abstract void configureValidation();
+
+ public abstract ValidationResult validateEditor();
+
+ public void insertUpdate(DocumentEvent e)
+ {
+ validateEditor();
+ }
+ public void removeUpdate(DocumentEvent e)
+ {
+ validateEditor();
+ }
+
+ public void changedUpdate(DocumentEvent e) {}
+
public boolean wasOKPressed()
{
return !cancelled;
Modified: izpack-frontend/trunk/src/izpack/frontend/view/mode/WizardMode.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/mode/WizardMode.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/mode/WizardMode.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -103,8 +103,7 @@
getContentPane().add(leftNavBar, BorderLayout.WEST);
createMenuBar();
-
- setPreferredSize(new Dimension(700, 700));
+
pack();
long stop = System.currentTimeMillis();
@@ -113,8 +112,19 @@
System.out.println("Startup time: " + startupTime + "ms " + (startupTime / 1000f) + "s "
+ (startupTime / 1000 / 60f) + "min");
}
-
- /*
+
+ public void resetState()
+ {
+ ArrayList<IzPackStage> stages = IzPackStage.getAllStages();
+ for (IzPackStage stage : stages)
+ {
+ stage.resetStage();
+ }
+
+ changeStage(new StageChangeEvent(GeneralInformation.class));
+ }
+
+ /*
* (non-Javadoc)
*
* @see izpack.frontend.controller.StageChangeListener#changeStage(izpack.frontend.controller.StageChangeEvent)
@@ -265,5 +275,5 @@
CardLayout layout = new CardLayout();
private static WelcomeScreen launcher;
- private static ActionHandler actionHandler;
+ private static ActionHandler actionHandler;
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/IzPackStage.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/IzPackStage.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/IzPackStage.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -36,10 +36,13 @@
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JPanel;
+import javax.swing.JScrollPane;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -49,14 +52,14 @@
import com.jgoodies.binding.PresentationModel;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.ValidationResultModel;
import com.jgoodies.validation.util.DefaultValidationResultModel;
-import com.jgoodies.validation.util.ValidationResultModel;
import com.jgoodies.validation.view.ValidationResultViewFactory;
/**
* @author Andy Gombos
*/
-public abstract class IzPackStage extends JPanel implements Stage
+public abstract class IzPackStage extends JPanel implements Stage, PropertyChangeListener
{
protected boolean addValidationListeners = true;
@@ -64,32 +67,59 @@
{
return validationModel;
}
+
public void setValidationModel(ValidationResultModel validationModel)
{
this.validationModel = validationModel;
}
+
protected IzPackStage()
{
- registerStage(this);
+ registerStage(this);
+ validationModel.addPropertyChangeListener(
+ ValidationResultModel.PROPERTYNAME_ERRORS, this);
+
+
//TODO Make the center component a fixed size
}
+
+ public abstract void resetStage();
+ public JPanel getLeftNavBar()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void initializeStage()
+ {
+ validationModel.setResult(validateStage());
+ }
+
+ public void initializeStageFromXML(Document doc)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ //if ( ((Boolean) evt.getNewValue() ).booleanValue() == false)
+ // next.setEnabled(true);
+ }
+
/*
* (non-Javadoc)
*
* @see izpack.frontend.view.stages.Stage#getTopNavBar()
*/
public final JPanel getTopNavBar()
- {
- //JPanel base = new JPanel();
-
-
-
+ {
final StageContainer previousCont = stageOrder.getPreviousStage(this.getClass());
final StageContainer nextCont = stageOrder.getNextStage(this.getClass());
- JButton previous = null, next = null;
+ JButton previous = null;
if (previousCont != null)
{
@@ -101,9 +131,7 @@
{
fireStageChangeEvent(new StageChangeEvent(previousCont.stageClass));
}
- });
-
- //base.add(previous);
+ });
}
if (nextCont != null)
@@ -111,18 +139,15 @@
next = UI.getNavButton(nextCont.buttonText, UI.FORWARD);
next.addActionListener(new ActionListener()
- {
-
+ {
public void actionPerformed(ActionEvent e)
{
fireStageChangeEvent(new StageChangeEvent(nextCont.stageClass));
- }
-
- });
-
- //if (previous != null)
- // next.setPreferredSize(previous.getPreferredSize());
- //base.add(next);
+ }
+ });
+
+// if (validationModel.hasErrors())
+ // next.setEnabled(false);
}
@@ -131,8 +156,7 @@
else if (next == null)
return ButtonBarFactory.buildRightAlignedBar(previous);
else
- return ButtonBarFactory.buildRightAlignedBar(previous, next);
- //return base;
+ return ButtonBarFactory.buildRightAlignedBar(previous, next);
}
/*
@@ -146,9 +170,12 @@
validationModel.setResult(validateStage());
- bottom.add(ValidationResultViewFactory.createReportList(validationModel));
+ JScrollPane resultsPane = new JScrollPane(ValidationResultViewFactory.createReportList(validationModel));
+ resultsPane.setPreferredSize(new Dimension(500, 100));
+
+ bottom.add(resultsPane);
- bottom.setPreferredSize(new Dimension(700, 100));
+ bottom.setPreferredSize(new Dimension(700, 120));
return bottom;
}
@@ -254,6 +281,8 @@
protected static LangResources lr = IzPackFrame.getInstance().langResources();
protected static StageOrder stageOrder = new StageOrder();
+
+ private JButton next = null;
protected ValidationResultModel validationModel = new DefaultValidationResultModel();
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/compile/Compile.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/compile/Compile.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/compile/Compile.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -105,4 +105,11 @@
}
final CompileDisplay displayer;
+
+ @Override
+ public void resetStage()
+ {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/configure/PanelConfigurator.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/configure/PanelConfigurator.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/configure/PanelConfigurator.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -69,8 +69,7 @@
panelSelectionModel = (PanelSelectionModel) panelSelectionInstance.getDataModel();
if (panelSelectionModel != null)
- {
-
+ {
panelSelectionModel.addListDataListener(this);
}
else
@@ -229,4 +228,15 @@
{
xmlDoc = doc;
}
+
+ @Override
+ public void resetStage()
+ {
+ model.reset();
+
+ PanelSelectionModel panelSelectionModel = new PanelSelectionModel();
+ //panelSelectionModel.initWithAllPanels();
+
+ model.setPanels(panelSelectionModel);
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInfoPanel.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInfoPanel.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInfoPanel.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -134,7 +134,7 @@
}
configureValidation();
- ValidationComponentUtils.updateComponentTreeValidationBackground(this, ValidationResult.EMPTY);
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, ValidationResult.EMPTY);
}
public void actionPerformed(ActionEvent e)
@@ -252,8 +252,8 @@
ValidationComponentUtils.setMessageKey(appName, "Info.application name");
ValidationComponentUtils.setMessageKey(version, "Info.application version");
ValidationComponentUtils.setMessageKey(homepage, "Info.homepage");
- }
-
+ }
+
ArrayList authorListModel;
SelectionInList authorModel;
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInformation.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInformation.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/GeneralInformation.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -119,7 +119,7 @@
}
public PresentationModel getValidatingModel()
- {
+ {
if (presModel == null)
{
presModel = new PresentationModel(getDataModel());
@@ -130,7 +130,7 @@
{
ValidationResult result = getValidator().validate();
validationModel.setResult(result);
- ValidationComponentUtils.updateComponentTreeValidationBackground(generalInfoPage, result);
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(generalInfoPage, result);
}
});
@@ -177,4 +177,11 @@
{
model.initFromXML(doc);
}
+
+ @Override
+ public void resetStage()
+ {
+ model.resetModel();
+ }
+
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/UIConfig.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/UIConfig.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/geninfo/UIConfig.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -27,16 +27,23 @@
import izpack.frontend.view.stages.IzPackStage;
import izpack.frontend.view.stages.configure.panels.IzPackPanel;
+import java.text.Format;
+import java.text.NumberFormat;
+
+import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JTextField;
import com.jgoodies.binding.PresentationModel;
import com.jgoodies.binding.adapter.BasicComponentFactory;
import com.jgoodies.binding.adapter.Bindings;
+import com.jgoodies.binding.value.ConverterFactory;
+import com.jgoodies.binding.value.ValueModel;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.formatter.EmptyNumberFormatter;
import com.jgoodies.validation.view.ValidationComponentUtils;
/**
@@ -68,7 +75,7 @@
//TODO internationailze
resizable = new YesNoCheckBox("Allow window resizes");
- width = BasicComponentFactory.createIntegerField(pm.getModel("width"));
+ width = BasicComponentFactory.createIntegerField(pm.getModel("width"));
width.setColumns(5);
height = BasicComponentFactory.createIntegerField(pm.getModel("height"));
height.setColumns(5);
@@ -96,7 +103,7 @@
ValidationComponentUtils.setMessageKey(height, "GUIPrefs.height");
ValidationComponentUtils.setMessageKey(width, "GUIPrefs.width");
- ValidationComponentUtils.updateComponentTreeValidationBackground(this, ValidationResult.EMPTY);
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, ValidationResult.EMPTY);
}
PresentationModel pm;
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/ListTable.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/ListTable.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/ListTable.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -81,7 +81,7 @@
}
public void addElement(ElementModel em)
- {
+ {
boolean elementAdded = false;
for (int i = 0; i < model.getRowCount(); i++)
{
@@ -119,7 +119,7 @@
}
private void insertElementWithEditor(int row, Class type)
- {
+ {
doubleClickEditor = em.getEditor(type);
doubleClickEditor.configureClean();
doubleClickEditor.setVisible(true);
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/Pack.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/Pack.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/Pack.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -220,7 +220,7 @@
{
JScrollPane scroll = new JScrollPane();
scroll
- .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scroll.setViewportView(table);
@@ -456,4 +456,10 @@
model.initFromXML(doc);
}
+ @Override
+ public void resetStage()
+ {
+ for (int i = 0; i < model.getRowCount(); i++)
+ model.removeRow(i);
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/DirectoryEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/DirectoryEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/DirectoryEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -26,7 +26,7 @@
import izpack.frontend.controller.filters.DirectoryFilter;
import izpack.frontend.model.files.DirectoryModel;
import izpack.frontend.model.files.ElementModel;
-import izpack.frontend.view.components.OSComboBox;
+import izpack.frontend.view.components.OSSelector;
import izpack.frontend.view.components.OverwriteComboBox;
import izpack.frontend.view.components.table.TableEditor;
@@ -34,8 +34,10 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
+import java.util.List;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTextField;
@@ -43,6 +45,10 @@
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.validation.Severity;
+import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.message.PropertyValidationMessage;
+import com.jgoodies.validation.view.ValidationComponentUtils;
/**
* @author Andy Gombos
@@ -52,6 +58,7 @@
public DirectoryEditor(Frame parent)
{
super(parent);
+ setTitle(lr.getText("UI.DirEditor.Title"));
FormLayout layout = new FormLayout("right:max(40dlu;p), 3dlu, 80dlu, 3dlu, max(25dlu;p)", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout, new JPanel());
@@ -60,7 +67,7 @@
target = new JTextField();
source = new JTextField();
overwrite = new OverwriteComboBox();
- os = new OSComboBox();
+ os = new OSSelector();
browse = new JButton(lr.getText("UI.Buttons.Browse"));
@@ -92,7 +99,7 @@
builder.nextLine();
builder.append("<html>" + lr.getText("UI.DirEditor.Overwrite"), overwrite);
builder.nextLine();
- builder.append(lr.getText("UI.DirEditor.OS"), os);
+ builder.append(lr.getText("UI.DirEditor.OS"), os, 3);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
@@ -124,7 +131,7 @@
target.setText(fm.target);
overwrite.setOverwriteOption(fm.override);
- os.setOS(fm.os);
+ os.setOsModel(fm.os);
}
/* (non-Javadoc)
@@ -137,7 +144,7 @@
target.setText("$INSTALL_PATH");
overwrite.setSelectedIndex(-1);
- os.setSelectedIndex(-1);
+ os.setNoneSelected();
}
/* (non-Javadoc)
@@ -150,7 +157,7 @@
fm.source = source.getText();
fm.target = target.getText();
- fm.os = os.getOS();
+ fm.os = os.getOsModel();
fm.override = overwrite.getOverwriteOption();
return fm;
@@ -158,7 +165,7 @@
JButton browse;
JTextField target, source;
- OSComboBox os;
+ OSSelector os;
OverwriteComboBox overwrite;
/* (non-Javadoc)
* @see izpack.frontend.view.components.table.TableEditor#handles(java.lang.Class)
@@ -167,4 +174,47 @@
{
return type.equals(DirectoryModel.class);
}
+
+ @Override
+ public void configureValidation()
+ {
+ System.out.println("Configure validation");
+
+ ValidationComponentUtils.setMandatory(target, true);
+ ValidationComponentUtils.setMandatory(source, true);
+
+ ValidationComponentUtils.setMessageKey(target, "Target.file");
+ ValidationComponentUtils.setMessageKey(source, "Source.file");
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, ValidationResult.EMPTY);
+ }
+
+ @Override
+ public ValidationResult validateEditor()
+ {
+ ValidationResult vr = new ValidationResult();
+
+ if (target.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", target, "Target", "file"));
+
+ if (source.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", source, "Source", "file"));
+ else
+ if (!new File(source.getText()).exists())
+ vr.add(new PropertyValidationMessage(Severity.WARNING, "may not exist", source, "Source", "file"));
+
+ target.setToolTipText(null);
+ source.setToolTipText(null);
+
+ List messages = vr.getMessages();
+ for (Object object : messages)
+ {
+ PropertyValidationMessage message = (PropertyValidationMessage) object;
+ ((JComponent) message.target()).setToolTipText(message.formattedText());
+ }
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, vr);
+
+ return vr;
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ExecutableEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ExecutableEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ExecutableEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -21,6 +21,16 @@
* limitations under the License.
*/
+/*
+ *
+ *
+ *
+ * TODO Implement arguments
+ *
+ *
+ *
+ *
+ */
package izpack.frontend.view.stages.packs.editors;
import izpack.frontend.controller.ComboBoxParser;
@@ -29,6 +39,7 @@
import izpack.frontend.model.files.ElementModel;
import izpack.frontend.model.files.Executable;
import izpack.frontend.view.ClassChooser;
+import izpack.frontend.view.components.OSSelector;
import izpack.frontend.view.components.YesNoRadioPanel;
import izpack.frontend.view.components.table.TableEditor;
@@ -37,10 +48,12 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
+import java.util.List;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
+import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
@@ -49,6 +62,10 @@
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.validation.Severity;
+import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.message.PropertyValidationMessage;
+import com.jgoodies.validation.view.ValidationComponentUtils;
/**
* @author Andy Gombos
@@ -71,10 +88,14 @@
execClass = new JTextField();
bin = new JRadioButton(lr.getText("UI.ExecutableEditor.Type.Bin"));
jar = new JRadioButton(lr.getText("UI.ExecutableEditor.Type.JAR"));
+ os = new OSSelector();
stage = new JComboBox(ComboBoxParser.parseProperty(lr.getText("UI.ComboBox.Stage")));
failure = new JComboBox(ComboBoxParser.parseProperty(lr.getText("UI.ComboBox.Failure")));
keep = new YesNoRadioPanel("no");
+ target.getDocument().addDocumentListener(this);
+ execClass.getDocument().addDocumentListener(this);
+
JPanel typePanel = new JPanel();
typePanel.setLayout(new FlowLayout());
typePanel.add(bin);
@@ -121,6 +142,8 @@
builder.nextLine();
builder.append(lr.getText("UI.ExecutableEditor.Type"), typePanel);
builder.nextLine();
+ builder.append(lr.getText("UI.ExecutableEditor.OS"), os);
+ builder.nextLine();
builder.append(lr.getText("UI.ExecutableEditor.Stage"), stage);
builder.nextLine();
builder.append(lr.getText("UI.ExecutableEditor.Failure"), failure);
@@ -210,12 +233,49 @@
return em;
}
+
+ @Override
+ public void configureValidation()
+ {
+ ValidationComponentUtils.setMessageKey(target, "Target.file");
+ ValidationComponentUtils.setMessageKey(execClass, "Executable.class");
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, ValidationResult.EMPTY);
+ }
+ @Override
+ public ValidationResult validateEditor()
+ {
+ System.out.println("Validating");
+ ValidationResult vr = new ValidationResult();
+
+ if (target.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.WARNING, "should be provided", target, "Target", "file"));
+
+ if (target.getText().endsWith("jar") && execClass.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.WARNING, "should specify the class to execute from the JAR", execClass, "Executable", "class"));
+
+ target.setToolTipText(null);
+ execClass.setToolTipText(null);
+
+ List messages = vr.getMessages();
+ for (Object object : messages)
+ {
+ PropertyValidationMessage message = (PropertyValidationMessage) object;
+ ((JComponent) message.target()).setToolTipText(message.formattedText());
+ }
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, vr);
+
+ return vr;
+ }
+
JButton browse;
JTextField target;
JTextField execClass;
- JRadioButton bin, jar;
+ JRadioButton bin, jar;
JComboBox stage;
JComboBox failure;
YesNoRadioPanel keep;
+ OSSelector os;
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -29,7 +29,7 @@
import izpack.frontend.controller.filters.XMLFilter;
import izpack.frontend.model.files.ElementModel;
import izpack.frontend.model.files.FileModel;
-import izpack.frontend.view.components.OSComboBox;
+import izpack.frontend.view.components.OSSelector;
import izpack.frontend.view.components.OverwriteComboBox;
import izpack.frontend.view.components.table.TableEditor;
@@ -37,8 +37,10 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
+import java.util.List;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTextField;
@@ -46,24 +48,33 @@
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.validation.Severity;
+import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.message.PropertyValidationMessage;
+import com.jgoodies.validation.view.ValidationComponentUtils;
/**
* @author Andy Gombos
*/
+
public class FileEditor extends TableEditor
{
public FileEditor(Frame parent)
{
super(parent);
+ setTitle(lr.getText("UI.FileEditor.Title"));
FormLayout layout = new FormLayout("right:max(40dlu;p), 3dlu, 80dlu, 3dlu, max(25dlu;p)", "");
- DefaultFormBuilder builder = new DefaultFormBuilder(layout, new JPanel());
+ DefaultFormBuilder builder = new DefaultFormBuilder(layout, new JPanel());
builder.setDefaultDialogBorder();
target = new JTextField();
source = new JTextField();
overwrite = new OverwriteComboBox();
- os = new OSComboBox();
+ os = new OSSelector();
+
+ target.getDocument().addDocumentListener(this);
+ source.getDocument().addDocumentListener(this);
browse = new JButton(lr.getText("UI.Buttons.Browse"));
@@ -97,13 +108,14 @@
builder.nextLine();
builder.append("<html>" + lr.getText("UI.FileEditor.Overwrite"), overwrite);
builder.nextLine();
- builder.append(lr.getText("UI.FileEditor.OS"), os);
+ builder.append(lr.getText("UI.FileEditor.OS"), os, 3);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
builder.nextLine();
builder.append(ButtonBarFactory.buildOKCancelBar(ok, cancel), 3);
+ configureValidation();
getContentPane().add(builder.getPanel());
pack();
getRootPane().setDefaultButton(ok);
@@ -129,7 +141,7 @@
target.setText(fm.target);
overwrite.setOverwriteOption(fm.override);
- os.setOS(fm.os);
+ os.setOsModel(fm.os);
}
/* (non-Javadoc)
@@ -142,7 +154,7 @@
target.setText("$INSTALL_PATH");
overwrite.setSelectedIndex(-1);
- os.setSelectedIndex(-1);
+ os.setNoneSelected();
}
/* (non-Javadoc)
@@ -155,7 +167,7 @@
fm.source = source.getText();
fm.target = target.getText();
- fm.os = os.getOS();
+ fm.os = os.getOsModel();
fm.override = overwrite.getOverwriteOption();
return fm;
@@ -163,7 +175,7 @@
JButton browse;
JTextField target, source;
- OSComboBox os;
+ OSSelector os;
OverwriteComboBox overwrite;
/* (non-Javadoc)
* @see izpack.frontend.view.components.table.TableEditor#handles(java.lang.Class)
@@ -172,4 +184,45 @@
{
return type.equals(FileModel.class);
}
+
+ @Override
+ public void configureValidation()
+ {
+ ValidationComponentUtils.setMandatory(target, true);
+ ValidationComponentUtils.setMandatory(source, true);
+
+ ValidationComponentUtils.setMessageKey(target, "Target.file");
+ ValidationComponentUtils.setMessageKey(source, "Source.file");
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, ValidationResult.EMPTY);
+ }
+
+ @Override
+ public ValidationResult validateEditor()
+ {
+ ValidationResult vr = new ValidationResult();
+
+ if (target.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", target, "Target", "file"));
+
+ if (source.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", source, "Source", "file"));
+ else
+ if (!new File(source.getText()).exists())
+ vr.add(new PropertyValidationMessage(Severity.WARNING, "may not exist", source, "Source", "file"));
+
+ target.setToolTipText(null);
+ source.setToolTipText(null);
+
+ List messages = vr.getMessages();
+ for (Object object : messages)
+ {
+ PropertyValidationMessage message = (PropertyValidationMessage) object;
+ ((JComponent) message.target()).setToolTipText(message.formattedText());
+ }
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, vr);
+
+ return vr;
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileSetEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileSetEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/FileSetEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -29,7 +29,7 @@
import izpack.frontend.controller.filters.XMLFilter;
import izpack.frontend.model.files.ElementModel;
import izpack.frontend.model.files.FileSet;
-import izpack.frontend.view.components.OSComboBox;
+import izpack.frontend.view.components.OSSelector;
import izpack.frontend.view.components.OverwriteComboBox;
import izpack.frontend.view.components.YesNoRadioPanel;
import izpack.frontend.view.components.table.TableEditor;
@@ -38,10 +38,12 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
+import java.util.List;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JList;
import javax.swing.JPanel;
@@ -52,6 +54,10 @@
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.validation.Severity;
+import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.message.PropertyValidationMessage;
+import com.jgoodies.validation.view.ValidationComponentUtils;
/**
* @author Andy Gombos
@@ -62,6 +68,8 @@
{
super(parent);
+ setTitle(lr.getText("UI.FileSetEditor.Title"));
+
FormLayout layout = new FormLayout("right:max(40dlu;p), 3dlu, 80dlu, 3dlu, max(25dlu;p)", "");
DefaultFormBuilder builder = new DefaultFormBuilder(layout, new JPanel());
builder.setDefaultDialogBorder();
@@ -69,10 +77,13 @@
target = new JTextField();
source = new JTextField();
overwrite = new OverwriteComboBox();
- os = new OSComboBox();
+ os = new OSSelector();
defaultExcludes = new YesNoRadioPanel("yes");
- caseSensitive = new YesNoRadioPanel("yes");
+ caseSensitive = new YesNoRadioPanel("yes");
+ target.getDocument().addDocumentListener(this);
+ source.getDocument().addDocumentListener(this);
+
fileSetsModel = new FileSet();
fileSets = new JList(fileSetsModel);
@@ -107,12 +118,8 @@
public void actionPerformed(ActionEvent e)
{
JFileChooser chooser = new JFileChooser();
- chooser.addChoosableFileFilter(new ImageFilter());
- chooser.addChoosableFileFilter(new TextFilter());
- chooser.addChoosableFileFilter(new XMLFilter());
- chooser.addChoosableFileFilter(new HTMLFilter());
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- chooser.setDialogTitle(lr.getText("UI.FileEditor.Title"));
+ chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+ chooser.setDialogTitle(lr.getText("UI.FileSetEditor.BrowseTitle"));
if (source.getText().length() != 0)
{
@@ -126,13 +133,13 @@
}
});
- builder.append(lr.getText("UI.FileEditor.Source"), source, browse);
+ builder.append(lr.getText("UI.FileSetEditor.Source"), source, browse);
builder.nextLine();
- builder.append(lr.getText("UI.FileEditor.Target"), target);
+ builder.append(lr.getText("UI.FileSetEditor.Target"), target);
builder.nextLine();
builder.append("<html>" + lr.getText("UI.FileEditor.Overwrite"), overwrite);
builder.nextLine();
- builder.append(lr.getText("UI.FileEditor.OS"), os);
+ builder.append(lr.getText("UI.FileEditor.OS"), os, 3);
builder.nextLine();
builder.append(lr.getText("UI.FileSetEditor.Excludes"), defaultExcludes);
@@ -149,7 +156,8 @@
builder.nextLine();
builder.append(ButtonBarFactory.buildOKCancelBar(ok, cancel), 3);
builder.nextLine();
-
+
+ configureValidation();
getContentPane().add(builder.getPanel());
pack();
getRootPane().setDefaultButton(ok);
@@ -174,7 +182,7 @@
target.setText(fs.target);
overwrite.setOverwriteOption(fs.override);
- os.setOS(fs.os);
+ os.setOsModel(fs.os);
defaultExcludes.setBoolean(fs.defaultExcludes);
caseSensitive.setBoolean(fs.caseSensitive);
@@ -191,7 +199,7 @@
target.setText("$INSTALL_PATH");
overwrite.setSelectedIndex(-1);
- os.setSelectedIndex(-1);
+ os.setNoneSelected();
defaultExcludes.setSelected("yes");
caseSensitive.setSelected("yes");
@@ -211,7 +219,7 @@
fs.source = source.getText();
fs.target = target.getText();
- fs.os = os.getOS();
+ fs.os = os.getOsModel();
fs.override = overwrite.getOverwriteOption();
fs.caseSensitive = caseSensitive.getBoolean();
@@ -224,7 +232,7 @@
JButton browse;
JTextField target, source;
- OSComboBox os;
+ OSSelector os;
OverwriteComboBox overwrite;
YesNoRadioPanel defaultExcludes;
YesNoRadioPanel caseSensitive;
@@ -240,4 +248,46 @@
{
return type.equals(FileSet.class);
}
+
+ @Override
+ public void configureValidation()
+ {
+ System.out.println("fileset config valid");
+ ValidationComponentUtils.setMandatory(target, true);
+ ValidationComponentUtils.setMandatory(source, true);
+
+ ValidationComponentUtils.setMessageKey(target, "Destination.directory");
+ ValidationComponentUtils.setMessageKey(source, "Source.directory");
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, ValidationResult.EMPTY);
+ }
+
+ @Override
+ public ValidationResult validateEditor()
+ {
+ ValidationResult vr = new ValidationResult();
+
+ if (target.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", target, "Destination", "directory"));
+
+ if (source.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", source, "Source", "directory"));
+ else
+ if (!new File(source.getText()).exists())
+ vr.add(new PropertyValidationMessage(Severity.WARNING, "may not exist", source, "Source", "directory"));
+
+ target.setToolTipText(null);
+ source.setToolTipText(null);
+
+ List messages = vr.getMessages();
+ for (Object object : messages)
+ {
+ PropertyValidationMessage message = (PropertyValidationMessage) object;
+ ((JComponent) message.target()).setToolTipText(message.formattedText());
+ }
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, vr);
+
+ return vr;
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/PackEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/PackEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/PackEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -27,19 +27,26 @@
import izpack.frontend.model.files.ElementModel;
import izpack.frontend.view.components.AbstractListSelect;
import izpack.frontend.view.components.DependencyListSelect;
-import izpack.frontend.view.components.OSComboBox;
+import izpack.frontend.view.components.OSSelector;
import izpack.frontend.view.components.YesNoRadioPanel;
import izpack.frontend.view.components.table.TableEditor;
import java.awt.Frame;
+import java.io.File;
+import java.util.List;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTextField;
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.validation.Severity;
+import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.message.PropertyValidationMessage;
+import com.jgoodies.validation.view.ValidationComponentUtils;
/**
* @author Andy Gombos
@@ -57,24 +64,27 @@
name = new JTextField();
desc = new JTextField();
id = new JTextField();
- osBox = new OSComboBox();
+ osSel = new OSSelector();
requiredPanel = new YesNoRadioPanel("yes");
preselectPanel = new YesNoRadioPanel("yes");
- looseFilesPanel = new YesNoRadioPanel("no");
+ looseFilesPanel = new YesNoRadioPanel("no");
+ name.getDocument().addDocumentListener(this);
+ desc.getDocument().addDocumentListener(this);
+
ok = new JButton(lr.getText("UI.Buttons.OK"));
ok.addActionListener(this);
cancel = new JButton(lr.getText("UI.Buttons.Cancel"));
cancel.addActionListener(this);
- builder.append(lr.getText("UI.PackEditor.Name"), name);
+ builder.append(lr.getText("UI.PackEditor.Name"), name, 2);
builder.nextLine();
builder.append(lr.getText("UI.PackEditor.Desc"), desc, 2);
builder.nextLine();
- builder.append(lr.getText("UI.PackEditor.ID"), id);
+ builder.append(lr.getText("UI.PackEditor.ID"), id, 2);
builder.nextLine();
- builder.append(lr.getText("UI.PackEditor.OS"), osBox);
+ builder.append(lr.getText("UI.PackEditor.OS"), osSel, 2);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
@@ -87,16 +97,13 @@
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
- builder.nextLine();
+ builder.nextLine();
- //builder.append(createDependencyPanel());
-
- //builder.appendUnrelatedComponentsGapRow();
- //builder.nextLine();
-
builder.append(ButtonBarFactory.buildOKCancelBar(ok, cancel), 3);
builder.nextLine();
+ configureValidation();
+
getContentPane().add(builder.getPanel());
pack();
getRootPane().setDefaultButton(ok);
@@ -122,6 +129,8 @@
{
name.requestFocusInWindow();
+ validateEditor();
+
super.setVisible(b);
}
@@ -132,7 +141,7 @@
name.setText(p.getName());
desc.setText(p.getDesc());
id.setText(p.getId());
- osBox.setOS(p.getOS());
+ osSel.setOsModel(p.getOS());
requiredPanel.setBoolean(p.isRequired());
preselectPanel.setBoolean(p.isPreselected());
@@ -146,7 +155,7 @@
p.setName(name.getText());
p.setDesc(desc.getText());
p.setId(id.getText());
- p.setOS(osBox.getOS());
+ p.setOSes(osSel.getOsModel());
p.setRequired(requiredPanel.getBoolean());
p.setPreselected(preselectPanel.getBoolean());
@@ -156,7 +165,7 @@
}
JTextField name, desc, id;
- OSComboBox osBox;
+ OSSelector osSel;
YesNoRadioPanel preselectPanel;
YesNoRadioPanel looseFilesPanel;
YesNoRadioPanel requiredPanel;
@@ -170,7 +179,7 @@
desc.setText("");
id.setText("");
- osBox.setSelectedIndex(-1);
+ osSel.setNoneSelected();
requiredPanel.setBoolean(true);
preselectPanel.setBoolean(true);
@@ -184,4 +193,44 @@
{
return type.equals(PackModel.class);
}
+
+ @Override
+ public void configureValidation()
+ {
+ System.out.println("pack config valid");
+ ValidationComponentUtils.setMandatory(name, true);
+ ValidationComponentUtils.setMandatory(desc, true);
+
+ ValidationComponentUtils.setMessageKey(name, "Pack.name");
+ ValidationComponentUtils.setMessageKey(desc, "Pack.description");
+
+ validateEditor();
+ }
+
+ @Override
+ public ValidationResult validateEditor()
+ {
+ ValidationResult vr = new ValidationResult();
+
+ if (name.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", name, "Pack", "name"));
+
+ if (desc.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", desc, "Pack", "description"));
+
+ name.setToolTipText(null);
+ desc.setToolTipText(null);
+
+ List messages = vr.getMessages();
+ for (Object object : messages)
+ {
+ PropertyValidationMessage message = (PropertyValidationMessage) object;
+ ((JComponent) message.target()).setToolTipText(message.formattedText());
+ }
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, vr);
+ ValidationComponentUtils.updateComponentTreeMandatoryAndBlankBackground(this);
+
+ return vr;
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ParsableEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ParsableEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/ParsableEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -26,14 +26,17 @@
import izpack.frontend.model.files.ElementModel;
import izpack.frontend.model.files.Parsable;
import izpack.frontend.view.components.FormatComboBox;
-import izpack.frontend.view.components.OSComboBox;
+import izpack.frontend.view.components.OSSelector;
import izpack.frontend.view.components.table.TableEditor;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.File;
+import java.util.List;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTextField;
@@ -41,6 +44,10 @@
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.factories.ButtonBarFactory;
import com.jgoodies.forms.layout.FormLayout;
+import com.jgoodies.validation.Severity;
+import com.jgoodies.validation.ValidationResult;
+import com.jgoodies.validation.message.PropertyValidationMessage;
+import com.jgoodies.validation.view.ValidationComponentUtils;
/**
* @author Andy Gombos
@@ -58,8 +65,10 @@
targetFile = new JTextField();
format = new FormatComboBox();
encoding = new JTextField();
- os = new OSComboBox();
+ os = new OSSelector();
+ targetFile.getDocument().addDocumentListener(this);
+
ok = new JButton(lr.getText("UI.Buttons.OK"));
ok.addActionListener(this);
@@ -84,13 +93,14 @@
builder.nextLine();
builder.append(lr.getText("UI.ParsableEditor.Encoding"), encoding);
builder.nextLine();
- builder.append(lr.getText("UI.ParsableEditor.OS"), os);
+ builder.append(lr.getText("UI.ParsableEditor.OS"), os, 3);
builder.nextLine();
builder.appendUnrelatedComponentsGapRow();
builder.nextLine();
builder.append(ButtonBarFactory.buildOKCancelBar(ok, cancel), 3);
+ configureValidation();
getContentPane().add(builder.getPanel());
pack();
getRootPane().setDefaultButton(ok);
@@ -116,7 +126,7 @@
encoding.setText(pm.encoding);
format.setFormat(pm.type);
- os.setOS(pm.os);
+ os.setOsModel(pm.os);
}
/* (non-Javadoc)
@@ -129,7 +139,7 @@
encoding.setText("");
format.setSelectedIndex(-1);
- os.setSelectedIndex(-1);
+ os.setNoneSelected();
}
/* (non-Javadoc)
@@ -143,7 +153,7 @@
pm.encoding = encoding.getText();
pm.type = format.getFormat();
- pm.os = os.getOS();
+ pm.os = os.getOsModel();
return pm;
}
@@ -152,7 +162,7 @@
JTextField targetFile;
FormatComboBox format;
JTextField encoding;
- OSComboBox os;
+ OSSelector os;
/* (non-Javadoc)
* @see izpack.frontend.view.components.table.TableEditor#handles(java.lang.Class)
*/
@@ -160,4 +170,38 @@
{
return type.equals(Parsable.class);
}
+
+ @Override
+ public void configureValidation()
+ {
+ ValidationComponentUtils.setMandatory(targetFile, true);
+
+ ValidationComponentUtils.setMessageKey(targetFile, "Target.file");
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, ValidationResult.EMPTY);
+ }
+
+ @Override
+ public ValidationResult validateEditor()
+ {
+ ValidationResult vr = new ValidationResult();
+
+ if (targetFile.getText().length() == 0)
+ vr.add(new PropertyValidationMessage(Severity.ERROR, "is mandatory", targetFile, "Target", "file"));
+ else if (!new File(targetFile.getText()).exists())
+ vr.add(new PropertyValidationMessage(Severity.WARNING, "may not exist", targetFile, "Target", "file"));
+
+ targetFile.setToolTipText(null);
+
+ List messages = vr.getMessages();
+ for (Object object : messages)
+ {
+ PropertyValidationMessage message = (PropertyValidationMessage) object;
+ ((JComponent) message.target()).setToolTipText(message.formattedText());
+ }
+
+ ValidationComponentUtils.updateComponentTreeSeverityBackground(this, vr);
+
+ return vr;
+ }
}
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/SetEditor.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/SetEditor.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/packs/editors/SetEditor.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -77,7 +77,7 @@
builder.add(new JLabel(lr.getText("UI.SetEditor.Name")), new CellConstraints(1, 1), descriptor, cc.xy(3, 1));
builder.add(include, cc.xy(1, 3));
builder.add(exclude, cc.xy(3, 3));
- builder.add(ButtonBarFactory.buildOKCancelBar(ok, cancel), cc.xyw(1, 5, 3, CellConstraints.CENTER, CellConstraints.FILL));
+ builder.add(ButtonBarFactory.buildOKCancelBar(ok, cancel), cc.xyw(1, 5, 3, CellConstraints.CENTER, CellConstraints.FILL));
add(builder.getPanel());
pack();
Modified: izpack-frontend/trunk/src/izpack/frontend/view/stages/panelselect/PanelSelection.java
===================================================================
--- izpack-frontend/trunk/src/izpack/frontend/view/stages/panelselect/PanelSelection.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/izpack/frontend/view/stages/panelselect/PanelSelection.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -135,4 +135,10 @@
{
model.initFromXML(doc);
}
+
+ @Override
+ public void resetStage()
+ {
+ model.clear();
+ }
}
Added: izpack-frontend/trunk/src/lib/validation-1.3.0.jar
===================================================================
(Binary files differ)
Property changes on: izpack-frontend/trunk/src/lib/validation-1.3.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: izpack-frontend/trunk/src/res/i18n/LangResources_en.properties
===================================================================
--- izpack-frontend/trunk/src/res/i18n/LangResources_en.properties 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/res/i18n/LangResources_en.properties 2006-08-11 15:52:24 UTC (rev 1527)
@@ -25,6 +25,7 @@
UI.ExecutableEditor.Stage = Stage to execute during
UI.ExecutableEditor.Target = Executable file
UI.ExecutableEditor.Type = Type of executable
+UI.ExecutableEditor.OS = OS(es) to execute on
UI.ExecutableEditor.Type.Bin = Binary
UI.ExecutableEditor.Type.JAR = Class in JAR
UI.FileEditor.OS = Applicable OS
@@ -42,11 +43,14 @@
UI.FileFilters.Jar.Desc = JAR Files (JAR)
UI.FileFilters.Text.Desc = Text Files (TXT, INI, CONF)
UI.FileFilters.XML.Desc = XML Files (XML, XSL)
+UI.FileSetEditor.Source = Source directory
+UI.FileSetEditor.Target = Destination directory
UI.FileSetEditor.AddSet = Add Set
UI.FileSetEditor.CaseSensitive = Set pattern is case sensitive
UI.FileSetEditor.Excludes = Use default exclude set
UI.FileSetEditor.RemoveSet = Remove Set
UI.FileSetEditor.Title = Create a file set...
+UI.FileSetEditor.BrowseTitle = Select the source directory...
UI.GeneralInfoPage.APPNAME.Text = Application Name\:
UI.GeneralInfoPage.AUTHORS.Text = Authors\:
UI.GeneralInfoPage.Dialog.ELEMENT.CancelButton = Cancel
Modified: izpack-frontend/trunk/src/utils/XML.java
===================================================================
--- izpack-frontend/trunk/src/utils/XML.java 2006-08-08 14:41:42 UTC (rev 1526)
+++ izpack-frontend/trunk/src/utils/XML.java 2006-08-11 15:52:24 UTC (rev 1527)
@@ -27,6 +27,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
+import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@@ -39,15 +40,16 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import exceptions.DocumentCreationException;
@@ -90,7 +92,7 @@
document = builder.parse(new File(filename));
String URI = new File(filename).getParent();
-
+
if (URI == null)
URI = "";
else
@@ -172,6 +174,47 @@
}
}
+ public static void writeXML(StreamResult stream, Node node, String xslFile)
+ {
+ try
+ {
+ // Prepare the DOM document for writing
+ Source source = new DOMSource(node);
+
+ // Prepare the output file
+ Result result = stream;
+
+ //Load the XSL file to make everything pretty
+ StreamSource xsl = new StreamSource(new File(xslFile));
+ // Write the DOM document to the file
+ // Get Transformer
+ //This won't properly indent - research indicates a 1.5 bug (so 1.3 JAXP?)
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ Transformer xformer = tFactory.newTransformer(xsl);
+
+ //Set the output doctype
+ //String systemValue = new File("dtd/installation.dtd").getPath();
+ //xformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, systemValue);
+
+ //xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+
+ // Write to a file
+ xformer.transform(source, result);
+ }
+ catch (TransformerConfigurationException tce)
+ {
+ //TODO Make this a better handler - it's not really a fatal error
+ //But, we can't save anything without a working transformer. So, maybe it is
+ //UI.showError("An error occurred configuring the transformer for XML output", )
+ throw new UnhandleableException(tce);
+ }
+ catch (TransformerException te)
+ {
+ //TODO Same as above
+ throw new UnhandleableException(te);
+ }
+ }
+
public static Document merge(Document doc1, Document doc2)
{
Element head1 = doc1.getDocumentElement();
@@ -202,7 +245,7 @@
{
try
{
- //Use XPath to return the resource value by searching with it
+ //Use XPath to return the resource value by searching with it
return xpath.evaluate("//res[@id='" + id + "']/@src", document);
}
catch (XPathExpressionException xpee)
More information about the izpack-changes
mailing list