# This file is part of the Coral project.
# Please read the copyright notice in the LICENSE file.

import coral


class CoralExManifestWriter:
    def __init__(self, name):
        self.package=coral.lang.CoralEx10.Package()
        self.package.name=name
        self.project=coral.Project()
        self.package.__setProject__(self.project)
        
    def addPropertyEditor(self, pe, model,moduleprefix):
        elementName=unicode(model.languageName)+"."+unicode(model.languageVersion)+"."+unicode(model.languageRevision)
        elementName+="::*"
        path=moduleprefix+".propertyeditors."+unicode(pe.name)+unicode("Editor")

        element=coral.lang.CoralEx10.Addins.PropertyEditor()
        element.element_kind=elementName
        element.path=path
        element.name=pe.name
        self.package.ownedElement.append(element)

    def dump(self,filename):
        self.project.setFilename(filename)
        self.project.setXMIFormat("2.0")
        coral.saveDocument(self.project)
