Java Code Examples for org.dom4j.Element.add()

The following are Jave code examples for showing how to use add() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: bdf2   File: AbstractBuilder.java   View Source Code Vote up 6 votes
protected Element createEntityFieldsCollectionElement(Entity fieldEntity){
	Collection<EntityField> entityFields=fieldEntity.getEntityFields();
	String entityTableName=fieldEntity.getTableName();
	Element collection=new BaseElement("Collection");
	for(EntityField ef:entityFields){
		if(!entityTableName.equals(ef.getTableName())){
			continue;
		}
		Element entity = new BaseElement("Entity");
		entity.add(this.createPropertyElement("name", ef.getName()));
		entity.add(this.createPropertyElement("keyGenerator", ef.getKeyGenerator()));
		entity.add(this.createPropertyElement("keyGenerateType", ef.getKeyGenerateType().toString()));
		entity.add(this.createPropertyElement("submittable", String.valueOf(ef.isSubmittable())));
		collection.add(entity);
	}
	return collection;
}
 
Example 2
Project: joai-project   File: AccessManager.java   View Source Code Vote up 6 votes
/**
 *  Update DocMap with recent ActionPath and GuardedPaths, and then write it to
 *  disk.
 *
 * @exception  Exception  NOT YET DOCUMENTED
 */
public synchronized void flush() throws Exception {
	Element root = df.createElement(rootElementName);
	Document doc = df.createDocument(root);
	try {
		Element guardedPaths = root.addElement("guarded-paths");
		for (Iterator i = guardedPathMap.values().iterator(); i.hasNext(); ) {
			GuardedPath gp = (GuardedPath) i.next();
			guardedPaths.add(gp.asElement());
		}
		Element actionpaths = root.addElement("action-paths");
		for (Iterator i = actionPathMap.values().iterator(); i.hasNext(); ) {
			ActionPath ap = (ActionPath) i.next();
			actionpaths.add(ap.asElement());
		}
		docMap = new DocMap(doc);
	} catch (Throwable t) {
		prtln("flush error: " + t.getMessage());
		t.printStackTrace();
		throw new Exception(t.getCause());
	}
	super.flush();
}
 
Example 3
Project: joai-project   File: MdeRepeatingAnyType.java   View Source Code Vote up 6 votes
Element newItemInput () {
	Element acceptsNewSibling = rhelper.acceptsNewSiblingTest(xpath);
	String itemPath = siblingPath + "_${" + indexId + "+1}_";
	Element id = this.df.createElement ("bean__define")
		.addAttribute ("id", indexId)
		.addAttribute ("name", this.formBeanName)
		.addAttribute ("property", "memberCountOf(" + xpath + ")");
	
			// create fieldElement (containing input element)
	Element fieldElement = df.createElement("div");

	// new anyType input element
	int rows = 8;
	Element input = df.createElement("html__textarea")
		.addAttribute("property", "anyTypeValueOf(" + itemPath + ")")
		.addAttribute("style", "width__98%")
		.addAttribute("rows", String.valueOf(rows));
	
	SimpleTypeLabel label = renderer.getSimpleTypeLabel(itemPath);
	
	acceptsNewSibling.add (id);
	acceptsNewSibling.add(this.renderer.getRenderedField(itemPath, label, input));
	return acceptsNewSibling;
}
 
Example 4
Project: joai-project   File: MdeRepeatingNode.java   View Source Code Vote up 6 votes
/**
 *  Render jsp element for adding a new repeating element that will be shown
 *  when there are no existing values for this field in the instance document.
 *
 * @return    NOT YET DOCUMENTED
 */
protected Element emptyRepeatingElement() {

	Element emptyRepeat = rhelper.nodeHasNoMembersTest(xpath);

	String nodeName = XPathUtils.getLeaf(xpath);
	prtln("emptyRepeatingElement() for " + nodeName);

	// build control element
	Element controlElement = df.createElement("div");

	Element newItemAction = controlElement.addElement("div")
		.addAttribute("class", "action-button");
	Element newItemLink = newItemAction.addElement("a")
		.addAttribute("href", "javascript:doNewElement(" + RendererHelper.jspQuotedString(xpath) + ")");
	rhelper.attachToolHelp(newItemLink, "Create a new " + nodeName);
	newItemLink.setText("add " + nodeName);

	prtln("calling renderer.getSimpleTypeLabel(xpath)");
	Label label = renderer.getSimpleTypeLabel(xpath);
	if (!this.schemaNode.isRequired())
		((SimpleTypeLabel)label).setOptional();
	emptyRepeat.add(getRenderedNoInputField(label, controlElement));

	return emptyRepeat;
}
 
