Author: fdesbois Date: 2009-10-26 19:35:44 +0100 (Mon, 26 Oct 2009) New Revision: 660 Added: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelReader.java Removed: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/UIModelGenerator.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModel.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelArgumentsImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelChildImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelConstraintImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelEventImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelObjectImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelPropertyImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParser.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/DigesterUIModelRuleSet.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelArgumentsImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelEventImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelPropertyImpl.java branches/1.1.0-Javabuilder/eugene/src/test/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParserTest.java Modified: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/Generator.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelGenerator.java Log: - Suppress old UIModel - Refactor Generators to use Readers Modified: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/Generator.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/Generator.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/Generator.java 2009-10-26 18:35:44 UTC (rev 660) @@ -46,8 +46,6 @@ protected Properties properties = new Properties(); protected boolean overwrite = true; - /** date de derniere modification de la source la plus recente */ - protected long lastModifiedSource = 0; protected List<String> excludeTemplates; @@ -75,14 +73,6 @@ setEncoding(parent.getEncoding()); } - public void generate(File file, File destDir) { - generate(new File[] { file }, destDir); - } - - public void generate(File file) { - generate(new File[] { file }, new File(".")); - } - public void setProperties(Properties p) { this.properties = p; } @@ -129,7 +119,7 @@ } return properties.getProperty(name); } - +/* protected void setLastModifiedSource(File[] files) { for (File file : files) { if (isNewerThanSource(file)) { @@ -148,18 +138,13 @@ return lastModifiedSource; } - /** - * @param file fichier a tester - * @return vrai si le fichier passé en parametre est plus recent que - * les sources sur generateur. - */ protected boolean isNewerThanSource(File file) { if (log.isDebugEnabled()) { log.debug("source date: " + getLastModifiedSource() + " file date: " + file.lastModified() + "(" + file + ")"); } return file.lastModified() > getLastModifiedSource(); - } + }*/ protected File getDestinationFile(File destDir, String filename) { return new File(destDir, filename); Modified: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java 2009-10-26 18:35:44 UTC (rev 660) @@ -91,18 +91,7 @@ protected ObjectModel model = null; - /** - * L'expression réguliere match les chaines de type - * <package.ClassName>.<class|attribute|operation>.[name].<stereotype|tagvalue>.[tag] - * fr.isisfish.entities.Population.class.stereotype=entity - * fr.isisfish.entities.Population.class.tagvalue.persistenceType=flatfile - * fr.isisfish.entities.Population.attribute.name.stereotype=... - * fr.isisfish.entities.Population.attribute.name.tagvalue.pk=topiaId - * fr.isisfish.entities.Population.operation.getRegion.stereotype=... - * fr.isisfish.entities.Population.operation.getRegion.tagvalue.pk=... - */ - protected Pattern propertiesPattern = Pattern - .compile("((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)(?:(class|attribute|operation)\\.)(?:([_a-z0-9][_a-zA-Z0-9]*)\\.)?(?:(stereotype|tagvalue)\\.?)([_a-z0-9][_a-zA-Z0-9]*)?"); + protected ObjectModelReader reader; public ObjectModelGenerator() { super(); @@ -126,152 +115,8 @@ */ @Override public void generate(File[] files, File destDir) { - setLastModifiedSource(files); - ObjectModel objectModel = new ObjectModelImpl(); - - // Digester parser configuration - Digester digester = new Digester(); - digester.addRuleSet(new DigesterObjectModelRuleSet()); - - for (File file : files) { - try { - digester.push(objectModel); - objectModel = (ObjectModel) digester.parse(file); - } catch (IOException e) { - log.warn("Unable to parse ObjectModel input file : " + file, e); - } catch (SAXException e) { - log.warn("Unable to parse ObjectModel input file : " + file, e); - } - - // recherche est charge le fichier propriete associe au modele - File dir = file.getParentFile(); - String ext = FileUtil.extension(file); - String name = FileUtil.basename(file, "." + ext); - File propFile = new File(dir, name + ".properties"); - RecursiveProperties prop = new RecursiveProperties(); - if (!propFile.exists()) { - if (log.isInfoEnabled()) { - log.info("Pas de fichier de propriete " + propFile - + " associé au model"); - } - } else { - if (log.isInfoEnabled()) { - log.info("Lecture du fichier de propriete " + propFile - + " associé au model"); - } - try { - prop.load(new FileInputStream(propFile)); - } catch (IOException eee) { - log.warn("Impossible de lire le fichier de propriete " - + propFile, eee); - } - - // on ajoute les proprietes du fichier associe au model - for (Enumeration<Object> e = prop.keys(); e.hasMoreElements();) { - String key = (String) e.nextElement(); - String value = prop.getProperty(key); - - if (key.startsWith("model")) { - if (!key.startsWith("model.tagvalue.")) { - log.warn("only tagvalue is allowed on model in properties"); - } else { - String tag = key.substring("model.tagvalue." - .length()); - - ObjectModelImplTagValue tagvalue = new ObjectModelImplTagValue(); - tagvalue.setName(tag); - tagvalue.setValue(value); - ((ObjectModelImpl) objectModel) - .addTagValue(tagvalue); - } - } else { - - Matcher matcher = propertiesPattern.matcher(key); - - if (log.isDebugEnabled()) { - log.debug("Propriete: '" + key + "'"); - } - - if (matcher.find()) { - // fqn is fully qualified name of class - String fqn = matcher.group(1); - fqn = StringUtil.substring(fqn, 0, -1); // remove ended - // . - // target is class, attribute or operation - String target = matcher.group(2); - String targetName = matcher.group(3); - // type is stereotype or tagvalue - String type = matcher.group(4); - String tag = matcher.group(5); - - if (log.isDebugEnabled()) { - log.debug("Propriete: '" + key + "' => " - + "fqn:" + fqn + " target:" + target - + " targetName:" + targetName - + " type:" + type + " tag:" + tag); - } - - ObjectModelClassifier omc = objectModel - .getClassifier(fqn); - if (omc instanceof ObjectModelClassifierImpl) { - // on utilise une liste car il peut y avoir plusieur - // operation avec le nom donné - List<ObjectModelElement> elems = new ArrayList<ObjectModelElement>(); - if ("class".equals(target)) { - elems.add(omc); - } else if ("attribute".equals(target)) { - ObjectModelClass classmodel = (ObjectModelClass) omc; - elems.add(classmodel - .getAttribute(targetName)); - } else if ("operation".equals(target)) { - elems.addAll(omc.getOperations(targetName)); - } - for (Object elem1 : elems) { - ObjectModelElementImpl elem = (ObjectModelElementImpl) elem1; - if ("stereotype".equals(type)) { - // pour les stereotypes - ObjectModelImplRef stereotype = new ObjectModelImplRef(); - stereotype.setName(value); - elem.addStereotype(stereotype); - continue; - } - - if ("tagvalue".equals(type)) { - // pour les tagvalues - ObjectModelImplTagValue tagvalue = new ObjectModelImplTagValue(); - tagvalue.setName(tag); - tagvalue.setValue(value); - if (log.isDebugEnabled()) { - log.debug("tagValue:" + tagvalue - + ", tag:" + tag - + ", value:" + value - + ", element:" + elem); - } - if (elem == null) { - log.warn("can not attach tagValue " - + key); - } else { - elem.addTagValue(tagvalue); - } - } - } - } else { - // TODO il faudra avoir des methodes d'acces en - // Set sur l'interface pour eviter ce message - if (log.isWarnEnabled()) { - log.warn("Can't add properties to model, it's not an ObjectModelClassifierImpl"); - } - } - } - } - } - } - } - if (log.isDebugEnabled()) { - for (ObjectModelClass m : objectModel.getClasses()) { - log.debug("loaded class in objectmodel : " + m.getName()); - } - } + reader = new ObjectModelReader(); + ObjectModel objectModel = reader.read(files, destDir); try { generate(objectModel, destDir); } catch (IOException eee) { @@ -381,7 +226,7 @@ if (canGenerateElement(element)) { File outputFile = getDestinationFile(destDir, filename); - if (!getOverwrite() && isNewerThanSource(outputFile)) { + if (!getOverwrite() && reader.isNewerThanSource(outputFile)) { if (log.isDebugEnabled()) { log.debug("file " + outputFile + " is up-to-date"); } Modified: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelGenerator.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelGenerator.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelGenerator.java 2009-10-26 18:35:44 UTC (rev 660) @@ -63,6 +63,8 @@ /** Model */ protected StateModel model; + protected StateModelReader reader; + /** * Empty constructor */ @@ -91,28 +93,9 @@ @Override public void generate(File[] files, File destDir) { - Digester digester = new Digester(); - digester.addRuleSet(new DigesterStateModelRuleSet()); + reader = new StateModelReader(); + StateModel stateModel = reader.read(files, destDir); - StateModelImpl stateModel = new StateModelImpl(); - - // process each file - for (File file : files) { - - // fin a deplacer - try { - digester.push(stateModel); - digester.parse(file); - - // try to load property file - loadPropertyFile(file, stateModel); - } catch (IOException e) { - log.warn("Can't read model file", e); - } catch (SAXException e) { - log.warn("Can't read model file", e); - } - } - // generate code try { generate(stateModel, destDir); @@ -121,50 +104,7 @@ } } - /** - * Try to load property file, associated to current statemodel file - * - * @param stateModelFile - * @param stateModel - */ - protected void loadPropertyFile(File stateModelFile, - StateModelImpl stateModel) { - // recherche et charge le fichier propriete associe au modele - File dir = stateModelFile.getParentFile(); - String ext = FileUtil.extension(stateModelFile); - String name = FileUtil.basename(stateModelFile, "." + ext); - File propFile = new File(dir, name + ".properties"); - RecursiveProperties prop = new RecursiveProperties(); - if (!propFile.exists()) { - if (log.isInfoEnabled()) { - log.info("No property file associated to model : " + propFile); - } - } else { - if (log.isInfoEnabled()) { - log.info("Reading model property file " + propFile); - } - try { - prop.load(new FileInputStream(propFile)); - } catch (IOException e) { - log.warn("Cannot read property file " + propFile, e); - } - - // on ajoute les proprietes du fichier associe au model - for (Enumeration<Object> e = prop.keys(); e.hasMoreElements();) { - String key = (String) e.nextElement(); - String value = prop.getProperty(key); - - if (!key.startsWith("model.tagvalue.")) { - log.warn("only tagvalue is allowed on model in properties"); - } else { - String tag = key.substring("model.tagvalue.".length()); - stateModel.addTagValue(tag, value); - } - } - } - } - /** * Par défaut, appel {@link #generateFromModel(MonitorWriter, org.nuiton.eugene.models.state.StateModel)} pour le * model et {@link #generateFromState(Writer,StateModelState)} pour tous les @@ -181,7 +121,7 @@ String filename = getFilenameFromModel(stateModel); File outputFile = getDestinationFile(destDir, filename); - if (getOverwrite() || !isNewerThanSource(outputFile)) { + if (getOverwrite() || !reader.isNewerThanSource(outputFile)) { try { StringWriter out = new StringWriter(); MonitorWriter monitorOut = new MonitorWriter(out); @@ -208,7 +148,7 @@ String filenameState = getFilenameFromState(state, chart .getName()); File outputFiletate = getDestinationFile(destDir, filenameState); - if (getOverwrite() || !isNewerThanSource(outputFiletate)) { + if (getOverwrite() || !reader.isNewerThanSource(outputFiletate)) { try { StringWriter out = new StringWriter(); MonitorWriter monitorOut = new MonitorWriter(out); Added: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelReader.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelReader.java (rev 0) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/StateModelReader.java 2009-10-26 18:35:44 UTC (rev 660) @@ -0,0 +1,102 @@ + +package org.nuiton.eugene; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Enumeration; +import org.apache.commons.digester.Digester; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.eugene.models.state.StateModel; +import org.nuiton.eugene.models.state.xml.DigesterStateModelRuleSet; +import org.nuiton.eugene.models.state.xml.StateModelImpl; +import org.nuiton.util.FileUtil; +import org.nuiton.util.RecursiveProperties; +import org.xml.sax.SAXException; + +/** + * StateModelReader + * + * Created: 26 oct. 2009 + * + * @author fdesbois + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class StateModelReader extends FileReader<StateModel> { + + private static final Log log = LogFactory.getLog(StateModelReader.class); + + @Override + public StateModel read(File[] files, File destDir) { + Digester digester = new Digester(); + digester.addRuleSet(new DigesterStateModelRuleSet()); + + StateModelImpl stateModel = new StateModelImpl(); + + // process each file + for (File file : files) { + + // fin a deplacer + try { + digester.push(stateModel); + digester.parse(file); + + // try to load property file + loadPropertyFile(file, stateModel); + } catch (IOException e) { + log.warn("Can't read model file", e); + } catch (SAXException e) { + log.warn("Can't read model file", e); + } + } + return stateModel; + } + + /** + * Try to load property file, associated to current statemodel file + * + * @param stateModelFile + * @param stateModel + */ + protected void loadPropertyFile(File stateModelFile, + StateModelImpl stateModel) { + // recherche et charge le fichier propriete associe au modele + File dir = stateModelFile.getParentFile(); + String ext = FileUtil.extension(stateModelFile); + String name = FileUtil.basename(stateModelFile, "." + ext); + File propFile = new File(dir, name + ".properties"); + RecursiveProperties prop = new RecursiveProperties(); + + if (!propFile.exists()) { + if (log.isInfoEnabled()) { + log.info("No property file associated to model : " + propFile); + } + } else { + if (log.isInfoEnabled()) { + log.info("Reading model property file " + propFile); + } + try { + prop.load(new FileInputStream(propFile)); + } catch (IOException e) { + log.warn("Cannot read property file " + propFile, e); + } + + // on ajoute les proprietes du fichier associe au model + for (Enumeration<Object> e = prop.keys(); e.hasMoreElements();) { + String key = (String) e.nextElement(); + String value = prop.getProperty(key); + + if (!key.startsWith("model.tagvalue.")) { + log.warn("only tagvalue is allowed on model in properties"); + } else { + String tag = key.substring("model.tagvalue.".length()); + stateModel.addTagValue(tag, value); + } + } + } + } +} Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/UIModelGenerator.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/UIModelGenerator.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/UIModelGenerator.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,176 +0,0 @@ -/* - * \*##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.nuiton.eugene; - -import java.io.File; -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.commons.digester.Digester; -import org.dom4j.DocumentException; -import org.nuiton.eugene.models.ui.UIModel; -import org.nuiton.eugene.models.ui.UIModelObject; -import org.nuiton.eugene.models.ui.UIModelProperty; -import org.nuiton.eugene.models.ui.impl.UIModelImpl; -import org.nuiton.eugene.models.ui.javaxml.JavaXMLParser; -import org.nuiton.util.ResourceNotFoundException; -import org.xml.sax.SAXException; - -/** - * UIModelGenerator.java - * - * @author cecrid - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class UIModelGenerator extends Generator { - - protected UIModel model = null; - - public UIModelGenerator() { - super(); - - } - - public UIModelGenerator(Generator parent) { - super(parent); - - } - - public UIModel getModel() { - return model; - } - - @Override - public void generate(File[] tabUIFilesName, File destDir) { - setLastModifiedSource(tabUIFilesName); - for (int i = 0; i < tabUIFilesName.length; i++) { - try { - String fileName = tabUIFilesName[i].getName(); - UIModel ui = null; - if (fileName.endsWith(".javaxml")) { - JavaXMLParser parser = new JavaXMLParser(); - ui = parser.parse(tabUIFilesName[i]); - } else { - - // New parser : commons-digester - Digester digester = new Digester(); - ui = new UIModelImpl(); - digester.push(ui); - digester.parse(tabUIFilesName[i]); - } - if (ui != null) { - generate(ui, destDir); - } - } catch (ResourceNotFoundException eee) { - System.out.println("Unable to parse topiaUI input file : " + i); - eee.printStackTrace(); - } catch (IOException eee) { - System.out.println("Unable to generate for file"); - eee.printStackTrace(); - } catch (DocumentException eee) { - System.out.println("Error during the processing of a DOM4J"); - eee.printStackTrace(); - } catch (SAXException e) { - System.out.println("Error during the parsing with digester"); - e.printStackTrace(); - } - } - } - - public void generate(UIModel ui, File destDir) throws IOException { - { - this.model = ui; - - String filename = getFilenameForUIModel(ui); - File outputFile = getDestinationFile(destDir, filename); - if (getOverwrite() || !isNewerThanSource(outputFile)) { - StringWriter out = new StringWriter(); - MonitorWriter monitorOut = new MonitorWriter(out); - generateFromUIModel(monitorOut, model); - write(outputFile, monitorOut); - } else { - Logger.getLogger(getClass().getName() + ".generate").log( - Level.FINE, "file " + outputFile + "is up-to-date"); - } - } - - for (UIModelObject uimodelobject : ui.getObjects()) { - - String filename = getFilenameForUIModelObject(uimodelobject); - File outputFile = getDestinationFile(destDir, filename); - if (getOverwrite() || !isNewerThanSource(outputFile)) { - StringWriter out = new StringWriter(); - MonitorWriter monitorOut = new MonitorWriter(out); - generateFromUIModelObject(monitorOut, uimodelobject); - write(outputFile, monitorOut); - } else { - Logger.getLogger(getClass().getName() + ".generate").log( - Level.FINE, "file " + outputFile + "is up-to-date"); - } - } - } - - /** - * Par defaut cette methode retourne le getName du model. Si l'on souhaite - * utiliser la methode generateFromUIModel il vaut mieux surcharger cette - * methode - * @param model le modele a utiliser - * @return le getName du model - */ - public String getFilenameForUIModel(UIModel model) { - return model.getRoot().getName().concat(".java"); - } - - public String getFilenameForUIModelObject(UIModelObject object) { - return object.getName().concat(".java"); - } - - public void generateFromUIModel(Writer output, UIModel model) - throws IOException { - } - - public void generateFromUIModelObject(Writer output, UIModelObject object) - throws IOException { - } - - public String capitalizeName(UIModelObject o) { - String name = o.getName(); - if (name == null) { - throw new GeneratorException("L'objet " + o.getType() - + " doit avoir un nom valide"); - } - return GeneratorUtil.capitalize(name); - } - - public String capitalizeName(UIModelProperty p) { - String name = p.getName(); - if (name == null) { - throw new GeneratorException("La propriete " + p - + " doit avoir un nom valide"); - } - return GeneratorUtil.capitalize(name); - } -} Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModel.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModel.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModel.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,76 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui; - -import java.util.Collection; - -/** -* UIModel.java -* -* Created: Jun 2, 2004 -* -* @author pineau -* @version $Revision$ -* -* Last update : $Date$ -* by : $Author$ -* -* Abstraction for the root node of ui model trees. -* This an entry point for browsing an ui model tree. -* This object offers as well several facilities for -* a direct access to some of the ui model elements. -*/ -public interface UIModel { - - /** - * Returns the version of this model. - * - * @return the version of this model. - */ - public String getVersion(); - - /** - * Returns the package of this model. - * - * @return the package of this model. - */ - public String getPackage(); - - /** - * Returns the object root defined in this ui model. - * @see UIModelObject - * - * @return the object root defined in this ui model. - */ - public UIModelObject getRoot(); - - /** - * Returns all objects defined in this ui model. - * @see UIModelObject - * - * @return a Collection containing all UIModelObjects for this ui model. - */ - public Collection<UIModelObject> getObjects(); - - /** - * Method used to add objects in this model - * @see UIModelObject - * - */ - public void addObject(UIModelObject object); -} Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelArguments.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,43 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui; - -import java.util.List; - -/** - * UIModelArguments. - * - * Created: Jun 2, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public interface UIModelArguments { // UIModelArguments - - /** - * Returns a arguments list. - * @return a arguments list. - */ - public List<Object> getArguments(); - -} // UIModelArguments - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelChild.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,51 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui; - -/** - * UIModelChild. - * - * Created: Jun 1, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public interface UIModelChild { // UIModelChild - - /** - * Returns a UIModelObject for this child. - * @see UIModelObject - * - * @return a UIModelObject for this child. - */ - public UIModelObject getObject(); - - /** - * Returns a UIModelConstraint for this child. - * @see UIModelObject - * - * @return a UIModelConstraint for this child. - */ - public UIModelConstraint getConstraint(); - -} // UIModelChild - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelConstraint.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,50 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui; - -/** - * UIModelConstraint. - * - * Created: Jun 3, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public interface UIModelConstraint { // UIModelConstraint - - /** - * Returns the value of this constraint. - * the value returned can be an instance of UIModelObject - * or String or null - * @return the value of this constraint. - */ - public Object getValue(); - - /** - * Returns the value of this constraint if the type is String - * else return null - * @return the value of this constraint. - */ - public String getStringValue(); - -} // UIModelConstraint - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelEvent.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,65 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui; - -/** -* UIModelEvent. -* -* Created: Jun 1, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public interface UIModelEvent { // UIModelEvent - - /** - * Returns the addListenerMethod of this event - * @return addListenerMethod - */ - public String getAddMethod(); - - /** - * Returns the listenerInterface of this event - * @return listenerInterface - */ - public String getSource(); - - /** - * Returns the listenerMethodName of this event - * @return listenerMethodName - */ - public String getAction(); - - /** - * Returns the handler of this event - * @return handler - */ - public String getHandler(); - - /** - * Returns the eventPropertyName of this event - * @return eventPropertyName - */ - public String getArgument(); - -} // UIModelEvent - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelObject.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,111 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ -package org.nuiton.eugene.models.ui; - -import java.util.Collection; - -/** -* UIModelObject.java -* -* Created: Jun 2, 2004 -* -* @author pineau -* @version $Revision$ -* -* Last update : $Date$ -* by : $Author$ -*/ -public interface UIModelObject { - - /** - * Returns the parent of this object. - * Returns null if this object is root - * @return the parent of this object. - */ - public UIModelObject getParent(); - - /** - * Returns the type of this object. - * - * @return the type of this object. - */ - public String getType(); - - /** - * Returns the value of the property "name" of this object - * - * @return the name of this object. - */ - public String getName(); - - /** - * Returns the constraint of this object - * @see UIModelConstraint - * - * @return the constraint of this object. - */ - public UIModelConstraint getConstraint(); - - /** - * Returns all arguments defined on this object. - * This collection can contain UIModelObject or a primitive type - * - * @return a Collection containing all arguments for this object. - */ - public Collection<Object> getArguments(); - - /** - * Returns all properties defined on this object. - * @see UIModelProperty - * - * @return a Collection containing all UIModelProperty for this object. - */ - public Collection<UIModelProperty> getProperties(); - - /** - * Returns the property defined on this object. - * @see UIModelProperty - * @param name the name of the property which must be returned - * @return a UIModelProperty for this object with the . - */ - public UIModelProperty getProperty(String name); - - /** - * Returns all events defined on this object. - * @see UIModelEvent - * - * @return a Collection containing all UIModelEvents for this object. - */ - public Collection<UIModelEvent> getEvents(); - - /** - * Returns all children defined on this object. - * @see UIModelChild - * - * @return a Collection containing all UIModelChildren for this object. - */ - public Collection<UIModelChild> getChildren(); - - /** - * Returns the uimodel of this object. - * @see UIModel - * - * @return the uimodel of this object. - */ - public UIModel getModel(); - -} Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/UIModelProperty.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,110 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui; - -/** - * UIModelProperty.java - * - * Created: Jun 2, 2004 - * - * @author pineau - * @version $Revision$ - * - * Last update : $Date$ - * by : $Author$ - */ -public interface UIModelProperty { - - /** - * Returns the name of this property. - * - * @return the name of this property. - */ - public String getName(); - - /** - * Returns the value of this property. - * the value returned can be an instance of UIModelObject - * or String or Integer or Boolean or Character - * @return the value of this property. - */ - public Object getValue(); - - /** - * Returns the index of this property if it's indexed property - * - * @return the index of this property. - */ - public int getIndex() throws Exception; - - public boolean isIndexed(); - - /** - * Returns the value of this property if the type is int - * @return the value of this property. - */ - public int getIntValue(); - - /** - * Returns the value of this property if the type is boolean - * @return the value of this property. - */ - public boolean getBooleanValue(); - - /** - * Returns the value of this property if the type is char - * @return the value of this property. - */ - public char getCharValue(); - - /** - * Returns the value of this property if the type is String - * @return the value of this property. - */ - public String getStringValue(); - - /** - * Returns the value of this property if the type is byte - * @return the value of this property. - */ - public byte getByteValue(); - - /** - * Returns the value of this property if the type is Short - * @return the value of this property. - */ - public short getShortValue(); - - /** - * Returns the value of this property if the type is long - * @return the value of this property. - */ - public long getLongValue(); - - /** - * Returns the value of this property if the type is float - * @return the value of this property. - */ - public float getFloatValue(); - - /** - * Returns the value of this property if the type is double - * @return the value of this property. - */ - public double getDoubleValue(); -} Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelArgumentsImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelArgumentsImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelArgumentsImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,80 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.impl; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.nuiton.eugene.models.ui.UIModelArguments; - -/** -* UIModelArgumentsImpl. -* -* Created: Aug 9, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class UIModelArgumentsImpl implements UIModelArguments { // UIModelArgumentsImpl - - protected List<Object> arguments = new ArrayList<Object>(); - - /** - * Changes the arguments list. - * @param arguments - a new arguments list. - */ - public void setArguments(List<Object> arguments) { - this.arguments = arguments; - } - - /** - * Returns a arguments list. - * @return a arguments list. - */ - public List<Object> getArguments() { - return arguments; - } - - /** - * Add an argument to the arguments list - * @param arg - object argument - */ - public void addArgument(Object arg) { - arguments.add(arg); - } - - /** - * @return a string representation of the object - */ - public String toString() { - String argString = "["; - for (Iterator<Object> i = arguments.iterator(); i.hasNext();) { - Object arg = i.next(); - argString = argString + " " + arg.toString(); - } - argString = argString + "]"; - return argString; - } - -} // UIModelArgumentsImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelChildImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelChildImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelChildImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,97 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.impl; - -import org.nuiton.eugene.models.ui.UIModelChild; -import org.nuiton.eugene.models.ui.UIModelConstraint; -import org.nuiton.eugene.models.ui.UIModelObject; - -/** - * UIModelChildImpl. - * -* Created: Aug 9, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class UIModelChildImpl implements UIModelChild { // UIModelChildImpl - - protected UIModelObject object = null; - protected UIModelConstraint constraint = null; - - /** - * Changes the UIModelObject for this child. - * @see UIModelObject - * - * @param object - a new UIModelObject - */ - public void setObject(UIModelObject object) { - this.object = object; - } - - /** - * Changes the UIModelConstraint for this child. - * @see UIModelConstraint - * - * @param constraint - a new UIModelConstraint - */ - public void setConstraint(UIModelConstraint constraint) { - this.constraint = constraint; - } - - /** - * Returns a UIModelObject for this child. - * @see UIModelObject - * - * @return a UIModelObject for this child. - */ - public UIModelObject getObject() { - return object; - } - - /** - * Returns a UIModelConstraint for this child. - * @see UIModelConstraint - * - * @return a UIModelConstraint for this child. - */ - public UIModelConstraint getConstraint() { - return constraint; - } - - /** - * @return a string representation of the object - */ - public String toString() { - String childString = "["; - childString = childString + " child : " + object.toString() + " \n"; - if (constraint != null) - childString = childString + "constraint : " + constraint.toString() - + " \n"; - childString = childString + "]"; - return childString; - } - -} // UIModelChildImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelConstraintImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelConstraintImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelConstraintImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,84 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.impl; - -import org.nuiton.eugene.models.ui.UIModelConstraint; - -/** -* UIModelConstraintImpl. -* -* Created: Aug 9, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class UIModelConstraintImpl implements UIModelConstraint { // UIModelConstraintImpl - - protected Object value = null; - - /** - * Changes the value of this constraint. - * the value can be an instance of UIModelObject - * or String or null - * @param value - the new value of this constraint. - */ - public void setValue(Object value) { - this.value = value; - } - - /** - * Returns the value of this constraint. - * the value returned can be an instance of UIModelObject - * or String or null - * @return the value of this constraint. - */ - public Object getValue() { - return value; - } - - /** - * Returns the value of this constraint - * if the type is String else returnnull - * - * @return the value of this constraint. - */ - public String getStringValue() { - if (value instanceof String) - return (String) value; - return null; - } - - /** - * @return a string representation of the object - */ - public String toString() { - String toString = null; - if (value != null) { - toString = value.toString(); - } - return toString; - } - -} // UIModelConstraintImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelEventImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelEventImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelEventImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,137 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.impl; - -import org.nuiton.eugene.models.ui.UIModelEvent; - -/** -* UIModelEventImpl. -* -* Created: Aug 9, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class UIModelEventImpl implements UIModelEvent { // UIModelEventImpl - - protected String addMethod = null; - protected String source = null; - protected String action = null; - protected String handler = null; - protected String argument = null; - - /** - * Changes the addListenerMethod of this event - * @param addMethod - the new addListenerMethod - */ - public void setAddMethod(String addMethod) { - this.addMethod = addMethod; - } - - /** - * Changes the listenerInterface of this event - * @param source - the new listenerInterface - */ - public void setSource(String source) { - this.source = source; - } - - /** - * Changes the listenerMethodName of this event - * @param action - the new listenerMethodName - */ - public void setAction(String action) { - this.action = action; - } - - /** - * Changes the handler of this event - * @param handler - the new handler - */ - public void setHandler(String handler) { - this.handler = handler; - } - - /** - * Changes the eventPropertyName of this event - * @param argument - the new eventPropertyName - */ - public void setArgument(String argument) { - this.argument = argument; - } - - /** - * Returns the addListenerMethod of this event - * @return addListenerMethod - */ - public String getAddMethod() { - return addMethod; - } - - /** - * Returns the listenerInterface of this event - * @return listenerInterface - */ - public String getSource() { - return source; - } - - /** - * Returns the listenerMethodName of this event - * @return listenerMethodName - */ - public String getAction() { - return action; - } - - /** - * Returns the handler of this event - * @return handler - */ - public String getHandler() { - return handler; - } - - /** - * Returns the eventPropertyName of this event - * @return eventPropertyName - */ - public String getArgument() { - return argument; - } - - /** - * @return a string representation of the object - */ - public String toString() { - String eventString = "[ addMethod : " + addMethod + ", "; - eventString = eventString + "source " + source + ", "; - eventString = eventString + "action " + action + ", "; - eventString = eventString + "handler " + handler + ", "; - eventString = eventString + "argument : " + argument + " ]"; - return eventString; - } - -} // UIModelEventImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,137 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.impl; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.nuiton.eugene.models.ui.UIModel; -import org.nuiton.eugene.models.ui.UIModelObject; - -/** -* UIModelImpl. -* -* Created: Aug 6, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class UIModelImpl implements UIModel { // UIModelImpl - - protected String version = null; - protected String packageName = null; - protected UIModelObject root = null; - /** - * Contient tous les objets du model. - * key: nom de l'objet; value: l'objet - */ - protected Map<String, UIModelObject> objects = new HashMap<String, UIModelObject>(); - - /** - * Changes the version of this model - * @param version - version of this model - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Changes the package of this model - * @param packageName - package name - */ - public void setPackageName(String packageName) { - this.packageName = packageName; - } - - /** - * Changes the object root defined in this model. - * @see UIModelObject - * @param root - object root - */ - public void setRoot(UIModelObject root) { - this.root = root; - } - - /** - * Returns the version of this model. - * - * @return the version of this model. - */ - public String getVersion() { - return version; - } - - /** - * Returns the package of this model. - * - * @return the package of this model. - */ - public String getPackage() { - return packageName; - } - - /** - * Returns the object root defined in this ui model. - * @see UIModelObject - * - * @return the object root defined in this ui model. - */ - public UIModelObject getRoot() { - return root; - } - - /** - * Returns all objects defined in this ui model. - * @see UIModelObject - * - * @return a Collection containing all UIModelObjects for this ui model. - */ - public Collection<UIModelObject> getObjects() { - return objects.values(); - } - - /** - * Method used to add objects in this model - * @see UIModelObject - * - */ - public void addObject(UIModelObject object) { - if (object.getName() != null) { - objects.put(object.getName(), object); - } - } - - /** - * @return a string representation of the object - */ - public String toString() { - String modelString = "version : " + version + ", "; - modelString = modelString + "package : " + packageName + ", "; - modelString = modelString + "root : " + root.toString(); - return modelString; - } - -} // UIModelImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelObjectImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelObjectImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelObjectImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,310 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.nuiton.eugene.models.ui.UIModel; -import org.nuiton.eugene.models.ui.UIModelArguments; -import org.nuiton.eugene.models.ui.UIModelChild; -import org.nuiton.eugene.models.ui.UIModelConstraint; -import org.nuiton.eugene.models.ui.UIModelEvent; -import org.nuiton.eugene.models.ui.UIModelObject; -import org.nuiton.eugene.models.ui.UIModelProperty; - -/** -* UIModelObjectImpl. -* -* Created: Aug 9, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class UIModelObjectImpl implements UIModelObject { // UIModelObjectImpl - - // model et parent semblent inutiles dans cette implantation mais obligatoire pour l'heritage - protected UIModel model = null; - protected UIModelObject parent = null; - - protected String type = null; - protected String name = null; - protected UIModelConstraint constraint = null; - - protected UIModelArguments arguments = null; - protected List<UIModelProperty> properties = new ArrayList<UIModelProperty>(); - protected List<UIModelEvent> events = new ArrayList<UIModelEvent>(); - protected List<UIModelChild> children = new ArrayList<UIModelChild>(); - - /** - * Changes the model of this object. - * @see UIModel - * - * @param model - the new model of this object. - */ - public void setModel(UIModel model) { - this.model = model; - } - - /** - * Changes the type of this object. - * - * @param type - the new type of this object. - */ - public void setType(String type) { - this.type = type; - } - - /** - * Changes the parent of this object. - * Returns null if this object is root - * @param parent - the parent of this object. - */ - public void setParent(UIModelObject parent) { - this.parent = parent; - } - - /** - * Changes the constraint of this object - * @see UIModelConstraint - * - * @param constraint - the new constraint of this object. - */ - public void setConstraint(UIModelConstraint constraint) { - this.constraint = constraint; - } - - /** - * Changes all arguments defined on this object. - * This collection can contain UIModelObject or a primitive type - * - * @param arguments - a Collection containing all arguments for this object. - */ - public void setArguments(UIModelArguments arguments) { - this.arguments = arguments; - } - - /** - * Changes all properties defined on this object. - * @see UIModelProperty - * - * @param properties - a Collection containing all UIModelProperty for this object. - */ - public void setProperties(List<UIModelProperty> properties) { - this.properties = properties; - } - - /** - * Changes all events defined on this object. - * @see UIModelEvent - * - * @param events - a Collection containing all UIModelEvents for this object. - */ - public void setEvents(List<UIModelEvent> events) { - this.events = events; - } - - /** - * Changes all children defined on this object. - * @see UIModelChild - * - * @param children - a Collection containing all UIModelChildren for this object. - */ - public void setChildren(List<UIModelChild> children) { - this.children = children; - } - - /** - * Returns the uimodel of this object. - * @see UIModel - * @deprecated - * @return the uimodel of this object. - */ - public UIModel getModel() { - return model; - } - - /** - * Returns the type of this object. - * - * @return the type of this object. - */ - public String getType() { - return type; - } - - /** - * Returns the value of the property "name" of this object - * - * @return the name of this object. - */ - public String getName() { - if (name == null) { - UIModelProperty propName = getProperty("name"); - if (propName != null) { - name = propName.getStringValue(); - } - } - return name; - } - - /** - * Returns the parent of this object. - * Returns null if this object is root - * @deprecated - * @return the parent of this object. - */ - public UIModelObject getParent() { - return parent; - } - - /** - * Returns the constraint of this object - * @see UIModelConstraint - * - * @return the constraint of this object. - */ - public UIModelConstraint getConstraint() { - return constraint; - } - - /** - * Returns all arguments defined on this object. - * This collection can contain UIModelObject or a primitive type - * - * @return a Collection containing all arguments for this object. - */ - public Collection<Object> getArguments() { - return arguments.getArguments(); - } - - /** - * Returns all properties defined on this object. - * @see UIModelProperty - * - * @return a Collection containing all UIModelProperty for this object. - */ - public Collection<UIModelProperty> getProperties() { - return properties; - } - - /** - * Returns all events defined on this object. - * @see UIModelEvent - * - * @return a Collection containing all UIModelEvents for this object. - */ - public Collection<UIModelEvent> getEvents() { - return events; - } - - /** - * Returns all children defined on this object. - * @see UIModelChild - * - * @return a Collection containing all UIModelChildren for this object. - */ - public Collection<UIModelChild> getChildren() { - return children; - } - - /** - * Returns the property defined on this object. - * @see UIModelProperty - * @param propName the name of the property which must be returned - * @return a UIModelProperty for this object with the . - */ - public UIModelProperty getProperty(String propName) { - Iterator<UIModelProperty> i = properties.iterator(); - UIModelPropertyImpl prop = null; - boolean find = false; - while (i.hasNext() && find == false) { - prop = (UIModelPropertyImpl) i.next(); - if (propName.equals(prop.getName())) { - find = true; - } - } - - return prop; - } - - /** - * Add a UIModelProperty to the properties list - * @see UIModelProperty - * @param prop - a new UIModelProperty - */ - public void addProperty(UIModelProperty prop) { - properties.add(prop); - } - - /** - * Add a UIModelEvent to the events list - * @see UIModelEvent - * @param event - a new UIModelEvent - */ - public void addEvent(UIModelEvent event) { - events.add(event); - } - - /** - * Add a UIModelChild to the children list - * @see UIModelChild - * @param child - a new UIModelChild - */ - public void addChild(UIModelChild child) { - children.add(child); - } - - /** - * @return a string representation of the object - */ - public String toString() { - String objectString = "\n[ type : " + type + ", "; - objectString = objectString + " name : " + getName() + ", "; - objectString = objectString + " arguments : " + arguments.toString(); - - objectString = objectString + " properties : "; - for (Iterator<UIModelProperty> i = properties.iterator(); i.hasNext();) { - Object prop = i.next(); - objectString = objectString + " " + prop.toString(); - } - - objectString = objectString + " events : "; - for (Iterator<UIModelEvent> i = events.iterator(); i.hasNext();) { - Object event = i.next(); - objectString = objectString + " " + event.toString(); - } - - objectString = objectString + " children : "; - for (Iterator<UIModelChild> i = children.iterator(); i.hasNext();) { - Object child = i.next(); - objectString = objectString + " " + child.toString(); - } - - objectString = objectString + "]\n"; - return objectString; - } - -} // UIModelObjectImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelPropertyImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelPropertyImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/impl/UIModelPropertyImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,238 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.impl; - -import org.nuiton.eugene.GeneratorException; -import org.nuiton.eugene.models.ui.UIModelProperty; - -/** -* UIModelPropertyImpl. -* -* Created: Aug 9, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class UIModelPropertyImpl implements UIModelProperty { // UIModelPropertyImpl - - protected String name; - protected UIModelArgumentsImpl arguments; - - /** - * Returns the name of this property. - * - * @return the name of this property. - */ - public String getName() { - return name; - } - - /** - * Returns the UIModelArgumentsImpl of this property. - * UIModelArgumentsImpl contains the arguments list - * @return UIModelArgumentsImpl - */ - public UIModelArgumentsImpl getArguments() { - return arguments; - } - - /** - * Returns the value of this property. - * the value returned can be an instance of UIModelObject - * or String or Integer or Boolean or Character - * @return the value of this property. - */ - public Object getValue() { - int i = arguments.getArguments().size() - 1; - if (i >= 0) { - return arguments.getArguments().get(i); - } - return null; - } - - /** - * Returns the index of this property if it's indexed property - * - * @return the index of this property. - */ - public int getIndex() throws Exception { - if (isIndexed()) { - return ((Integer) arguments.getArguments().get(0)).intValue(); - } - throw new Exception( - "Impossible d'obtenir l'index d'une propriete non indexee"); - } - - /** - * Returns true if the property is indexed - * @return true if the property is indexed - */ - public boolean isIndexed() { - return arguments.getArguments().size() >= 2; - } - - /** - * Returns the value of this property if the type is int - * @return the value of this property. - */ - public int getIntValue() { - Object object = getValue(); - if (object != null) { - return ((Integer) object).intValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is boolean - * @return the value of this property. - */ - public boolean getBooleanValue() { - Object object = getValue(); - if (object != null) { - return ((Boolean) object).booleanValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is char - * @return the value of this property. - */ - public char getCharValue() { - Object object = getValue(); - if (object != null) { - return ((Character) object).charValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is String - * @return the value of this property. - */ - public String getStringValue() { - Object object = getValue(); - if (object != null) { - return getValue().toString(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is byte - * @return the value of this property. - */ - public byte getByteValue() { - Object object = getValue(); - if (object != null) { - return ((Byte) object).byteValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is long - * @return the value of this property. - */ - public long getLongValue() { - Object object = getValue(); - if (object != null) { - return ((Long) object).longValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is short - * @return the value of this property. - */ - public short getShortValue() { - Object object = getValue(); - if (object != null) { - return ((Short) object).shortValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is float - * @return the value of this property. - */ - public float getFloatValue() { - Object object = getValue(); - if (object != null) { - return ((Float) object).floatValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Returns the value of this property if the type is double - * @return the value of this property. - */ - public double getDoubleValue() { - Object object = getValue(); - if (object != null) { - return ((Double) object).doubleValue(); - } - throw new GeneratorException("La propriete " + name - + " n'a pas de valeur"); - } - - /** - * Changes the name of this property. - * - * @param name - the new name of this property. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Changes the UIModelArgumentsImpl of this property. - * UIModelArgumentsImpl contains the arguments list - * @param arguments - the new UIModelArgumentsImpl of this property. - */ - public void setArguments(UIModelArgumentsImpl arguments) { - this.arguments = arguments; - } - - /** - * @return a string representation of the object - */ - public String toString() { - return getValue().toString(); - } - -} // UIModelPropertyImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParser.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParser.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParser.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,448 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.javaxml; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import org.nuiton.eugene.models.ui.UIModelEvent; -import org.nuiton.eugene.models.ui.UIModelObject; -import org.nuiton.eugene.models.ui.UIModelProperty; -import org.nuiton.eugene.models.ui.impl.UIModelArgumentsImpl; -import org.nuiton.eugene.models.ui.impl.UIModelChildImpl; -import org.nuiton.eugene.models.ui.impl.UIModelConstraintImpl; -import org.nuiton.eugene.models.ui.impl.UIModelEventImpl; -import org.nuiton.eugene.models.ui.impl.UIModelImpl; -import org.nuiton.eugene.models.ui.impl.UIModelObjectImpl; -import org.nuiton.eugene.models.ui.impl.UIModelPropertyImpl; - -/** -* Parser of a xml file issue of XMLEncoder. -* -* Created: Aug 6, 2004 -* -* @author Benjamin Poussin <poussin@codelutin.com> -* Copyright Code Lutin -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -*/ -public class JavaXMLParser { // JavaXMLParser - protected Element rootElement; - protected UIModelImpl uimodel; - - /** - * Parses a xml file and return a uimodel - * @param file - xml file issue of XMLEncoder - * @return UIModelImpl - */ - public UIModelImpl parse(File file) throws DocumentException, - MalformedURLException { - return parse(file.toURI().toURL()); - } - - /** - * Parses a xml file and return a uimodel - * @param url - url of xml file issue of XMLEncoder - * @return UIModelImpl - */ - public UIModelImpl parse(URL url) throws DocumentException, - MalformedURLException { - SAXReader reader = new SAXReader(); - Document document = reader.read(url); - - rootElement = document.getRootElement(); - UIModelImpl result = parseModel(rootElement); - String urlName = url.getFile(); - // exemple - // urlFileName = /home/mazelier/PROJECT/lutingenerator/src/test/org/codelutin/generator/models/ui/javaxml/org.codelutin.chorem.entities.ui.LoggedPanel.javaxml - // on enleve la premiere partie de l'arborescence - // org.codelutin.chorem.entities.ui.LoggedPanel.javaxml - // on enleve l'extension .javaxml - // org.codelutin.chorem.entities.ui.LoggedPanel - // on enleve le nom du fichier pour obtenir le nom du package - // org.codelutin.chorem.entities.ui - - int indexSlash = urlName.lastIndexOf("/"); - if (indexSlash != -1) { - indexSlash++; - String name = urlName.substring(indexSlash, urlName - .lastIndexOf(".javaxml")); - - int indexPoint = name.lastIndexOf("."); - if (indexPoint != -1) { - name = name.substring(0, indexPoint); - } - result.setPackageName(name); - } - return result; - } - - /** - * Returns a UIModelImpl from a element - * @param current - element root of model - * @return UIModelImpl - */ - protected UIModelImpl parseModel(Element current) { - uimodel = new UIModelImpl(); - - String version = current.attributeValue("version"); - uimodel.setVersion(version); - - // selectionne l'unique object racine de l'arbre - Element rootElement = (Element) current - .selectSingleNode("/java/object"); - UIModelObject root = parseObject(rootElement, null); - uimodel.setRoot(root); - - return uimodel; - } - - /** - * Returns a UIModelObjectImpl equivalent to current element. - * It has arguments, properties, events and children - * @param current - element to parse - * @return UIModelObjectImpl - */ - protected UIModelObjectImpl parseObject(Element current, - UIModelObject parent) { - - UIModelObjectImpl result = new UIModelObjectImpl(); - - result.setModel(uimodel); - result.setParent(parent); - - String type = current.attributeValue("class"); - result.setType(type); - - // parse la liste des attributs - UIModelArgumentsImpl arguments = parseArguments(current, result); - result.setArguments(arguments); - - // liste des enfants de l'objet (collection de UIModelChild) - ArrayList children = null; - - // Cas ou l'objet est une instance de RootPaneContainer, les enfants se trouvent dans le contentPane - Element contentPaneElem = (Element) current - .selectSingleNode("void[@property=\"contentPane\"]"); - - if (contentPaneElem != null) { - children = parseChildren(contentPaneElem, result); - } else { - children = parseChildren(current, result); - } - - result.setChildren(children); - - // liste des properties de l'objet courant, on est sur que le tag des properties est de la forme <void property="propertyName">, ce tag est un enfant de l'objet courant - List propertiesElement = current.selectNodes("void[@property]"); - if (contentPaneElem != null) { - Element layoutElement = (Element) contentPaneElem - .selectSingleNode(" void[@property=\"layout\"]"); - propertiesElement.add(layoutElement); - } - - for (Iterator i = propertiesElement.iterator(); i.hasNext();) { - Element propElement = (Element) i.next(); - System.out.println(" propElement " + propElement); - UIModelProperty prop = parseProperty(propElement, result); - result.addProperty(prop); - } - - /* liste des events de l'objet courant - les evenements sont decrits par un tag <void method="addMethod"> - addMethod sera utilisee pour decrire l'event - sous ce tag un objet de type EventHandler avec sa methode create - dessous on trouve l'ensemble des proprietes de l'event (source, action ...)*/ - List eventsElement = current - .selectNodes("void/object[@class=\"java.beans.EventHandler\" and @method=\"create\"]"); - - for (Iterator i = eventsElement.iterator(); i.hasNext();) { - Element eventProp = (Element) i.next(); - UIModelEvent event = parseEvent(eventProp); - result.addEvent(event); - } - - uimodel.addObject(result); - - return result; - } - - /** - * Returns UIModelArgumentsImpl equivalent to current element - * A argument can be an object or a value with a primitiv type - * @param current - element to parse - * @return UIModelArgumentsImpl - */ - protected UIModelArgumentsImpl parseArguments(Element current, - UIModelObject parent) { - - UIModelArgumentsImpl result = new UIModelArgumentsImpl(); - - //liste des arguments d'un propriete ou d'un objet. Ils ne sont pas des entites void mais int, double, ... (types primitfs), String - List listPrimitivElement = current.selectNodes("*[not(self::void)]"); - - for (Iterator i = listPrimitivElement.iterator(); i.hasNext();) { - Element element = (Element) i.next(); - String type = element.getQualifiedName(); - // pour eviter le cas ou l'element est de type <null/> - if (!type.equals("null")) { - String valueString = element.getText(); - Object value = valueString; - if (type.equals("int")) { - value = new Integer(valueString); - } else if (type.equals("float")) { - value = new Float(valueString); - } else if (type.equals("double")) { - value = new Double(valueString); - } else if (type.equals("long")) { - value = new Long(valueString); - } else if (type.equals("short")) { - value = new Short(valueString); - } else if (type.equals("boolean")) { - value = new Boolean(valueString); - } else if (type.equals("byte")) { - value = new Byte(valueString); - } else if (type.equals("object")) { - value = parseObject(element, parent); - } - result.addArgument(value); - } - - } - return result; - } - - /** - * Returns UIModelPropertyImpl equivalent to current element - * A property has a name and a list of Arguments - * @param current - element to parse - * @return UIModelPropertyImpl - */ - protected UIModelPropertyImpl parseProperty(Element current, - UIModelObject parent) { - - // la propriete possede un nom definit par la valeur de l'attribut property - UIModelPropertyImpl result = new UIModelPropertyImpl(); - System.out.println(" current " + current); - String name = current.attributeValue("property"); - result.setName(name); - - // la propriete possede aussi une liste d'arguments - UIModelArgumentsImpl arguments = parseArguments(current, parent); - result.setArguments(arguments); - - return result; - } - - /** - * Returns UIModelEventImpl equivalent to current element - * A event has a addMethod, source, handler, argument and an action - * @param current - element to parse - * @return UIModelEventImpl - */ - protected UIModelEventImpl parseEvent(Element current) { - UIModelEventImpl result = new UIModelEventImpl(); - - /* Modele d'un event - <void method="addMethod"> - <objet class="EventHandler" method="create"> - <class>source</class> - <string>target</string> - <string>handler</handler> - <string>arguments</string> (attention ou <null/>) - <string>action</string> - </objet> - </void> - */ - // parfois il n'y aura pas d'arguments et il est possible que handler soit vide ! - // recuperation de la valeur de addMethod dans le tag parent void de l'objet courant avec l'attribut method - Element addMethodElement = (Element) current - .selectSingleNode("parent::void[@method]"); - result.setAddMethod(addMethodElement.attributeValue("method")); - - // la source est definie pour le tag class place juste en dessous de l'objet courant - Element sourceElement = (Element) current.selectSingleNode("class"); - if (sourceElement != null) { - result.setSource(sourceElement.getText()); - } - - // le handler sera le troisieme element en tout - Element handlerElement = (Element) current - .selectSingleNode("*[position()=3]"); - if (handlerElement != null) { - result.setHandler(handlerElement.getText()); - } - - // on ne connait pas le type d'arguments (null ou string) d'ou * mais on sait que sa position sera toujours 4 ! - Element argumentsElement = (Element) current - .selectSingleNode("*[position()=4]"); - if (argumentsElement != null) { - result.setArgument(argumentsElement.getText()); - } - - // l'action est toujours de type string mais on ne peut pas vraiment determine sa position a cause de arguments : position= 4 si arguments est de type string 3 sinon mais on sait que action sera toujours en dernier position - Element actionElement = (Element) current - .selectSingleNode("*[position()=last()]"); - if (actionElement != null) { - result.setAction(actionElement.getText()); - } - - return result; - } - - protected ArrayList parseChildren(Element current, UIModelObject parent) { - ArrayList result = new ArrayList(); - - //liste des enfants de l'objet - - // l'objet est identifie par un id - //un enfant est un objet qui a ete ajoute par la methode add au container - // sous l'objet courant, on cherche la methode add du tag void puis on recupere l'objet se trouvant sous ce tag. L'enfant est alors identifie par un id ou idref (si l'objet a deja ete defini) - List childrenElement = current - .selectNodes("void[@method=\"add\"]/object"); - - if (!childrenElement.isEmpty()) { - - for (Iterator i = childrenElement.iterator(); i.hasNext();) { - - Element childElem = (Element) i.next(); - String id = childElem.attributeValue("idref"); - // selectionner l'enfant qui possede le meme id que l'idref - // cet enfant se trouve dans les descendants du noeud root - if (id != null) { - childElem = (Element) rootElement - .selectSingleNode("descendant::object[@id=\"" + id - + "\"]"); - } - - id = childElem.attributeValue("id"); - UIModelObjectImpl child = parseObject(childElem, parent); - - // selectionner la constraint - // sous la propriete layout de l'objet, il y a l'argument object layout - // sous cet objet layout, se trouve la methode addLayoutComponent - // avec object ajoute au container avec un idref qui doit etre identique a l'un des enfants vus precedemment (definis dans la methode add) (cet objet est toujours en premiere position - // en deuxieme position se trouve la constrainte du premier object (string ou object) - Element constraintElem = (Element) current - .selectSingleNode("descendant::void[@property=\"layout\"]/object[(@class)]/void[@method=\"addLayoutComponent\"]/object[1][(@idref=\"" - + id - + "\") or (@id=\"" - + id - + "\")]/../*[2][(self::object) or (self::string)]"); - - // ATTENTION : dans l'expression XPath on trouve deux conditions car dans le cas des panels generes l'argument de la proptriete layout n'apparait pas, nous n'avons pas du determine l'origine de l'erreur - if (constraintElem == null) { - constraintElem = (Element) current - .selectSingleNode("descendant::void[@property=\"layout\"]/void[@method=\"addLayoutComponent\"]/object[1][(@idref=\"" - + id - + "\") or (@id=\"" - + id - + "\")]/../*[2][(self::object) or (self::string)]"); - } - - UIModelConstraintImpl constraint = null; - - if (constraintElem != null) { - constraint = parseConstraint(constraintElem, parent); - } - - // uimodelChild est compose un child et d'une contrainte - UIModelChildImpl ch = new UIModelChildImpl(); - ch.setObject(child); - ch.setConstraint(constraint); - - //child.setConstraint(constraint); - - result.add(ch); - - } - } else { - - childrenElement = current - .selectNodes("void[@property=\"layout\"]/void[@method=\"addLayoutComponent\"]"); - - for (Iterator i = childrenElement.iterator(); i.hasNext();) { - - Element objElem = (Element) i.next(); - Element childElem = (Element) objElem - .selectSingleNode("object[1]"); - UIModelObjectImpl child = parseObject(childElem, parent); - - Element constraintElem = (Element) current - .selectSingleNode("*[2][(self::object) or (self::string)]"); - - UIModelConstraintImpl constraint = null; - - if (constraintElem != null) { - constraint = parseConstraint(constraintElem, parent); - } - - // uimodelChild est compose un child et d'une contrainte - UIModelChildImpl ch = new UIModelChildImpl(); - ch.setObject(child); - ch.setConstraint(constraint); - - //child.setConstraint(constraint); - - result.add(ch); - - } - } - - return result; - } - - /** - * Returns UIModelConstraintImpl ewuivalent to current element - * This is ths constraint of an object. It has an object value. - * @param current - element to parse - * @return UIModelConstraintImpl - */ - protected UIModelConstraintImpl parseConstraint(Element current, - UIModelObject parent) { - UIModelConstraintImpl result = new UIModelConstraintImpl(); - Object value = null; - - if (current.matches("self::object")) { - // la valeur de la constrainte est un objet - value = parseObject(current, parent); - - } else if (current.matches("self::string")) { - // la valeur de la constrainte est une string - value = current.getData(); - - } - - result.setValue(value); - - return result; - - } - -} // JavaXMLParser - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/DigesterUIModelRuleSet.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/DigesterUIModelRuleSet.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/DigesterUIModelRuleSet.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,70 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.xml; - -import org.apache.commons.digester.Digester; -import org.apache.commons.digester.RuleSetBase; - -/** - * DigesterUIModelRules - * - * Definit principalement : - la classe d'implementation a utiliser pour chaque - * noeud - la methode a appeler apres chaque noeud - * - * Ce jeu de regle ne cree pas l'element racine. Il doit etre cree et ajoute a - * la pile digester avant l'appel a <tt>Digester.parse(File)</tt>. - * - * Exemple: <code> - * UIModel monModel = new UIModelImpl() - * Digester d = new Digester(); - * d.push(monModel); - * d.parse(file); - * </code> - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ By : $Author$ - */ -public class DigesterUIModelRuleSet extends RuleSetBase { - - protected String prefix = null; - - public DigesterUIModelRuleSet() { - this(""); - } - - public DigesterUIModelRuleSet(String prefix) { - super(); - this.prefix = prefix; - this.namespaceURI = "http://www.codelutin.org/lutingenerator/uiModel"; - } - - /* - * (non-Javadoc) - * - * @see org.apache.commons.digester.RuleSetBase#addRuleInstances(org.apache.commons.digester.Digester) - */ - @Override - public void addRuleInstances(Digester d) { - - // FIXME pas d'exemple pour pouvoir definir les regles - - } - -} Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelArgumentsImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelArgumentsImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelArgumentsImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,109 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.xml; - -import java.util.ArrayList; -import java.util.List; - -import org.nuiton.eugene.models.ui.UIModelArguments; -import org.nuiton.eugene.models.ui.UIModelObject; - -/** - * UIModelArgumentsImpl. - * - * Created: Jun 4, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class UIModelArgumentsImpl implements UIModelArguments { // UIModelArgumentsImpl - - // protected UIModel model = null; - // protected UIModelObject parent = null; - // Liste des arguments de differents types (object, int, bool, String, ...) - protected List<Object> arguments = new ArrayList<Object>(); - - public UIModelArgumentsImpl() { - super(); - } - - public void addObject(UIModelObject value) { - // if(value == null) { - // return new UIModelObjectImpl(model, parent); - // } - - arguments.add(value); - // return value; - } - - public void addInt(Integer value) { - arguments.add(value); - } - - public void addBoolean(Boolean value) { - arguments.add(value); - } - - public void addChar(Character value) { - arguments.add(value); - } - - public void addString(String value) { - arguments.add(value); - } - - public void addLong(Long value) { - arguments.add(value); - } - - public void addFloat(Float value) { - arguments.add(value); - } - - public void addByte(Byte value) { - arguments.add(value); - } - - public void addShort(Short value) { - arguments.add(value); - } - - public void addDouble(Double value) { - arguments.add(value); - } - - /** - * Returns a arguments list. - * - * @see UIModelObject This list can contain UIModelObject or a primitive - * type - * - * @return a arguments list. - */ - public List<Object> getArguments() { - return arguments; - } - -} // UIModelArgumentsImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelChildImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,92 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.xml; - -import org.nuiton.eugene.models.ui.UIModelChild; -import org.nuiton.eugene.models.ui.UIModelConstraint; -import org.nuiton.eugene.models.ui.UIModelObject; - -/** - * UIModelChildImpl. - * - * Created: Jun 4, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class UIModelChildImpl implements UIModelChild { // UIModelChildImpl - - // protected UIModel model = null; - // protected UIModelObject parent = null; - - protected UIModelObject object = null; - - protected UIModelConstraintImpl constraint = null; - - public UIModelChildImpl() { - super(); - } - - public void setObject(UIModelObject object) { - // if(object == null) { - // return new UIModelObjectImpl(model, parent); - // } - - this.object = object; - // return object; - } - - public void setLayout(UIModelConstraintImpl constraint) { - // if (constraint == null) { - // return new UIModelConstraintImpl(model, parent); - // } - - this.constraint = constraint; - // return constraint; - } - - /** - * Returns a UIModelObject for this child. - * - * @see UIModelObject - * - * @return a UIModelObject for this child. - */ - public UIModelObject getObject() { - return object; - } - - /** - * Returns a UIModelConstraint for this child - * - * @see UIModelConstraint - * - * @return a UIModelConstraint for this child. - */ - public UIModelConstraint getConstraint() { - return constraint; - } - -} // UIModelChildImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelConstraintImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,84 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.xml; - -import org.nuiton.eugene.models.ui.UIModelConstraint; - -/** - * UIModelConstraintImpl. - * - * Created: Jun 4, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> Copyright Code Lutin - * - * @version $Revision$ - * - * Mise a jour: $Date$ par : $Author$ - */ -public class UIModelConstraintImpl implements UIModelConstraint { // UIModelConstraintImpl - - // protected UIModel model = null; - // protected UIModelObject parent = null; - - // valeur de la constraint de type UIModelObject ou String (cas du - // borderLayout) - protected Object value = null; - - public UIModelConstraintImpl() { - // this.model = model; - // this.parent = parent; - } - - public void setObject(UIModelObjectImpl value) { - // if (value == null) { - // return new UIModelObjectImpl(model, parent); - // } - - this.value = value; - // return value; - } - - public void setString(String value) { - this.value = value; - } - - /** - * Returns the value of this constraint. the value returned can be an - * instance of UIModelObject or String or null - * - * @return the value of this constraint. - */ - public Object getValue() { - return value; - } - - /** - * Returns the value of this constraint if the type is String else return - * null - * - * @return the value of this constraint. - */ - public String getStringValue() { - if (value instanceof String) { - return (String) value; - } - return null; - } - -} // UIModelConstraintImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelEventImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelEventImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelEventImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,121 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.xml; - -import org.nuiton.eugene.models.ui.UIModelEvent; - -/** - * UIModelEventImpl. - * - * Created: Jun 4, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class UIModelEventImpl implements UIModelEvent { // UIModelEventImpl - - //protected UIModel model = null; - - protected String addMethod = null; - - protected String source = null; - - protected String action = null; - - protected String handler = null; - - protected String argument = null; - - public UIModelEventImpl() { - super(); - } - - public void setAddmethod(String addMethod) { - this.addMethod = addMethod; - } - - public void setSource(String source) { - this.source = source; - } - - public void setAction(String action) { - this.action = action; - } - - public void setHandler(String handler) { - this.handler = handler; - } - - public void setArgument(String argument) { - this.argument = argument; - } - - /** - * Return the method which will have the EventHandler in parameter - * - * @return String - */ - public String getAddMethod() { - return addMethod; - } - - /** - * Return the listener interface to create a proxy for - * - * @return String - */ - public String getSource() { - return source; - } - - /** - * Return the name of the method in the listener interface that should - * trigger the action - * - * @return String - */ - public String getAction() { - return action; - } - - /** - * Return the name of a writable method on the target - * - * @return String - */ - public String getHandler() { - return handler; - } - - /** - * Return the name of a readable property of the incoming event - * - * @return String - */ - public String getArgument() { - return argument; - } - -} // UIModelEventImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,135 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.xml; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.nuiton.eugene.models.ui.UIModel; -import org.nuiton.eugene.models.ui.UIModelObject; - -/** - * UIModelImpl. - * - * Created: Jun 4, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class UIModelImpl implements UIModel { // UIModelImpl - - protected String version = null; - protected String packageUIModel = null; - protected UIModelObjectImpl root = null; - - /** - * Contient tous les objets du model. - * key: nom de l'objet; value: l'objet - */ - protected Map<String, UIModelObject> objects = new HashMap<String, UIModelObject>(); - - public UIModelImpl() { - super(); - } - - public void setVersion(String version) { - this.version = version; - } - - public void setPackage(String packageUIModel) { - this.packageUIModel = packageUIModel; - } - - /** - * TODO pas setObject, mais addObject - * TODO il y aurait ambiguite lors de l'appel par digester - * @param object - */ - public void setObject(UIModelObjectImpl object) { - //if (object == null) { - // return new UIModelObjectImpl(this, null); - //} - - // set model and parent - object.setParent(null); - object.setModel(this); - - root = object; - addObject(root); - //return object; - } - - /** - * Method used to add objects in this model - * @see UIModelObject - */ - public void addObject(UIModelObject object) { - if (object.getName() != null) { - objects.put(object.getName(), object); - } - } - - /** - * Returns the version of this model. - * - * @return the version of this model. - */ - public String getVersion() { - return version; - } - - /** - * Returns the package of this model. - * - * @return the package of this model. - */ - public String getPackage() { - return packageUIModel; - } - - /** - * Return the object root defined in this ui model. - * @see UIModelObject - * - * @return the object root defined in this ui model. - */ - public UIModelObject getRoot() { - return root; - } - - /** - * Returns all objects defined in this ui model. - * @see UIModelObject - * - * @return a Collection containing all UIModelObjects for this ui model. - */ - public Collection<UIModelObject> getObjects() { - return objects.values(); - } - - public UIModelObject getObject(String name) { - return (UIModelObject) objects.get(name); - } - -} // UIModelImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelObjectImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,263 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.xml; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.nuiton.eugene.models.ui.UIModel; -import org.nuiton.eugene.models.ui.UIModelChild; -import org.nuiton.eugene.models.ui.UIModelConstraint; -import org.nuiton.eugene.models.ui.UIModelEvent; -import org.nuiton.eugene.models.ui.UIModelObject; -import org.nuiton.eugene.models.ui.UIModelProperty; - -/** - * UIModelObjectImpl. - * - * Created: Jun 4, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com>Copyright Code Lutin - * - * @version $Revision$ - * - * Mise a jour: $Date$ par : $Author$ - */ -public class UIModelObjectImpl implements UIModelObject { // UIModelObjectImpl - - protected UIModel model = null; - - protected UIModelObject parent = null; - - protected UIModelConstraint constraint = null; - - protected String type = null; - - protected String name = null; - - protected UIModelArgumentsImpl arguments = null; - - protected List<UIModelProperty> properties = new ArrayList<UIModelProperty>(); - - protected List<UIModelEvent> events = new ArrayList<UIModelEvent>(); - - /** Collection de UIModelObject */ - protected List<UIModelChild> children = new ArrayList<UIModelChild>(); - - public UIModelObjectImpl() { - super(); - } - - public void setClass(String type) { - this.type = type; - } - - public void setArguments(UIModelArgumentsImpl argument) { - // if (argument == null) { - // return new UIModelArgumentsImpl(model, this); - // } - - this.arguments = argument; - // return argument; - } - - public void addProperty(UIModelPropertyImpl property) { - // if (property == null) { - // return new UIModelPropertyImpl(model, this); - // } - - if (property.getValue() instanceof UIModelObjectImpl) { - getModel().addObject((UIModelObject) property.getValue()); - } - - if (property.getName().equals("name")) { - name = property.getStringValue(); - } - properties.add(property); - // return property; - } - - public void addEvent(UIModelEventImpl event) { - // if (event == null) { - // return new UIModelEventImpl(model); - // } - - events.add(event); - // return event; - } - - public void addChild(UIModelChildImpl child) { - // if (child == null) { - // return new UIModelChildImpl(model, this); - // } - - UIModelObjectImpl childObject = (UIModelObjectImpl) child.getObject(); - UIModelConstraintImpl childConstraint = (UIModelConstraintImpl) child - .getConstraint(); - childObject.setConstraint(childConstraint); - - getModel().addObject(childObject); - - children.add(child); - // return child; - } - - public void setConstraint(UIModelConstraintImpl constraint) { - this.constraint = constraint; - } - - /** - * Returns the parent of this object. Returns null if this object is root - * - * @return the parent of this object. - */ - public UIModelObject getParent() { - return parent; - } - - /** - * Set the parent of this object. - */ - public void setParent(UIModelObject parent) { - this.parent = parent; - } - - /** - * Returns the type of this object. - * - * @return the type of this object. - */ - public String getType() { - return type; - } - - /** - * Returns the value of the property "name" of this object - * - * @return the name of this object. - */ - public String getName() { - return name; - } - - /** - * Returns the constraint of this object - * - * @see UIModelConstraint - * - * @return the constraint of this object. - */ - public UIModelConstraint getConstraint() { - return constraint; - } - - /** - * Returns all arguments defined on this object. if this objects hasn't - * arguments return null This collection can contain UIModelObject or a - * primitive type - * - * @return a Collection containing all arguments for this object. - */ - public Collection<Object> getArguments() { - if (arguments != null) { - return arguments.getArguments(); - } - return new ArrayList<Object>(); - } - - /** - * Returns all properties defined on this object. - * - * @see UIModelProperty - * - * @return a Collection containing all UIModelProperties for this object. - */ - public Collection<UIModelProperty> getProperties() { - return properties; - } - - /** - * Returns the property defined on this object. - * - * @see UIModelProperty - * @param name the name of the property which must be returned - * @return a UIModelProperty for this object with the . - */ - public UIModelProperty getProperty(String name) { - - UIModelProperty property = null; - int position = 0; - - while (position < properties.size()) { - - property = (UIModelProperty) properties.get(position); - - if (property.getName().equals(name)) { - break; - } - position++; - } - - if (position >= properties.size()) { - throw new IllegalStateException("Propriete " + name - + " inexistante pour l'objet " + this.name); - } - return property; - } - - /** - * Returns all events defined on this object. - * - * @see UIModelEvent - * - * @return a Collection containing all UIModelEvents for this object. - */ - public Collection<UIModelEvent> getEvents() { - return events; - } - - /** - * Returns all children defined on this object. - * - * @return a Collection containing all UIModelObject for this object. - */ - public Collection<UIModelChild> getChildren() { - return children; - } - - /** - * Returns the uimodel of this object. - * - * @see UIModel - * - * @return the uimodel of this object. - */ - public UIModel getModel() { - return model; - } - - /** - * Set model - */ - public void setModel(UIModel model) { - this.model = model; - } - -} // UIModelObjectImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelPropertyImpl.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelPropertyImpl.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/main/java/org/nuiton/eugene/models/ui/xml/UIModelPropertyImpl.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,181 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - - - -package org.nuiton.eugene.models.ui.xml; - -import org.nuiton.eugene.models.ui.UIModelProperty; - -/** - * UIModelPropertyImpl. - * - * Created: Jun 4, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class UIModelPropertyImpl implements UIModelProperty { // UIModelPropertyImpl - - // protected UIModel model = null; - // protected UIModelObject parent = null; - - protected String name = null; - - protected UIModelArgumentsImpl arguments = null; - - public UIModelPropertyImpl() { - super(); - } - - public void setName(String name) { - this.name = name; - } - - public void setArguments(UIModelArgumentsImpl argument) { - // if (argument == null) { - // return new UIModelArgumentsImpl(model, parent); - // } - - this.arguments = argument; - // return argument; - } - - /** - * Returns the name of this property. - * - * @return the name of this property. - */ - public String getName() { - return name; - } - - /** - * Returns the value of this property. the value returned can be an instance - * of UIModelObject or String or Integer or Boolean or Character - * - * @return the value of this property. - */ - public Object getValue() { - int i = (arguments.getArguments().size()) - 1; - return arguments.getArguments().get(i); - } - - /** - * Returns the index of this property if it's indexed property - * - * @return the index of this property. - */ - public int getIndex() throws Exception { - if (isIndexed()) { - return ((Integer) arguments.getArguments().get(0)).intValue(); - } - throw new Exception( - "Impossible d'obtenir l'index d'une propriete non indexee"); - } - - public boolean isIndexed() { - return arguments.getArguments().size() >= 2; - } - - /** - * Returns the value of this property if the type is int - * - * @return the value of this property. - */ - public int getIntValue() { - return ((Integer) getValue()).intValue(); - } - - /** - * Returns the value of this property if the type is boolean - * - * @return the value of this property. - */ - public boolean getBooleanValue() { - return ((Boolean) getValue()).booleanValue(); - } - - /** - * Returns the value of this property if the type is char - * - * @return the value of this property. - */ - public char getCharValue() { - return ((Character) getValue()).charValue(); - } - - /** - * Returns the value of this property if the type is String - * - * @return the value of this property. - */ - public String getStringValue() { - return getValue().toString(); - } - - /** - * Returns the value of this property if the type is byte - * - * @return the value of this property. - */ - public byte getByteValue() { - return ((Byte) getValue()).byteValue(); - } - - /** - * Returns the value of this property if the type is long - * - * @return the value of this property. - */ - public long getLongValue() { - return ((Long) getValue()).longValue(); - } - - /** - * Returns the value of this property if the type is short - * - * @return the value of this property. - */ - public short getShortValue() { - return ((Short) getValue()).shortValue(); - } - - /** - * Returns the value of this property if the type is float - * - * @return the value of this property. - */ - public float getFloatValue() { - return ((Float) getValue()).floatValue(); - } - - /** - * Returns the value of this property if the type is double - * - * @return the value of this property. - */ - public double getDoubleValue() { - return ((Double) getValue()).doubleValue(); - } - -} // UIModelPropertyImpl - Deleted: branches/1.1.0-Javabuilder/eugene/src/test/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParserTest.java =================================================================== --- branches/1.1.0-Javabuilder/eugene/src/test/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParserTest.java 2009-10-26 18:18:35 UTC (rev 659) +++ branches/1.1.0-Javabuilder/eugene/src/test/java/org/nuiton/eugene/models/ui/javaxml/JavaXMLParserTest.java 2009-10-26 18:35:44 UTC (rev 660) @@ -1,126 +0,0 @@ -/* *##% Eugene - * Copyright (C) 2004 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/ - -package org.nuiton.eugene.models.ui.javaxml; - -import java.io.File; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.nuiton.eugene.models.ui.UIModel; -import org.nuiton.eugene.models.ui.impl.UIModelChildImpl; -import org.nuiton.eugene.models.ui.impl.UIModelEventImpl; -import org.nuiton.eugene.models.ui.impl.UIModelObjectImpl; -import org.nuiton.util.Resource; - -/** - * JavaXMLParserTest. - * - * Created: Aug 9, 2004 - * - * @author Benjamin Poussin <poussin@codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class JavaXMLParserTest { // JavaXMLParserTest - - @Test - public void testParse() throws Exception { - - // 1 panel, 2 boutons, gridbaglayout - File testFile = new File(Resource.getURL("models/uimodel/test.javaxml").toURI()); - - // 1 panel, 1 bouton, borderlayout - File testFile1 = new File(Resource.getURL("models/uimodel/test1.javaxml").toURI()); - - // alarmPanel de Chorem dans une JFrame - File testFile2 = new File(Resource.getURL("models/uimodel/test2.javaxml").toURI()); - - if (testFile.exists() && testFile1.exists() && testFile2.exists()) { - - JavaXMLParser parser = new JavaXMLParser(); - UIModel ui = parser.parse(testFile); - UIModel ui1 = parser.parse(testFile1); - UIModel ui2 = parser.parse(testFile2); - //UIModel ui3 = parser.parse(testFile3); - - //System.out.println("UI : \n" + ui); - //System.out.println("UI1 : \n" + ui1); - //System.out.println("UI2 : \n" + ui2); - //System.out.println("UI3 : \n" + ui3); - - // test si l'element racine est parse - Assert.assertNotNull(ui.getRoot()); - Assert.assertNotNull(ui.getRoot().getName()); - - // tests sur tous les elements du root - Assert.assertTrue(ui.getRoot().getArguments().size() == 0); - Assert.assertTrue(ui.getRoot().getChildren().size() == 2); - Assert.assertTrue(ui.getRoot().getEvents().size() == 1); - Assert.assertTrue(ui.getRoot().getProperties().size() == 2); - - // test si le layout est bien recupere - UIModelObjectImpl object = (UIModelObjectImpl) ui.getRoot().getProperty("layout").getValue(); - - Assert.assertEquals(object.getType(), "java.awt.GridBagLayout"); - - // test sur un event de l'enfant - List<?> children = (List<?>) ui.getRoot().getChildren(); - UIModelChildImpl child = (UIModelChildImpl) children.get(0); - - List<?> events = (List<?>) child.getObject().getEvents(); - UIModelEventImpl event = (UIModelEventImpl) events.get(0); - - Assert.assertEquals(event.getAction(), "actionPerformed"); - Assert.assertNotNull(event.getAddMethod()); - - // test sur constraint de l'enfant - UIModelObjectImpl constraint = (UIModelObjectImpl) child.getConstraint().getValue(); - List<?> argConstraint = (List<?>) constraint.getArguments(); - - Assert.assertEquals(constraint.getType(), "java.awt.GridBagConstraints"); - - Assert.assertEquals(argConstraint.get(1).toString(), "0"); - - // test sur le nombre d'enfant d'un enfant - Assert.assertTrue(child.getObject().getChildren().size() == 0); - - // test sur une contrainte string (BorderLayout) - List<?> children1 = (List<?>) ui1.getRoot().getChildren(); - UIModelChildImpl child1 = (UIModelChildImpl) children1.get(0); - - Object constraint1 = child1.getConstraint().getValue(); - Assert.assertEquals(constraint1, "Center"); - - // test sur le nombre d'enfants d'une Frame est correct - List<?> children2 = (List<?>) ui2.getRoot().getChildren(); - Assert.assertTrue(children2.size() == 1); - - // test sur une contrainte d'un panel genere - UIModelChildImpl child2 = (UIModelChildImpl) children2.get(0); - - Object constraint2 = child2.getConstraint().getValue(); - Assert.assertEquals(constraint2, "Center"); - } - } - -} // JavaXMLParserTest -