Author: mareshkau
Date: 2008-07-31 05:04:49 -0400 (Thu, 31 Jul 2008)
New Revision: 9444
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlCommentTemplate.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.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/VpePreviewDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
Log:
JBIDE-2584
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2008-07-31
08:50:51 UTC (rev 9443)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2008-07-31
09:04:49 UTC (rev 9444)
@@ -12,21 +12,16 @@
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeTemplate;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.util.ElService;
-import org.jboss.tools.vpe.editor.util.HTML;
-import org.jboss.tools.vpe.editor.util.TextUtil;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.xpcom.XPCOMException;
@@ -41,7 +36,7 @@
boolean rebuildFlag = false;
- private static final String YES_STRING = "yes";
+// private static final String YES_STRING = "yes";
/**
*
@@ -63,9 +58,9 @@
*/
@Override
protected nsIDOMNode createNode(Node sourceNode, nsIDOMNode visualOldContainer) {
- boolean registerFlag = isCurrentMainDocument();
- switch (sourceNode.getNodeType()) {
- case Node.ELEMENT_NODE:
+// boolean registerFlag = isCurrentMainDocument();
+// switch (sourceNode.getNodeType()) {
+// case Node.ELEMENT_NODE:
// Map xmlnsMap = createXmlns((Element)sourceNode);
Set ifDependencySet = new HashSet();
@@ -74,14 +69,20 @@
* to fix h:dataTable content visibility on Preview tab.
*
http://jira.jboss.com/jira/browse/JBIDE-2059
*/
+ if(sourceNode==null||(
+ sourceNode.getNodeType()!=Node.TEXT_NODE
+ &&sourceNode.getNodeType()!=Node.ELEMENT_NODE
+ &&sourceNode.getNodeType()!=Node.COMMENT_NODE)) {
+ return null;
+ }
getPageContext().setCurrentVisualNode(visualOldContainer);
- VpeTemplate template = templateManager.getTemplate(getPageContext(),
(Element)sourceNode, ifDependencySet);
+ VpeTemplate template = templateManager.getTemplate(getPageContext(), sourceNode,
ifDependencySet);
VpeCreationData creationData;
//FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if (ElService.getInstance().isCloneableNode(getPageContext(), (Element)
sourceNode)) {
- final Element sourceNodeClone = (Element) ((Element)
sourceNode).cloneNode(true);
+ if (ElService.getInstance().isCloneableNode(getPageContext(), sourceNode))
{
+ final Node sourceNodeClone = sourceNode.cloneNode(true);
template.beforeTemplateCreated(getPageContext(), sourceNodeClone,
getVisualDocument());
creationData = template.create(getPageContext(), sourceNodeClone,
getVisualDocument());
} else {
@@ -93,19 +94,21 @@
creationData = defTemplate.create(getPageContext(), sourceNode,
getVisualDocument());
}
getPageContext().setCurrentVisualNode(null);
- nsIDOMElement visualNewElement;
- visualNewElement = (nsIDOMElement)creationData.getNode();
+ nsIDOMNode visualNewNode;
+ visualNewNode = creationData.getNode();
- setTooltip((Element)sourceNode, visualNewElement);
-
- if (!isCurrentMainDocument() && visualNewElement != null) {
- setReadOnlyElement(visualNewElement);
+ if(sourceNode instanceof Element && visualNewNode != null) {
+
+ setTooltip((Element)sourceNode,
(nsIDOMElement)visualNewNode.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID));
}
+// if (!isCurrentMainDocument() && visualNewElement != null) {
+// setReadOnlyElement(visualNewElement);
+// }
if (template.isChildren()) {
List<?> childrenInfoList = creationData.getChildrenInfoList();
if (childrenInfoList == null) {
- addChildren(template, sourceNode, visualNewElement != null ? visualNewElement :
visualOldContainer);
+ addChildren(template, sourceNode, visualNewNode != null ? visualNewNode :
visualOldContainer);
} else {
addChildren(template, sourceNode, visualOldContainer, childrenInfoList);
}
@@ -117,23 +120,23 @@
*
http://jira.jboss.com/jira/browse/JBIDE-2059
*/
getPageContext().setCurrentVisualNode(visualOldContainer);
- template.validate(getPageContext(), (Element)sourceNode, getVisualDocument(),
creationData);
+ template.validate(getPageContext(), sourceNode, getVisualDocument(), creationData);
getPageContext().setCurrentVisualNode(null);
- return visualNewElement;
- case Node.TEXT_NODE:
- return createTextNode(sourceNode, registerFlag);
- case Node.COMMENT_NODE:
- if(!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
- return null;
- }
- nsIDOMElement visualNewComment = createComment(sourceNode);
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
- }
- return visualNewComment;
- }
- return null;
+ return visualNewNode;
+// case Node.TEXT_NODE:
+// return createTextNode(sourceNode, registerFlag);
+// case Node.COMMENT_NODE:
+// if(!YES_STRING.equals(VpePreference.SHOW_COMMENTS.getValue())) {
+// return null;
+// }
+// nsIDOMElement visualNewComment = createComment(sourceNode);
+// if (registerFlag) {
+// registerNodes(new VpeNodeMapping(sourceNode, visualNewComment));
+// }
+// return visualNewComment;
+// }
+// return null;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-07-31
08:50:51 UTC (rev 9443)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-07-31
09:04:49 UTC (rev 9444)
@@ -418,8 +418,7 @@
&&sourceNode.getNodeType()!=Node.COMMENT_NODE)) {
return null;
}
-
-
+
// switch (sourceNode.getNodeType()) {
// case Node.ELEMENT_NODE:
@@ -2274,55 +2273,55 @@
* @return a visual element for text node
*/
- protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
- String sourceText = sourceNode.getNodeValue();
- if(sourceText!=null){
- final IFile file =
getPageContext().getVisualBuilder().getCurrentIncludeInfo().getFile();
-
- sourceText = ElService.getInstance().replaceEl(file, sourceText);
- }
- /*
- * Max Areshkau this code causes very slow work of visual editor
- * when we editing in big files txt nodes.For example exmployee.xhtml
- * from JBIDE1105
- *
- * Denis Maliarevich:
- * To fix JBIDE-2003 and JBIDE-2042
- * this code should be uncommented.
- */
- if (sourceText.trim().length() <= 0) {
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, null));
- }
- return null;
- }
+// protected nsIDOMNode createTextNode(Node sourceNode, boolean registerFlag) {
+// String sourceText = sourceNode.getNodeValue();
+// if(sourceText!=null){
+// final IFile file =
getPageContext().getVisualBuilder().getCurrentIncludeInfo().getFile();
+//
+// sourceText = ElService.getInstance().replaceEl(file, sourceText);
+// }
+// /*
+// * Max Areshkau this code causes very slow work of visual editor
+// * when we editing in big files txt nodes.For example exmployee.xhtml
+// * from JBIDE1105
+// *
+// * Denis Maliarevich:
+// * To fix JBIDE-2003 and JBIDE-2042
+// * this code should be uncommented.
+// */
+// if (sourceText.trim().length() <= 0) {
+// if (registerFlag) {
+// registerNodes(new VpeNodeMapping(sourceNode, null));
+// }
+// return null;
+// }
+//
+// if (faceletFile) {
+// Matcher matcher_EL = REGEX_EL.matcher(sourceText);
+// if (matcher_EL.find()) {
+// BundleMap bundle = pageContext.getBundle();
+// int offset = pageContext.getVisualBuilder()
+// .getCurrentMainIncludeOffset();
+// if (offset == -1)
+// offset = ((IndexedRegion) sourceNode).getStartOffset();
+// String jsfValue = bundle.getBundleValue(sourceText, offset);
+// sourceText = jsfValue;
+// }
+// }
+// String visualText = TextUtil.visualText(sourceText);
+//
+// nsIDOMNode visualNewTextNode = visualDocument
+// .createTextNode(visualText);
+// nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
+// element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
+// element.appendChild(visualNewTextNode);
+// if (registerFlag) {
+// registerNodes(new VpeNodeMapping(sourceNode, element));
+// }
+//
+// return element;
+// }
- if (faceletFile) {
- Matcher matcher_EL = REGEX_EL.matcher(sourceText);
- if (matcher_EL.find()) {
- BundleMap bundle = pageContext.getBundle();
- int offset = pageContext.getVisualBuilder()
- .getCurrentMainIncludeOffset();
- if (offset == -1)
- offset = ((IndexedRegion) sourceNode).getStartOffset();
- String jsfValue = bundle.getBundleValue(sourceText, offset);
- sourceText = jsfValue;
- }
- }
- String visualText = TextUtil.visualText(sourceText);
-
- nsIDOMNode visualNewTextNode = visualDocument
- .createTextNode(visualText);
- nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
- element.setAttribute(HTML.ATTR_STYLE, ""); //$NON-NLS-1$
- element.appendChild(visualNewTextNode);
- if (registerFlag) {
- registerNodes(new VpeNodeMapping(sourceNode, element));
- }
-
- return element;
- }
-
/**
* @return the xulRunnerEditor
*/
Added:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlCommentTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlCommentTemplate.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlCommentTemplate.java 2008-07-31
09:04:49 UTC (rev 9444)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (c) 2007-2008 Red Hat, Inc.
+* Distributed under license by Red Hat, Inc. All rights reserved.
+* This program is made available under the terms of the
+* Eclipse Public License v1.0 which accompanies this distribution,
+* and is available at
http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributor:
+* Red Hat, Inc. - initial API and implementation
+******************************************************************************/
+package org.jboss.tools.vpe.html.template;
+
+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.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+/**
+ * @author mareshkau
+ * Template for comment node
+ */
+public class HtmlCommentTemplate extends VpeAbstractTemplate {
+
+ /* (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) {
+
+ nsIDOMNode commentNode = visualDocument.createComment(sourceNode.getNodeValue());
+
+ return new VpeCreationData(commentNode);
+ }
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2008-07-31
08:50:51 UTC (rev 9443)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2008-07-31
09:04:49 UTC (rev 9444)
@@ -1,13 +1,13 @@
-/*******************************************************************************
-* Copyright (c) 2007 Red Hat, Inc.
-* Distributed under license by Red Hat, Inc. All rights reserved.
-* This program is made available under the terms of the
-* Eclipse Public License v1.0 which accompanies this distribution,
-* and is available at
http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* Red Hat, Inc. - initial API and implementation
-******************************************************************************/
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.vpe.html.template;
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-07-31
08:50:51 UTC (rev 9443)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/templates/vpe-templates-html.xml 2008-07-31
09:04:49 UTC (rev 9444)
@@ -2132,8 +2132,8 @@
</vpe:tag>
<vpe:tag name="#comment" case-sensitive="no">
- <vpe:template children="no" modify="yes">
- <vpe:comment />
+ <vpe:template children="no" modify="yes"
+ class="org.jboss.tools.vpe.html.template.HtmlCommentTemplate">
</vpe:template>
</vpe:tag>