Example 5
Project: directory-ldap-api   File: BatchResponseDsml.java   View Source Code Vote up 5 votes
/**
 * Converts this Batch Response to its XML representation in the DSMLv2 format.
 * 
 * @param prettyPrint if true, formats the document for pretty printing
 * @return the XML representation in DSMLv2 format
 */
public String toDsml( boolean prettyPrint )
{
    Document document = DocumentHelper.createDocument();
    Element element = document.addElement( "batchResponse" );

    element.add( ParserUtils.DSML_NAMESPACE );
    element.add( ParserUtils.XSD_NAMESPACE );
    element.add( ParserUtils.XSI_NAMESPACE );

    // RequestID
    if ( requestID != 0 )
    {
        element.addAttribute( "requestID", Integer.toString( requestID ) );
    }

    for ( DsmlDecorator<? extends Response> response : responses )
    {
        response.toDsml( element );
    }

    if ( prettyPrint )
    {
        document = ParserUtils.styleDocument( document );
    }
    
    return document.asXML();
}
 
Example 6
Project: bdf2   File: ModelBuilder.java   View Source Code Vote up 5 votes
private Element createDataProvider(Entity entity){
	Element element=new BaseElement("DataProvider");
	element.addAttribute("type", "direct");
	String entityName=entity.getName();
	element.addAttribute("name", "dataProvider"+entityName.substring(0,1).toUpperCase()+entityName.substring(1,entityName.length()));
	element.add(this.createPropertyElement("interceptor", "spring:bdf.rapido.commonPR#loadEntityData"));
	Element metaData=this.createPropertyElement("metaData", null);
	metaData.add(this.createPropertyElement(Constants.QUERY_SQL, entity.getQuerySql()));
	element.add(metaData);
	return element;
}
 
Example 7
Project: ARCLib   File: XmlBuilderTest.java   View Source Code Vote up 5 votes
@Test
public void addSiblingNodeTest() throws IOException, SAXException, TransformerException {
    Document doc = DocumentHelper.createDocument(DocumentHelper.createElement("root"));

    Element root = doc.getRootElement();

    Element child = DocumentHelper.createElement("child");
    child.setText("test value 1");

    root.add(child);

    xmlBuilder.addNode(doc, "/root/child", "test value 2", uris.get("ARCLIB"));
    assertThat(doc.asXML(), is("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root><child>test value 1</child><child xmlns=\"http://arclib.lib.cas.cz/ARCLIB_XML\">test value 2</child></root>"));
}
 
Example 8
Project: joai-project   File: DocMap.java   View Source Code Vote up 5 votes
/**
 *  Insert an element in it's parent element using compositor. The compositor
 *  can provide information that allows us to place the new element at the
 *  correct place in the parent element.
 *
 * @param  element        NOT YET DOCUMENTED
 * @param  parent         NOT YET DOCUMENTED
 * @exception  Exception  NOT YET DOCUMENTED
 */
private void untargetedInsert(Element element, Element parent) throws Exception {
	// prtln("\n untargetedInsert()");
	// prtln("\telement name: " + element.getQualifiedName());
	// prtln ("\telement to insert: " + Dom4jUtils.prettyPrint(element) + "\n");
	String parentPath = parent.getPath();

	if (schemaHelper == null || !schemaHelper.hasSequenceCompositor(parentPath)) {

		// prtln ("no help from schemaHelper - inserting element at end of parent");
		if (schemaHelper == null)
			prtln("SchemaHelper is NULL");
		parent.add(element);
		return;
	}
	else {
		Sequence compositor = (Sequence) schemaHelper.getCompositor(parentPath);
		String compositorMemberName = resolveElementName(parentPath, element);
		int memberIndex = compositor.getIndexOfMember(compositorMemberName);

		/*
		 insert element immediately following other like-named elements, or just ahead
		 of the following member if no like-named elements exist.
		 when the childMemberIndex is greater than the (target) memberIndex, then it is
		 time to insert.
		*/
		List elements = parent.elements();
		for (int i = 0; i < elements.size(); i++) {
			Element child = (Element) elements.get(i);
			String childCompositorMemberName = resolveElementName(parentPath, child);
			int childMemberIndex = compositor.getIndexOfMember(childCompositorMemberName);

			if (childMemberIndex > memberIndex) {
				elements.add(i, element);
				return;
			}
		}
		parent.add(element);
	}
}
 
