Package de.innovationgate.eclipse.editors.config

Source Code of de.innovationgate.eclipse.editors.config.Generator

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.editors.config;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;



public class Generator {
 
  public static void main(String[] args) throws IOException {
    Reader reader = null;
    Writer writer = null;
    try {
      reader = new FileReader(new File("/home/tbinias/eclipse/plugin-dev/WGAEclipseEditors/resources/wga/tmlTagDefinitionsXStream.xml"));
      TMLTagDefinitions def = TMLTagDefinitions.fromXML(reader);
      def.getTagByName("item").getValidators().add("de.innovationgate.test");
      writer = new FileWriter(new File("/tmp/defout.xml"));
      def.toXML(def, writer);
    } finally {
      if (reader != null) {
        reader.close();
      }
      if (writer != null) {
        writer.close();
      }
    }
   
  }

  /**
   * @param args
   * @throws DocumentException
   * @throws IOException
   */
  /*
  public static void main(String[] args) throws DocumentException, IOException {
    TMLTagDefinitions definitions = new TMLTagDefinitions();
    File file = new File("/home/tbinias/eclipse/plugin-dev/WGADesigner/resources/wga/tmlTagDefinitions.xml");
    SAXReader reader = new SAXReader();
    Document doc = reader.read(file);
    Element root = doc.getRootElement();
   
    // add tags
    Element tags = root.element("tags");
    Iterator tagIt = tags.elementIterator("tag");
    while (tagIt.hasNext()) {
      Element tag = (Element) tagIt.next();
      TMLTag tmlTag = new TMLTag();
      tmlTag.setName(tag.elementText("name"));
      tmlTag.setDescription(tag.elementText("info"));
      tmlTag.setBodycontent(tag.elementText("bodycontent"));
     
      Iterator<Element> aliases = tag.elementIterator("alias");
      while (aliases.hasNext()) {
        tmlTag.addAlias(aliases.next().getText()); 
      }
     
      Iterator<Element> attGroups = tag.elementIterator("attributeGroup");
      while (attGroups.hasNext()) {
        tmlTag.addAttributeGroup(attGroups.next().attributeValue("ref")); 
      }
     
      Iterator attributes = tag.elementIterator("attribute");
      while (attributes.hasNext()) {
        Element attribute = (Element) attributes.next();
        TMLTagAttribute tmlAttribute = new TMLTagAttribute();
        tmlAttribute.setName(attribute.elementText("name"));
        boolean required = Boolean.parseBoolean(attribute.elementText("required"));
        tmlAttribute.setRequired(required);
        String serializedValues = attribute.elementText("values");
        if (serializedValues == null) {
          serializedValues = "";
        }
        Set values = new HashSet(WGUtils.deserializeCollection(serializedValues, ","));
        if (!WGUtils.isEmpty(values)) {
          tmlAttribute.setValues(values);         
        }
        tmlTag.addAttribute(tmlAttribute);
      }
     
     
     
      definitions.addTag(tmlTag);
    }
   
    // add attributegroups
    Element attributeGroups = root.element("attributeGroups");
    Iterator attributeGroupsIt = attributeGroups.elementIterator("attributeGroup");
    while (attributeGroupsIt.hasNext()) {
      Element attributeGroup = (Element) attributeGroupsIt.next();
      TMLAttributeGroup tmlAttributeGroup = new TMLAttributeGroup();
      tmlAttributeGroup.setName(attributeGroup.attributeValue("name", null));
     
      Iterator attributes = attributeGroup.elementIterator("attribute");
      while (attributes.hasNext()) {
        Element attribute = (Element) attributes.next();
        TMLTagAttribute tmlAttribute = new TMLTagAttribute();
        tmlAttribute.setName(attribute.elementText("name"));
        tmlAttribute.setRequired(Boolean.getBoolean(attribute.elementText("required")));
        String serializedValues = attribute.elementText("values");
        if (serializedValues == null) {
          serializedValues = "";
        }
        Set values = new HashSet(WGUtils.deserializeCollection(serializedValues, ","));
        if (!WGUtils.isEmpty(values)) {
          tmlAttribute.setValues(values);         
        }
        tmlAttributeGroup.addAttribute(tmlAttribute);
      }
      definitions.addAttributeGroup(tmlAttributeGroup);
    }
   
    FileWriter writer = new FileWriter("/home/tbinias/eclipse/plugin-dev/WGADesigner/resources/wga/tmlTagDefinitionsXStream.xml");
    definitions.toXML(definitions, writer);
    writer.close();
  }*/

TOP

Related Classes of de.innovationgate.eclipse.editors.config.Generator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.