Author: mareshkau
Date: 2007-11-03 10:46:38 -0400 (Sat, 03 Nov 2007)
New Revision: 4682
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeInsertTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1213, s:decorate was adjusted, also was adjusted
some facelets(ui:compozition,ui:inser)
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java 2007-11-03
14:46:32 UTC (rev 4681)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java 2007-11-03
14:46:38 UTC (rev 4682)
@@ -16,11 +16,23 @@
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class VpeCompositionTemplate extends VpeDefineContainerTemplate {
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument){
+
+ Attr attr =
((Element)sourceNode).getAttributeNode(VpeDefineContainerTemplate.ATTR_TEMPLATE);
+ if (attr != null) {
+ return super.create(pageContext, sourceNode, visualDocument);
+ } else {
+ nsIDOMElement composition = visualDocument.createElement(HTML.TAG_DIV);
+ return new VpeCreationData(composition);
+ }
+ }
+
protected VpeCreationData createStub(String fileName, Node sourceElement, nsIDOMDocument
visualDocument) {
nsIDOMElement container = visualDocument.createElement(HTML.TAG_DIV);
container.setAttribute("style", "border: 1px dashed #2A7F00");
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java 2007-11-03
14:46:32 UTC (rev 4681)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java 2007-11-03
14:46:38 UTC (rev 4682)
@@ -34,7 +34,7 @@
import org.mozilla.interfaces.nsIDOMNode;
public abstract class VpeDefineContainerTemplate extends VpeAbstractTemplate {
- private static final String ATTR_TEMPLATE = "template";
+ protected static final String ATTR_TEMPLATE = "template";
private static Set<Node> defineContainer = new HashSet<Node>();
@Override
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java 2007-11-03
14:46:32 UTC (rev 4681)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java 2007-11-03
14:46:38 UTC (rev 4682)
@@ -10,13 +10,10 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.facelets.template;
-import java.util.Map;
-
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
-import org.jboss.tools.vpe.editor.template.VpeTemplate;
-import org.jboss.tools.vpe.editor.util.HTML;
+ import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeInsertTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeInsertTemplate.java 2007-11-03
14:46:32 UTC (rev 4681)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeInsertTemplate.java 2007-11-03
14:46:38 UTC (rev 4682)
@@ -19,10 +19,10 @@
import org.jboss.tools.vpe.editor.util.HTML;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
public class VpeInsertTemplate extends VpeAbstractTemplate {
@@ -48,21 +48,27 @@
creationData.setData(pageContext.getVisualBuilder().popIncludeStack());
return creationData;
}
+ } else {
+ Node undefineElement = findUndefinedElement(includeInfo.getElement());
+ if (undefineElement != null) {
+ VpeCreationData creationData = createInsert(undefineElement, visualDocument);
+ creationData.setData(pageContext.getVisualBuilder().popIncludeStack());
+ return creationData;
+ }
}
}
VpeCreationData creationData = createStub((Element)sourceNode, visualDocument);
creationData.setData(null);
return creationData;
}
-
public void validate(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, VpeCreationData creationData) {
VpeIncludeInfo includeInfo = (VpeIncludeInfo)creationData.getData();
if (includeInfo != null) {
pageContext.getVisualBuilder().pushIncludeStack((VpeIncludeInfo)includeInfo);
}
}
-
- public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
Document visualDocument, Node visualNode, Object data, String name, String value) {
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement visualNode, Object data, String name, String
value) {
return true;
}
@@ -81,7 +87,28 @@
return defineElement;
}
- private VpeCreationData createInsert(Element defineElement, nsIDOMDocument
visualDocument) {
+ private Node findUndefinedElement(Element defineContainer) {
+ Node defineElement = null;
+ NodeList children = defineContainer.getChildNodes();
+ int len = children.getLength();
+ for (int i = 0; i < len; i++) {
+ Node child = children.item(i);
+ if ((child.getNodeType() == Node.ELEMENT_NODE||child.getNodeType() == Node.TEXT_NODE))
{
+
+ if(child.getNodeType() ==
Node.ELEMENT_NODE&&!"define".equals(child.getLocalName())&&((Element)child).getAttribute("name")==null)
{
+ defineElement = child;
+ break;
+ } else if(child.getNodeType() ==
Node.TEXT_NODE&&((Text)child).getNodeValue()!=null&&
+ ((Text)child).getNodeValue().trim().length()>0) {
+ defineElement = child;
+ break;
+ }
+ }
+ }
+ return defineElement;
+ }
+
+ private VpeCreationData createInsert(Node defineElement, nsIDOMDocument visualDocument)
{
VpeCreationData creationData = new VpeCreationData(null);
VpeChildrenInfo childrenInfo = new VpeChildrenInfo(null);
childrenInfo.addSourceChild(defineElement);