Example 9
Project: joai-project   File: DocMap.java   View Source Code Vote up 5 votes
/**
 *  Put sequence elements in the order specified by the sequence compositor.
 *
 * @param  parent  NOT YET DOCUMENTED
 */
public void orderSequenceElements(Element parent) {
	String xpath = parent.getPath();
	List order = schemaHelper.getChildrenOrder(xpath);

	// just as a safeguard, don't reorder if there is only one child
	// for the schemaNode, since parent is probably a repeating element
	// and reordering would wipe out all but one child
	if (order.size() < 2)
		return;

	// map element name to a list of elements to accomodate repeating elements
	Map elementMap = new HashMap();
	List elements = parent.elements();
	for (int i = elements.size() - 1; i > -1; i--) {
		Element e = (Element) elements.get(i);
		String tagName = e.getName();
		List items = (List) elementMap.get(tagName);
		if (items == null)
			items = new ArrayList();
		items.add(0, e.detach()); // add to beginning to maintain doc ordering
		elementMap.put(tagName, items);
	}

	for (Iterator i = order.iterator(); i.hasNext(); ) {
		String name = (String) i.next();
		elements = (List) elementMap.get(name);
		if (elements != null) {
			for (Iterator ii = elements.iterator(); ii.hasNext(); ) {
				parent.add((Element) ii.next());
			}
		}
	}
}
 
Example 10
Project: joai-project   File: MdeRepeatingComplexType.java   View Source Code Vote up 5 votes
/**
 *  Renders the contents of this node, which are in turn rendered inside an iteration element.
 *
 * @param  itemPath  the xpath for this element, with indexing to support iteration
 * @return           The repeatingContent value
 */
protected Element getRepeatingContent(String itemPath) {
	// prtln ("getRepeatingContent() with itemPath: " + itemPath);
	Element repeatingContent = getRepeatingContentBox (itemPath);
	
	Label label;
	if (indexRepeatingContentLabels) {
		label = renderer.getComplexTypeLabel(xpath, itemPath, indexId);
	}
	else {
		label = renderer.getComplexTypeLabel(xpath);
	}
		
	String elementName = XPathUtils.getNodeName(this.siblingPath);
	Element controller = renderer.getDeleteController(itemPath, elementName);		
	
	Element inputHelper = this.renderer.getInputHelperElement(this.xpath);
	
	repeatingContent.add(getRenderedNoInputField(label, controller, inputHelper));

	Element subElementsBox = repeatingContent.addElement("div");
	subElementsBox.addAttribute("id", "${id}");
	if (getLevel() > 0 && isEditMode()) {
		subElementsBox.addAttribute("style", "display:${"+formBeanName+".collapseBean.displayState};");
		/* this.attachElementDebugInfo(subElementsBox, "subElementsBox: id=${id}", "green"); */
	}
	
	newRenderer(itemPath, subElementsBox).renderSubElements();	
	
	return repeatingContent;
}
 
Example 11
Project: joai-project   File: RendererImpl.java   View Source Code Vote up 5 votes
/**
 *  Renders a multiSelect input (a set of of checkboxes) as an Element. The
 *  multiSelect is represented as a HTML table
 *
 * @param  xpath  NOT YET DOCUMENTED
 * @return        The multiSelectInput as an element
 */
public Element getMultiSelectInput(String xpath) {
	// prtln("getMultiSelectInput() with " + xpath);

	Element multiSelectTable = df.createElement("table");

	if (!this.sh.isSingleton(xpath)) {
		// multiSelectTable.addAttribute("info", "multiSelectTable: id=${id}");
		String style = "display__${" + formBeanName + ".collapseBean.displayState};";
		// style +=  "border__red thin dotted;";
		multiSelectTable.addAttribute("style", style);
	}

	multiSelectTable.addAttribute("width", "100%");

	Element row = multiSelectTable.addElement("tr")
		.addAttribute("valign", "top");

	Element multiSelectCell = row.addElement("td");

	/*
		a hidden field is necessary to compensate for the fact that we don't have a reset method in the
		form bean. the hidden field points to the subjectsPath without an index modifier on the leaf..
	  */
	Element hidden = multiSelectCell.addElement("input")
		.addAttribute("type", "hidden")
		.addAttribute("name", "enumerationValuesOf(" + XPathUtils.getSiblingXPath(xpath) + ")")
		.addAttribute("value", "");

	multiSelectCell.add(getMultiBoxInput(xpath));

	return multiSelectTable;
}
 
