git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268938 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -72,16 +72,32 @@ import com.sun.xml.parser.Resolver; | |||||
| * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | * @author Nick Davis<a href="mailto:nick_home_account@yahoo.com">nick_home_account@yahoo.com</a> | ||||
| */ | */ | ||||
| public class ACSDocumentType extends java.lang.Object { | public class ACSDocumentType extends java.lang.Object { | ||||
| /** ID for core elements */ | |||||
| public final static int CORE_ELEMENT = 0; | |||||
| /** ID for optional elements */ | |||||
| public final static int OPTIONAL_ELEMENT = 1; | |||||
| /** True if the DTD has been loaded */ | /** True if the DTD has been loaded */ | ||||
| private boolean isInit = false; | private boolean isInit = false; | ||||
| /** Hold the core DTD elements */ | |||||
| private HashMap coreElementMap = new HashMap(); | |||||
| /** Hold the optional DTD elements */ | |||||
| private HashMap optionalElementMap = new HashMap(); | |||||
| /** Hold the DTD elements */ | /** Hold the DTD elements */ | ||||
| private HashMap elementMap = new HashMap(); | |||||
| /** XML document used to load the DTD */ | |||||
| final static String XMLDOC = | |||||
| private HashMap elementMap; | |||||
| /** First part of the XML document used to load the DTD */ | |||||
| private final static String XMLDOC_1 = | |||||
| "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + | ||||
| "<!DOCTYPE project SYSTEM \"file:/project.dtd\">" + | |||||
| "<project name=\"sample-project\">" + | |||||
| "<!DOCTYPE project SYSTEM \"file:/"; | |||||
| /** Second part of the XML document used to load the DTD */ | |||||
| private final static String XMLDOC_2 = | |||||
| "\"><project name=\"sample-project\">" + | |||||
| "</project>"; | "</project>"; | ||||
| /** DTD which holds the core tasks */ | |||||
| private final static String DTD_1 = "project.dtd"; | |||||
| /** DTD which holds the optional tasks */ | |||||
| private final static String DTD_2 = "project-ext.dtd"; | |||||
| /** DTD which holds the shared elements */ | |||||
| private final static String DTD_SHARE = "share.dtd"; | |||||
| /** | /** | ||||
| * Standard ctor. | * Standard ctor. | ||||
| @@ -114,12 +130,20 @@ public class ACSDocumentType extends java.lang.Object { | |||||
| DtdHandler dtdh = new DtdHandler(); | DtdHandler dtdh = new DtdHandler(); | ||||
| p.setDTDHandler(dtdh); | p.setDTDHandler(dtdh); | ||||
| // Create the default xml file | |||||
| InputSource xmldoc = new InputSource( | |||||
| new ByteArrayInputStream(XMLDOC.getBytes())); | |||||
| String coreDoc = XMLDOC_1 + DTD_1 + XMLDOC_2; | |||||
| String optionalDoc = XMLDOC_1 + DTD_2 + XMLDOC_2; | |||||
| // Parse the document | |||||
| p.parse(xmldoc); | |||||
| // Parse the core task DTD | |||||
| elementMap = coreElementMap; | |||||
| InputSource xmldocCore = new InputSource( | |||||
| new ByteArrayInputStream(coreDoc.getBytes())); | |||||
| p.parse(xmldocCore); | |||||
| // Parse the core task DTD | |||||
| elementMap = optionalElementMap; | |||||
| InputSource xmldocOptional = new InputSource( | |||||
| new ByteArrayInputStream(optionalDoc.getBytes())); | |||||
| p.parse(xmldocOptional); | |||||
| isInit = true; | isInit = true; | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -130,10 +154,14 @@ public class ACSDocumentType extends java.lang.Object { | |||||
| /** | /** | ||||
| * Returns the dtd element. | * Returns the dtd element. | ||||
| * | * | ||||
| * @param elementType CORE_ELEMENT or OPTIONAL_ELEMENT | |||||
| * @param name the element name | * @param name the element name | ||||
| */ | */ | ||||
| public DtdElement findElement(String name) { | |||||
| return (DtdElement) elementMap.get(name); | |||||
| public DtdElement findElement(int elementType, String name) { | |||||
| if (elementType == OPTIONAL_ELEMENT) { | |||||
| return (DtdElement) optionalElementMap.get(name); | |||||
| } | |||||
| return (DtdElement) coreElementMap.get(name); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -247,7 +275,7 @@ public class ACSDocumentType extends java.lang.Object { | |||||
| Iterator i = values().iterator(); | Iterator i = values().iterator(); | ||||
| while(i.hasNext()) { | while(i.hasNext()) { | ||||
| DtdAttribute a = (DtdAttribute)i.next(); | DtdAttribute a = (DtdAttribute)i.next(); | ||||
| if (a.isRequired()) { | |||||
| if (!a.isRequired()) { | |||||
| list.add(a.getName()); | list.add(a.getName()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -264,7 +292,7 @@ public class ACSDocumentType extends java.lang.Object { | |||||
| Iterator i = values().iterator(); | Iterator i = values().iterator(); | ||||
| while(i.hasNext()) { | while(i.hasNext()) { | ||||
| DtdAttribute a = (DtdAttribute)i.next(); | DtdAttribute a = (DtdAttribute)i.next(); | ||||
| if (!a.isRequired()) { | |||||
| if (a.isRequired()) { | |||||
| list.add(a.getName()); | list.add(a.getName()); | ||||
| } | } | ||||
| } | } | ||||
| @@ -438,22 +466,30 @@ public class ACSDocumentType extends java.lang.Object { | |||||
| String systemId) | String systemId) | ||||
| throws SAXException, IOException { | throws SAXException, IOException { | ||||
| final String PROJECT = "project.dtd"; | |||||
| final String PROJECTEXT = "project-ext.dtd"; | |||||
| InputStream result = null; | InputStream result = null; | ||||
| // Is it the project.dtd? | // Is it the project.dtd? | ||||
| if (systemId.indexOf(PROJECT) != -1) { | |||||
| if (systemId.indexOf(DTD_1) != -1) { | |||||
| try { | try { | ||||
| // Look for it as a resource | // Look for it as a resource | ||||
| result = getClass().getResourceAsStream(PROJECT); | |||||
| result = getClass().getResourceAsStream(DTD_1); | |||||
| } catch (Exception e) {} | } catch (Exception e) {} | ||||
| } | } | ||||
| // Is it the project-ext.dtd? | // Is it the project-ext.dtd? | ||||
| if (systemId.indexOf(PROJECTEXT) != -1) { | |||||
| if (systemId.indexOf(DTD_2) != -1) { | |||||
| try { | |||||
| // Look for it as a resource | |||||
| result = getClass().getResourceAsStream(DTD_2); | |||||
| } catch (Exception e) {} | |||||
| } | |||||
| if (result != null) { | |||||
| return new InputSource(result); | |||||
| } | |||||
| // Is it the share.dtd? | |||||
| if (systemId.indexOf(DTD_SHARE) != -1) { | |||||
| try { | try { | ||||
| // Look for it as a resource | // Look for it as a resource | ||||
| result = getClass().getResourceAsStream(PROJECTEXT); | |||||
| result = getClass().getResourceAsStream(DTD_SHARE); | |||||
| } catch (Exception e) {} | } catch (Exception e) {} | ||||
| } | } | ||||
| if (result != null) { | if (result != null) { | ||||
| @@ -53,6 +53,7 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant.gui.acs; | package org.apache.tools.ant.gui.acs; | ||||
| import org.apache.tools.ant.gui.command.NewElementCmd; | import org.apache.tools.ant.gui.command.NewElementCmd; | ||||
| import org.apache.tools.ant.gui.util.Collections; | |||||
| import org.w3c.dom.*; | import org.w3c.dom.*; | ||||
| import java.beans.*; | import java.beans.*; | ||||
| import java.util.*; | import java.util.*; | ||||
| @@ -181,12 +182,21 @@ implements ACSInfoProvider { | |||||
| } | } | ||||
| ACSDocumentType.DtdElement e = | ACSDocumentType.DtdElement e = | ||||
| docType.findElement(name); | |||||
| docType.findElement(ACSDocumentType.CORE_ELEMENT, name); | |||||
| if (e == null) { | |||||
| e = docType.findElement(ACSDocumentType.OPTIONAL_ELEMENT, name); | |||||
| } | |||||
| if (e != null) { | if (e != null) { | ||||
| // Use the content model (all the possible | // Use the content model (all the possible | ||||
| // sub-elements) to create the menu. | // sub-elements) to create the menu. | ||||
| String[] temp = e.getContentModel(); | String[] temp = e.getContentModel(); | ||||
| // Sort the items | |||||
| List list = Collections.fill(null, temp); | |||||
| java.util.Collections.sort(list); | |||||
| list.toArray(temp); | |||||
| int size = (temp.length > 5) ? 5 : temp.length; | int size = (temp.length > 5) ? 5 : temp.length; | ||||
| // The project doesn't need a delete menu | // The project doesn't need a delete menu | ||||
| @@ -222,15 +232,17 @@ implements ACSInfoProvider { | |||||
| } | } | ||||
| /** | /** | ||||
| * Retuns a string array which contains this elements | |||||
| * possible children. It is created from the DTD's | |||||
| * content model. | |||||
| * Returns a string array which contains this elements | |||||
| * possible children. | |||||
| * | |||||
| * @param childType ACSDocumentType.CORE_ELEMENT or | |||||
| * ACSDocumentType.OPTIONAL_ELEMENT | |||||
| */ | */ | ||||
| public String[] getPossibleChildren() { | |||||
| public String[] getPossibleChildren(int childType) { | |||||
| String name = getTagName(); | String name = getTagName(); | ||||
| ACSDocumentType.DtdElement e = | ACSDocumentType.DtdElement e = | ||||
| docType.findElement(name); | |||||
| docType.findElement(childType, name); | |||||
| if (e != null) { | if (e != null) { | ||||
| return e.getContentModel(); | return e.getContentModel(); | ||||
| } | } | ||||
| @@ -266,7 +278,13 @@ implements ACSInfoProvider { | |||||
| } | } | ||||
| String name = getNodeName(); | String name = getNodeName(); | ||||
| _dtdElement = docType.findElement(name); | |||||
| _dtdElement = docType.findElement(ACSDocumentType.CORE_ELEMENT, name); | |||||
| if (_dtdElement == null) { | |||||
| _dtdElement = docType.findElement( | |||||
| ACSDocumentType.OPTIONAL_ELEMENT, name); | |||||
| } | |||||
| return _dtdElement; | return _dtdElement; | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,34 +1,255 @@ | |||||
| <?xml version="1.0" encoding="iso-8859-1"?> | <?xml version="1.0" encoding="iso-8859-1"?> | ||||
| <!-- | <!-- | ||||
| Copyright (c) 2000 Michel CASABIANCA. All Rights Reserved. | |||||
| Permission to use, copy, modify, and distribute this software and its | |||||
| documentation for any purpose and without fee or royalty is hereby | |||||
| granted, provided that both the above copyright notice and this | |||||
| permission notice appear in all copies of the software and | |||||
| documentation or portions thereof, including modifications, that you | |||||
| make. | |||||
| THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO | |||||
| REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, | |||||
| BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR | |||||
| WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR | |||||
| THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY | |||||
| THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. | |||||
| COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE | |||||
| OR DOCUMENTATION. | |||||
| The Apache Software License, Version 1.1 | |||||
| Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| reserved. | |||||
| Redistribution and use in source and binary forms, with or without | |||||
| modification, are permitted provided that the following conditions | |||||
| are met: | |||||
| 1. Redistributions of source code must retain the above copyright | |||||
| notice, this list of conditions and the following disclaimer. | |||||
| 2. Redistributions in binary form must reproduce the above copyright | |||||
| notice, this list of conditions and the following disclaimer in | |||||
| the documentation and/or other materials provided with the | |||||
| distribution. | |||||
| 3. The end-user documentation included with the redistribution, if | |||||
| any, must include the following acknowlegement: | |||||
| "This product includes software developed by the | |||||
| Apache Software Foundation (http://www.apache.org/)." | |||||
| Alternately, this acknowlegement may appear in the software itself, | |||||
| if and wherever such third-party acknowlegements normally appear. | |||||
| 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| Foundation" must not be used to endorse or promote products derived | |||||
| from this software without prior written permission. For written | |||||
| permission, please contact apache@apache.org. | |||||
| 5. Products derived from this software may not be called "Apache" | |||||
| nor may "Apache" appear in their names without prior written | |||||
| permission of the Apache Group. | |||||
| THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| SUCH DAMAGE. | |||||
| ==================================================================== | |||||
| This software consists of voluntary contributions made by many | |||||
| individuals on behalf of the Apache Software Foundation. For more | |||||
| information on the Apache Software Foundation, please see | |||||
| <http://www.apache.org/>. | |||||
| --> | --> | ||||
| <!-- @author Michel CASABIANCA --> | |||||
| <!-- @version $Revision$ --> | |||||
| <!ENTITY % share-file SYSTEM "file:/share.dtd"> | |||||
| %share-file; | |||||
| <!ELEMENT target (p4sync | p4label | p4have | p4submit | p4edit | p4change | junit | ddcreator | ejbc | wlrun | wlstop | ejbjar | weblogic | TOPLink | PropertyFile)*> | |||||
| <!-- *********** PERFORCE ************** --> | |||||
| <!ELEMENT p4sync EMPTY> | |||||
| <!ATTLIST p4sync | |||||
| view CDATA #IMPLIED | |||||
| label CDATA #IMPLIED | |||||
| force CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT p4change EMPTY> | |||||
| <!ELEMENT p4edit EMPTY> | |||||
| <!ATTLIST p4edit | |||||
| view CDATA #REQUIRED | |||||
| change CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT p4submit EMPTY> | |||||
| <!ATTLIST p4submit | |||||
| change CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT p4have EMPTY> | |||||
| <!ELEMENT p4label EMPTY> | |||||
| <!ATTLIST p4label | |||||
| name CDATA #REQUIRED | |||||
| view CDATA #IMPLIED | |||||
| desc CDATA #IMPLIED | |||||
| > | |||||
| <!-- *********** JUNIT ************** --> | |||||
| <!-- project ext DTD for Ant --> | |||||
| <!-- 2000-04-03 --> | |||||
| <!ELEMENT junit (jvmarg | batchtest | test | formatter | sysproperty)*> | |||||
| <!ATTLIST junit | |||||
| printsummary CDATA #IMPLIED | |||||
| fork CDATA #IMPLIED | |||||
| haltonerror CDATA #IMPLIED | |||||
| haltonfailure CDATA #IMPLIED | |||||
| timeout CDATA #IMPLIED | |||||
| maxmemory CDATA #IMPLIED | |||||
| jvm CDATA #IMPLIED | |||||
| dir CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT jvmarg EMPTY> | |||||
| <!ATTLIST jvmarg | |||||
| value CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT sysproperty EMPTY> | |||||
| <!ATTLIST sysproperty | |||||
| key CDATA #REQUIRED | |||||
| value CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT formatter EMPTY> | |||||
| <!ATTLIST formatter | |||||
| type CDATA #IMPLIED | |||||
| classname CDATA #IMPLIED | |||||
| extension CDATA #REQUIRED | |||||
| usefile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT test EMPTY> | |||||
| <!ATTLIST test | |||||
| name CDATA #REQUIRED | |||||
| fork CDATA #IMPLIED | |||||
| haltonerror CDATA #IMPLIED | |||||
| haltonfailure CDATA #IMPLIED | |||||
| todir CDATA #IMPLIED | |||||
| outfile CDATA #IMPLIED | |||||
| if CDATA #IMPLIED | |||||
| unless CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT batchtest EMPTY> | |||||
| <!ATTLIST batchtest | |||||
| fork CDATA #IMPLIED | |||||
| haltonerror CDATA #IMPLIED | |||||
| haltonfailure CDATA #IMPLIED | |||||
| todir CDATA #IMPLIED | |||||
| if CDATA #IMPLIED | |||||
| unless CDATA #IMPLIED | |||||
| > | |||||
| <!ENTITY % ext "| xt"> | |||||
| <!-- *********** EJB ************** --> | |||||
| <!ELEMENT xt EMPTY> | |||||
| <!ATTLIST xt | |||||
| xml CDATA #REQUIRED | |||||
| xsl CDATA #REQUIRED | |||||
| out CDATA #REQUIRED> | |||||
| <!ELEMENT ddcreator (include | exclude)*> | |||||
| <!ATTLIST ddcreator | |||||
| descriptors CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| classpath CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT ejbc (include | exclude)*> | |||||
| <!ATTLIST ejbc | |||||
| descriptors CDATA #REQUIRED | |||||
| manifest CDATA #REQUIRED | |||||
| dest CDATA #REQUIRED | |||||
| src CDATA #REQUIRED | |||||
| classpath CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT wlrun (classpath | wlclasspath)*> | |||||
| <!ATTLIST wlrun | |||||
| beahome CDATA #REQUIRED | |||||
| home CDATA #REQUIRED | |||||
| Domain CDATA #REQUIRED | |||||
| classpath CDATA #IMPLIED | |||||
| wlclasspath CDATA #IMPLIED | |||||
| properties CDATA #IMPLIED | |||||
| name CDATA #IMPLIED | |||||
| policy CDATA #IMPLIED | |||||
| username CDATA #IMPLIED | |||||
| password CDATA #IMPLIED | |||||
| pkPassword CDATA #IMPLIED | |||||
| jvmargs CDATA #IMPLIED | |||||
| args CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT wlstop (classpath)*> | |||||
| <!ATTLIST wlstop | |||||
| beahome CDATA #REQUIRED | |||||
| classpath CDATA #REQUIRED | |||||
| user CDATA #REQUIRED | |||||
| password CDATA #REQUIRED | |||||
| url CDATA #IMPLIED | |||||
| delay CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT ejbjar (classpath | dtd | support)*> | |||||
| <!ATTLIST ejbjar | |||||
| descriptordir CDATA #IMPLIED | |||||
| srcdir CDATA #REQUIRED | |||||
| destdir CDATA #REQUIRED | |||||
| basejarname CDATA #IMPLIED | |||||
| basenameterminator CDATA #IMPLIED | |||||
| genericjarsuffix CDATA #IMPLIED | |||||
| classpath CDATA #IMPLIED | |||||
| latdestdir CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT dtd EMPTY> | |||||
| <!ATTLIST dtd | |||||
| publicId CDATA #REQUIRED | |||||
| location CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT support (include | exclude)*> | |||||
| <!ATTLIST support | |||||
| dir CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT weblogic (classpath | dtd | support)*> | |||||
| <!ATTLIST weblogic | |||||
| destdir CDATA #IMPLIED | |||||
| genericjarsuffix CDATA #IMPLIED | |||||
| suffix CDATA #IMPLIED | |||||
| wlclasspath CDATA #IMPLIED | |||||
| keepgeneric CDATA #IMPLIED | |||||
| compiler CDATA #IMPLIED | |||||
| rebuild CDATA #IMPLIED | |||||
| keepgenerated CDATA #IMPLIED | |||||
| args CDATA #IMPLIED | |||||
| weblogicdtd CDATA #IMPLIED | |||||
| wldtd CDATA #IMPLIED | |||||
| ejbdtd CDATA #IMPLIED | |||||
| newCMP CDATA #IMPLIED | |||||
| oldCMP CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT TOPLink (classpath | dtd | support)*> | |||||
| <!ATTLIST TOPLink | |||||
| destdir CDATA #IMPLIED | |||||
| genericjarsuffix CDATA #IMPLIED | |||||
| suffix CDATA #IMPLIED | |||||
| wlclasspath CDATA #IMPLIED | |||||
| keepgeneric CDATA #IMPLIED | |||||
| compiler CDATA #IMPLIED | |||||
| rebuild CDATA #IMPLIED | |||||
| keepgenerated CDATA #IMPLIED | |||||
| args CDATA #IMPLIED | |||||
| weblogicdtd CDATA #IMPLIED | |||||
| wldtd CDATA #IMPLIED | |||||
| ejbdtd CDATA #IMPLIED | |||||
| newCMP CDATA #IMPLIED | |||||
| oldCMP CDATA #IMPLIED | |||||
| toplinkdescriptor CDATA #IMPLIED | |||||
| toplinkdtd CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT wlclasspath (pathelement | path | fileset)*> | |||||
| <!ATTLIST wlclasspath | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!-- *********** PERFORCE ************** --> | |||||
| <!ELEMENT PropertyFile (entry)*> | |||||
| <!ATTLIST PropertyFile | |||||
| file CDATA #REQUIRED | |||||
| comment CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT entry EMPTY> | |||||
| <!ATTLIST entry | |||||
| key CDATA #REQUIRED | |||||
| value CDATA #REQUIRED | |||||
| type CDATA #IMPLIED | |||||
| operation CDATA #IMPLIED | |||||
| default CDATA #IMPLIED | |||||
| pattern CDATA #IMPLIED | |||||
| > | |||||
| @@ -1,80 +1,84 @@ | |||||
| <?xml version="1.0" encoding="iso-8859-1"?> | <?xml version="1.0" encoding="iso-8859-1"?> | ||||
| <!-- | <!-- | ||||
| Copyright (c) 2000 Michel CASABIANCA. All Rights Reserved. | |||||
| The Apache Software License, Version 1.1 | |||||
| Permission to use, copy, modify, and distribute this software and its | |||||
| documentation for any purpose and without fee or royalty is hereby | |||||
| granted, provided that both the above copyright notice and this | |||||
| permission notice appear in all copies of the software and | |||||
| documentation or portions thereof, including modifications, that you | |||||
| make. | |||||
| Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| reserved. | |||||
| THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO | |||||
| REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, | |||||
| BUT NOT LIMITATION, COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR | |||||
| WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR | |||||
| THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY | |||||
| THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. | |||||
| COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE | |||||
| OR DOCUMENTATION. | |||||
| Redistribution and use in source and binary forms, with or without | |||||
| modification, are permitted provided that the following conditions | |||||
| are met: | |||||
| 1. Redistributions of source code must retain the above copyright | |||||
| notice, this list of conditions and the following disclaimer. | |||||
| 2. Redistributions in binary form must reproduce the above copyright | |||||
| notice, this list of conditions and the following disclaimer in | |||||
| the documentation and/or other materials provided with the | |||||
| distribution. | |||||
| 3. The end-user documentation included with the redistribution, if | |||||
| any, must include the following acknowlegement: | |||||
| "This product includes software developed by the | |||||
| Apache Software Foundation (http://www.apache.org/)." | |||||
| Alternately, this acknowlegement may appear in the software itself, | |||||
| if and wherever such third-party acknowlegements normally appear. | |||||
| 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| Foundation" must not be used to endorse or promote products derived | |||||
| from this software without prior written permission. For written | |||||
| permission, please contact apache@apache.org. | |||||
| 5. Products derived from this software may not be called "Apache" | |||||
| nor may "Apache" appear in their names without prior written | |||||
| permission of the Apache Group. | |||||
| THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| SUCH DAMAGE. | |||||
| ==================================================================== | |||||
| This software consists of voluntary contributions made by many | |||||
| individuals on behalf of the Apache Software Foundation. For more | |||||
| information on the Apache Software Foundation, please see | |||||
| <http://www.apache.org/>. | |||||
| --> | --> | ||||
| <!-- project DTD for Ant --> | |||||
| <!-- 2000-04-03 --> | |||||
| <!ENTITY % ext-file SYSTEM "file:/project-ext.dtd"> | |||||
| %ext-file; | |||||
| <!ELEMENT project (target | property | path)*> | |||||
| <!ATTLIST project | |||||
| name CDATA #REQUIRED | |||||
| default CDATA #REQUIRED | |||||
| basedir CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT target (ant | available | chmod | copy | cvs | delete | deltree | echo | exec | expand | filter | get | gzip | fixcrlf | jar | java | javac | javadoc | keysubst | mkdir | property | rename | replace | rmic | tar | taskdef | tstamp | zip | path | classpath)*> | |||||
| <!-- @author Michel CASABIANCA --> | |||||
| <!-- @version $Revision$ --> | |||||
| <!ENTITY % share-file SYSTEM "file:/share.dtd"> | |||||
| %share-file; | |||||
| <!ELEMENT target (ant | antcall | available | chmod | copy | cvs | delete | deltree | echo | exec | expand | filter | get | gzip | fixcrlf | jar | java | javac | javadoc | keysubst | mkdir | property | recorder | rename | replace | rmic | tar | taskdef | tstamp | zip | path | classpath | mail)*> | |||||
| <!ATTLIST target | <!ATTLIST target | ||||
| name CDATA #REQUIRED | name CDATA #REQUIRED | ||||
| depends CDATA #IMPLIED | depends CDATA #IMPLIED | ||||
| if CDATA #IMPLIED | if CDATA #IMPLIED | ||||
| > | > | ||||
| <!ELEMENT path (pathelement | path)*> | |||||
| <!ATTLIST path | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT classpath (pathelement | path | fileset)*> | |||||
| <!ATTLIST classpath | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT fileset (include | exclude)*> | |||||
| <!ATTLIST fileset | |||||
| dir CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT exclude EMPTY> | |||||
| <!ATTLIST exclude | |||||
| name CDATA #REQUIRED | |||||
| unless CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT include EMPTY> | |||||
| <!ATTLIST include | |||||
| name CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT pathelement EMPTY> | |||||
| <!ATTLIST pathelement | |||||
| location CDATA #IMPLIED | |||||
| path CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT property EMPTY> | |||||
| <!ATTLIST property | |||||
| name CDATA #IMPLIED | |||||
| value CDATA #IMPLIED | |||||
| resource CDATA #IMPLIED | |||||
| file CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT ant EMPTY> | |||||
| <!ELEMENT ant (property)*> | |||||
| <!ATTLIST ant | <!ATTLIST ant | ||||
| antfile CDATA #IMPLIED | antfile CDATA #IMPLIED | ||||
| dir CDATA #REQUIRED | dir CDATA #REQUIRED | ||||
| target CDATA #IMPLIED | target CDATA #IMPLIED | ||||
| output CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT antcall (param)*> | |||||
| <!ATTLIST antcall | |||||
| target CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT param EMPTY> | |||||
| <!ATTLIST param | |||||
| name CDATA #REQUIRED | |||||
| value CDATA #REQUIRED | |||||
| > | > | ||||
| <!ELEMENT available EMPTY> | <!ELEMENT available EMPTY> | ||||
| <!ATTLIST available | <!ATTLIST available | ||||
| @@ -88,11 +92,16 @@ | |||||
| src CDATA #REQUIRED | src CDATA #REQUIRED | ||||
| perm CDATA #REQUIRED | perm CDATA #REQUIRED | ||||
| > | > | ||||
| <!ELEMENT copy (fileset)*> | |||||
| <!ELEMENT copy (fileset | mapper)*> | |||||
| <!ATTLIST copy | <!ATTLIST copy | ||||
| file CDATA #IMPLIED | file CDATA #IMPLIED | ||||
| todir CDATA #IMPLIED | todir CDATA #IMPLIED | ||||
| todir CDATA #IMPLIED | todir CDATA #IMPLIED | ||||
| preservelastmodified CDATA #IMPLIED | |||||
| overwrite CDATA #IMPLIED | |||||
| filtering CDATA #IMPLIED | |||||
| flatten CDATA #IMPLIED | |||||
| includeEmptyDirs CDATA #IMPLIED | |||||
| > | > | ||||
| <!ELEMENT cvs EMPTY> | <!ELEMENT cvs EMPTY> | ||||
| <!ATTLIST cvs | <!ATTLIST cvs | ||||
| @@ -101,9 +110,18 @@ | |||||
| package CDATA #REQUIRED | package CDATA #REQUIRED | ||||
| tag CDATA #IMPLIED | tag CDATA #IMPLIED | ||||
| > | > | ||||
| <!ELEMENT delete EMPTY> | |||||
| <!ELEMENT delete (fileset)*> | |||||
| <!ATTLIST delete | <!ATTLIST delete | ||||
| file CDATA #REQUIRED | |||||
| file CDATA #IMPLIED | |||||
| dir CDATA #IMPLIED | |||||
| verbose CDATA #IMPLIED | |||||
| quiet CDATA #IMPLIED | |||||
| includeEmptyDirs CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| > | > | ||||
| <!ELEMENT deltree EMPTY> | <!ELEMENT deltree EMPTY> | ||||
| <!ATTLIST deltree | <!ATTLIST deltree | ||||
| @@ -233,10 +251,35 @@ | |||||
| sep CDATA #IMPLIED | sep CDATA #IMPLIED | ||||
| keys CDATA #REQUIRED | keys CDATA #REQUIRED | ||||
| > | > | ||||
| <!ELEMENT mail EMPTY> | |||||
| <!ATTLIST mail | |||||
| from CDATA #REQUIRED | |||||
| tolist CDATA #REQUIRED | |||||
| message CDATA #REQUIRED | |||||
| files CDATA #IMPLIED | |||||
| mailhost CDATA #IMPLIED | |||||
| subject CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT mapper EMPTY> | |||||
| <!ATTLIST mapper | |||||
| type CDATA #REQUIRED | |||||
| from CDATA #REQUIRED | |||||
| to CDATA #REQUIRED | |||||
| classname CDATA #IMPLIED | |||||
| classpath CDATA #IMPLIED | |||||
| classpathref CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT mkdir EMPTY> | <!ELEMENT mkdir EMPTY> | ||||
| <!ATTLIST mkdir | <!ATTLIST mkdir | ||||
| dir CDATA #REQUIRED | dir CDATA #REQUIRED | ||||
| > | > | ||||
| <!ELEMENT recorder EMPTY> | |||||
| <!ATTLIST recorder | |||||
| name CDATA #REQUIRED | |||||
| action CDATA #IMPLIED | |||||
| append CDATA #IMPLIED | |||||
| loglevel CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT rename EMPTY> | <!ELEMENT rename EMPTY> | ||||
| <!ATTLIST rename | <!ATTLIST rename | ||||
| src CDATA #REQUIRED | src CDATA #REQUIRED | ||||
| @@ -263,12 +306,12 @@ | |||||
| excludes CDATA #IMPLIED | excludes CDATA #IMPLIED | ||||
| defaultexcludes CDATA #IMPLIED | defaultexcludes CDATA #IMPLIED | ||||
| > | > | ||||
| <!ELEMENT taskdef EMPTY> | |||||
| <!ATTLIST taskdef | |||||
| name CDATA #REQUIRED | |||||
| classname CDATA #REQUIRED | |||||
| <!ELEMENT tstamp (format)*> | |||||
| <!ELEMENT format EMPTY> | |||||
| <!ATTLIST format | |||||
| property CDATA #REQUIRED | |||||
| pattern CDATA #REQUIRED | |||||
| > | > | ||||
| <!ELEMENT tstamp EMPTY> | |||||
| <!ELEMENT zip EMPTY> | <!ELEMENT zip EMPTY> | ||||
| <!ATTLIST zip | <!ATTLIST zip | ||||
| zipfile CDATA #REQUIRED | zipfile CDATA #REQUIRED | ||||
| @@ -0,0 +1,118 @@ | |||||
| <?xml version="1.0" encoding="iso-8859-1"?> | |||||
| <!-- | |||||
| The Apache Software License, Version 1.1 | |||||
| Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||||
| reserved. | |||||
| Redistribution and use in source and binary forms, with or without | |||||
| modification, are permitted provided that the following conditions | |||||
| are met: | |||||
| 1. Redistributions of source code must retain the above copyright | |||||
| notice, this list of conditions and the following disclaimer. | |||||
| 2. Redistributions in binary form must reproduce the above copyright | |||||
| notice, this list of conditions and the following disclaimer in | |||||
| the documentation and/or other materials provided with the | |||||
| distribution. | |||||
| 3. The end-user documentation included with the redistribution, if | |||||
| any, must include the following acknowlegement: | |||||
| "This product includes software developed by the | |||||
| Apache Software Foundation (http://www.apache.org/)." | |||||
| Alternately, this acknowlegement may appear in the software itself, | |||||
| if and wherever such third-party acknowlegements normally appear. | |||||
| 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||||
| Foundation" must not be used to endorse or promote products derived | |||||
| from this software without prior written permission. For written | |||||
| permission, please contact apache@apache.org. | |||||
| 5. Products derived from this software may not be called "Apache" | |||||
| nor may "Apache" appear in their names without prior written | |||||
| permission of the Apache Group. | |||||
| THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
| OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
| DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
| ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
| USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
| ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
| OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
| SUCH DAMAGE. | |||||
| ==================================================================== | |||||
| This software consists of voluntary contributions made by many | |||||
| individuals on behalf of the Apache Software Foundation. For more | |||||
| information on the Apache Software Foundation, please see | |||||
| <http://www.apache.org/>. | |||||
| --> | |||||
| <!-- @author Michel CASABIANCA --> | |||||
| <!-- @version $Revision$ --> | |||||
| <!ELEMENT project (target | property | path | taskdef | patternset | fileset)*> | |||||
| <!ATTLIST project | |||||
| name CDATA #REQUIRED | |||||
| default CDATA #REQUIRED | |||||
| basedir CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT property EMPTY> | |||||
| <!ATTLIST property | |||||
| name CDATA #IMPLIED | |||||
| value CDATA #IMPLIED | |||||
| resource CDATA #IMPLIED | |||||
| file CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT path (pathelement | path)*> | |||||
| <!ATTLIST path | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT classpath (pathelement | path | fileset)*> | |||||
| <!ATTLIST classpath | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT fileset (include | exclude)*> | |||||
| <!ATTLIST fileset | |||||
| id CDATA #IMPLIED | |||||
| refid CDATA #IMPLIED | |||||
| dir CDATA #REQUIRED | |||||
| defaultexcludes CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT patternset (include | exclude)*> | |||||
| <!ATTLIST patternset | |||||
| id CDATA #REQUIRED | |||||
| refid CDATA #IMPLIED | |||||
| includes CDATA #IMPLIED | |||||
| includesfile CDATA #IMPLIED | |||||
| excludes CDATA #IMPLIED | |||||
| excludesfile CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT exclude EMPTY> | |||||
| <!ATTLIST exclude | |||||
| name CDATA #REQUIRED | |||||
| unless CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT include EMPTY> | |||||
| <!ATTLIST include | |||||
| name CDATA #REQUIRED | |||||
| > | |||||
| <!ELEMENT pathelement EMPTY> | |||||
| <!ATTLIST pathelement | |||||
| location CDATA #IMPLIED | |||||
| path CDATA #IMPLIED | |||||
| > | |||||
| <!ELEMENT taskdef EMPTY> | |||||
| <!ATTLIST taskdef | |||||
| name CDATA #REQUIRED | |||||
| classname CDATA #REQUIRED | |||||
| > | |||||
| @@ -124,7 +124,9 @@ public class NewElementCmd extends AbstractCommand { | |||||
| ACSDtdDefinedElement dtde = (ACSDtdDefinedElement) e; | ACSDtdDefinedElement dtde = (ACSDtdDefinedElement) e; | ||||
| NewElementDlg dlg = new NewElementDlg( | NewElementDlg dlg = new NewElementDlg( | ||||
| getContext().getParentFrame(), true); | getContext().getParentFrame(), true); | ||||
| dlg.setList(dtde.getPossibleChildren()); | |||||
| dlg.setLists( | |||||
| dtde.getPossibleChildren(ACSDocumentType.CORE_ELEMENT), | |||||
| dtde.getPossibleChildren(ACSDocumentType.OPTIONAL_ELEMENT) ); | |||||
| dlg.pack(); | dlg.pack(); | ||||
| WindowUtils.centerWindow(dlg); | WindowUtils.centerWindow(dlg); | ||||
| dlg.setTitle("Select the new element type"); | dlg.setTitle("Select the new element type"); | ||||
| @@ -54,6 +54,9 @@ | |||||
| package org.apache.tools.ant.gui.command; | package org.apache.tools.ant.gui.command; | ||||
| import javax.swing.*; | import javax.swing.*; | ||||
| import java.util.List; | |||||
| import java.util.ArrayList; | |||||
| import org.apache.tools.ant.gui.util.Collections; | |||||
| /** | /** | ||||
| * A Dialog which asks for a new xml element's type. | * A Dialog which asks for a new xml element's type. | ||||
| @@ -67,6 +70,7 @@ public class NewElementDlg extends javax.swing.JDialog { | |||||
| private javax.swing.JPanel _buttonPanel; | private javax.swing.JPanel _buttonPanel; | ||||
| private javax.swing.JButton _buttonOK; | private javax.swing.JButton _buttonOK; | ||||
| private javax.swing.JButton _buttonCancel; | private javax.swing.JButton _buttonCancel; | ||||
| private javax.swing.JCheckBox _optionalButton; | |||||
| private javax.swing.JPanel _selectPanel; | private javax.swing.JPanel _selectPanel; | ||||
| private javax.swing.JPanel _panelData; | private javax.swing.JPanel _panelData; | ||||
| private javax.swing.JLabel _label; | private javax.swing.JLabel _label; | ||||
| @@ -77,11 +81,17 @@ public class NewElementDlg extends javax.swing.JDialog { | |||||
| private boolean _cancel = true; | private boolean _cancel = true; | ||||
| /** holds the element type */ | /** holds the element type */ | ||||
| private String _elementName; | private String _elementName; | ||||
| /** list of core tasks */ | |||||
| private List _coreElements; | |||||
| /** list of optional tasks */ | |||||
| private List _optionalElements; | |||||
| /** list of tasks to display */ | |||||
| private List _elements; | |||||
| /** | /** | ||||
| * Creates new form NewElementDlg | * Creates new form NewElementDlg | ||||
| */ | */ | ||||
| public NewElementDlg(java.awt.Frame parent,boolean modal) { | |||||
| public NewElementDlg(java.awt.Frame parent, boolean modal) { | |||||
| super(parent, modal); | super(parent, modal); | ||||
| initComponents(); | initComponents(); | ||||
| enableButtons(); | enableButtons(); | ||||
| @@ -90,12 +100,54 @@ public class NewElementDlg extends javax.swing.JDialog { | |||||
| /** | /** | ||||
| * Fills the listbox with the input list. | * Fills the listbox with the input list. | ||||
| */ | */ | ||||
| public void setList(String[] list) { | |||||
| if (list == null || list.length == 0) { | |||||
| public void setLists(String[] coreElements, String[] optionalElements) { | |||||
| // Are there any items to display? | |||||
| if ( (coreElements == null || coreElements.length == 0) && | |||||
| (optionalElements == null || optionalElements.length == 0 ) ) { | |||||
| // Hide the list | |||||
| _listScrollPane.setVisible(false); | _listScrollPane.setVisible(false); | ||||
| _optionalButton.setVisible(false); | |||||
| } else { | } else { | ||||
| _elementList.setListData(list); | |||||
| // Are there any core elements? | |||||
| if (coreElements == null) { | |||||
| _coreElements = new ArrayList(); | |||||
| // Display the optional elements | |||||
| _optionalButton.setSelected(true); | |||||
| _optionalButton.setVisible(false); | |||||
| } else { | |||||
| // Create a sorted list of the core elements | |||||
| List temp = Collections.fill(null, coreElements); | |||||
| java.util.Collections.sort(temp); | |||||
| _coreElements = temp; | |||||
| } | |||||
| // Are there any optional elements? | |||||
| if (optionalElements == null) { | |||||
| _optionalElements = new ArrayList(); | |||||
| // Display the core elements | |||||
| _optionalButton.setSelected(false); | |||||
| _optionalButton.setVisible(false); | |||||
| } else { | |||||
| // Create a sorted list of the optional elements | |||||
| List temp = Collections.fill(null, optionalElements); | |||||
| java.util.Collections.sort(temp); | |||||
| _optionalElements = temp; | |||||
| } | |||||
| // Are the lists the same? | |||||
| if (_optionalElements.containsAll(_coreElements) && | |||||
| _coreElements.containsAll(_optionalElements) ) { | |||||
| // Hide the button | |||||
| _optionalButton.setVisible(false); | |||||
| } | |||||
| } | } | ||||
| enableButtons(); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -116,11 +168,26 @@ public class NewElementDlg extends javax.swing.JDialog { | |||||
| * Enable or disable buttons | * Enable or disable buttons | ||||
| */ | */ | ||||
| private void enableButtons() { | private void enableButtons() { | ||||
| // Enable the OK button? | |||||
| if (isInputValid()) { | if (isInputValid()) { | ||||
| _buttonOK.setEnabled(true); | _buttonOK.setEnabled(true); | ||||
| } else { | } else { | ||||
| _buttonOK.setEnabled(false); | _buttonOK.setEnabled(false); | ||||
| } | } | ||||
| // Display the core or optional elements? | |||||
| Object oldList = _elements; | |||||
| if (_optionalButton.isSelected()) { | |||||
| _elements = _optionalElements; | |||||
| } else { | |||||
| _elements = _coreElements; | |||||
| } | |||||
| // Did the list change? | |||||
| if (oldList != _elements) { | |||||
| _elementList.setListData(_elements.toArray()); | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -159,6 +226,8 @@ public class NewElementDlg extends javax.swing.JDialog { | |||||
| return true; | return true; | ||||
| else if (c == '>') | else if (c == '>') | ||||
| return false; | return false; | ||||
| else if (c >= '0' && c <= '9') | |||||
| return true; | |||||
| else if (c == '.' || c == '-' || c == '_' || c == ':') | else if (c == '.' || c == '-' || c == '_' || c == ':') | ||||
| return true; | return true; | ||||
| else | else | ||||
| @@ -193,6 +262,8 @@ public class NewElementDlg extends javax.swing.JDialog { | |||||
| _elementText = new javax.swing.JTextField(); | _elementText = new javax.swing.JTextField(); | ||||
| _listScrollPane = new javax.swing.JScrollPane(); | _listScrollPane = new javax.swing.JScrollPane(); | ||||
| _elementList = new javax.swing.JList(); | _elementList = new javax.swing.JList(); | ||||
| _optionalButton = new javax.swing.JCheckBox( | |||||
| "show optional elements", false); | |||||
| getContentPane().setLayout(new java.awt.BorderLayout(10, 10)); | getContentPane().setLayout(new java.awt.BorderLayout(10, 10)); | ||||
| addWindowListener(new java.awt.event.WindowAdapter() { | addWindowListener(new java.awt.event.WindowAdapter() { | ||||
| public void windowClosing(java.awt.event.WindowEvent evt) { | public void windowClosing(java.awt.event.WindowEvent evt) { | ||||
| @@ -272,7 +343,16 @@ public class NewElementDlg extends javax.swing.JDialog { | |||||
| } | } | ||||
| ); | ); | ||||
| _listScrollPane.setViewportView(_elementList); | _listScrollPane.setViewportView(_elementList); | ||||
| _optionalButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); | |||||
| _optionalButton.addActionListener(new java.awt.event.ActionListener() { | |||||
| public void actionPerformed(java.awt.event.ActionEvent evt) { | |||||
| enableButtons(); | |||||
| } | |||||
| } | |||||
| ); | |||||
| _selectPanel.add(_optionalButton, java.awt.BorderLayout.NORTH); | |||||
| _selectPanel.add(_listScrollPane, java.awt.BorderLayout.CENTER); | _selectPanel.add(_listScrollPane, java.awt.BorderLayout.CENTER); | ||||
| getContentPane().add(_selectPanel, java.awt.BorderLayout.CENTER); | getContentPane().add(_selectPanel, java.awt.BorderLayout.CENTER); | ||||
| pack(); | pack(); | ||||