Author: mareshkau
Date: 2008-11-13 11:00:54 -0500 (Thu, 13 Nov 2008)
New Revision: 11763
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeProxyUtil.java
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/VpeDefineTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.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.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/home.xhtml
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java
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/bundle/BundleMap.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
Log:
JBIDE-3144
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 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineContainerTemplate.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -58,11 +58,9 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- String fileName = null;
- Attr attr = ((Element)sourceNode).getAttributeNode(ATTR_TEMPLATE);
- if (attr != null && attr.getNodeValue().trim().length() > 0) {
- fileName = attr.getNodeValue().trim();
- IFile file = VpeCreatorUtil.getFile(fileName, pageContext);
+ String fileName = ((Element)sourceNode).getAttribute(ATTR_TEMPLATE);
+ if (fileName != null && fileName.trim().length() > 0) {
+ IFile file = VpeCreatorUtil.getFile(fileName, pageContext);
if (file != null) {
if (!pageContext.getVisualBuilder().isFileInIncludeStack(file)) {
registerDefine(pageContext, sourceNode);
@@ -80,7 +78,11 @@
pageContext.getVisualBuilder().pushIncludeStack(
new VpeIncludeInfo((Element) sourceNode, file,
document));
- defineContainer.add(sourceNode);
+ //we should add only real nodem, sourceNode can be a proxy
+ //so
+ if(sourceNode.getFirstChild()!=null) {
+ defineContainer.add(sourceNode.getFirstChild().getParentNode());
+ }
return creationData;
}
}
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 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -13,11 +13,10 @@
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.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;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -142,10 +142,10 @@
// get parent element
Node parent = sourceNode.getParentNode();
- if ((parent == null) && (sourceNode instanceof Element)
- && (((Element)
sourceNode).getAttribute(VpeVisualDomBuilder.PARENT) != null)) {
- parent = (Node) ((Element)
sourceNode).getAttributeNode(VpeVisualDomBuilder.PARENT).getUserData(VpeVisualDomBuilder.PARENT);
- }
+// if ((parent == null) && (sourceNode instanceof Element)
+// && (((Element)
sourceNode).getAttribute(VpeVisualDomBuilder.PARENT) != null)) {
+// parent = (Node) ((Element)
sourceNode).getAttributeNode(VpeVisualDomBuilder.PARENT).getUserData(VpeVisualDomBuilder.PARENT);
+// }
if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) {
ElementImpl element = (ElementImpl) parent;
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-13
15:16:39 UTC (rev 11762)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -109,7 +109,7 @@
BundleMap bundle = pageContext.getBundle();
- return bundle.getBundleValue(value, offfset);
+ return bundle.getBundleValue(value);
}
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -158,10 +158,10 @@
Element groupSourceElement = (Element) sourceNode;
Element srcNode = null;
- if ((groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE) != null)
- && (groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE)
instanceof Element)) {
- srcNode = (Element)
groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE);
- }
+// if ((groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE) != null)
+// &&
(groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE) instanceof Element)) {
+// srcNode = (Element)
groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE);
+// }
nsIDOMElement creationDataDiv = visualDocument
.createElement(HtmlComponentUtil.HTML_TAG_DIV);
VpeCreationData creationData = new VpeCreationData(creationDataDiv);
@@ -204,11 +204,11 @@
List<Node> children = null;
- if (srcNode != null) {
- children = ComponentUtil.getChildren((Element)
groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE));
- } else {
+// if (srcNode != null) {
+// children = ComponentUtil.getChildren((Element)
groupSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE));
+// } else {
children = ComponentUtil.getChildren(groupSourceElement);
- }
+// }
if (expanded) {
for (Node child : children) {
boolean isGroup = child.getNodeName().endsWith(
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -130,10 +130,10 @@
Element itemSourceElement = (Element) sourceNode;
Element srcElement = null;
//added by estherbin fixed
https://jira.jboss.org/jira/browse/JBIDE-1605
- if ((itemSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE) != null)
- && (itemSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE)
instanceof Element)) {
- srcElement = (Element)
itemSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE);
- }
+// if ((itemSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE) != null)
+// && (itemSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE)
instanceof Element)) {
+// srcElement = (Element)
itemSourceElement.getUserData(VpeVisualDomBuilder.SRC_NODE);
+// }
ComponentUtil.setCSSLink(pageContext, STYLE_PATH, COMPONENT_NAME);
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/home.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/home.xhtml 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/3144/home.xhtml 2008-11-13
16:00:54 UTC (rev 11763)
@@ -30,5 +30,4 @@
<li><h:outputText value="Test Test" /></li>
</ul>
</rich:panel>
-</ui:define>
-</ui:composition>
+</ui:define></ui:composition>
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-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -55,7 +55,7 @@
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
import org.jboss.tools.vpe.editor.mozilla.MozillaEditor;
-import org.jboss.tools.vpe.editor.template.IEditableTemplate;
+import org.jboss.tools.vpe.editor.proxy.VpeProxyUtil;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
@@ -413,7 +413,8 @@
boolean registerFlag = isCurrentMainDocument();
- // reads and dispatch events
+ // reads and dispatch events, this code prevent eclipse
+ //from sleeping during processing big pages
getPageContext().processDisplayEvents();
// JBIDE-675, checks if editor was disposed or not
if (getPageContext().getSourceBuilder() == null
@@ -421,8 +422,6 @@
throw new VpeDisposeException();
}
- //getPageContext().processDisplayEvents();
-
// check source node can be changed and link can be a null in this case
// we shouldn't process this node
if (sourceNode == null
@@ -444,18 +443,20 @@
if (ElService.getInstance().isCloneableNode(getPageContext(),
sourceNode)) {
- sourceNodeClone = (sourceNode).cloneNode(true);
- if(sourceNodeClone instanceof Element){
- ((Element)sourceNodeClone).setAttribute(PARENT,""); //$NON-NLS-1$
- Attr a = ((Element)sourceNodeClone).getAttributeNode(PARENT);
- a.setUserData(PARENT, sourceNode.getParentNode(),null);
-
- //added by estherbin fix
https://jira.jboss.org/jira/browse/JBIDE-1605 issue.
- sourceNodeClone.setUserData(SRC_NODE, sourceNode,null);
-
- }
- template.beforeTemplateCreated(getPageContext(),
- sourceNodeClone, getVisualDocument());
+
+ sourceNodeClone = VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
+ sourceNode);
+// if(sourceNodeClone instanceof Element){
+// ((Element)sourceNodeClone).setAttribute(PARENT,""); //$NON-NLS-1$
+// Attr a = ((Element)sourceNodeClone).getAttributeNode(PARENT);
+// a.setUserData(PARENT, sourceNode.getParentNode(),null);
+//
+// //added by estherbin fix
https://jira.jboss.org/jira/browse/JBIDE-1605 issue.
+// sourceNodeClone.setUserData(SRC_NODE, sourceNode,null);
+//
+// }
+// template.beforeTemplateCreated(getPageContext(),
+// sourceNodeClone, getVisualDocument());
creationData = template.create(getPageContext(),
sourceNodeClone, getVisualDocument());
} else {
@@ -518,7 +519,7 @@
if (registerFlag) {
final VpeElementData data = creationData.getElementData();
-
+
if ((sourceNodeClone != null) && (data != null)
&& (data.getNodesData() != null)
&& (data.getNodesData().size() > 0)) {
@@ -971,19 +972,6 @@
return sourceNode;
}
- // private void updateComment(Node sourceNode) {
- // VpeNodeMapping mapping = domMapping.getNodeMapping(sourceNode);
- // if (mapping != null
- // && mapping.getType() == VpeNodeMapping.COMMENT_MAPPING) {
- // nsIDOMNodeList visualNodes = mapping.getVisualNode()
- // .getChildNodes();
- //
- // if (visualNodes.getLength() > 0) {
- // visualNodes.item(0).setNodeValue(sourceNode.getNodeValue());
- // }
- // }
- // }
-
private void updateElement(Node sourceNode) {
VpeElementMapping elementMapping = null;
VpeNodeMapping nodeMapping = domMapping.getNodeMapping(sourceNode);
@@ -1075,31 +1063,6 @@
return null;
}
- // public void setText(Node sourceText) {
- // Node sourceParent = sourceText.getParentNode();
- // if (sourceParent != null && sourceParent.getLocalName() != null) {
- // String sourceParentName = sourceParent.getLocalName();
- // if (HTML.TAG_TEXTAREA.equalsIgnoreCase(sourceParentName)
- // || HTML.TAG_OPTION.equalsIgnoreCase(sourceParentName)) {
- // updateNode(sourceText.getParentNode());
- // return;
- // }
- // }
- // nsIDOMNode visualText = domMapping.getVisualNode(sourceText);
- // if (visualText != null) {
- // String visualValue = TextUtil.visualText(sourceText.getNodeValue());
- // visualText.setNodeValue(visualValue);
- // }else {
- // VpeNodeMapping nodeMapping = domMapping
- // .getNodeMapping(sourceParent);
- // if (nodeMapping != null
- // && nodeMapping.getType() == VpeNodeMapping.ELEMENT_MAPPING) {
- // VpeTemplate template = ((VpeElementMapping) nodeMapping)
- // .getTemplate();
- // if (template != null) {
- // if (!template.containsText()) {
- // return;
- // }
public boolean setText(Node sourceText) {
Node sourceParent = sourceText.getParentNode();
if (sourceParent != null && sourceParent.getLocalName() != null) {
@@ -2244,60 +2207,6 @@
includeDocuments.clear();
}
- // protected Map createXmlns(Element sourceNode) {
- // NamedNodeMap attrs = ((Element) sourceNode).getAttributes();
- // if (attrs != null) {
- // Map xmlnsMap = new HashMap();
- // for (int i = 0; i < attrs.getLength(); i++) {
- // addTaglib(sourceNode, xmlnsMap, attrs.item(i).getNodeName(),
- // true);
- // }
- // if (xmlnsMap.size() > 0) {
- // return xmlnsMap;
- // }
- // }
- // return null;
- // }
-
- // private void setXmlnsAttribute(VpeElementMapping elementMapping,
- // String name, String value) {
- // Element sourceElement = (Element) elementMapping.getSourceNode();
- // if (sourceElement != null) {
- // Map xmlnsMap = elementMapping.getXmlnsMap();
- // if (xmlnsMap == null)
- // xmlnsMap = new HashMap();
- // addTaglib(sourceElement, xmlnsMap, name, true);
- // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap : null);
- // }
- // }
-
- // private void removeXmlnsAttribute(VpeElementMapping elementMapping,
- // String name) {
- // Element sourceElement = (Element) elementMapping.getSourceNode();
- // if (sourceElement != null) {
- // Map xmlnsMap = elementMapping.getXmlnsMap();
- // if (xmlnsMap != null) {
- // Object id = xmlnsMap.remove(name);
- // if (id != null) {
- // pageContext.setTaglib(((Integer) id).intValue(), null,
- // null, true);
- // elementMapping.setXmlnsMap(xmlnsMap.size() > 0 ? xmlnsMap
- // : null);
- // }
- // }
- // }
- // }
- //
- // private void addTaglib(Element sourceElement, Map xmlnsMap,
- // String attrName, boolean ns) {
- // Attr attr = sourceElement.getAttributeNode(attrName);
- // if (ATTR_XMLNS.equals(attr.getPrefix())) {
- // xmlnsMap.put(attr.getNodeName(), Integer.valueOf(attr.hashCode()));
- // pageContext.setTaglib(attr.hashCode(), attr.getNodeValue(), attr
- // .getLocalName(), ns);
- // }
- // }
-
/**
* @return the dnd
*/
@@ -2380,64 +2289,6 @@
}
/**
- * Create a visual element for text node
- *
- * @param sourceNode
- * @param registerFlag
- * @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;
- // }
- //
- // 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
*/
public XulRunnerEditor getXulRunnerEditor() {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/bundle/BundleMap.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -353,7 +353,7 @@
return is;
}
- public String getBundleValue(String name, int offset){
+ public String getBundleValue(String name){
if(isShowBundleUsageAsEL) return name;
List<ELInstance> is = parseJSFExpression(name);
if(is == null) return null;
@@ -367,7 +367,7 @@
ELInvocationExpression expr = (ELInvocationExpression)i.getExpression();
String[] values = getCall(expr);
if(values != null) {
- String value = (values == null) ? null : getBundleValue(values[0], values[1],
offset);
+ String value = (values == null) ? null : getBundleValue(values[0], values[1]);
if(value != null) {
sb.append(value);
index = i.getEndPosition();
@@ -405,11 +405,9 @@
return null;
}
- private String getBundleValue(String prefix, String propertyName, int offset) {
+ private String getBundleValue(String prefix, String propertyName) {
BundleEntry entry = getBundle(prefix);
if(entry != null) {
- //Added by estherbin fix JBIDE-2010 (issue with resources).
- if(offset!=0 && (entry.offset > offset))return null;
String name = prefix + "." + propertyName;
try{
String value = (String)entry.bundle.getObject(propertyName);
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.editor.proxy;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.ElService;
+import org.jboss.tools.vpe.editor.util.ResourceUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Node;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class VpeNodeInvocationHandler implements InvocationHandler {
+
+ /**
+ * Node for which we process events
+ */
+ private Node node;
+
+ private VpePageContext pageContext;
+
+ /**
+ * @param node
+ */
+ public VpeNodeInvocationHandler(VpePageContext pageContext,Node node) {
+ this.node = node;
+ this.pageContext = pageContext;
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ Object result = method.invoke(node, args);
+ if(result instanceof String) {
+ String processedStr = (String) result;
+ result = replaceEL(processedStr);
+ } else if(result instanceof Attr) {
+ result = VpeProxyUtil.createProxyForELExpressionNode(pageContext,
+ (Node)result);
+ }
+ return result;
+ }
+
+ protected String replaceEL(String toReplace) {
+ String result = toReplace;
+
+ //fix for JBIDE-3030
+ result = ResourceUtil.getBundleValue(pageContext, toReplace);
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
+ return result;
+ }
+ final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+ return ElService.getInstance().replaceEl(file, toReplace);
+ }
+
+}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeProxyUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeProxyUtil.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeProxyUtil.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.editor.proxy;
+
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Utill Class created for creating proxis for vpe
+ * and manipulation them
+ *
+ * @author mareshkau
+ */
+public class VpeProxyUtil {
+
+ /**
+ * Create proxy for source nodes. This function should be called for nodes,
+ * in which used el expressions which should be replaced
+ * @param sourceNode
+ * @return proxy for node
+ */
+ public static Node createProxyForELExpressionNode(VpePageContext pageContext,
+ Node sourceNode) {
+
+ Node proxy = null;
+ List<Class<?>> interfaceses = new ArrayList<Class<?>>();
+ interfaceses.add(Node.class);
+ if(sourceNode instanceof Element) {
+ interfaceses.add(Element.class);
+ } else if(sourceNode instanceof Attr) {
+ interfaceses.add(Attr.class);
+ }
+ proxy = (Node) Proxy.newProxyInstance(Node.class.getClassLoader(),
+ interfaceses.toArray(new Class[0]),
+ new VpeNodeInvocationHandler(pageContext,sourceNode));
+
+ return proxy;
+ }
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -1462,30 +1462,6 @@
*/
public void afterTemplateCreated(VpePageContext pageContext, nsIDOMElement source,
nsIDOMDocument visualDocument) {
-// final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
-//
-// if ((file != null) && ElService.getInstance().isAvailable(file)) {
-// final nsIDOMNamedNodeMap nodeMap = source.getAttributes();
-// for (int i = 0; i < nodeMap.getLength(); i++) {
-// nsIDOMNode n = nodeMap.item(i);
-//
-// source.setAttribute(n.getNodeName(),
ElService.getInstance().replaceEl(file, n.getNodeValue()));
-//
-// }
-//// if(source.getNodeName().equalsIgnoreCase("img")){
-//// source.setAttribute("src",
ElService.getInstance().replaceEl(file, source.getAttribute("src")));
-//// }
-// if ((source.getChildNodes() != null) &&
source.getChildNodes().getLength() > 0) {
-// for (int j = 0; j < source.getChildNodes().getLength(); j++) {
-// if (source.getChildNodes().item(j).getNodeType() ==
nsIDOMNode.ELEMENT_NODE) {
-// afterTemplateCreated(pageContext, (nsIDOMElement)
source.getChildNodes().item(j).queryInterface(
-// nsIDOMElement.NS_IDOMELEMENT_IID), visualDocument);
-// }
-// }
-// }
-// }
-//
-// System.err.println("Hello world4");
}
public void beforeTemplateCreated(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument domDocument) {
@@ -1500,13 +1476,6 @@
sourceNode.setNodeValue(
ElService.getInstance().replaceElAndResources(pageContext,
sourceNode));
}
- /*
- else if (sourceNode.getFirstChild() instanceof Text) {
-
sourceNode.getFirstChild().setNodeValue(ElService.getInstance().replaceElAndResources(pageContext,
sourceNode.getFirstChild()));
- } else if ((sourceNode.getFirstChild() != null) &&
(sourceNode.getFirstChild().getFirstChild() instanceof Text)) {
-
sourceNode.getFirstChild().getFirstChild().setNodeValue(ElService.getInstance().replaceElAndResources(pageContext,sourceNode.getFirstChild().getFirstChild()));
- }
- */
final NamedNodeMap nodeMap = sourceNode.getAttributes();
if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionJsfValue.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -10,20 +10,16 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template.expression;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.w3c.dom.Node;
-
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.w3c.dom.Node;
public class VpeFunctionJsfValue extends VpeFunction {
public VpeValue exec(VpePageContext pageContext, Node sourceNode) throws
VpeExpressionException {
String value = getParameter(0).exec(pageContext, sourceNode).stringValue();
BundleMap bundle = pageContext.getBundle();
- int offset = pageContext.getVisualBuilder().getCurrentMainIncludeOffset();
- if (offset == -1) offset = ((IndexedRegion)sourceNode).getStartOffset();
- String jsfValue = bundle.getBundleValue(value, offset);
+ String jsfValue = bundle.getBundleValue(value);
return new VpeValue(jsfValue != null ? jsfValue : value);
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -85,9 +85,8 @@
*
* @return the string
*
- * @see IELService#getReplacedElValue(IFile, String)
+ * @see IELService#replaceEl(IFile, String)
*/
- //@Deprecated
public String replaceEl(IFile resourceFile, String resourceString) {
// Assert.isNotNull(resourceString);
if ((resourceString == null) || (resourceFile == null)) {
@@ -161,22 +160,6 @@
*/
public boolean isInResourcesBundle(VpePageContext pageContext, Node sourceNode) {
boolean rst = findInResourcesBundle(pageContext, sourceNode);
-
-// if (!rst && (sourceNode.getChildNodes() != null) &&
(sourceNode.getChildNodes().getLength() > 0)) {
-// for (int i = 0; i < sourceNode.getChildNodes().getLength(); i++) {
-// final Node node = sourceNode.getChildNodes().item(i);
-//
-// if (node.getNodeType() == Node.ELEMENT_NODE) {
-// if((rst = findInResourcesBundle(pageContext, node))){
-// break;
-// }
-//
-//
-// }
-//
-// }
-// }
-
return rst;
}
@@ -197,7 +180,7 @@
textValue = sourceNode.getNodeValue();
if ((textValue != null) && TextUtil.isContainsEl(textValue)) {
- final String newValue = bundleMap.getBundleValue(textValue, 0);
+ final String newValue = bundleMap.getBundleValue(textValue);
if (!textValue.equals(newValue)) {
rst = true;
@@ -217,7 +200,7 @@
final String value = attr.getValue();
if (value != null && TextUtil.isContainsEl(value)) {
- final String value2 = bundleMap.getBundleValue(value, 0);
+ final String value2 = bundleMap.getBundleValue(value);
if (!value2.equals(value)) {
rst = true;
@@ -243,20 +226,6 @@
*/
private boolean isAvailableForNode(Node sourceNode, IFile resourceFile) {
boolean rst = findForNode(sourceNode, resourceFile);
-
-// if (!rst && (sourceNode.getChildNodes() != null) &&
(sourceNode.getChildNodes().getLength() > 0)) {
-// for (int i = 0; i < sourceNode.getChildNodes().getLength(); i++) {
-// final Node node = sourceNode.getChildNodes().item(i);
-//
-// if (node.getNodeType() == Node.ELEMENT_NODE) {
-// if((rst = findForNode((Element) node, resourceFile))){
-// break;
-// }
-// }
-//
-// }
-// }
-
return rst;
}
@@ -379,7 +348,7 @@
return rst;
}
-
+
public String replaceElAndResources(VpePageContext pageContext, Node attributeNode)
{
@@ -401,12 +370,9 @@
return rst;
}
+
-// private String replaceResourceBundle(VpePageContext context,Attr attributeNode){
-//
-// }
-
private boolean equalsExppression(String value, String expression) {
final String dollarEl = String.valueOf(DOLLAR_PREFIX) + expression
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -11,17 +11,15 @@
package org.jboss.tools.vpe.editor.util;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.w3c.dom.Attr;
import org.w3c.dom.Node;
/**
* @author Evgenij Stherbin
*
*/
-@SuppressWarnings("restriction")
+
public class ResourceUtil {
/**
* Gets the bundle value.
@@ -34,12 +32,11 @@
*
* @return the bundle value
*/
- public static String getBundleValue(VpePageContext pageContext, String value, int
offset) {
+ public static String getBundleValue(VpePageContext pageContext, String value) {
BundleMap bundle = pageContext.getBundle();
- return bundle.getBundleValue(value, offset);
+ return bundle.getBundleValue(value);
}
-
/**
* get bundle.
*
@@ -48,26 +45,8 @@
*
* @return the bundle value
*/
- public static String getBundleValue(VpePageContext pageContext, Attr attr) {
- return getBundleValue(pageContext, attr.getNodeValue(), ((IDOMAttr)
attr).getValueRegionStartOffset());
- }
-
-
-
- /**
- * get bundle.
- *
- * @param pageContext the page context
- * @param attr the attr
- *
- * @return the bundle value
- */
public static String getBundleValue(VpePageContext pageContext, Node attr) {
- if(attr instanceof IDOMAttr){
- return getBundleValue(pageContext, attr.getNodeValue(), ((IDOMAttr)
attr).getValueRegionStartOffset());
- }else{
- return getBundleValue(pageContext,attr.getNodeValue(),0);
- }
+ return getBundleValue(pageContext,attr.getNodeValue());
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2008-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/SourceDomUtil.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -10,10 +10,8 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.util;
-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.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Node;
public class SourceDomUtil {
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-11-13
15:16:39 UTC (rev 11762)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2008-11-13
16:00:54 UTC (rev 11763)
@@ -68,24 +68,8 @@
} else {
textNode = node;
}
-
- String sourceNodeValue=null;
- if((nodeMapping.getSourceNode()!=null) &&
- (nodeMapping.getSourceNode().getNodeType()==Node.TEXT_NODE)) {
- sourceNodeValue=nodeMapping.getSourceNode().getNodeValue();
- }
- String visualNodeValue=null;
- if((textNode!=null)&&
- (textNode.getNodeType()==nsIDOMNode.TEXT_NODE)) {
- visualNodeValue = textNode.getNodeValue();
- }
-
- boolean editable =false;
- if(sourceNodeValue!=null && visualNodeValue!=null) {
- editable =sourceNodeValue.trim().equals(visualNodeValue.trim());
- }
- result = new NodeData(nodeMapping.getSourceNode(),textNode,editable);
+ result = new NodeData(nodeMapping.getSourceNode(),textNode,true);
return result;
}