Example 12
Project: joai-project   File: MdeRepeatingSubstitutionGroup.java   View Source Code Vote up 4 votes
protected Element getSubstitutionGroupNewItemControl() {

		Element newItemAction = df.createElement("div")
				.addAttribute("class", "action-button");
		//make a drop-down menu with choices, and present as controller
		
		/*
			do not present control if there are no children 
			- this case is handled elsewhere (search for "required choice")
			-- but should it be handled here?
		*/
		Element notEmptyTest = newItemAction.addElement("logic__notEmpty")
			.addAttribute("name", formBeanName)
			.addAttribute("property", "membersOf(" + xpath + "/*)");
			
		notEmptyTest = newItemAction;

		// tests whether the instance document can accept a new child given
		// schema constraints
		Element canAcceptTest = notEmptyTest.addElement("logic__equal")
			.addAttribute("name", formBeanName)
			.addAttribute("property", "acceptsNewSubstitionGroupMember(" + xpath + ")")
			.addAttribute("value", "true");
			
		String elementId = "${id}_controller";
		String Name = XPathUtils.getNodeName(normalizedXPath);
		
		Element newItemPrompt = canAcceptTest.addElement("div");
		newItemPrompt.setText("add " + XPathUtils.getNodeName (xpath));
		rhelper.attachToolHelp(newItemPrompt, "Choose a field to add from the pulldown menu");
		
		// wrap prompt and select in div
		Element selectWrapper = canAcceptTest.addElement ("div");
		this.embedDebugInfo(selectWrapper, "MdeRepeatingSubstitutionGroup - selectWrapper");
		
		
		// tmpArg is initialized to "" so the "-- choice --" option is selected,
		// rather than one of the choices
		Element tmpArgInit = selectWrapper.addElement("jsp__setProperty")
				.addAttribute("name", formBeanName)
				.addAttribute("property", "tmpArg")
				.addAttribute("value", "");		
				
		// the select element for making a choice
		Element newItemSelect = selectWrapper.addElement("html__select")
				.addAttribute("name", formBeanName)
				.addAttribute("property", "tmpArg")
				.addAttribute("onchange", "doNewChoice (this.value)");

		// the permissible choices for this element
		Element newChoiceOptions = newItemSelect.addElement("html__optionsCollection")
				.addAttribute("property", "substitutionGroupOptions(" + xpath + ")");

		rhelper.attachToolHelp(newItemSelect, "Choose an element to create");
		
		// wrap the newItemAction in a table. the left cell is the controller, and the right is blank
		Element table = df.createElement("table")
			.addAttribute ("class", "input-field-table");
		
		Element row = table.addElement ("tr")
			.addAttribute ("class", "form-row");
			
		Element controllerCell = row.addElement ("td")
			.addAttribute ("class", "action-box")
			.addAttribute ("nowrap", "1");
			
		controllerCell.add (newItemAction);
		
		Element emptyCell = row.addElement ("td")
			.addAttribute ("width", "95%");
		emptyCell.setText (" ");
		
		return table;
		
	}
 
Example 13
Project: lams   File: ElementWrapper.java   View Source Code Vote up 4 votes
public void add(Element element) {
	element.add( element );
}
 
Example 14
Project: Divinity_Original_Sin_2_zhCN   File: DOS2Extract.java   View Source Code Vote up 4 votes
/**
 * 根据节点数据,生成增量文本xml
 * 
 * @param list 节点数据
 * @param buildNew 替换新文本
 * @param printAll 是否打印结果
 * @return
 * @throws Exception
 */
