Index: buix/src/java/org/codelutin/buix/Buix.java diff -u buix/src/java/org/codelutin/buix/Buix.java:1.42 buix/src/java/org/codelutin/buix/Buix.java:1.43 --- buix/src/java/org/codelutin/buix/Buix.java:1.42 Mon Aug 2 10:45:46 2004 +++ buix/src/java/org/codelutin/buix/Buix.java Thu Aug 5 16:04:48 2004 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.42 $ +* @version $Revision: 1.43 $ * -* Mise a jour: $Date: 2004/08/02 10:45:46 $ +* Mise a jour: $Date: 2004/08/05 16:04:48 $ * par : $Author: mazelier $ */ @@ -243,6 +243,7 @@ * Initialisation du classLoader */ protected void initClassLoader(){ + try{ List jarURLList = getJarURLList(new File("src/resources")); URL[] arrayJarURL = (URL[])jarURLList.toArray(new URL[jarURLList.size()]); @@ -252,7 +253,7 @@ Thread.currentThread().setContextClassLoader(classLoader); }catch(Exception eee){ - System.out.println(eee); + Logger.getLogger(getClass().getName() + ".initClassLoader").log(Level.WARNING, "Impossible d'initialiser le classLoader", eee); } } @@ -425,25 +426,13 @@ * Exportation du fichier sous format uimodel (BuixXmlEncoder) */ public void exportBuixXml(String packageName, File file) throws IOException { + BuixExportThread thread = new BuixExportThread(packageName, file); + thread.setContextClassLoader(classLoader); + thread.start(); try{ - Class buixXMLEncoderClass = Class.forName("org.codelutin.buix.BuixXMLEncoder", true, getClass().getClassLoader()); - - Class[] parameterType = {String.class, OutputStream.class}; - - Constructor buixXMLEncoderConst = - buixXMLEncoderClass.getConstructor(parameterType); - - Object[] initargs = {packageName, - new BufferedOutputStream(new FileOutputStream(file))}; - - BuixXMLEncoder e = - (BuixXMLEncoder)buixXMLEncoderConst.newInstance(initargs); - - e.writeObject(getRootComponent()); - e.close(); + thread.join(); }catch(Exception eee){ Logger.getLogger(getClass().getName() + ".export").log(Level.WARNING, "Impossible d'exporter cet objet", eee); - MessageDialog.error("Error", "Impossible d'exporter cet objet", eee); } } @@ -454,7 +443,7 @@ try{ BuixUIModelEncoder encoder = new BuixUIModelEncoder (packageName, - new BufferedOutputStream(new FileOutputStream(file)), getRootComponent()); + new BufferedOutputStream(new FileOutputStream(file)), getRootComponent()); }catch(Exception eee){ Logger.getLogger(getClass().getName() + ".export").log(Level.WARNING, "Impossible d'exporter cet objet", eee); @@ -466,10 +455,14 @@ * Sauvegarde du fichier */ public void save(File file) throws IOException { - XMLEncoder e = new XMLEncoder(new BufferedOutputStream( - new FileOutputStream(file))); - e.writeObject(getRootComponent()); - e.close(); + BuixJavaExportThread thread = new BuixJavaExportThread(file); + thread.setContextClassLoader(classLoader); + thread.start(); + try{ + thread.join(); + }catch(Exception eee){ + Logger.getLogger(getClass().getName() + ".export").log(Level.WARNING, "Impossible d'exporter cet objet", eee); + } } /** @@ -889,6 +882,70 @@ if (clipBoard !=null){ ((Component)clipBoard).validate(); ((Component)clipBoard).repaint(); + } + } + + class BuixExportThread extends Thread { + + protected String packageName = null; + protected File file = null; + + public BuixExportThread(String packageName, File file){ + this.packageName = packageName; + this.file = file; + } + + public void run() { + + try{ + Class buixXMLEncoderClass = Class.forName("org.codelutin.buix.BuixXMLEncoder", true, getClass().getClassLoader()); + + Class[] parameterType = {String.class, OutputStream.class}; + + Constructor buixXMLEncoderConst = + buixXMLEncoderClass.getConstructor(parameterType); + + URL[] urlList = classLoader.getURLs(); + for (int i=0; i * Copyright Code Lutin -* @version $Revision: 1.2 $ +* @version $Revision: 1.3 $ * -* Mise a jour: $Date: 2004/07/29 15:18:23 $ +* Mise a jour: $Date: 2004/08/05 16:04:48 $ * par : $Author: mazelier $ */ @@ -37,17 +37,18 @@ /** * Classe qui permet d'encoder sous le format uimodel +* @deprecated cette classe ne donne pas le xml souhaite */ public class BuixUIModelEncoder { // BuixUIModelEncoder public BuixUIModelEncoder(String packageName, OutputStream out, Component component){ - UIModelWriter writer = new UIModelWriter(packageName, out); - ComponentWalker walker = new ComponentWalker(writer); - writer.begin(); - walker.walkerThrow(component); - writer.end(); +// UIModelWriter writer = new UIModelWriter(packageName, out); +// ComponentWalker walker = new ComponentWalker(writer); +// writer.begin(); +// walker.walkerThrow((Object)component); +// writer.end(); } Index: buix/src/java/org/codelutin/buix/BuixXMLEncoder.java diff -u buix/src/java/org/codelutin/buix/BuixXMLEncoder.java:1.21 buix/src/java/org/codelutin/buix/BuixXMLEncoder.java:1.22 --- buix/src/java/org/codelutin/buix/BuixXMLEncoder.java:1.21 Wed Jul 28 16:06:25 2004 +++ buix/src/java/org/codelutin/buix/BuixXMLEncoder.java Thu Aug 5 16:04:48 2004 @@ -23,15 +23,16 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.21 $ +* @version $Revision: 1.22 $ * -* Mise a jour: $Date: 2004/07/28 16:06:25 $ +* Mise a jour: $Date: 2004/08/05 16:04:48 $ * par : $Author: mazelier $ */ package org.codelutin.buix; import java.awt.Container; +import java.awt.Component; import java.io.OutputStream; import java.io.IOException; @@ -39,6 +40,8 @@ import java.beans.Statement; import java.beans.Expression; import java.beans.Introspector; +import java.beans.DefaultPersistenceDelegate; +import java.beans.Encoder; import java.util.ArrayList; import java.util.List; @@ -49,40 +52,39 @@ import org.codelutin.xml.XMLUtil; import org.codelutin.widget.MessageDialog; +import org.codelutin.util.Resource; import javax.swing.RootPaneContainer; import java.net.URLClassLoader; -import java.awt.Component; - +import java.net.URL; /** * Cette classe n'étend pas {@link java.beans.XMLEncoder} car celle-ci ne permet * pas la surcharge de méthode, on etend donc {@link java.beans.Encoder} +* @deprecated Cette classe ne donne pas le xml souhaite */ -public class BuixXMLEncoder extends java.beans.Encoder { // BuixXMLEncoder +public class BuixXMLEncoder extends Encoder { // BuixXMLEncoder - protected String encoding = "UTF-8"; - protected OutputStream out = null; + protected ComponentWalkerCallback writer = null; protected Map valuesToExpression = new IdentityHashMap(); - protected Map objectToProperties = new IdentityHashMap(); protected Map objectToEvents = new IdentityHashMap(); protected Map objectToChildren = new IdentityHashMap(); protected Map objectToArguments = new IdentityHashMap(); - protected Map objectToLayout = new IdentityHashMap(); protected Object root = null; protected Container contentPane = null; protected boolean firstObject = true; - protected int indent = 0; - protected String packageName = null; + public BuixXMLEncoder(String packageName, OutputStream out){ super(); - this.out = out; - this.packageName = packageName; + + this.writer = new UIModelWriter(packageName, out); + + setPersistenceDelegate(org.codelutin.topia.ui.swing.TopiaPanel.class, new TopiaPanel_PersistenceDelegate()); } /** @@ -99,7 +101,6 @@ } super.writeObject(o); - System.out.println("---- XMLEncoder::writeObject: " + o); } @@ -110,7 +111,9 @@ public void writeStatement(Statement oldStm) { System.out.println("XMLEncoder::writeStatement: " + oldStm); Object target = null; + try { + target = oldStm.getTarget(); String methodName = oldStm.getMethodName(); Object[] args = oldStm.getArguments(); @@ -120,16 +123,21 @@ target = root; } getObjectToChildren(target).add(oldStm); + }else if (methodName.equals("setLayout") && target == contentPane ){ target = root; getObjectToProperties(target).add(oldStm); + }else if(methodName.startsWith("set")){ getObjectToProperties(target).add(oldStm); + }else if(isEventStatement(oldStm)){ getObjectToEvents(target).add(oldStm); + }else if (methodName.equals("addLayoutComponent")){ objectToLayout.put(args[0], args[1]); } + super.writeStatement(oldStm); } catch (Exception e) { @@ -162,13 +170,11 @@ System.out.println("XMLEncoder::writeExpression: " + oldExp + "target==root ? "+ (getValue(oldExp)==root) + " ou " + (getValue(oldExp) == get(root))); try { - System.out.println("oldExp : " + oldExp); + Object target = getValue(oldExp); - System.out.println("target : " + target); String methodName = oldExp.getMethodName(); - System.out.println("methodName : " + methodName); - Object[] args = oldExp.getArguments(); + if(methodName.equals("new")){ for(int i=0; i"); - writeln(""); - - indent++; + writer.begin(); outObject(root); - indent--; - writeln(""); - try{ - out.close(); - }catch(IOException eee){ - MessageDialog.error("Error", "L'application a rencontre une erreur", eee); - } + writer.end(); } /** @@ -223,35 +221,19 @@ List props = getObjectToProperties(o); List events = getObjectToEvents(o); List children = getObjectToChildren(o); - System.out.println("objet "+o); + if (o instanceof String){ - writeln(""+o+""); + writer.beginObject(o); }else{ Expression exp = getExpression(o); - System.out.println("exp "+exp); - Class clazz = (Class)exp.getTarget(); - System.out.println("class "+clazz); - String tag = ""); } + writer.endObject(); } /** @@ -262,14 +244,16 @@ if(args.size() == 0) return; - writeln(""); - indent++; + + writer.beginArguments(); + for(Iterator i=args.iterator(); i.hasNext();){ Expression exp = getExpression(i.next()); - outExpression(exp); + Object value = getValue(exp); + outObject(value); } - indent--; - writeln(""); + + writer.endArguments(); } /** @@ -279,23 +263,22 @@ protected void outProperties(List props){ if(props.size() == 0) return; - writeln(""); - indent++; + + writer.beginProperties(); + for(Iterator i=props.iterator(); i.hasNext();){ Statement stm = (Statement)i.next(); String methodName = stm.getMethodName(); List args = Arrays.asList(stm.getArguments()); + if (!methodName.equals("setGlassPane")){ - writeln(""); - indent++; + writer.beginProperty(getPropertyName(methodName)); outArguments(args); - indent--; - writeln(""); + writer.endProperty(); } } - indent--; - writeln(""); + writer.endProperties(); } /** @@ -305,40 +288,37 @@ protected void outEvents(List events){ if(events.size() == 0) return; - writeln(""); - indent++; + + writer.beginEvents(); + for(Iterator i=events.iterator(); i.hasNext();){ + Statement stm = (Statement)i.next(); String methodName = stm.getMethodName(); + String source = null; + String action = null; + String handler = null; + String argument = null; + Object[] args = stm.getArguments(); args = ((Expression)valuesToExpression.get(args[0])).getArguments(); - - // exemple d'expression: - // $Proxy30=EventHandler.create(ActionListener, "this", "on_click", "e", "actionPerformed") - // $Proxy50=EventHandler.create(MouseListener, "this", "on_mouse", null, "mouseClicked"); - // $Proxy51=EventHandler.create(MouseListener, "this", "on_allmouse"); if (args.length > 0) { - String source = ((Class)args[0]).getName(); - String event = " 4){ - event += " action=\"" + args[4] + "\""; + if(args.length > 4 && args[4]!=null){ + action = args[4].toString(); } - event += " handler=\"" + args[2] + "\""; - if(args.length > 3 && args[3] != null){ - event += " argument=\"" + args[3] + "\""; + if(args.length > 2 && args[2]!=null){ + handler = args[2].toString(); + } + if(args.length > 3 && args[3]!=null){ + argument = args[3].toString(); } - - event += "/>"; - - writeln(event); } + //attention il faudra gerer les cas ou arguments... peuvent etre null dans le writer + writer.addEvent(methodName, source, action, handler, argument); } - indent--; - writeln(""); - + writer.endEvents(); } /** @@ -346,53 +326,21 @@ * prealablement chargee (appel de la methode d'ecriture du layout) */ protected void outChildren(List children){ - System.out.println("children.size(): "+children.size()); + if(children.size() == 0) return; - writeln(""); - indent++; + + writer.beginChildren(); + for(Iterator i=children.iterator(); i.hasNext();){ Statement stm = (Statement)i.next(); Object [] child = stm.getArguments(); - writeln(""); - indent++; + writer.beginChild(); outObject(child[0]); - System.out.println("child 0: "+child[0]); outLayout(child[0]); - indent--; - writeln(""); - } - indent--; - writeln(""); - } - - /** - * Ecriture des expressions dans le fichier xml - */ - protected void outExpression(Expression exp){ - if(exp == null){ - writeln(" "); - return; - } - Object value = getValue(exp); - Object target = exp.getTarget(); - String methodName = exp.getMethodName(); - - if(value == null){ - writeln(""); - }else if(value instanceof Class){ - writeln(""+((Class)value).getName()+""); - }else if(isPrimitive(value.getClass()) && methodName.equals("new")){ - Class clazz = getPrimitiveClass(value.getClass()); - if(clazz == Character.TYPE){ - value = XMLUtil.quote(((Character)value).toString()); - } - writeln("<"+clazz.getName()+">"+value+""); - }else if(value instanceof String){ - writeln(""+XMLUtil.quote((String)value)+""); - }else{ - outObject(value); + writer.endChild(); } + writer.endChildren(); } /** @@ -400,82 +348,69 @@ */ protected void outLayout(Object o){ System.out.println("outLayout:"+ o + " --- " + o.getClass()); - Object constraints = objectToLayout.get(o); - System.out.println("LayoutConstraints:"+ constraints + " --- " + o.getClass()); + if (constraints != null){ - writeln(""); - indent++; + writer.beginLayout(); outObject(constraints); - indent--; - writeln(""); + writer.endLayout(); } } + protected String getPropertyName(String methodName) { return Introspector.decapitalize(methodName.substring(3)); } - protected boolean isPrimitive(Class clazz){ - return clazz.isPrimitive() - || clazz == Boolean.class - || clazz == Byte.class - || clazz == Character.class - || clazz == Short.class - || clazz == Integer.class - || clazz == Long.class - || clazz == Float.class - || clazz == Double.class; - } - - protected Class getPrimitiveClass(Class clazz) { - if (clazz == Boolean.class) return Boolean.TYPE; - if (clazz == Byte.class) return Byte.TYPE; - if (clazz == Character.class) return Character.TYPE; - if (clazz == Short.class) return Short.TYPE; - if (clazz == Integer.class) return Integer.TYPE; - if (clazz == Long.class) return Long.TYPE; - if (clazz == Float.class) return Float.TYPE; - if (clazz == Double.class) return Double.TYPE; - if (clazz == Void.class) return Void.TYPE; - return null; - } - - /** - * Methode qui permet d'ecrire dans le fichier xml - */ - protected void writeln(String s){ - try{ - for(int i=0; i * Copyright Code Lutin -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * -* Mise a jour: $Date: 2004/08/02 10:45:46 $ +* Mise a jour: $Date: 2004/08/05 16:04:48 $ * par : $Author: mazelier $ */ package org.codelutin.buix; +import org.codelutin.util.Resource; import org.codelutin.buix.layoutinfo.LayoutInfo; import org.codelutin.buix.layoutinfo.LayoutIntrospector; import org.codelutin.buix.layoutinfo.PropertyChildDescriptor; @@ -59,6 +60,8 @@ import java.awt.BorderLayout; import java.awt.GridBagLayout; import java.awt.LayoutManager; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; public class ComponentWalker { // ComponentWalker @@ -69,165 +72,189 @@ this.writer = writer; } - public void walkerThrow(Component component){ + public void walkerThrow(Object object){ - if (component instanceof RootPaneContainer){ - contentPane = ((RootPaneContainer)component).getContentPane(); + if (object instanceof RootPaneContainer){ + contentPane = ((RootPaneContainer)object).getContentPane(); } // pour eviter que ces donnees sont presentes dans le fichier de sortie - if ((!(component instanceof JRootPane)) - && (!(component instanceof JLayeredPane)) - && (!(component instanceof BuixGlassPane)) - && (component != contentPane)){ - - writer.addComponent(component.getClass()); + if (!(object instanceof JRootPane) + && !(object instanceof JLayeredPane) + && !(object instanceof BuixGlassPane) + && object != contentPane){ + + writer.addObject(object.getClass()); + + // Arguments + Field[] fields = object.getClass().getDeclaredFields(); + if (fields.length!=0){ + writer.beginArguments(); + for(int i = 0; i * Copyright Code Lutin - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * - * Mise a jour: $Date: 2004/08/02 10:45:46 $ + * Mise a jour: $Date: 2004/08/05 16:04:48 $ * par : $Author: mazelier $ */ @@ -36,24 +36,31 @@ public void begin(); public void end(); - // Object - public void addComponent(Class clazz); + public void beginObject(Object value); + public void endObject(); - // Properties - public void addProperties(); - public void addProperty(String propertyName, Object value); - - // Events - public void addEvents(); - public void addEvent(String methodName, String source, String action, String handler, - String argument); - - // Children - public void addChildren(); - public void addChild(); + public void beginArguments(); + public void endArguments(); - // Layout - public void addLayout(Object constraint); + public void beginProperties(); + public void endProperties(); + + public void beginProperty(String propertyName); + public void endProperty(); + + public void beginEvents(); + public void endEvents(); + + public void beginChildren(); + public void endChildren(); + + public void beginChild(); + public void endChild(); + + public void beginLayout(); + public void endLayout(); + + public void addEvent(String methodName, String source, String action, String handler, String argument); } // ComponentWalkerCallback Index: buix/src/java/org/codelutin/buix/UIModelWriter.java diff -u buix/src/java/org/codelutin/buix/UIModelWriter.java:1.3 buix/src/java/org/codelutin/buix/UIModelWriter.java:1.4 --- buix/src/java/org/codelutin/buix/UIModelWriter.java:1.3 Mon Aug 2 10:45:46 2004 +++ buix/src/java/org/codelutin/buix/UIModelWriter.java Thu Aug 5 16:04:48 2004 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * -* Mise a jour: $Date: 2004/08/02 10:45:46 $ +* Mise a jour: $Date: 2004/08/05 16:04:48 $ * par : $Author: mazelier $ */ @@ -35,11 +35,10 @@ import java.io.FileWriter; import java.io.OutputStream; +import org.codelutin.util.Resource; import org.codelutin.widget.MessageDialog; import org.codelutin.xml.XMLUtil; -//import java.beans.XMLEncoder; - import org.dom4j.io.XMLWriter; import org.dom4j.io.OutputFormat; @@ -53,142 +52,136 @@ protected String packageName = null; protected OutputStream out = null; - //protected XMLEncoder e = null; - protected Document document = null; - protected Element currentObjectElement = null; - protected Element currentPropertiesElement = null; - protected Element currentEventsElement = null; - protected Element currentChildrenElement = null; - protected Element currentChildElement = null; - public UIModelWriter(String packageName, OutputStream out){ + protected Element currentElement = null; + public UIModelWriter(String packageName, OutputStream out){ this.packageName = packageName; this.out = out; - //e = new XMLEncoder(out); } public void begin(){ document = DocumentHelper.createDocument(); - currentObjectElement = document.addElement("uimodel"); - currentObjectElement.addAttribute("version", "1.0"); - currentObjectElement.addAttribute("package", packageName); + currentElement = document.addElement("uimodel") + .addAttribute("version", "1.0") + .addAttribute("package", packageName); } public void end(){ - try{ - OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter output = new XMLWriter(out, format); output.write(document); output.close(); } catch(IOException eee){ - MessageDialog.error("Error", "L'application a rencontre une erreur lors de la fermeture des encodeurs", eee); + MessageDialog.error("Error", "L'application a rencontre une erreur lors de la fermeture de l'encodeur", eee); } } - public void addComponent(Class clazz){ - if(currentChildElement!=null){ - currentObjectElement = currentChildElement; + public void beginObject(Object value){ + if(value == null){ + currentElement = currentElement.addElement("null"); + }else if (Resource.isPrimitive(value.getClass())){ + Class clazz = Resource.getPrimitiveClass(value.getClass()); + if(clazz == Character.TYPE){ + value = XMLUtil.quote(((Character)value).toString()); + } + currentElement = currentElement.addElement(clazz.getName()); + currentElement.setText(value.toString()); + }else if(value instanceof String){ + currentElement = currentElement.addElement("string"); + currentElement.setText(XMLUtil.quote((String)value)); + }else if(value instanceof Class){ + currentElement = currentElement.addElement("class"); + currentElement.setText(((Class)value).getName()); + }else{ + currentElement = currentElement.addElement("object") + .addAttribute("class", value.getClass().getName()); } - currentObjectElement = currentObjectElement.addElement("object"); - currentObjectElement.addAttribute("class", clazz.getName()); } + public void endObject(){ + currentElement = (Element)currentElement.getParent(); + } - public void addProperties(){ - currentPropertiesElement = currentObjectElement.addElement("properties"); + public void beginArguments(){ + currentElement = currentElement.addElement("arguments"); } - public void addProperty(String propertyName, Object value){ + public void endArguments(){ + currentElement = (Element)currentElement.getParent(); + } - Element currentPropertyElement = currentPropertiesElement.addElement("property"); - currentPropertyElement.addAttribute("name", propertyName); - Element currentArgumentsElement = currentPropertyElement.addElement("arguments"); + public void beginProperties(){ + currentElement = currentElement.addElement("properties"); + } - addExpression(value, currentArgumentsElement); + public void endProperties(){ + currentElement = (Element)currentElement.getParent(); + } + public void beginProperty(String propertyName){ + currentElement = currentElement.addElement("property") + .addAttribute("name", propertyName); } - public void addEvents(){ - currentEventsElement = currentObjectElement.addElement("events"); + public void endProperty(){ + currentElement = (Element)currentElement.getParent(); } - public void addEvent(String methodName, String source, String action, String handler, String argument){ + public void beginEvents(){ + currentElement = currentElement.addElement("events"); + } - Element currentEventElement = currentEventsElement.addElement("event"); - currentEventElement.addAttribute("addmethod", methodName); - currentEventElement.addAttribute("source", source); - currentEventElement.addAttribute("action", action); - currentEventElement.addAttribute("handler", handler); - currentEventElement.addAttribute("argument", argument); + public void endEvents(){ + currentElement = (Element)currentElement.getParent(); } - public void addChildren(){ - currentChildrenElement = currentObjectElement.addElement("children"); + public void beginChildren(){ + currentElement = currentElement.addElement("children"); } - public void addChild(){ - currentChildElement = currentChildrenElement.addElement("child"); + public void endChildren(){ + currentElement = (Element)currentElement.getParent(); } - public void addLayout(Object constraint){ - Element currentLayoutElement = currentChildElement.addElement("layout"); - addExpression(constraint, currentLayoutElement); + public void beginChild(){ + currentElement = currentElement.addElement("child"); } - public void addExpression(Object value, Element currentElement){ - if(value == null){ - currentElement = currentElement.addElement("null"); + public void endChild(){ + currentElement = (Element)currentElement.getParent(); + } - }else if(value instanceof Class){ - currentElement = currentElement.addElement("class"); - currentElement.setText(((Class)value).getName()); - }else if (isPrimitive(value.getClass())){ - Class clazz = getPrimitiveClass(value.getClass()); - if(clazz == Character.TYPE){ - value = XMLUtil.quote(((Character)value).toString()); - } - currentElement = currentElement.addElement(clazz.getName()); - currentElement.setText(value.toString()); - }else if(value instanceof String){ - currentElement = currentElement.addElement("string"); - currentElement.setText(XMLUtil.quote((String)value)); - }else{ - // OBJET - //e.writeObject(value); - //e.flush(); - } + public void beginLayout(){ + currentElement = currentElement.addElement("layout"); } - protected boolean isPrimitive(Class clazz){ - return clazz.isPrimitive() - || clazz == Boolean.class - || clazz == Byte.class - || clazz == Character.class - || clazz == Short.class - || clazz == Integer.class - || clazz == Long.class - || clazz == Float.class - || clazz == Double.class; - } - - protected Class getPrimitiveClass(Class clazz) { - if (clazz == Boolean.class) return Boolean.TYPE; - if (clazz == Byte.class) return Byte.TYPE; - if (clazz == Character.class) return Character.TYPE; - if (clazz == Short.class) return Short.TYPE; - if (clazz == Integer.class) return Integer.TYPE; - if (clazz == Long.class) return Long.TYPE; - if (clazz == Float.class) return Float.TYPE; - if (clazz == Double.class) return Double.TYPE; - if (clazz == Void.class) return Void.TYPE; - return null; + public void endLayout(){ + currentElement = (Element)currentElement.getParent(); } + public void addEvent(String methodName, String source, String action, String handler, String argument){ + + Element e = currentElement.addElement("event"); + if (methodName!=null){ + e.addAttribute("addmethod", methodName); + } + if (source!=null){ + e.addAttribute("source", source); + } + if (action!=null){ + e.addAttribute("action", action); + } + if (handler!=null){ + e.addAttribute("handler", handler); + } + if (argument!=null){ + e.addAttribute("argument", argument); + } + } } // UIModelWriter