Search in sources :

Example 6 with Element

use of de.pdark.decentxml.Element in project sling by apache.

the class LinkHelper method createSelectionNode.

private JcrNode createSelectionNode(IResource resource) {
    if (resource == null) {
        return null;
    }
    final IContainer resourceParent = resource.getParent();
    if (resource instanceof IFolder) {
        IFolder container = (IFolder) resource;
        IPath syncDirFullPath = ProjectUtil.getSyncDirectoryFullPath(resource.getProject());
        if (syncDirFullPath.equals(container.getFullPath())) {
            // then we've reached the syncdir
            return new SyncDir(container);
        }
    } else if (!(resource instanceof IFile)) {
        return null;
    }
    JcrNode parent = createSelectionNode(resourceParent);
    if (parent == null) {
        return null;
    }
    Element domNode = null;
    JcrNode selectedNode = new JcrNode(parent, domNode, resource);
    return selectedNode;
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) Element(de.pdark.decentxml.Element) IContainer(org.eclipse.core.resources.IContainer) IFolder(org.eclipse.core.resources.IFolder)

Example 7 with Element

use of de.pdark.decentxml.Element in project sling by apache.

the class GenericJcrRootFile method handleChild.

private void handleChild(JcrNode parent, Element domNode) {
    if (domNode.getType() == Type.TEXT) {
        // ignore
        return;
    }
    JcrNode childJcrNode = new JcrNode(parent, domNode, this, null);
    handleProperties(domNode, childJcrNode.properties);
    for (Element element : domNode.getChildren()) {
        handleChild(childJcrNode, element);
    }
}
Also used : Element(de.pdark.decentxml.Element)

Example 8 with Element

use of de.pdark.decentxml.Element in project sling by apache.

the class GenericJcrRootFile method handleJcrRoot.

private void handleJcrRoot(Element element) {
    List<Element> children = element.getChildren();
    final JcrNode effectiveParent;
    if (isRootContentXml()) {
        if (parent instanceof DirNode) {
            DirNode dirNodeParent = (DirNode) parent;
            JcrNode effectiveSibling = dirNodeParent.getEffectiveSibling();
            if (effectiveSibling != null) {
                effectiveSibling.dirSibling = dirNodeParent;
                handleProperties(element, effectiveSibling.properties);
            } else {
                handleProperties(element, parent.properties);
            }
            effectiveParent = parent;
        } else {
            handleProperties(element, parent.properties);
            effectiveParent = parent;
        }
    } else {
        handleProperties(element, properties);
        effectiveParent = this;
        parent.addChild(this);
    }
    for (Iterator<Element> it = children.iterator(); it.hasNext(); ) {
        Element aChild = it.next();
        handleChild(effectiveParent, aChild);
    }
}
Also used : Element(de.pdark.decentxml.Element)

Aggregations

Element (de.pdark.decentxml.Element)8 IFile (org.eclipse.core.resources.IFile)2 IFolder (org.eclipse.core.resources.IFolder)2 CoreException (org.eclipse.core.runtime.CoreException)2 Attribute (de.pdark.decentxml.Attribute)1 Node (de.pdark.decentxml.Node)1 Text (de.pdark.decentxml.Text)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Logger (org.apache.sling.ide.log.Logger)1 SerializationKind (org.apache.sling.ide.serialization.SerializationKind)1 NodeTypeRegistry (org.apache.sling.ide.transport.NodeTypeRegistry)1 Repository (org.apache.sling.ide.transport.Repository)1 RepositoryException (org.apache.sling.ide.transport.RepositoryException)1 IContainer (org.eclipse.core.resources.IContainer)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1