@Override
public Document extractIncrement(List<? extends NodeResult> list, boolean buildNew, boolean print)
    throws Exception {
  Element root = DocumentHelper.createElement("contentList");
  Iterator<?> it = list.iterator();
  boolean first100 = true, first80 = true, first50 = true, first25 = true, first15 = true,
      first5 = true, first = true;
  if (print) {
    if (buildNew) {
      System.out.println("----------------------------左边是增量文本,右边是原文本-----------------");
    } else {
      System.out.println("----------------------------左边是原文本,右边是增量文本-----------------");
    }
  }
  while (it.hasNext()) {
    NodeResult nodeResult = (NodeResult) it.next();
    Element e = DocumentHelper.createElement("content");
    e.addAttribute("contentuid", nodeResult.getContentuid());
    e.setText(buildNew ? nodeResult.getNewText() : nodeResult.getText());
    if (print) {
      if (nodeResult instanceof DiffResult) {
        DiffResult res = (DiffResult) nodeResult;

        if (first100 && res.getDifference() >= 1.0) {
          System.out.println("----------------------------差异超过100%的文本-----------------");
          first100 = false;
        }
        if (first80 && res.getDifference() < 1.0 && res.getDifference() > 0.8) {
          System.out.println("\n\n----------------------------差异超过80%的文本-----------------");
          first80 = false;
        }
        if (first50 && res.getDifference() <= 0.8 && res.getDifference() > 0.5) {
          System.out.println("\n\n----------------------------差异超过50%的文本-----------------");
          first50 = false;
        }
        if (first25 && res.getDifference() <= 0.5 && res.getDifference() > 0.25) {
          System.out.println("\n\n----------------------------差异超过25%的文本-----------------");
          first25 = false;
        }
        if (first15 && res.getDifference() <= 0.25 && res.getDifference() > 0.15) {
          System.out.println("\n\n----------------------------差异超过15%的文本-----------------");
          first15 = false;
        }
        if (first5 && res.getDifference() <= 0.15 && res.getDifference() > 0.05) {
          System.out.println("\n\n----------------------------差异超过5%的文本-----------------");
          first5 = false;
        }
        if (first && res.getDifference() < 0.05) {
          System.out.println("\n\n----------------------------差异低于5%的文本-----------------");
          first = false;
        }
      }
      System.out.println(nodeResult.getContentuid() + "="
          + (buildNew ? (nodeResult.getText() + "|" + nodeResult.getNewText())
              : (nodeResult.getNewText() + "|" + nodeResult.getText())));
    }
    root.add(e);
  }
  Document doc = DocumentHelper.createDocument(root);
  return doc;
}
 
Example 15
Project: joai-project   File: MdeRepeatingDerivedContentModel.java   View Source Code Vote up 4 votes
/**
 *  Identical to SimpleJspRenderer.renderRepeatingElement, but adds a controller
 *  for deleting items`
 */
public void render() {
	prtln("\nrender() with " + xpath);
	// prtln ("mode: " + getMode());

	Element repeatingItemsBox = df.createElement("div");
	this.embedDebugInfo (repeatingItemsBox, "MdeRepeatingDerivedContentModel - repeatingItemsBox");
	
	Element iteration = null;
	// attachElementDebugInfo(repeatingItemsBox, "repeating Derived Model Box (" + xpath + ")", "blue");
	
	if (isEditMode()) {
		
		// we don't want to show anything here if the parent doesn't exist!
		Element parentExists = rhelper.parentNodeExistsTest(xpath);
		parent.add (parentExists);
		
		parentExists.add (repeatingItemsBox);
		
		if (!sh.isRepeatingComplexSingleton(normalizedXPath)) {
			prtln ("\t calling emptyRepeatingElement()");
			repeatingItemsBox.add (emptyRepeatingElement());
		}
		
		Element hasMemberTest = rhelper.nodeHasMembersTest (xpath);
		repeatingItemsBox.add (hasMemberTest);
		iteration = getIteration(itemPath, siblingPath, indexId);
		insertRepeatingDisplaySetup(iteration);
		hasMemberTest.add (iteration);
		Element siblingController = newSiblingController();
		repeatingItemsBox.add (siblingController);
	}
	else {
		parent.add (repeatingItemsBox);
		iteration = getIteration(itemPath, siblingPath, indexId);
		repeatingItemsBox.add (iteration);
	}

	// attach repeatingContent as child of the iteration, so each item is displayed
	Element repeatingContent = getRepeatingContent();
	
	if (repeatingContent != null)
		iteration.add(repeatingContent);
	
}
 
