Added some javadoc and improved swixml unit test.
This commit is contained in:
parent
9aa15198c9
commit
661ac8079e
|
@ -51,6 +51,12 @@ import org.xml.sax.XMLReader;
|
||||||
import org.xml.sax.ext.DefaultHandler2;
|
import org.xml.sax.ext.DefaultHandler2;
|
||||||
import org.xml.sax.helpers.XMLReaderFactory;
|
import org.xml.sax.helpers.XMLReaderFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4ODriverManager controls all the x4o driver and languages loaded in the classpath.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public final class X4ODriverManager {
|
public final class X4ODriverManager {
|
||||||
|
|
||||||
public final static String X4O_DRIVERS_RESOURCE = "META-INF/x4o-drivers.xml";
|
public final static String X4O_DRIVERS_RESOURCE = "META-INF/x4o-drivers.xml";
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
package org.x4o.xml.eld.lang;
|
package org.x4o.xml.eld.lang;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -44,6 +43,7 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
private Class<?> childClass = null;
|
private Class<?> childClass = null;
|
||||||
private String addMethod = null;
|
private String addMethod = null;
|
||||||
private String getMethod = null;
|
private String getMethod = null;
|
||||||
|
private String skipChilderenClassRegex = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
* @see org.x4o.xml.element.ElementBindingHandler#getBindParentClass()
|
||||||
|
@ -105,38 +105,54 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
if (getMethod.equalsIgnoreCase(m.getName())==false) {
|
if (getMethod.equalsIgnoreCase(m.getName())==false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Object result;
|
||||||
try {
|
try {
|
||||||
Object result = m.invoke(parentObject, new Object[]{});
|
result = m.invoke(parentObject, new Object[]{});
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ElementBindingHandlerException("Invoke error: "+e.getMessage()+" from: "+getMethod+" on: "+parentObject+" id:"+getId(),e);
|
||||||
|
}
|
||||||
if (result==null) {
|
if (result==null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result instanceof List) {
|
if (result instanceof List) {
|
||||||
for (Object o:(List)result) {
|
for (Object o:(List)result) {
|
||||||
createChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (result instanceof Collection) {
|
} else if (result instanceof Collection) {
|
||||||
for (Object o:(Collection)result) {
|
for (Object o:(Collection)result) {
|
||||||
createChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (result instanceof Array) {
|
} else if (result.getClass().isArray()) {
|
||||||
for (Object o:(Object[])result) {
|
for (Object o:(Object[])result) {
|
||||||
createChild(parentElement, o);
|
createSafeChild(parentElement, o);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else if (childClass.isAssignableFrom(result.getClass())) {
|
||||||
|
createSafeChild(parentElement, result);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw new ElementBindingHandlerException("Unsuported return type: "+result.getClass()+" from: "+getMethod+" on: "+parentObject);
|
throw new ElementBindingHandlerException("Unsuported return type: "+result.getClass()+" need: "+childClass+" from: "+getMethod+" on: "+parentObject+" id:"+getId());
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ElementBindingHandlerException("Error invoke binding method of: "+getId()+" error: "+e.getMessage(),e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ElementBindingHandlerException("Could not find method: "+getMethod+" on: "+parentObject+" id:"+getId());
|
throw new ElementBindingHandlerException("Could not find method: "+getMethod+" on: "+parentObject+" id:"+getId());
|
||||||
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void createSafeChild(Element parentElement,Object childObject) {
|
||||||
|
if (childClass.isAssignableFrom(childObject.getClass())==false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (skipChilderenClassRegex!=null) {
|
||||||
|
if (childObject.getClass().getName().matches(skipChilderenClassRegex)) {
|
||||||
|
return; // skip
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createChild(parentElement,childObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the parentClass
|
* @return the parentClass
|
||||||
*/
|
*/
|
||||||
|
@ -192,4 +208,18 @@ public class ElementRefectionBindingHandler extends AbstractElementBindingHandle
|
||||||
public void setGetMethod(String getMethod) {
|
public void setGetMethod(String getMethod) {
|
||||||
this.getMethod = getMethod;
|
this.getMethod = getMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the skipChilderenClassRegex
|
||||||
|
*/
|
||||||
|
public String getSkipChilderenClassRegex() {
|
||||||
|
return skipChilderenClassRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param skipChilderenClassRegex the skipChilderenClassRegex to set
|
||||||
|
*/
|
||||||
|
public void setSkipChilderenClassRegex(String skipChilderenClassRegex) {
|
||||||
|
this.skipChilderenClassRegex = skipChilderenClassRegex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,6 +273,10 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
// a bit hackie
|
// a bit hackie
|
||||||
for(int i=0;i<methodes.length;i++) {
|
for(int i=0;i<methodes.length;i++) {
|
||||||
Method method = methodes[i];
|
Method method = methodes[i];
|
||||||
|
Class<?>[] types = method.getParameterTypes();
|
||||||
|
if (types.length != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(method.getName().equalsIgnoreCase(parameterNameSet)) {
|
if(method.getName().equalsIgnoreCase(parameterNameSet)) {
|
||||||
logger.finest("Found method: "+method.getName());
|
logger.finest("Found method: "+method.getName());
|
||||||
lastMethod = method;
|
lastMethod = method;
|
||||||
|
@ -302,7 +306,7 @@ public class DefaultElementObjectPropertyValue implements ElementObjectPropertyV
|
||||||
|
|
||||||
Object result = null;
|
Object result = null;
|
||||||
try {
|
try {
|
||||||
result = lastMethod.invoke(object);
|
result = lastMethod.invoke(object,new Object[]{});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
throw new ElementObjectPropertyValueException(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,12 @@ package org.x4o.xml.io;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageProperty;
|
import org.x4o.xml.lang.X4OLanguageProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbstractX4OConnection is the read/write interface for the classes.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public abstract class AbstractX4OConnection implements X4OConnection {
|
public abstract class AbstractX4OConnection implements X4OConnection {
|
||||||
|
|
||||||
private X4OLanguageContext languageContext = null;
|
private X4OLanguageContext languageContext = null;
|
||||||
|
|
|
@ -36,6 +36,12 @@ import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbstractX4OWriter.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> implements X4OWriter<T> {
|
public abstract class AbstractX4OWriter<T> extends AbstractX4OWriterContext<T> implements X4OWriter<T> {
|
||||||
|
|
||||||
public AbstractX4OWriter(X4OLanguageContext elementLanguage) {
|
public AbstractX4OWriter(X4OLanguageContext elementLanguage) {
|
||||||
|
|
|
@ -34,6 +34,12 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AbstractX4OWriterContext.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public abstract class AbstractX4OWriterContext<T> extends AbstractX4OConnection implements X4OWriterContext<T> {
|
public abstract class AbstractX4OWriterContext<T> extends AbstractX4OConnection implements X4OWriterContext<T> {
|
||||||
|
|
||||||
public AbstractX4OWriterContext(X4OLanguageContext elementLanguage) {
|
public AbstractX4OWriterContext(X4OLanguageContext elementLanguage) {
|
||||||
|
|
|
@ -25,6 +25,12 @@ package org.x4o.xml.io;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultX4ODriver can be used to create language without code and type safty.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
public class DefaultX4ODriver<T> extends X4ODriver<T> {
|
||||||
|
|
||||||
private final String languageName;
|
private final String languageName;
|
||||||
|
|
|
@ -30,6 +30,12 @@ import org.x4o.xml.element.ElementException;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultX4OSchemaWriter can write the schema of a x4o language.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public class DefaultX4OSchemaWriter extends AbstractX4OConnection implements X4OSchemaWriter {
|
public class DefaultX4OSchemaWriter extends AbstractX4OConnection implements X4OSchemaWriter {
|
||||||
|
|
||||||
public DefaultX4OSchemaWriter(X4OLanguageContext languageContext) {
|
public DefaultX4OSchemaWriter(X4OLanguageContext languageContext) {
|
||||||
|
|
|
@ -44,12 +44,17 @@ import org.x4o.xml.element.ElementNamespaceContext;
|
||||||
import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
|
import org.x4o.xml.element.ElementNamespaceInstanceProviderException;
|
||||||
import org.x4o.xml.element.ElementObjectPropertyValueException;
|
import org.x4o.xml.element.ElementObjectPropertyValueException;
|
||||||
import org.x4o.xml.io.sax.XMLWriter;
|
import org.x4o.xml.io.sax.XMLWriter;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguageModule;
|
import org.x4o.xml.lang.X4OLanguageModule;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.helpers.AttributesImpl;
|
import org.xml.sax.helpers.AttributesImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefaultX4OWriter can write the xml language.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
|
|
||||||
public DefaultX4OWriter(X4OLanguageContext elementLanguage) {
|
public DefaultX4OWriter(X4OLanguageContext elementLanguage) {
|
||||||
|
@ -115,6 +120,9 @@ public class DefaultX4OWriter<T> extends AbstractX4OWriter<T> {
|
||||||
if (m.getName().startsWith("get")==false) {
|
if (m.getName().startsWith("get")==false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(m.getName().startsWith("getLocationOnScreen")) {
|
||||||
|
continue; // TODO: rm this
|
||||||
|
}
|
||||||
String name = m.getName().substring(3,4).toLowerCase()+m.getName().substring(4);
|
String name = m.getName().substring(3,4).toLowerCase()+m.getName().substring(4);
|
||||||
result.add(name);
|
result.add(name);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
|
|
||||||
package org.x4o.xml.io;
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OConnection interface for config the io drivers.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public interface X4OConnection {
|
public interface X4OConnection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,6 +33,12 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OReader can read different input formats.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public interface X4OReader<T> extends X4OConnection {
|
public interface X4OReader<T> extends X4OConnection {
|
||||||
|
|
||||||
public void addELBeanInstance(String name,Object bean);
|
public void addELBeanInstance(String name,Object bean);
|
||||||
|
|
|
@ -35,6 +35,12 @@ import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.phase.X4OPhaseException;
|
import org.x4o.xml.lang.phase.X4OPhaseException;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OReaderContext is reader with language context.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public interface X4OReaderContext<T> extends X4OReader<T> {
|
public interface X4OReaderContext<T> extends X4OReader<T> {
|
||||||
|
|
||||||
void releaseContext(X4OLanguageContext context) throws X4OPhaseException;
|
void releaseContext(X4OLanguageContext context) throws X4OPhaseException;
|
||||||
|
|
|
@ -27,6 +27,12 @@ import java.io.File;
|
||||||
|
|
||||||
import org.x4o.xml.element.ElementException;
|
import org.x4o.xml.element.ElementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OSchemaWriter can write the schema for the language.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public interface X4OSchemaWriter extends X4OConnection {
|
public interface X4OSchemaWriter extends X4OConnection {
|
||||||
|
|
||||||
void writeSchema(File basePath) throws ElementException;
|
void writeSchema(File basePath) throws ElementException;
|
||||||
|
|
|
@ -32,6 +32,12 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OWriter can write the xml language.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public interface X4OWriter<T> extends X4OConnection {
|
public interface X4OWriter<T> extends X4OConnection {
|
||||||
|
|
||||||
void write(T object,OutputStream out) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException;
|
void write(T object,OutputStream out) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException;
|
||||||
|
|
|
@ -33,6 +33,12 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* X4OWriterContext is writer with language context.
|
||||||
|
*
|
||||||
|
* @author Willem Cazander
|
||||||
|
* @version 1.0 Apr 6, 2013
|
||||||
|
*/
|
||||||
public interface X4OWriterContext<T> extends X4OWriter<T> {
|
public interface X4OWriterContext<T> extends X4OWriter<T> {
|
||||||
|
|
||||||
void writeContext(X4OLanguageContext context,OutputStream out) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException;
|
void writeContext(X4OLanguageContext context,OutputStream out) throws ParserConfigurationException,FileNotFoundException,SecurityException,NullPointerException,SAXException,IOException;
|
||||||
|
|
|
@ -196,6 +196,18 @@ public final class XMLConstants {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public boolean isNameString(String value) {
|
||||||
|
for (int i=0;i<value.length();i++) {
|
||||||
|
char c = value.charAt(i);
|
||||||
|
if (i==0 && isNameStartChar(c)==false) {
|
||||||
|
return false;
|
||||||
|
} else if (isNameChar(c)==false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static public String escapeAttributeValue(String value) {
|
static public String escapeAttributeValue(String value) {
|
||||||
int l = value.length();
|
int l = value.length();
|
||||||
StringBuffer result = new StringBuffer(l);
|
StringBuffer result = new StringBuffer(l);
|
||||||
|
|
|
@ -163,6 +163,9 @@ public class XMLWriter extends DefaultHandler2 {
|
||||||
if (localName==null) {
|
if (localName==null) {
|
||||||
localName = "null";
|
localName = "null";
|
||||||
}
|
}
|
||||||
|
if (XMLConstants.isNameString(localName)==false) {
|
||||||
|
throw new SAXException("LocalName of element is not valid in xml; '"+localName+"'");
|
||||||
|
}
|
||||||
|
|
||||||
if (XMLConstants.NULL_NS_URI.equals(uri) | uri==null) {
|
if (XMLConstants.NULL_NS_URI.equals(uri) | uri==null) {
|
||||||
startElement.append(localName);
|
startElement.append(localName);
|
||||||
|
|
|
@ -23,16 +23,18 @@
|
||||||
|
|
||||||
package org.x4o.xml.io;
|
package org.x4o.xml.io;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.io.X4OReader;
|
import org.x4o.xml.io.X4OReader;
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
|
||||||
import org.x4o.xml.test.TestDriver;
|
import org.x4o.xml.test.TestDriver;
|
||||||
import org.x4o.xml.test.models.TestObjectRoot;
|
import org.x4o.xml.test.models.TestObjectRoot;
|
||||||
|
import org.x4o.xml.test.swixml.Accelerator3;
|
||||||
|
import org.x4o.xml.test.swixml.SwiXmlDriver;
|
||||||
|
import org.x4o.xml.test.swixml.SwingEngine;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
@ -67,4 +69,25 @@ public class X4OWriterTest extends TestCase {
|
||||||
|
|
||||||
outputFile.delete();
|
outputFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testWriterSwiXmlOutput() throws Exception {
|
||||||
|
Accelerator3 ac3 = new Accelerator3(false);
|
||||||
|
SwingEngine engine = new SwingEngine(ac3);
|
||||||
|
|
||||||
|
File outputFile = createOutputFile();
|
||||||
|
X4ODriver<Component> driver = SwiXmlDriver.getInstance();
|
||||||
|
X4OReader<Component> reader = driver.createReader();
|
||||||
|
X4OWriter<Component> writer = driver.createWriter();
|
||||||
|
|
||||||
|
reader.addELBeanInstance(SwiXmlDriver.LANGUAGE_EL_SWING_ENGINE, engine);
|
||||||
|
Component root = reader.readResource("tests/swixml/swixml-accelerator-3.0.xml");
|
||||||
|
writer.writeFile(root, outputFile);
|
||||||
|
|
||||||
|
assertTrue("Debug file does not exists.",outputFile.exists());
|
||||||
|
|
||||||
|
//String text = new Scanner( outputFile ).useDelimiter("\\A").next();
|
||||||
|
//System.out.println("Output: '\n"+text+"\n' end in "+outputFile.getAbsolutePath());
|
||||||
|
|
||||||
|
outputFile.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,7 @@ import javax.el.ValueExpression;
|
||||||
|
|
||||||
import org.x4o.xml.X4ODriver;
|
import org.x4o.xml.X4ODriver;
|
||||||
import org.x4o.xml.X4ODriverManager;
|
import org.x4o.xml.X4ODriverManager;
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguage;
|
|
||||||
import org.x4o.xml.lang.DefaultX4OLanguageConfiguration;
|
|
||||||
import org.x4o.xml.lang.X4OLanguageContext;
|
import org.x4o.xml.lang.X4OLanguageContext;
|
||||||
import org.x4o.xml.lang.X4OLanguage;
|
|
||||||
import org.x4o.xml.lang.X4OLanguagePropertyKeys;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SwiXmlParser works with the SwingEngine to config the UI tree.
|
* SwiXmlParser works with the SwingEngine to config the UI tree.
|
||||||
|
|
|
@ -86,6 +86,9 @@ public class JInternalFrameBindingHandler extends AbstractElementBindingHandler<
|
||||||
public void createChilderen(Element parentElement,JInternalFrame parent) throws ElementBindingHandlerException {
|
public void createChilderen(Element parentElement,JInternalFrame parent) throws ElementBindingHandlerException {
|
||||||
for (Component c:parent.getComponents()) {
|
for (Component c:parent.getComponents()) {
|
||||||
if (c instanceof JComponent) {
|
if (c instanceof JComponent) {
|
||||||
|
if (c.getClass().getName().startsWith("javax.swing.plaf")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
createChild(parentElement, c);
|
createChild(parentElement, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" addMethod="setContentPane" getMethod="getContentPane"/>
|
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" addMethod="setContentPane" getMethod="getContentPane"/>
|
||||||
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" addMethod="add" getMethod="getComponents"/>
|
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" addMethod="add" getMethod="getComponents"/>
|
||||||
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" addMethod="add" getMethod="getComponents"/>
|
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" addMethod="add" getMethod="getComponents"/>
|
||||||
|
<classBindingHandler id="JRootPane-JComponent" parentClass="javax.swing.JRootPane" childClass="javax.swing.JComponent" addMethod="add" getMethod="getComponents"/>
|
||||||
|
|
||||||
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
||||||
<attribute name="bounds">
|
<attribute name="bounds">
|
||||||
|
@ -128,6 +129,8 @@
|
||||||
<conv:integerConverter/>
|
<conv:integerConverter/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</element>
|
</element>
|
||||||
|
<element tag="layeredPane" objectClass="javax.swing.JLayeredPane"/>
|
||||||
|
<element tag="rootPane" objectClass="javax.swing.JRootPane"/>
|
||||||
<element tag="scrollPane" objectClass="javax.swing.JScrollPane"/>
|
<element tag="scrollPane" objectClass="javax.swing.JScrollPane"/>
|
||||||
<element tag="tree" objectClass="javax.swing.JTree"/>
|
<element tag="tree" objectClass="javax.swing.JTree"/>
|
||||||
<element tag="button" objectClass="javax.swing.JButton">
|
<element tag="button" objectClass="javax.swing.JButton">
|
||||||
|
|
|
@ -39,10 +39,11 @@
|
||||||
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
<bindingHandler id="JPanelBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JPanelBindingHandler"/>
|
||||||
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
<bindingHandler id="JSplitPaneBindingHandler" bean.class="org.x4o.xml.test.swixml.bind.JSplitPaneBindingHandler"/>
|
||||||
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" addMethod="setViewportView" getMethod="getViewport"/>
|
<classBindingHandler id="JScrollPane-JComponent" parentClass="javax.swing.JScrollPane" childClass="javax.swing.JComponent" addMethod="setViewportView" getMethod="getViewport"/>
|
||||||
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" addMethod="add" getMethod="getComponents"/>
|
<classBindingHandler id="JDesktopPane-JInternalFrame" parentClass="javax.swing.JDesktopPane" childClass="javax.swing.JInternalFrame" addMethod="add" getMethod="getComponents" />
|
||||||
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" addMethod="setContentPane" getMethod="getContentPane"/>
|
<classBindingHandler id="JFrame-JDesktopPane" parentClass="javax.swing.JFrame" childClass="javax.swing.JDesktopPane" addMethod="setContentPane" getMethod="getContentPane"/>
|
||||||
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" addMethod="add" getMethod="getComponents"/>
|
<classBindingHandler id="JMenuBar-JMenu" parentClass="javax.swing.JMenuBar" childClass="javax.swing.JMenu" addMethod="add" getMethod="getComponents"/>
|
||||||
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" addMethod="add" getMethod="getComponents"/>
|
<classBindingHandler id="JMenu-JMenuItem" parentClass="javax.swing.JMenu" childClass="javax.swing.JMenuItem" addMethod="add" getMethod="getComponents"/>
|
||||||
|
<classBindingHandler id="JRootPane-JComponent" parentClass="javax.swing.JRootPane" childClass="javax.swing.JComponent" addMethod="add" getMethod="getComponents"/>
|
||||||
|
|
||||||
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
<elementInterface id="Component" interfaceClass="java.awt.Component">
|
||||||
<attribute name="bounds">
|
<attribute name="bounds">
|
||||||
|
@ -122,6 +123,9 @@
|
||||||
<conv:integerConverter/>
|
<conv:integerConverter/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
<element tag="JLayeredPane" objectClass="javax.swing.JLayeredPane"/>
|
||||||
|
<element tag="JRootPane" objectClass="javax.swing.JRootPane"/>
|
||||||
<element tag="JScrollPane" objectClass="javax.swing.JScrollPane"/>
|
<element tag="JScrollPane" objectClass="javax.swing.JScrollPane"/>
|
||||||
<element tag="JTree" objectClass="javax.swing.JTree"/>
|
<element tag="JTree" objectClass="javax.swing.JTree"/>
|
||||||
<element tag="JButton" objectClass="javax.swing.JButton"/>
|
<element tag="JButton" objectClass="javax.swing.JButton"/>
|
||||||
|
|
Loading…
Reference in a new issue