Search in sources :

Example 6 with Resource

use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.

the class VersionedSchemaDefaultValueService method compute.

@Override
protected String compute() {
    String version = _defaultVersion;
    Resource elementResource = context(Element.class).resource();
    RootXmlResource resource = elementResource.adapt(RootXmlResource.class);
    if (resource != null) {
        Document document = resource.getDomDocument();
        if (document != null) {
            Node node = document.getDocumentElement();
            if (node != null) {
                String namespace = node.getNamespaceURI();
                Matcher matcher = _namespacePattern.matcher(namespace);
                if (matcher.matches()) {
                    version = matcher.group(1);
                }
            }
        }
    }
    return version.replaceAll(StringPool.UNDERSCORE, ".");
}
Also used : Matcher(java.util.regex.Matcher) Element(org.eclipse.sapphire.Element) Node(org.w3c.dom.Node) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) Resource(org.eclipse.sapphire.Resource) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) Document(org.w3c.dom.Document)

Example 7 with Resource

use of org.eclipse.sapphire.Resource in project liferay-ide by liferay.

the class VersionedDTDDefaultValueService method compute.

@Override
protected String compute() {
    String defaultVersion = null;
    Resource resource = context(Element.class).resource();
    RootXmlResource xmlResource = resource.adapt(RootXmlResource.class);
    if (xmlResource != null) {
        Document document = xmlResource.getDomDocument();
        if ((document != null) && (document.getDoctype() != null)) {
            String systemId = document.getDoctype().getSystemId();
            Matcher matcher = _systemIdPattern.matcher(systemId);
            if (matcher.matches()) {
                defaultVersion = matcher.group(1);
            }
        }
    }
    if (defaultVersion == null) {
        // default should be 6.0.0
        defaultVersion = "6.0.0";
    }
    return defaultVersion.replaceAll(StringPool.UNDERSCORE, ".");
}
Also used : Matcher(java.util.regex.Matcher) Element(org.eclipse.sapphire.Element) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) Resource(org.eclipse.sapphire.Resource) RootXmlResource(org.eclipse.sapphire.modeling.xml.RootXmlResource) Document(org.w3c.dom.Document)

Aggregations

Resource (org.eclipse.sapphire.Resource)7 Element (org.eclipse.sapphire.Element)5 XmlResource (org.eclipse.sapphire.modeling.xml.XmlResource)3 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 ElementType (org.eclipse.sapphire.ElementType)2 LayeredListPropertyBinding (org.eclipse.sapphire.LayeredListPropertyBinding)2 PropertyBinding (org.eclipse.sapphire.PropertyBinding)2 PropertyDef (org.eclipse.sapphire.PropertyDef)2 ValuePropertyBinding (org.eclipse.sapphire.ValuePropertyBinding)2 RootXmlResource (org.eclipse.sapphire.modeling.xml.RootXmlResource)2 XmlElement (org.eclipse.sapphire.modeling.xml.XmlElement)2 Document (org.w3c.dom.Document)2 ConnectionBendpoint (com.liferay.ide.kaleo.core.model.ConnectionBendpoint)1 IResource (org.eclipse.core.resources.IResource)1 ElementPropertyBinding (org.eclipse.sapphire.modeling.ElementPropertyBinding)1 LayeredElementBindingImpl (org.eclipse.sapphire.modeling.LayeredElementBindingImpl)1 Node (org.w3c.dom.Node)1