Example 16
Project: joai-project   File: MdeRepeatingDerivedTextOnlyModel.java   View Source Code Vote up 4 votes
/**
 *  Identical to SimpleJspRenderer.renderRepeatingElement, but adds a
 *  controller for deleting items`
 */
public void render() {
	prtln("\nrender() with " + xpath);
	// prtln ("mode: " + getMode());

	Element repeatingItemsBox = df.createElement("div");
	this.embedDebugInfo(repeatingItemsBox, "MdeRepeatingDerivedTextOnlyModel - repeatingItemsBox");

	Element iteration = null;
	// attachElementDebugInfo(repeatingItemsBox, "repeating Derived Text Only Box (" + xpath + ")", "blue");

	if (isEditMode()) {

		// we don't want to show anything here if the parent doesn't exist!
		Element parentExists = rhelper.parentNodeExistsTest(xpath);
		parent.add(parentExists);

		parentExists.add(repeatingItemsBox);

		if (!sh.isRepeatingComplexSingleton(normalizedXPath)) {
			repeatingItemsBox.add(emptyRepeatingElement());
		}

		Element hasMemberTest = rhelper.nodeHasMembersTest(xpath);
		
		repeatingItemsBox.add(hasMemberTest);
		iteration = getIteration(itemPath, siblingPath, indexId);
		insertRepeatingDisplaySetup(iteration);
		hasMemberTest.add(iteration);
		Element siblingController = newSiblingController();
		repeatingItemsBox.add(siblingController);
	}
	else {
		parent.add(repeatingItemsBox);
		iteration = getIteration(itemPath, siblingPath, indexId);
		repeatingItemsBox.add(iteration);
	}

	// attach repeatingContent as child of the iteration, so each item is displayed
	Element repeatingContent = getRepeatingContent();

	if (repeatingContent != null)
		iteration.add(repeatingContent);

}
 
Example 17
Project: joai-project   File: MdeRepeatingDerivedContentModel.java   View Source Code Vote up 4 votes
/**
 *  Renders the contents of this node, which are in turn rendered inside an iteration element.
 *
 * @return           The repeatingContent value
 */
protected Element getRepeatingContent() {
	// prtln ("getRepeatingContent() with itemPath: " + itemPath);
	Element repeatingContent = getRepeatingContentBox (itemPath);
	
	Label label;
	if (indexRepeatingContentLabels) {
		label = renderer.getComplexTypeLabel(xpath, itemPath, indexId);
	}
	else {
		label = renderer.getComplexTypeLabel(xpath);
	}
		
	String elementName = XPathUtils.getNodeName(this.siblingPath);
	Element controller = renderer.getDeleteController(itemPath, elementName);
	repeatingContent.add(getRenderedNoInputField(label, controller));

	Element subElementsBox = repeatingContent.addElement("div");
	subElementsBox.addAttribute("id", "${id}");
	if (getLevel() > 0 && isEditMode()) {
		subElementsBox.addAttribute("style", "display:${"+formBeanName+".collapseBean.displayState};");
		// this.attachElementDebugInfo(subElementsBox, "subElementsBox: id=${id}", "green");
	}
	
	Element complexContent = complexTypeDef.getComplexContent();

	Element extension = complexTypeDef.getExtensionElement();
	Element restriction = complexTypeDef.getRestrictionElement();
	
	Renderer modelRender = newRenderer (itemPath, subElementsBox);
	
	// this.renderer.parent = subElementsBox;
	// parent = subElementsBox;
	
	if (extension != null) {
		GlobalDef extnType = complexTypeDef.getExtensionType();
		if (extnType == null) {
			prtln("ERROR: renderDerivedContentModel() could not find extension base type");
			return null;
		}
		modelRender.renderSubElements(extnType);
		modelRender.renderSubElements(extension.elements());
	}
	else if (restriction != null) {
		modelRender.renderSubElements(restriction.elements());			
	}
	
	return repeatingContent;
}
 
