Made eld docs more compleet and updated xsd to add missing description
tag.
This commit is contained in:
parent
91064df3f3
commit
aa9c9743d7
22 changed files with 609 additions and 124 deletions
|
|
@ -623,7 +623,7 @@ public class X4OPhaseHandlerFactory {
|
|||
protected void setX4OPhase() {
|
||||
phase = X4OPhase.fillTemplatingPhase;
|
||||
}
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
}
|
||||
};
|
||||
return result;
|
||||
|
|
@ -638,13 +638,13 @@ public class X4OPhaseHandlerFactory {
|
|||
protected void setX4OPhase() {
|
||||
phase = X4OPhase.transformPhase;
|
||||
}
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
if (element.isTransformingTree()==false) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (hasX4ODebugWriter()) {
|
||||
getX4ODebugWriter().debugElement(element);
|
||||
getX4ODebugWriter().debugElement(element);
|
||||
}
|
||||
element.doElementRun();
|
||||
} catch (ElementException e) {
|
||||
|
|
@ -665,7 +665,7 @@ public class X4OPhaseHandlerFactory {
|
|||
protected void setX4OPhase() {
|
||||
phase = X4OPhase.runDirtyElementPhase;
|
||||
}
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
public void runElementPhase(Element element) throws X4OPhaseException {
|
||||
Map<Element,X4OPhase> dirtyElements = element.getElementLanguage().getDirtyElements();
|
||||
if (dirtyElements.isEmpty()) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
|
|||
|
||||
ec = new DefaultElementClass("bindingHandler",null,BeanElement.class);
|
||||
ec.addElementParent(CEL_ROOT_URI, "module");
|
||||
ec.addElementParent("", "elementInterface");
|
||||
ec.addElementParent(CEL_CORE_URI, "elementInterface");
|
||||
try {
|
||||
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||
attr.setName("id");
|
||||
|
|
@ -247,8 +247,8 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
|
|||
|
||||
ec = new DefaultElementClass("configurator",null,BeanElement.class);
|
||||
//ec.addElementParent(CEL_ROOT_URI, "module");
|
||||
ec.addElementParent("", "elementInterface");
|
||||
ec.addElementParent("", "element");
|
||||
ec.addElementParent(CEL_CORE_URI, "elementInterface");
|
||||
ec.addElementParent(CEL_CORE_URI, "element");
|
||||
try {
|
||||
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||
attr.setName("bean.class");
|
||||
|
|
@ -282,17 +282,18 @@ public class EldModuleLoaderCore implements ElementLanguageModuleLoader {
|
|||
ec = new DefaultElementClass("description",null,DescriptionElement.class);
|
||||
ec.setSchemaContentBase("string");
|
||||
ec.addElementParent(CEL_ROOT_URI, "module");
|
||||
ec.addElementParent("", "attributeHandler");
|
||||
ec.addElementParent("", "bindingHandler");
|
||||
ec.addElementParent("", "configurator");
|
||||
ec.addElementParent("", "configuratorGlobal");
|
||||
ec.addElementParent("", "elementInterface");
|
||||
ec.addElementParent("", "element");
|
||||
ec.addElementParent("", "attribute");
|
||||
ec.addElementParent(CEL_CORE_URI, "namespace");
|
||||
ec.addElementParent(CEL_CORE_URI, "attributeHandler");
|
||||
ec.addElementParent(CEL_CORE_URI, "bindingHandler");
|
||||
ec.addElementParent(CEL_CORE_URI, "configurator");
|
||||
ec.addElementParent(CEL_CORE_URI, "configuratorGlobal");
|
||||
ec.addElementParent(CEL_CORE_URI, "elementInterface");
|
||||
ec.addElementParent(CEL_CORE_URI, "element");
|
||||
ec.addElementParent(CEL_CORE_URI, "attribute");
|
||||
elementClassList.add(ec);
|
||||
|
||||
ec = new DefaultElementClass("elementParent",null,ElementClassAddParentElement.class);
|
||||
ec.addElementParent("", "element");
|
||||
ec.addElementParent(CEL_CORE_URI, "element");
|
||||
try {
|
||||
attr = (ElementClassAttribute)X4OLanguageClassLoader.newInstance(elementLanguage.getLanguageConfiguration().getDefaultElementClassAttribute());
|
||||
attr.setName("tag");
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ElementClassAddParentElement extends AbstractElement {
|
|||
}
|
||||
String namespaceUri = getAttributes().get("uri");
|
||||
if (namespaceUri==null) {
|
||||
namespaceUri = ""; // current namespace ?
|
||||
namespaceUri = getParent().getParent().getAttributes().get("uri"); // copy uri from namespace element.
|
||||
}
|
||||
if (getParent().getElementObject() instanceof ElementClass) {
|
||||
((ElementClass)getParent().getElementObject()).addElementParent(namespaceUri,tag);
|
||||
|
|
|
|||
|
|
@ -369,12 +369,6 @@ public class EldXsdXmlWriter {
|
|||
if (parents!=null && parents.contains(ec.getTag())) {
|
||||
refElements.add(checkClass.getTag());
|
||||
}
|
||||
if (nsWrite.getUri().equals(ns.getUri())) {
|
||||
parents = checkClass.getElementParents("");
|
||||
if (parents!=null && parents.contains(ec.getTag())) {
|
||||
refElements.add(checkClass.getTag());
|
||||
}
|
||||
}
|
||||
if (ec.getObjectClass()==null) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,6 +111,12 @@ public abstract class AbstractElementClass extends AbstractElementClassBase impl
|
|||
* @see org.x4o.xml.element.ElementClass#addElementParent(java.lang.String,java.lang.String)
|
||||
*/
|
||||
public void addElementParent(String namespaceUri,String tag) {
|
||||
if (namespaceUri==null) {
|
||||
throw new NullPointerException("Can't add parent tag with null namespace uri.");
|
||||
}
|
||||
if (namespaceUri.isEmpty()) {
|
||||
throw new IllegalArgumentException("Can't add parent tag with empty namespace uri.");
|
||||
}
|
||||
List<String> tags = elementParents.get(namespaceUri);
|
||||
if (tags==null) {
|
||||
tags = new ArrayList<String>(5);
|
||||
|
|
|
|||
|
|
@ -123,9 +123,18 @@ public abstract class AbstractElementLanguageModule extends AbstractElementMetaB
|
|||
* @see org.x4o.xml.element.ElementLanguageModule#addElementBindingHandler(ElementBindingHandler)
|
||||
*/
|
||||
public void addElementBindingHandler(ElementBindingHandler elementBindingHandler) {
|
||||
if (elementBindingHandler==null) {
|
||||
throw new NullPointerException("Can't add null binding handler.");
|
||||
}
|
||||
if (elementBindingHandler.getId()==null) {
|
||||
throw new NullPointerException("Can't add with null id property.");
|
||||
}
|
||||
// Check so doc tree does not loop; see EldDocHtmlWriter.findChilderen()
|
||||
for (Class<?> cl:elementBindingHandler.getBindChildClasses()) {
|
||||
if (elementBindingHandler.getBindParentClass().equals(cl)) {
|
||||
throw new IllegalStateException("Can't add binding handler: "+elementBindingHandler.getId()+" with same parent as child class.");
|
||||
}
|
||||
}
|
||||
logger.finer("Adding ElementBindingHandler: "+elementBindingHandler);
|
||||
elementBindingHandlers.add(elementBindingHandler);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,25 +7,26 @@
|
|||
ModuleName: Core Element Languag Module
|
||||
Namespaces: 2
|
||||
Namespace: http://cel.x4o.org/xml/ns/cel-core
|
||||
Created on: Sun Nov 18 06:22:14 CET 2012
|
||||
Created on: Thu Dec 20 22:30:55 CET 2012
|
||||
-->
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:this="http://cel.x4o.org/xml/ns/cel-core"
|
||||
version="1.0" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://cel.x4o.org/xml/ns/cel-core">
|
||||
<complexType name="namespaceType">
|
||||
<choice minOccurs="0" maxOccurs="unbounded">
|
||||
<element name="description" type="this:descriptionType"/>
|
||||
<element name="element" type="this:elementType"/>
|
||||
</choice>
|
||||
<attribute name="uri" type="string" use="required"/>
|
||||
<attribute name="name" type="string"/>
|
||||
<attribute name="prefixMapping" type="string"/>
|
||||
<attribute name="elementNamespaceInstanceProvider" type="string"/>
|
||||
<attribute name="schemaUri" type="string"/>
|
||||
<attribute name="schemaResource" type="string"/>
|
||||
<attribute name="schemaPrefix" type="string"/>
|
||||
<attribute name="languageRoot" type="boolean"/>
|
||||
<attribute name="elementNamespaceInstanceProvider" type="string"/>
|
||||
<attribute name="schemaUri" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="prefixMapping" type="string"/>
|
||||
<attribute name="description" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
</complexType>
|
||||
<complexType name="descriptionType">
|
||||
<simpleContent>
|
||||
|
|
@ -44,12 +45,12 @@
|
|||
<attribute name="objectClass" type="string"/>
|
||||
<attribute name="elementClass" type="string"/>
|
||||
<attribute name="tag" type="string"/>
|
||||
<attribute name="schemaContentBase" type="string"/>
|
||||
<attribute name="autoAttributes" type="boolean"/>
|
||||
<attribute name="schemaContentComplex" type="boolean"/>
|
||||
<attribute name="schemaContentMixed" type="boolean"/>
|
||||
<attribute name="autoAttributes" type="boolean"/>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="schemaContentBase" type="string"/>
|
||||
<attribute name="description" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
</complexType>
|
||||
<complexType name="configuratorGlobalType">
|
||||
<choice minOccurs="0" maxOccurs="unbounded">
|
||||
|
|
@ -80,14 +81,14 @@
|
|||
<element name="description" type="this:descriptionType"/>
|
||||
</choice>
|
||||
<attribute name="name" type="string"/>
|
||||
<attribute name="defaultValue" type="string"/>
|
||||
<attribute name="required" type="boolean"/>
|
||||
<attribute name="runResolveEL" type="boolean"/>
|
||||
<attribute name="runConverters" type="boolean"/>
|
||||
<attribute name="runBeanFill" type="boolean"/>
|
||||
<attribute name="defaultValue" type="string"/>
|
||||
<attribute name="objectConverter" type="string"/>
|
||||
<attribute name="required" type="boolean"/>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="runBeanFill" type="boolean"/>
|
||||
<attribute name="description" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
</complexType>
|
||||
<complexType name="classConverterType">
|
||||
<choice minOccurs="0" maxOccurs="unbounded"/>
|
||||
|
|
@ -108,8 +109,8 @@
|
|||
<element name="description" type="this:descriptionType"/>
|
||||
</choice>
|
||||
<attribute name="interfaceClass" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="description" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
</complexType>
|
||||
<complexType name="elementParentType">
|
||||
<choice minOccurs="0" maxOccurs="unbounded"/>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
ModuleName: Core Element Languag Module
|
||||
Namespaces: 2
|
||||
Namespace: http://cel.x4o.org/xml/ns/cel-root
|
||||
Created on: Sun Nov 18 06:22:14 CET 2012
|
||||
Created on: Thu Dec 20 22:30:55 CET 2012
|
||||
-->
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:cel-core="http://cel.x4o.org/xml/ns/cel-core"
|
||||
|
|
@ -25,10 +25,10 @@
|
|||
</choice>
|
||||
<attribute name="name" type="string"/>
|
||||
<attribute name="providerName" type="string"/>
|
||||
<attribute name="sourceResource" type="string"/>
|
||||
<attribute name="elementLanguageModuleLoader" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="sourceResource" type="string"/>
|
||||
<attribute name="description" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
</schema>
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
ModuleName: Element Language Definition
|
||||
Namespaces: 3
|
||||
Namespace: http://eld.x4o.org/xml/ns/eld-conv
|
||||
Created on: Sun Nov 18 06:22:58 CET 2012
|
||||
Created on: Thu Dec 20 22:30:10 CET 2012
|
||||
-->
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:this="http://eld.x4o.org/xml/ns/eld-conv"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
ModuleName: Element Language Definition
|
||||
Namespaces: 3
|
||||
Namespace: http://eld.x4o.org/xml/ns/eld-lang
|
||||
Created on: Sun Nov 18 06:22:58 CET 2012
|
||||
Created on: Thu Dec 20 22:30:10 CET 2012
|
||||
-->
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||
|
|
@ -16,16 +16,17 @@
|
|||
<import namespace="http://eld.x4o.org/xml/ns/eld-conv" schemaLocation="eld-conv-1.0.xsd"/>
|
||||
<complexType name="namespaceType">
|
||||
<choice minOccurs="0" maxOccurs="unbounded">
|
||||
<element name="description" type="this:descriptionType"/>
|
||||
<element name="element" type="this:elementType"/>
|
||||
</choice>
|
||||
<attribute name="uri" type="string" use="required"/>
|
||||
<attribute name="name" type="string"/>
|
||||
<attribute name="elementNamespaceInstanceProvider" type="string"/>
|
||||
<attribute name="schemaUri" type="string"/>
|
||||
<attribute name="schemaResource" type="string"/>
|
||||
<attribute name="schemaPrefix" type="string"/>
|
||||
<attribute name="prefixMapping" type="string"/>
|
||||
<attribute name="languageRoot" type="boolean"/>
|
||||
<attribute name="elementNamespaceInstanceProvider" type="string"/>
|
||||
<attribute name="prefixMapping" type="string"/>
|
||||
<attribute name="id" type="string"/>
|
||||
<attribute name="description" type="string"/>
|
||||
</complexType>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
providerName="eld.x4o.org"
|
||||
id="eld-module"
|
||||
>
|
||||
<description>The full element language definition(eld) which is used to define xml languages.</description>
|
||||
|
||||
<bindingHandler id="ElementClassBindingHandler" bean.class="org.x4o.xml.eld.lang.ElementClassBindingHandler"/>
|
||||
<bindingHandler id="ElementModuleBindingHandler" bean.class="org.x4o.xml.eld.lang.ElementModuleBindingHandler"/>
|
||||
|
|
@ -50,7 +51,7 @@
|
|||
languageRoot="true"
|
||||
id="eld-root"
|
||||
>
|
||||
<!-- Root Element for nice namespace'ing -->
|
||||
<description>Single root namespace so xsd schema generation works correct.</description>
|
||||
<element tag="module" objectClass="${parentLanguageConfiguration.defaultElementLanguageModule}" elementClass="org.x4o.xml.eld.lang.ModuleElement">
|
||||
<attribute name="id" required="true">
|
||||
<description>The module id.</description>
|
||||
|
|
@ -67,6 +68,7 @@
|
|||
name="Element Language Definition"
|
||||
id="eld-lang"
|
||||
>
|
||||
<description>Some basic language definitions and some helper tags.</description>
|
||||
|
||||
<!-- First copy some core elements over from parent config -->
|
||||
<element tag="namespace" objectClass="${parentLanguageConfiguration.defaultElementNamespaceContext}">
|
||||
|
|
@ -160,6 +162,7 @@
|
|||
<element tag="description" elementClass="org.x4o.xml.eld.lang.DescriptionElement" schemaContentBase="string">
|
||||
<description>An ELD elementDescription field which lets you type text like this one in xml characters instead of an attribute.</description>
|
||||
<elementParent tag="module" uri="http://eld.x4o.org/xml/ns/eld-root"/>
|
||||
<elementParent tag="namespace"/>
|
||||
<elementParent tag="bindingHandler"/>
|
||||
<elementParent tag="attributeHandler"/>
|
||||
<elementParent tag="configurator"/>
|
||||
|
|
@ -267,7 +270,8 @@
|
|||
name="Element Attribute Converters"
|
||||
id="eld-conv"
|
||||
>
|
||||
<!-- Config all converters, move ? -->
|
||||
<description>Basic set of attribute value converters.</description>
|
||||
|
||||
<element tag="beanConverter" elementClass="org.x4o.xml.eld.lang.BeanElement">
|
||||
<description>Define an loadable in bean.class for an ObjectConverter.</description>
|
||||
<attribute name="bean.class">
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
ModuleName: Element Language Definition
|
||||
Namespaces: 3
|
||||
Namespace: http://eld.x4o.org/xml/ns/eld-root
|
||||
Created on: Sun Nov 18 06:22:58 CET 2012
|
||||
Created on: Thu Dec 20 22:30:10 CET 2012
|
||||
-->
|
||||
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:conv="http://eld.x4o.org/xml/ns/eld-conv"
|
||||
|
|
@ -29,9 +29,9 @@
|
|||
</choice>
|
||||
<attribute name="id" type="string" use="required"/>
|
||||
<attribute name="name" type="string"/>
|
||||
<attribute name="sourceResource" type="string"/>
|
||||
<attribute name="elementLanguageModuleLoader" type="string"/>
|
||||
<attribute name="providerName" type="string"/>
|
||||
<attribute name="elementLanguageModuleLoader" type="string"/>
|
||||
<attribute name="sourceResource" type="string"/>
|
||||
<attribute name="description" type="string"/>
|
||||
</complexType>
|
||||
</element>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2012, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS 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 COPYRIGHT HOLDER OR 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.
|
||||
*/
|
||||
|
||||
package org.x4o.xml.test.swixml.bind;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenuBar;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementBindingHandlerException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 16, 2012
|
||||
*/
|
||||
public class JFrameBindingHandler extends AbstractElementBindingHandler {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
public Class<?> getBindParentClass() {
|
||||
return JFrame.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
||||
*/
|
||||
public Class<?>[] getBindChildClasses() {
|
||||
return new Class[] {JMenuBar.class,JComponent.class};
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
||||
JFrame frame = (JFrame)parentObject;
|
||||
if (childObject instanceof JMenuBar) {
|
||||
JMenuBar child = (JMenuBar)childObject;
|
||||
frame.getRootPane().setJMenuBar(child);
|
||||
} else if (childObject instanceof JComponent) {
|
||||
JComponent child = (JComponent)childObject;
|
||||
|
||||
String c = childElement.getAttributes().get("constraints");
|
||||
Object con = null;
|
||||
if ("BorderLayout.CENTER".equals(c)) {
|
||||
con = BorderLayout.CENTER;
|
||||
} else if ("BorderLayout.NORTH".equals(c)) {
|
||||
con = BorderLayout.NORTH;
|
||||
} else if ("BorderLayout.CENTER".equals(c)) {
|
||||
con = BorderLayout.CENTER;
|
||||
} else if ("BorderLayout.SOUTH".equals(c)) {
|
||||
con = BorderLayout.SOUTH;
|
||||
}
|
||||
|
||||
if (con==null) {
|
||||
frame.getContentPane().add(child);
|
||||
} else {
|
||||
frame.getContentPane().add(child,con);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,13 +25,8 @@ package org.x4o.xml.test.swixml.bind;
|
|||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
|
|
@ -43,14 +38,13 @@ import org.x4o.xml.element.ElementBindingHandlerException;
|
|||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 16, 2012
|
||||
*/
|
||||
public class JComponentBindingHandler extends AbstractElementBindingHandler {
|
||||
public class JInternalFrameBindingHandler extends AbstractElementBindingHandler {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
public Class<?> getBindParentClass() {
|
||||
return JComponent.class;
|
||||
//return new Class[] {JPanel.class,JScrollPane.class,JSplitPane.class,JFrame.class,JInternalFrame.class};
|
||||
return JInternalFrame.class;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,41 +72,11 @@ public class JComponentBindingHandler extends AbstractElementBindingHandler {
|
|||
con = BorderLayout.SOUTH;
|
||||
}
|
||||
|
||||
if (parentObject instanceof JSplitPane) {
|
||||
JSplitPane pane = (JSplitPane)parentObject;
|
||||
if (pane.getLeftComponent() instanceof JButton) { // strange swing constructor for splitpane
|
||||
pane.setLeftComponent(child);
|
||||
} else if (pane.getRightComponent() instanceof JButton) {
|
||||
pane.setRightComponent(child);
|
||||
} else {
|
||||
throw new ElementBindingHandlerException("SplitPane is full.");
|
||||
}
|
||||
} else if (parentObject instanceof JScrollPane) {
|
||||
JScrollPane pane = (JScrollPane)parentObject;
|
||||
pane.setViewportView(child);
|
||||
} else if (parentObject instanceof JFrame) {
|
||||
JFrame frame = (JFrame)parentObject;
|
||||
if (con==null) {
|
||||
frame.getContentPane().add(child);
|
||||
} else {
|
||||
frame.getContentPane().add(child,con);
|
||||
}
|
||||
} else if (parentObject instanceof JInternalFrame) {
|
||||
JInternalFrame frame = (JInternalFrame)parentObject;
|
||||
if (con==null) {
|
||||
frame.getContentPane().add(child);
|
||||
} else {
|
||||
frame.getContentPane().add(child,con);
|
||||
}
|
||||
} else if (parentObject instanceof JPanel) {
|
||||
JPanel parent = (JPanel)parentObject;
|
||||
if (con==null) {
|
||||
parent.add(child);
|
||||
} else {
|
||||
parent.add(child,con);
|
||||
}
|
||||
JInternalFrame frame = (JInternalFrame)parentObject;
|
||||
if (con==null) {
|
||||
frame.getContentPane().add(child);
|
||||
} else {
|
||||
// No bind but this destroys the xsd, change into multiple classes.
|
||||
frame.getContentPane().add(child,con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2012, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS 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 COPYRIGHT HOLDER OR 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.
|
||||
*/
|
||||
|
||||
package org.x4o.xml.test.swixml.bind;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementBindingHandlerException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 16, 2012
|
||||
*/
|
||||
public class JPanelBindingHandler extends AbstractElementBindingHandler {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
public Class<?> getBindParentClass() {
|
||||
return JPanel.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
||||
*/
|
||||
public Class<?>[] getBindChildClasses() {
|
||||
return new Class[] {JComponent.class};
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
||||
JComponent child = (JComponent)childObject;
|
||||
|
||||
String c = childElement.getAttributes().get("constraints");
|
||||
Object con = null;
|
||||
if ("BorderLayout.CENTER".equals(c)) {
|
||||
con = BorderLayout.CENTER;
|
||||
} else if ("BorderLayout.NORTH".equals(c)) {
|
||||
con = BorderLayout.NORTH;
|
||||
} else if ("BorderLayout.CENTER".equals(c)) {
|
||||
con = BorderLayout.CENTER;
|
||||
} else if ("BorderLayout.SOUTH".equals(c)) {
|
||||
con = BorderLayout.SOUTH;
|
||||
}
|
||||
|
||||
JPanel parent = (JPanel)parentObject;
|
||||
if (con==null) {
|
||||
parent.add(child);
|
||||
} else {
|
||||
parent.add(child,con);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,41 +23,48 @@
|
|||
|
||||
package org.x4o.xml.test.swixml.bind;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JSplitPane;
|
||||
|
||||
import org.x4o.xml.element.AbstractElementBindingHandler;
|
||||
import org.x4o.xml.element.Element;
|
||||
import org.x4o.xml.element.ElementBindingHandlerException;
|
||||
|
||||
/**
|
||||
*
|
||||
* JSplitPaneBindingHandler binds components to the JSplitPane
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 16, 2012
|
||||
*/
|
||||
public class JMenuBarBindingHandler extends AbstractElementBindingHandler {
|
||||
public class JSplitPaneBindingHandler extends AbstractElementBindingHandler {
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||
*/
|
||||
public Class<?> getBindParentClass() {
|
||||
return JFrame.class;
|
||||
return JSplitPane.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindChildClasses()
|
||||
*/
|
||||
public Class<?>[] getBindChildClasses() {
|
||||
return new Class[] {JMenuBar.class};
|
||||
return new Class[] {JComponent.class};
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.x4o.xml.element.ElementBindingHandler#doBind(java.lang.Object, java.lang.Object, org.x4o.xml.element.Element)
|
||||
*/
|
||||
public void doBind(Object parentObject, Object childObject, Element childElement) throws ElementBindingHandlerException {
|
||||
JMenuBar child = (JMenuBar)childObject;
|
||||
JFrame frame = (JFrame)parentObject;
|
||||
frame.getRootPane().setJMenuBar(child);
|
||||
JComponent child = (JComponent)childObject;
|
||||
JSplitPane pane = (JSplitPane)parentObject;
|
||||
if (pane.getLeftComponent() instanceof JButton) { // strange swing constructor for splitpane
|
||||
pane.setLeftComponent(child);
|
||||
} else if (pane.getRightComponent() instanceof JButton) {
|
||||
pane.setRightComponent(child);
|
||||
} else {
|
||||
throw new ElementBindingHandlerException("SplitPane is full.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,8 +34,11 @@
|
|||
id="swixml2-module"
|
||||
>
|
||||
|
||||
<bindingHandler id="JComponentBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JComponentBindingHandler"/>
|
||||
<bindingHandler id="JMenuBarBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JMenuBarBindingHandler"/>
|
||||
<bindingHandler id="JFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JFrameBindingHandler"/>
|
||||
<bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
|
||||
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
||||
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
||||
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" method="setViewportView"/>
|
||||
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/>
|
||||
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/>
|
||||
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/>
|
||||
|
|
@ -87,9 +90,10 @@
|
|||
uri="http://swixml.x4o.org/xml/ns/swixml-root"
|
||||
schemaUri="http://swixml.x4o.org/xml/ns/swixml-root-2.0.xsd"
|
||||
schemaResource="swixml-root-2.0.xsd"
|
||||
schemaPrefix="root"
|
||||
schemaPrefix="sx-root"
|
||||
name="Root element"
|
||||
languageRoot="true"
|
||||
id="sx-root"
|
||||
>
|
||||
<!-- Single element in language root to create nice tree, for imports in xsd namespace aware generated files. -->
|
||||
<element tag="frame" objectClass="javax.swing.JFrame"/>
|
||||
|
|
@ -99,6 +103,7 @@
|
|||
schemaUri="http://swixml.x4o.org/xml/ns/swixml-lang-2.0.xsd"
|
||||
schemaResource="swixml-lang-2.0.xsd"
|
||||
schemaPrefix="sx-lang"
|
||||
id="sx-lang"
|
||||
>
|
||||
<!-- Note frame should not be here(it can but xsd needs root), but else classic xml does not parse without xmlns additions. -->
|
||||
<element tag="frame" objectClass="javax.swing.JFrame"/>
|
||||
|
|
|
|||
|
|
@ -34,8 +34,11 @@
|
|||
id="swixml3-module"
|
||||
>
|
||||
|
||||
<bindingHandler id="JComponentBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JComponentBindingHandler"/>
|
||||
<bindingHandler id="JMenuBarBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JMenuBarBindingHandler"/>
|
||||
<bindingHandler id="JFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JFrameBindingHandler"/>
|
||||
<bindingHandler id="JInternalFrameBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JInternalFrameBindingHandler"/>
|
||||
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
||||
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
||||
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" method="setViewportView"/>
|
||||
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" method="add"/>
|
||||
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" method="setContentPane"/>
|
||||
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" method="add"/>
|
||||
|
|
@ -84,9 +87,10 @@
|
|||
uri="http://swixml.x4o.org/xml/ns/swixml-root"
|
||||
schemaUri="http://swixml.x4o.org/xml/ns/swixml-root-3.0.xsd"
|
||||
schemaResource="swixml-root-3.0.xsd"
|
||||
schemaPrefix="root"
|
||||
schemaPrefix="sx-root"
|
||||
name="Root element"
|
||||
languageRoot="true"
|
||||
id="sx-root"
|
||||
>
|
||||
<element tag="JFrame" objectClass="javax.swing.JFrame"/>
|
||||
</namespace>
|
||||
|
|
@ -95,6 +99,7 @@
|
|||
schemaUri="http://swixml.x4o.org/xml/ns/swixml-lang-3.0.xsd"
|
||||
schemaResource="swixml-lang-3.0.xsd"
|
||||
schemaPrefix="sx-lang"
|
||||
id="sx-lang"
|
||||
>
|
||||
<element tag="JMenubar" objectClass="javax.swing.JMenuBar"/>
|
||||
<element tag="JMenu" objectClass="javax.swing.JMenu"/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue