|
From: jistrawn <jis...@us...> - 2006-10-02 17:27:23
|
Update of /cvsroot/modelwizard/source/Chameleon Plugin/src/net/sourceforge/modelWizard/chameleon/transforms In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv10109/src/net/sourceforge/modelWizard/chameleon/transforms Modified Files: XmlTransformer.java MofTransformer.java CimV2QualifierDeclarations.java QualifierListFactory.java XmlQualifierFactoryImpl.java HtmlTransformer.java Log Message: removed unused imports Index: MofTransformer.java =================================================================== RCS file: /cvsroot/modelwizard/source/Chameleon Plugin/src/net/sourceforge/modelWizard/chameleon/transforms/MofTransformer.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MofTransformer.java 5 May 2006 15:33:38 -0000 1.5 --- MofTransformer.java 2 Oct 2006 17:27:19 -0000 1.6 *************** *** 3,11 **** import java.io.StringBufferInputStream; import java.util.ArrayList; - import java.util.Collection; import java.util.HashMap; import java.util.Iterator; - import net.sourceforge.modelWizard.backingModelAbstraction.ModelTransformationException; import net.sourceforge.modelWizard.chameleon.ModelAbstraction.UmlUtilities; --- 3,9 ---- *************** *** 19,23 **** import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.emf.common.util.EList; - import org.eclipse.emf.ecore.util.EcoreUtil.Copier; import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; import org.eclipse.uml2.Association; --- 17,20 ---- *************** *** 31,35 **** import org.eclipse.uml2.Operation; import org.eclipse.uml2.Parameter; - import org.eclipse.uml2.ParameterDirectionKind; import org.eclipse.uml2.PrimitiveType; import org.eclipse.uml2.Property; --- 28,31 ---- *************** *** 37,41 **** import org.eclipse.uml2.Type; import org.eclipse.uml2.TypedElement; - import org.eclipse.uml2.UML2Factory; /** --- 33,36 ---- Index: XmlTransformer.java =================================================================== RCS file: /cvsroot/modelwizard/source/Chameleon Plugin/src/net/sourceforge/modelWizard/chameleon/transforms/XmlTransformer.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** XmlTransformer.java 26 Jul 2006 22:49:38 -0000 1.6 --- XmlTransformer.java 2 Oct 2006 17:27:19 -0000 1.7 *************** *** 7,11 **** import java.util.Iterator; import java.util.Map; - import java.util.Set; import net.sourceforge.modelWizard.backingModelAbstraction.ModelTransformationException; --- 7,10 ---- Index: QualifierListFactory.java =================================================================== RCS file: /cvsroot/modelwizard/source/Chameleon Plugin/src/net/sourceforge/modelWizard/chameleon/transforms/QualifierListFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QualifierListFactory.java 8 Jan 2006 12:46:07 -0000 1.2 --- QualifierListFactory.java 2 Oct 2006 17:27:19 -0000 1.3 *************** *** 25,29 **** import org.eclipse.uml2.Association; import org.eclipse.uml2.AssociationClass; - import org.eclipse.uml2.Class; import org.eclipse.uml2.Classifier; import org.eclipse.uml2.NamedElement; --- 25,28 ---- Index: XmlQualifierFactoryImpl.java =================================================================== RCS file: /cvsroot/modelwizard/source/Chameleon Plugin/src/net/sourceforge/modelWizard/chameleon/transforms/XmlQualifierFactoryImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XmlQualifierFactoryImpl.java 15 Nov 2005 20:38:16 -0000 1.1 --- XmlQualifierFactoryImpl.java 2 Oct 2006 17:27:19 -0000 1.2 *************** *** 1,117 **** ! /* ! * Created on Oct 4, 2005 ! * @author stjerman ! * <copyright> ! * ! * Copyright (c) 2005 Cisco Systems Inc, ! * All rights reserved. This program and the accompanying materials ! * are made available under the terms of the BSD License ! * which accompanies this distribution. ! * ! * Contributors: ! * CISCO - Initial API and implementation ! * ! * </copyright> ! */ ! package net.sourceforge.modelWizard.chameleon.transforms; ! ! import org.eclipse.emf.common.util.EList; ! import org.eclipse.uml2.Enumeration; ! import org.eclipse.uml2.EnumerationLiteral; ! import org.eclipse.uml2.NamedElement; ! import org.eclipse.uml2.Property; ! import org.eclipse.uml2.Stereotype; ! import org.eclipse.uml2.Type; ! ! import net.sourceforge.modelWizard.chameleon.XmlOut.CimQualifier; ! import net.sourceforge.modelWizard.chameleon.XmlOut.XmlOutFactory; ! ! /** ! * @author stjerman ! * ! * TODO To change the template for this generated type comment go to ! * Window - Preferences - Java - Code Style - Code Templates ! */ ! public class XmlQualifierFactoryImpl implements QualifierFactory { ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createQualifier(java.lang.String, java.lang.String, java.util.ArrayList) ! */ ! public Object createQualifier(String name) { ! return createBooleanQualifier (name,true); ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createQualifier(org.eclipse.uml2.Stereotype, org.eclipse.uml2.NamedElement) ! */ ! public Object createQualifier(Stereotype s, NamedElement obj) { ! Property p = s.getAttribute("value"); ! if (p != null) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(s.getName()); ! //type must be a enumeration or a primitive type ! Type t = p.getType(); ! if (t instanceof Enumeration) ! q.setType("string"); ! else ! q.setType(t.getName().toLowerCase()); ! if (p.isMultivalued()){ ! EList values = (EList) obj.getValue(s,p.getName()); ! for (int n=0;n<values.size();n++){ ! if (t instanceof Enumeration) { ! q.getValue().add(((EnumerationLiteral)values.get(n)).getName()); ! } else { ! q.getValue().add(values.get(n).toString()); ! } ! } ! } else { ! Object value = (Object)obj.getValue(s,p.getName()); ! if (t instanceof Enumeration) { ! q.getValue().add(((EnumerationLiteral)value).getName()); ! } else { ! q.getValue().add(value.toString()); ! } ! } ! return q; ! } else ! return createBooleanQualifier (s.getName(),true); ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createStringQualifier(java.lang.String) ! */ ! public Object createStringQualifier(String name, String value) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(name); ! q.setType("string"); ! if (value != null) ! q.getValue().add(value); ! return q; ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createBooleanQualifier(boolean) ! */ ! public Object createBooleanQualifier(String name, boolean value) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(name); ! q.setType("boolean"); ! if (value) ! q.getValue().add("true"); ! else ! q.getValue().add("false"); ! return q; ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createIntegerQualifier(java.lang.String, int) ! */ ! public Object createIntegerQualifier(String name, int value) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(name); ! q.setType("int"); ! q.getValue().add(Integer.toString(value)); ! return q; ! } ! ! } --- 1,117 ---- ! /* ! * Created on Oct 4, 2005 ! * @author stjerman ! * <copyright> ! * ! * Copyright (c) 2005 Cisco Systems Inc, ! * All rights reserved. This program and the accompanying materials ! * are made available under the terms of the BSD License ! * which accompanies this distribution. ! * ! * Contributors: ! * CISCO - Initial API and implementation ! * ! * </copyright> ! */ ! package net.sourceforge.modelWizard.chameleon.transforms; ! ! import net.sourceforge.modelWizard.chameleon.XmlOut.CimQualifier; ! import net.sourceforge.modelWizard.chameleon.XmlOut.XmlOutFactory; ! ! import org.eclipse.emf.common.util.EList; ! import org.eclipse.uml2.Enumeration; ! import org.eclipse.uml2.EnumerationLiteral; ! import org.eclipse.uml2.NamedElement; ! import org.eclipse.uml2.Property; ! import org.eclipse.uml2.Stereotype; ! import org.eclipse.uml2.Type; ! ! /** ! * @author stjerman ! * ! * TODO To change the template for this generated type comment go to ! * Window - Preferences - Java - Code Style - Code Templates ! */ ! public class XmlQualifierFactoryImpl implements QualifierFactory { ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createQualifier(java.lang.String, java.lang.String, java.util.ArrayList) ! */ ! public Object createQualifier(String name) { ! return createBooleanQualifier (name,true); ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createQualifier(org.eclipse.uml2.Stereotype, org.eclipse.uml2.NamedElement) ! */ ! public Object createQualifier(Stereotype s, NamedElement obj) { ! Property p = s.getAttribute("value"); ! if (p != null) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(s.getName()); ! //type must be a enumeration or a primitive type ! Type t = p.getType(); ! if (t instanceof Enumeration) ! q.setType("string"); ! else ! q.setType(t.getName().toLowerCase()); ! if (p.isMultivalued()){ ! EList values = (EList) obj.getValue(s,p.getName()); ! for (int n=0;n<values.size();n++){ ! if (t instanceof Enumeration) { ! q.getValue().add(((EnumerationLiteral)values.get(n)).getName()); ! } else { ! q.getValue().add(values.get(n).toString()); ! } ! } ! } else { ! Object value = (Object)obj.getValue(s,p.getName()); ! if (t instanceof Enumeration) { ! q.getValue().add(((EnumerationLiteral)value).getName()); ! } else { ! q.getValue().add(value.toString()); ! } ! } ! return q; ! } else ! return createBooleanQualifier (s.getName(),true); ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createStringQualifier(java.lang.String) ! */ ! public Object createStringQualifier(String name, String value) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(name); ! q.setType("string"); ! if (value != null) ! q.getValue().add(value); ! return q; ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createBooleanQualifier(boolean) ! */ ! public Object createBooleanQualifier(String name, boolean value) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(name); ! q.setType("boolean"); ! if (value) ! q.getValue().add("true"); ! else ! q.getValue().add("false"); ! return q; ! } ! ! /* (non-Javadoc) ! * @see com.cisco.nm.cto.cimWizard.umlAccess.QualifierFactory#createIntegerQualifier(java.lang.String, int) ! */ ! public Object createIntegerQualifier(String name, int value) { ! CimQualifier q = XmlOutFactory.eINSTANCE.createCimQualifier(); ! q.setName(name); ! q.setType("int"); ! q.getValue().add(Integer.toString(value)); ! return q; ! } ! ! } Index: HtmlTransformer.java =================================================================== RCS file: /cvsroot/modelwizard/source/Chameleon Plugin/src/net/sourceforge/modelWizard/chameleon/transforms/HtmlTransformer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** HtmlTransformer.java 7 Dec 2005 18:17:37 -0000 1.3 --- HtmlTransformer.java 2 Oct 2006 17:27:19 -0000 1.4 *************** *** 1,241 **** ! package net.sourceforge.modelWizard.chameleon.transforms; ! ! import java.io.ByteArrayInputStream; ! import java.io.ByteArrayOutputStream; ! import java.io.IOException; ! import java.net.URL; ! import java.util.HashMap; ! import java.util.Iterator; ! import java.util.Map; ! ! import javax.xml.transform.TransformerException; ! ! import net.sourceforge.modelWizard.chameleon.Plugin; ! import net.sourceforge.modelWizard.chameleon.XmlOut.CimPackage; ! import net.sourceforge.modelWizard.chameleon.XmlOut.DocumentRoot; ! import net.sourceforge.modelWizard.chameleon.XmlOut.util.XmlOutResourceFactoryImpl; ! import net.sourceforge.modelWizard.utilities.ModelWizardConsole; ! import net.sourceforge.modelWizard.utilities.XslTransformer; ! ! import org.eclipse.core.resources.IContainer; ! import org.eclipse.core.resources.IFolder; ! import org.eclipse.core.resources.IProject; ! import org.eclipse.core.resources.IResource; ! import org.eclipse.core.resources.IWorkspaceRoot; ! import org.eclipse.core.resources.ResourcesPlugin; ! import org.eclipse.core.runtime.CoreException; ! import org.eclipse.core.runtime.IPath; ! import org.eclipse.core.runtime.IProgressMonitor; ! import org.eclipse.core.runtime.Path; ! import org.eclipse.core.runtime.Platform; ! import org.eclipse.core.runtime.SubProgressMonitor; ! import org.eclipse.emf.common.util.EList; ! import org.eclipse.emf.common.util.TreeIterator; ! import org.eclipse.emf.common.util.URI; ! import org.eclipse.emf.ecore.EObject; ! import org.eclipse.emf.ecore.resource.Resource; ! import org.eclipse.emf.ecore.xmi.XMLResource; ! import org.eclipse.emf.ecore.xml.type.AnyType; ! import org.eclipse.emf.ecore.util.EcoreUtil.Copier; ! import org.eclipse.uml2.Model; ! import org.eclipse.uml2.Package;; ! ! ! /** ! * Singleton converter that will take a model and spit out the XML transform format to a ! * passed filename ! */ ! ! public class HtmlTransformer { ! ! public static HtmlTransformer INSTANCE = new HtmlTransformer(); ! private static XmlOutResourceFactoryImpl rf = new XmlOutResourceFactoryImpl(); ! private XslTransformer packageTx; ! private Copier copier = new Copier(); ! ! //file for transforming to profiles... ! private static String CREATEPACKAGE_XSL = "xsl/createProfile.xsl"; ! ! // private static String xslPath = "transformCimXml.xsl"; ! private static String INDEX_XSL = "xsl/index.xsl"; ! private static String INDEX_HTML = "index.html"; ! private static String COMPLEXTYPES_XSL = "xsl/complexTypes.xsl"; ! private static String COMPLEXTYPES_HTML = "complexTypes.html"; ! private static String ENUM_XSL = "xsl/enumerations.xsl"; ! private static String ENUM_HTML = "enumerations.html"; ! private static String PACKAGE_XSL = "xsl/package.xsl"; ! ! int id; ! ! public void createPackageBlueprints (IPath container, DocumentRoot docRoot, IProgressMonitor mainMonitor) throws CoreException, InterruptedException, IOException, TransformerException{ ! SubProgressMonitor monitor = new SubProgressMonitor(mainMonitor,1); ! monitor.beginTask("Creating Profiles for packages",5); ! ! //now prepare the output directory... ! IWorkspaceRoot root =ResourcesPlugin.getWorkspace().getRoot(); ! IContainer cont = (IContainer) root.findMember(container); //assumption that the path is valid (should be...) ! IFolder packFolder = cont.getFolder(new Path("blueprints")); ! if (packFolder.exists()) { ! packFolder.delete(true,monitor); ! packFolder.create(true,true,monitor); ! } else { ! packFolder.create(true,true,monitor); ! } ! ! //now create each output file ... ! CimPackage pCx = docRoot.getCimCx(); ! String version = pCx.getVersion(); ! EList packs = pCx.getCimPackage(); ! int size = packs.size(); ! int done =0; ! monitor.beginTask("Creating packages",size); ! for (int n = 0;n<size;n++){ ! CimPackage p = (CimPackage) packs.get(n); ! p.setVersion(version); ! ModelWizardConsole.INSTANCE.status("("+n+") Creating "+p.getName()); ! doPackage(packFolder,p,monitor); ! monitor.worked(done++); ! } ! monitor.done(); ! } ! ! ! /** ! * @param p ! * @param in ! * @param monitor ! * @throws CimWizardTransformException ! * @throws InterruptedException ! * @throws IOException ! * @throws TransformerException ! */ ! private void doPackage(IResource container, CimPackage basep, SubProgressMonitor monitor) throws InterruptedException, IOException, TransformerException { ! ! if (monitor.isCanceled()) ! throw new InterruptedException(); ! ! //first get source document into an array ... ! URI testUri = URI.createPlatformResourceURI(container.getFullPath().addTrailingSeparator().append(basep.getName()).addFileExtension("xml").toOSString()); ! ! Resource resource = rf.createResource(testUri); ! ! CimPackage p = (CimPackage) copier.copy(basep); ! resource.getContents().add(p); ! copier.copyReferences(); ! Map options = new HashMap(); ! options.put(XMLResource.OPTION_ENCODING, "UTF-8"); ! options.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD); ! options.put(XMLResource.OPTION_DISABLE_NOTIFY, "True"); ! ! // resource.save(options); ! ! ByteArrayOutputStream out = new ByteArrayOutputStream(); ! resource.save(out,options); ! resource.unload(); ! resource = null; ! ! ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ! ! String fName = p.getName().replaceAll("[\\s,]","")+".prf"; ! ModelWizardConsole.INSTANCE.status("Creating "+fName); ! String path = container.getFullPath().append(fName).toOSString(); ! ! if (packageTx == null){ ! packageTx = new XslTransformer(Plugin.getURL(CREATEPACKAGE_XSL)); ! packageTx.setVersionParameter(); ! } ! URI uri = URI.createPlatformResourceURI(path); ! packageTx.setParameter("InputParam",p.getName()); ! packageTx.transformStream(uri,in); ! ! in.close(); ! in = null; ! out = null; ! String version = basep.getVersion(); ! EList packs = p.getCimPackage(); ! for (int n = 0;n<packs.size();n++){ ! CimPackage sp = (CimPackage) packs.get(n); ! basep.setVersion(version); ! doPackage(container,sp,monitor); ! } ! } ! ! public void createHtml (IPath container, DocumentRoot docRoot, IProgressMonitor mainMonitor) throws InterruptedException, IOException, TransformerException, CoreException { ! ! SubProgressMonitor monitor = new SubProgressMonitor(mainMonitor,1); ! monitor.beginTask("Creating HTML",5); ! //first get source document into an array ... ! Resource resource = rf.createResource(null); ! resource.getContents().add(docRoot); ! Map options = new HashMap(); ! options.put(XMLResource.OPTION_ENCODING, "UTF-8"); ! ByteArrayOutputStream out = new ByteArrayOutputStream(); ! resource.save(out,options); ! //now prepare the output directory... ! IWorkspaceRoot root =ResourcesPlugin.getWorkspace().getRoot(); ! IContainer cont = (IContainer) root.findMember(container); //assumption that the path is valid (should be...) ! IFolder packFolder = cont.getFolder(new Path("html")); ! if (packFolder.exists()) { ! packFolder.delete(true,monitor); ! packFolder.create(true,true,monitor); ! } else { ! packFolder.create(true,true,monitor); ! } ! ! XslTransformer transformer = new XslTransformer(Plugin.getURL(INDEX_XSL)); ! ! //now create each output file ... ! //first the index ! ! ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ! URI uri = URI.createPlatformResourceURI(packFolder.getFullPath().append(INDEX_HTML).toOSString()); ! transformer.transformStream(uri,in); ! ! //then the enums ! in = new ByteArrayInputStream(out.toByteArray()); ! transformer.setXsl(Plugin.getURL(ENUM_XSL)); ! uri = URI.createPlatformResourceURI(packFolder.getFullPath().append(ENUM_HTML).toOSString()); ! transformer.transformStream (uri,in); ! ! //then do each top level package.. ! transformer.setXsl(Plugin.getURL(PACKAGE_XSL)); ! Iterator i = docRoot.getCimCx().getCimPackage().iterator(); ! int size = docRoot.getCimCx().getCimPackage().size(); ! int done =0; ! monitor.beginTask("Creating HTML",size); ! while (i.hasNext()){ ! CimPackage p = (CimPackage) i.next(); ! dph(in, packFolder, p, monitor, transformer); ! monitor.worked(++done); ! } ! monitor.done(); ! } ! ! /** ! * @param out ! * @param packFolder ! * @param p ! * @param monitor ! * @param transformer ! * @throws CimWizardTransformException ! * @throws InterruptedException ! * @throws TransformerException ! * @throws IOException ! */ ! private void dph(ByteArrayInputStream in, IFolder packFolder, CimPackage p, SubProgressMonitor monitor, XslTransformer transformer) throws InterruptedException, IOException, TransformerException { ! URL xsl; ! URI uri; ! String name = p.getId()+".html"; ! in.reset(); ! uri = URI.createPlatformResourceURI(packFolder.getFullPath().append(name).toOSString()); ! transformer.setParameter("InputParam",p.getId()); ! transformer.transformStream (uri,in); ! Iterator i = p.getCimPackage().iterator(); ! if (monitor.isCanceled()) ! throw new InterruptedException(); ! while (i.hasNext()){ ! CimPackage pk = (CimPackage) i.next(); ! dph(in, packFolder, pk, monitor,transformer); ! } ! } } \ No newline at end of file --- 1,235 ---- ! package net.sourceforge.modelWizard.chameleon.transforms; ! ! import java.io.ByteArrayInputStream; ! import java.io.ByteArrayOutputStream; ! import java.io.IOException; ! import java.net.URL; ! import java.util.HashMap; ! import java.util.Iterator; ! import java.util.Map; ! ! import javax.xml.transform.TransformerException; ! ! import net.sourceforge.modelWizard.chameleon.Plugin; ! import net.sourceforge.modelWizard.chameleon.XmlOut.CimPackage; ! import net.sourceforge.modelWizard.chameleon.XmlOut.DocumentRoot; ! import net.sourceforge.modelWizard.chameleon.XmlOut.util.XmlOutResourceFactoryImpl; ! import net.sourceforge.modelWizard.utilities.ModelWizardConsole; ! import net.sourceforge.modelWizard.utilities.XslTransformer; ! ! import org.eclipse.core.resources.IContainer; ! import org.eclipse.core.resources.IFolder; ! import org.eclipse.core.resources.IResource; ! import org.eclipse.core.resources.IWorkspaceRoot; ! import org.eclipse.core.resources.ResourcesPlugin; ! import org.eclipse.core.runtime.CoreException; ! import org.eclipse.core.runtime.IPath; ! import org.eclipse.core.runtime.IProgressMonitor; ! import org.eclipse.core.runtime.Path; ! import org.eclipse.core.runtime.SubProgressMonitor; ! import org.eclipse.emf.common.util.EList; ! import org.eclipse.emf.common.util.URI; ! import org.eclipse.emf.ecore.resource.Resource; ! import org.eclipse.emf.ecore.util.EcoreUtil.Copier; ! import org.eclipse.emf.ecore.xmi.XMLResource; ! ; ! ! ! /** ! * Singleton converter that will take a model and spit out the XML transform format to a ! * passed filename ! */ ! ! public class HtmlTransformer { ! ! public static HtmlTransformer INSTANCE = new HtmlTransformer(); ! private static XmlOutResourceFactoryImpl rf = new XmlOutResourceFactoryImpl(); ! private XslTransformer packageTx; ! private Copier copier = new Copier(); ! ! //file for transforming to profiles... ! private static String CREATEPACKAGE_XSL = "xsl/createProfile.xsl"; ! ! // private static String xslPath = "transformCimXml.xsl"; ! private static String INDEX_XSL = "xsl/index.xsl"; ! private static String INDEX_HTML = "index.html"; ! private static String COMPLEXTYPES_XSL = "xsl/complexTypes.xsl"; ! private static String COMPLEXTYPES_HTML = "complexTypes.html"; ! private static String ENUM_XSL = "xsl/enumerations.xsl"; ! private static String ENUM_HTML = "enumerations.html"; ! private static String PACKAGE_XSL = "xsl/package.xsl"; ! ! int id; ! ! public void createPackageBlueprints (IPath container, DocumentRoot docRoot, IProgressMonitor mainMonitor) throws CoreException, InterruptedException, IOException, TransformerException{ ! SubProgressMonitor monitor = new SubProgressMonitor(mainMonitor,1); ! monitor.beginTask("Creating Profiles for packages",5); ! ! //now prepare the output directory... ! IWorkspaceRoot root =ResourcesPlugin.getWorkspace().getRoot(); ! IContainer cont = (IContainer) root.findMember(container); //assumption that the path is valid (should be...) ! IFolder packFolder = cont.getFolder(new Path("blueprints")); ! if (packFolder.exists()) { ! packFolder.delete(true,monitor); ! packFolder.create(true,true,monitor); ! } else { ! packFolder.create(true,true,monitor); ! } ! ! //now create each output file ... ! CimPackage pCx = docRoot.getCimCx(); ! String version = pCx.getVersion(); ! EList packs = pCx.getCimPackage(); ! int size = packs.size(); ! int done =0; ! monitor.beginTask("Creating packages",size); ! for (int n = 0;n<size;n++){ ! CimPackage p = (CimPackage) packs.get(n); ! p.setVersion(version); ! ModelWizardConsole.INSTANCE.status("("+n+") Creating "+p.getName()); ! doPackage(packFolder,p,monitor); ! monitor.worked(done++); ! } ! monitor.done(); ! } ! ! ! /** ! * @param p ! * @param in ! * @param monitor ! * @throws CimWizardTransformException ! * @throws InterruptedException ! * @throws IOException ! * @throws TransformerException ! */ ! private void doPackage(IResource container, CimPackage basep, SubProgressMonitor monitor) throws InterruptedException, IOException, TransformerException { ! ! if (monitor.isCanceled()) ! throw new InterruptedException(); ! ! //first get source document into an array ... ! URI testUri = URI.createPlatformResourceURI(container.getFullPath().addTrailingSeparator().append(basep.getName()).addFileExtension("xml").toOSString()); ! ! Resource resource = rf.createResource(testUri); ! ! CimPackage p = (CimPackage) copier.copy(basep); ! resource.getContents().add(p); ! copier.copyReferences(); ! Map options = new HashMap(); ! options.put(XMLResource.OPTION_ENCODING, "UTF-8"); ! options.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD); ! options.put(XMLResource.OPTION_DISABLE_NOTIFY, "True"); ! ! // resource.save(options); ! ! ByteArrayOutputStream out = new ByteArrayOutputStream(); ! resource.save(out,options); ! resource.unload(); ! resource = null; ! ! ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ! ! String fName = p.getName().replaceAll("[\\s,]","")+".prf"; ! ModelWizardConsole.INSTANCE.status("Creating "+fName); ! String path = container.getFullPath().append(fName).toOSString(); ! ! if (packageTx == null){ ! packageTx = new XslTransformer(Plugin.getURL(CREATEPACKAGE_XSL)); ! packageTx.setVersionParameter(); ! } ! URI uri = URI.createPlatformResourceURI(path); ! packageTx.setParameter("InputParam",p.getName()); ! packageTx.transformStream(uri,in); ! ! in.close(); ! in = null; ! out = null; ! String version = basep.getVersion(); ! EList packs = p.getCimPackage(); ! for (int n = 0;n<packs.size();n++){ ! CimPackage sp = (CimPackage) packs.get(n); ! basep.setVersion(version); ! doPackage(container,sp,monitor); ! } ! } ! ! public void createHtml (IPath container, DocumentRoot docRoot, IProgressMonitor mainMonitor) throws InterruptedException, IOException, TransformerException, CoreException { ! ! SubProgressMonitor monitor = new SubProgressMonitor(mainMonitor,1); ! monitor.beginTask("Creating HTML",5); ! //first get source document into an array ... ! Resource resource = rf.createResource(null); ! resource.getContents().add(docRoot); ! Map options = new HashMap(); ! options.put(XMLResource.OPTION_ENCODING, "UTF-8"); ! ByteArrayOutputStream out = new ByteArrayOutputStream(); ! resource.save(out,options); ! //now prepare the output directory... ! IWorkspaceRoot root =ResourcesPlugin.getWorkspace().getRoot(); ! IContainer cont = (IContainer) root.findMember(container); //assumption that the path is valid (should be...) ! IFolder packFolder = cont.getFolder(new Path("html")); ! if (packFolder.exists()) { ! packFolder.delete(true,monitor); ! packFolder.create(true,true,monitor); ! } else { ! packFolder.create(true,true,monitor); ! } ! ! XslTransformer transformer = new XslTransformer(Plugin.getURL(INDEX_XSL)); ! ! //now create each output file ... ! //first the index ! ! ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); ! URI uri = URI.createPlatformResourceURI(packFolder.getFullPath().append(INDEX_HTML).toOSString()); ! transformer.transformStream(uri,in); ! ! //then the enums ! in = new ByteArrayInputStream(out.toByteArray()); ! transformer.setXsl(Plugin.getURL(ENUM_XSL)); ! uri = URI.createPlatformResourceURI(packFolder.getFullPath().append(ENUM_HTML).toOSString()); ! transformer.transformStream (uri,in); ! ! //then do each top level package.. ! transformer.setXsl(Plugin.getURL(PACKAGE_XSL)); ! Iterator i = docRoot.getCimCx().getCimPackage().iterator(); ! int size = docRoot.getCimCx().getCimPackage().size(); ! int done =0; ! monitor.beginTask("Creating HTML",size); ! while (i.hasNext()){ ! CimPackage p = (CimPackage) i.next(); ! dph(in, packFolder, p, monitor, transformer); ! monitor.worked(++done); ! } ! monitor.done(); ! } ! ! /** ! * @param out ! * @param packFolder ! * @param p ! * @param monitor ! * @param transformer ! * @throws CimWizardTransformException ! * @throws InterruptedException ! * @throws TransformerException ! * @throws IOException ! */ ! private void dph(ByteArrayInputStream in, IFolder packFolder, CimPackage p, SubProgressMonitor monitor, XslTransformer transformer) throws InterruptedException, IOException, TransformerException { ! URL xsl; ! URI uri; ! String name = p.getId()+".html"; ! in.reset(); ! uri = URI.createPlatformResourceURI(packFolder.getFullPath().append(name).toOSString()); ! transformer.setParameter("InputParam",p.getId()); ! transformer.transformStream (uri,in); ! Iterator i = p.getCimPackage().iterator(); ! if (monitor.isCanceled()) ! throw new InterruptedException(); ! while (i.hasNext()){ ! CimPackage pk = (CimPackage) i.next(); ! dph(in, packFolder, pk, monitor,transformer); ! } ! } } \ No newline at end of file Index: CimV2QualifierDeclarations.java =================================================================== RCS file: /cvsroot/modelwizard/source/Chameleon Plugin/src/net/sourceforge/modelWizard/chameleon/transforms/CimV2QualifierDeclarations.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CimV2QualifierDeclarations.java 21 Apr 2006 18:11:42 -0000 1.5 --- CimV2QualifierDeclarations.java 2 Oct 2006 17:27:19 -0000 1.6 *************** *** 14,23 **** import org.eclipse.emf.ecore.EClass; - import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.uml2.Enumeration; import org.eclipse.uml2.EnumerationLiteral; import org.eclipse.uml2.Model; import org.eclipse.uml2.Profile; - import org.eclipse.uml2.Class; import org.eclipse.uml2.ProfileApplication; import org.eclipse.uml2.Property; --- 14,21 ---- |