Example 18
Project: joai-project   File: MdeComplexType.java   View Source Code Vote up 4 votes
/**  Render editing field for this complex element */
	private void render_edit_mode() {
		prtln ("reder_edit_mode with: " + xpath);
		if (getLevel() != 0) {
			insertDisplaySetup(parent);
		}
		else {
			Element elementPath = df.createElement("c__set")
				.addAttribute("var", "elementPath")
				.addAttribute("value", xpath);
			parent.add(elementPath);

			Element setId = df.createElement("c__set")
				.addAttribute("var", "id")
				.addAttribute("value", "${sf__pathToId(elementPath)}");
			parent.add(setId);
		}
		
		Label label = renderer.getComplexTypeLabel(xpath);
		Element controlElement = null;

		Element containerBox = getComplexTypeBox();
		containerBox.addAttribute("id", "${id}_box");
		parent.add(containerBox);
		
		// test for the existence of a parent, unless we are at the 0th level of the page
		Element parentExists = null;
		if (getLevel() == 0) {
			parentExists = df.createElement("div");
			attachElementId (parentExists);
		}
		else {
			parentExists = rhelper.parentNodeExistsTest(xpath);
		}
		containerBox.add(parentExists);


		controlElement = df.createElement("div");
		attachControl(controlElement);

/* 		prtln ("---------- Control Element --------------");
		prtln (Dom4jUtils.prettyPrint(controlElement)); */
		
		parent = parentExists;
		
		Element inputHelper = this.renderer.getInputHelperElement(this.xpath);
		parent.add(getRenderedNoInputField(label, controlElement, inputHelper));
		
		// make collapsible subElementBox
		Element subElementsBox = parent.addElement("div");
		// this.attachElementDebugInfo(subElementsBox, "MdeComplexType - subElementsBox - ${id}");

		// add id to subElement Box so it can be collapsed
		subElementsBox.addAttribute("id", "${id}");
		if (getLevel() > 0 && isEditMode()) {
			subElementsBox.addAttribute("style", "display:${" + formBeanName + ".collapseBean.displayState};");
		}
		
		// new attach point becomes subElementsBox
		parent = subElementsBox;
		
		renderSubElements();

	}
 
Example 19
Project: joai-project   File: MdeRepeatingSimpleType.java   View Source Code Vote up 4 votes
/**
 *  Identical to SimpleJspRenderer.renderRepeatingElement, but adds a
 *  controller for deleting items`
 */
public void render() {
	prtln("render()");
	// prtln("\n renderRepeatingElement() with " + xpath);

	// we don't want to show anything here if the parent doesn't exist!


	Element repeatingItemsBox = df.createElement("div");
	embedDebugInfo(repeatingItemsBox, "MdeRepeatingSimpleType - repeatingItemsBox");
	// attachElementDebugInfo(repeatingItemsBox, "repeating Simple Items Box", "purple");


	// element to loop through the items
	String siblingPath = XPathUtils.getSiblingXPath(xpath);
	String indexId = RendererHelper.encodeIndexId(siblingPath);
	String itemPath = siblingPath + "_${" + indexId + "+1}_";
	Element iteration = getIteration(itemPath, siblingPath, indexId);
	// attach repeatingContent as child of the iteration, so each item is displayed
	iteration.add(getRepeatingContent(itemPath));

	if (isEditMode()) {
		Element parentExists = rhelper.parentNodeExistsTest(xpath);
		parent.add(parentExists);
		parentExists.add(repeatingItemsBox);

		if (!sh.isRepeatingComplexSingleton(normalizedXPath)) {
			prtln("\t calling emptyRepeatingElement()");
			repeatingItemsBox.add(emptyRepeatingElement());
		}

		Element hasMemberTest = rhelper.nodeHasMembersTest(xpath);
		repeatingItemsBox.add(hasMemberTest);
		hasMemberTest.add(iteration);
		repeatingItemsBox.add(newSiblingController());
	}
	else {
		Element viewNodeTest = rhelper.viewNodeTest(xpath);
		parent.add(viewNodeTest);
		viewNodeTest.add(repeatingItemsBox);
		repeatingItemsBox.add(iteration);
	}
}
 
Example 20
Project: bdf2   File: ViewConfigMetaDataBuilder.java   View Source Code Vote up 4 votes
public Element build(PageInfo page, RuleSet ruleSet) throws Exception {
	Element metaDataPropertyElement=this.createPropertyElement("metaData", null);
	metaDataPropertyElement.add(this.createPropertyElement("securityTag", page.getName()));
	return metaDataPropertyElement;
}