Author: mareshkau
Date: 2008-11-29 10:33:18 -0500 (Sat, 29 Nov 2008)
New Revision: 12146
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfForm.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesGMapTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/test.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java
trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
Log:
JBIDE-3011
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractEditableJsfTemplate.java 2008-11-29
15:33:18 UTC (rev 12146)
@@ -14,16 +14,12 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.IEditableTemplate;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
-import org.jboss.tools.vpe.editor.template.VpeCreationData;
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;
/**
* general class for jsf templates.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfForm.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfForm.java 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfForm.java 2008-11-29
15:33:18 UTC (rev 12146)
@@ -10,123 +10,54 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.template;
-import java.util.ArrayList;
-import java.util.List;
-
+import org.jboss.tools.jsf.vpe.jsf.template.util.JSF;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
-import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.util.HTML;
-import org.jboss.tools.vpe.editor.util.VpeStyleUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
- * @author dmaliarevich
+ * @author mareshkau
*
*/
public class JsfForm extends VpeAbstractTemplate {
- private static String CONTENT_DIV_STYLE = "width: 100%; display: table; ";
//$NON-NLS-1$
-
- private static final String DIR_VALUE_RTL = "RTL"; //$NON-NLS-1$
- private static final String DIR_VALUE_LTR = "LTR"; //$NON-NLS-1$
-
- private static final String SPACE = " "; //$NON-NLS-1$
- private static final String STYLE_CLASS = "styleClass"; //$NON-NLS-1$
-
- private String dir;
- private String style;
- private String styleClass;
-
- /**
- * Instantiates a new jsf form.
- */
- public JsfForm() {
- }
-
/* (non-Javadoc)
* @see
org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument)
*/
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- Element sourceElement = (Element)sourceNode;
- readAttributes(sourceElement);
-
- nsIDOMElement content_div = visualDocument.createElement(HTML.TAG_DIV);
- content_div.setAttribute(HTML.ATTR_STYLE, CONTENT_DIV_STYLE + SPACE + style);
-
- if (attrPresents(styleClass)) {
- content_div.setAttribute(HTML.ATTR_CLASS, styleClass);
- }
- if (attrPresents(dir)
- && (dir.equalsIgnoreCase(DIR_VALUE_RTL)
- || dir.equalsIgnoreCase(DIR_VALUE_LTR))) {
- content_div.setAttribute(HTML.ATTR_DIR, dir);
- }
-
-
- VpeCreationData creationData = new VpeCreationData(content_div);
- VpeChildrenInfo divInfo = new VpeChildrenInfo(content_div);
- creationData.addChildrenInfo(divInfo);
-
- for (Node child : getChildren(sourceElement)) {
- divInfo.addSourceChild(child);
- }
-
+ nsIDOMElement content_form= null;
+ if(!isExistingInParent(sourceNode)) {
+ content_form = visualDocument.createElement(HTML.TAG_FORM);
+ // copy jsf attributes to html, util function hasn't been founded, mareshkat
+ Element form = (Element) sourceNode;
+ if(form.hasAttribute(JSF.ATTR_STYLE)) {
+ content_form.setAttribute(HTML.ATTR_STYLE, form.getAttribute(JSF.ATTR_STYLE));
+ }
+ if(form.hasAttribute(JSF.ATTR_STYLE_CLASS)) {
+ content_form.setAttribute(HTML.ATTR_CLASS, form.getAttribute(JSF.ATTR_STYLE_CLASS));
+ }
+ } else {
+ content_form = visualDocument.createElement(HTML.TAG_SPAN);
+ }
+ VpeCreationData creationData = new VpeCreationData(content_form);
return creationData;
}
-
- /**
- * Gets the children.
- *
- * @param sourceElement the source element
- *
- * @return the children
- */
- public static List<Node> getChildren(Element sourceElement) {
- ArrayList<Node> children = new ArrayList<Node>();
- NodeList nodeList = sourceElement.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node child = nodeList.item(i);
- children.add(child);
+ //mareshkau, fir for JBIDE-3011
+ private static boolean isExistingInParent(Node sourceNode) {
+ String nodeName=sourceNode.getNodeName();
+ Node parentNode = sourceNode.getParentNode();
+ while((parentNode!=null)&&(parentNode instanceof Node)){
+ if(nodeName.equals(parentNode.getNodeName())) {
+ return true;
+ }
+ parentNode = parentNode.getParentNode();
}
- return children;
+ return false;
}
-
- /* (non-Javadoc)
- * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMElement, java.lang.Object, java.lang.String,
java.lang.String)
- */
- public boolean isRecreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
- return true;
- }
-
- /**
- * Read attributes from the source element.
- *
- * @param sourceNode
- * the source node
- */
- private void readAttributes(Element sourceElement) {
- style = sourceElement.getAttribute(HTML.ATTR_STYLE);
- styleClass = sourceElement.getAttribute(STYLE_CLASS);
- dir = sourceElement.getAttribute(HTML.ATTR_DIR);
- }
-
- /**
- * Checks is attribute presents.
- *
- * @param attr the attribute
- *
- * @return true, if successful
- */
- private boolean attrPresents(String attr) {
- return ((null != attr) && (!"".equals(attr))); //$NON-NLS-1$
- }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2008-11-29
15:33:18 UTC (rev 12146)
@@ -10,12 +10,6 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.template.util;
-import java.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.jboss.tools.jsf.vpe.jsf.JsfTemplatePlugin;
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.util.HTML;
@@ -123,8 +117,7 @@
*/
public static String getBundleValue(VpePageContext pageContext, Attr attr) {
- return getBundleValue(pageContext, attr.getNodeValue(),
- ((IDOMAttr) attr).getValueRegionStartOffset());
+ return getBundleValue(pageContext, attr.getNodeValue());
}
@@ -136,7 +129,7 @@
* @return
*/
public static String getBundleValue(VpePageContext pageContext,
- String value, int offfset) {
+ String value) {
BundleMap bundle = pageContext.getBundle();
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-11-29
15:33:18 UTC (rev 12146)
@@ -753,25 +753,7 @@
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />
</vpe:dnd>
- <vpe:textFormatting>
- <vpe:format type="BoldFormat">
- <vpe:formatAttribute type="style" />
- </vpe:format>
- <vpe:format type="ItalicFormat">
- <vpe:formatAttribute type="style" />
- </vpe:format>
- <vpe:format type="FontNameFormat">
- <vpe:formatAttribute type="style" />
- </vpe:format>
- <vpe:format type="FontSizeFormat">
- <vpe:formatAttribute type="style" />
- </vpe:format>
- <vpe:format type="BackgroundColorFormat">
- <vpe:formatAttribute type="style" />
- </vpe:format>
- <vpe:format type="ForegroundColorFormat">
- <vpe:formatAttribute type="style" />
- </vpe:format>
+ <vpe:textFormatting use-default-formats="yes">
</vpe:textFormatting>
</vpe:template>
</vpe:tag>
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesGMapTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesGMapTemplate.java 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesGMapTemplate.java 2008-11-29
15:33:18 UTC (rev 12146)
@@ -125,13 +125,4 @@
VpeCreationData creationData = new VpeCreationData(mapImg);
return creationData;
}
-
- public boolean isRecreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
- return true;
- }
-
-
-
}
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/test.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/test.xhtml.xml 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/test.xhtml.xml 2008-11-29
15:33:18 UTC (rev 12146)
@@ -1,7 +1,7 @@
<tests>
<test id="test_el">
-<DIV
- STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%; display:
table;">
+<FORM
+ STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px;">
<SPAN CLASS="message" STYLE="-moz-user-modify: read-only;">
Error Messages
</SPAN>
@@ -24,6 +24,6 @@
</SPAN>
</DIV>
</DIV>
-</DIV>
+</FORM>
</test>
</tests>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/components/form.jsp.xml 2008-11-29
15:33:18 UTC (rev 12146)
@@ -1,14 +1,6 @@
<tests>
<test id="form">
- <TABLE
- STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px; width: 100%;">
- <TR>
- <TD>
- <DIV>
- </DIV>
- <BR />
- </TD>
- </TR>
- </TABLE>
+ <FORM STYLE="border: 1px dotted rgb(255, 102, 0); padding: 5px;">
+ </FORM>
</test>
</tests>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfComponentContentTest.java 2008-11-29
15:33:18 UTC (rev 12146)
@@ -215,6 +215,7 @@
performContentTest("components/view.jsp"); //$NON-NLS-1$
}
+ @Override
protected String getTestProjectName() {
return JsfAllTests.IMPORT_PROJECT_NAME;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-11-29
13:00:23 UTC (rev 12145)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-11-29
15:33:18 UTC (rev 12146)
@@ -59,6 +59,7 @@
public static final String TAG_LABEL = "LABEL"; //$NON-NLS-1$
public static final String TAG_A = "A"; //$NON-NLS-1$
public static final String TAG_H1 = "H1"; //$NON-NLS-1$
+ public static final String TAG_FORM = "FORM"; //$NON-NLS-1$
public static final String ATTR_ID = "ID"; //$NON-NLS-1$
public static final String ATTR_TYPE = "TYPE"; //$NON-NLS-1$
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2008-11-29
13:00:23 UTC (rev 12145)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2008-11-29
15:33:18 UTC (rev 12146)
@@ -799,7 +799,7 @@
<vpe:tag name="form" case-sensitive="no">
<vpe:template children="yes" modify="yes">
<vpe:copy attrs="id,style,class,align,dir" />
- <div />
+ <form />
<vpe:dnd>
<vpe:drag start-enable="yes" />
<vpe:drop container="yes" />