Package com.dragome.templates.interfaces

Examples of com.dragome.templates.interfaces.Template


    Element cloneNode= (Element) node.cloneNode(true);
    cloneNode.setAttribute("data-template-cloning", "true");
    node.getParentNode().appendChild(cloneNode);

    String path= "[data-template-cloning=\"true\"]  ";
    Template clonedTemplate= cloneChildren(template, path, cloneNode);

    cloneNode.removeAttribute("data-template-cloning");
    node.getParentNode().removeChild(cloneNode);

    return clonedTemplate;
View Full Code Here


  }

  private Template cloneChildren(Template template, String aSelector, Element cloneNode)
  {
    cloneNode.removeAttribute("data-debug-id");
    Template clonedTemplate= HTMLTemplateFactory.createTemplate(template.getName());
    clonedTemplate.setFiringEvents(false);
    clonedTemplate.setContent(new ContentImpl<Element>(cloneNode));

    for (Template child : template.getChildrenMap().values())
    {
      String childName= child.getName();
      String selector= aSelector + " " + createSelector(childName);
      Element clonedElement= ServiceLocator.getInstance().getDomHandler().getElementBySelector(selector);
      Template clonedChild= cloneChildren(child, selector, clonedElement);
      clonedTemplate.addChild(clonedChild);
    }

    clonedTemplate.setFiringEvents(true);
View Full Code Here

    templateContent= HtmlTemplateHelper.getHtmlPart(templateName + ".html", null);
  }

  public Template loadTemplateCloned(String templateName, String aContainerId)
  {
    Template template= loadTemplate(templateName, aContainerId);
    return ServiceLocator.getInstance().getTemplateHandler().clone(template);
  }
View Full Code Here

    String aTemplateName= "loaded-template-" + templateNumber++;
    childElement.setAttribute("data-template", aTemplateName);
    childElement.setAttribute("id", aTemplateName);

    Template createTemplate= ServiceLocator.getInstance().getTemplateManager().createTemplate(aTemplateName);
    //  Template createTemplate= new HTMLTemplateFactory().createTemplate(element, aTemplateName);
    return createTemplate;
    }
View Full Code Here

    }

  }
  private void insertTemplates(ItemProcessor<T> itemProcessor, T item, List<Template> clonedRepeatChildren, Entry<T, List<Template>> entry)
  {
    Template insertChild= entry != null ? entry.getValue().get(0) : itemProcessor.getInsertTemplate(item);
    for (Template clonedRepeatedChild : clonedRepeatChildren)
    {
      clonedRepeatedChild.setName(clonedRepeatedChild.getName() + "_" + Integer.toHexString((int) System.currentTimeMillis()));
      insertChild.getParent().insertBefore(clonedRepeatedChild, insertChild);
    }
  }
View Full Code Here

  }

  public Template getUpdatedTemplateFor(T item)
  {
    TemplateHandler templateHandler= ServiceLocator.getInstance().getTemplateHandler();
    Template updatedTemplate= itemProcessor.getRepeatTemplates(item).get(0);
    Template clone= templateHandler.clone(updatedTemplate);
    templateHandler.makeVisible(clone);

    templatesByItem.get(item).add(clone);
    return clone;
  }
View Full Code Here

public class TemplateImpl extends DefaultEventProducer implements Template
{
  public static Template getTemplateElementInDepth(Template templateElement, String aDeepAlias)
  {
    String[] aliases= aDeepAlias.split("\\.");
    Template currentTemplateElement= templateElement;

    for (int i= 0; i < aliases.length; i++)
    {
      if (currentTemplateElement instanceof Template)
        currentTemplateElement= ((Template) currentTemplateElement).getChild(aliases[i]);
View Full Code Here

    return templateContent;
  }

  public Template getChild(String anAlias)
  {
    Template templateElement= children.get(anAlias);
    if (templateElement == null)
      throw new RuntimeException("Cannot find template element '" + anAlias + "' in '" + name + "'");

    return templateElement;
  }
View Full Code Here

    templateListener.insertBefore(newChild, referenceChild, children, childrenList, this);
  }

  public void addChild(Template template)
  {
    Template previous= children.put(template.getName(), template);
    if (previous != null)
    {
      previous.setParent(null);
      childrenList.set(childrenList.indexOf(previous), template);
    }
    else
    {
      childrenList.add(template);
View Full Code Here

  }

  public void renameChild(Template child, String aName)
  {
    String childName= child.getName();
    Template previous= children.remove(childName);
    if (previous != child)
      throw new RuntimeException("This is not a child of this template!");

    children.put(aName, child);
  }
View Full Code Here

TOP

Related Classes of com.dragome.templates.interfaces.Template

Copyright © 2018 www.massapicom. 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.