Author: estherbin
Date: 2008-08-04 08:50:19 -0400 (Mon, 04 Aug 2008)
New Revision: 9488
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/template/VpeAbstractTemplate.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/IELService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java
Log:
Fix bug.
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-08-04
11:59:31 UTC (rev 9487)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-08-04
12:50:19 UTC (rev 9488)
@@ -419,6 +419,10 @@
return null;
}
+//
+// if(sourceNode.getNodeType() == Node.TEXT_NODE){
+// System.err.println("Hello world");
+// }
// switch (sourceNode.getNodeType()) {
// case Node.ELEMENT_NODE:
@@ -429,11 +433,12 @@
sourceNode, ifDependencySet);
VpeCreationData creationData = null;
+ Node sourceNodeClone = null;
// FIX FOR JBIDE-1568, added by Max Areshkau
try {
if (ElService.getInstance().isCloneableNode(getPageContext(),
sourceNode)) {
- final Node sourceNodeClone = (sourceNode).cloneNode(true);
+ sourceNodeClone = (sourceNode).cloneNode(true);
template.beforeTemplateCreated(getPageContext(), sourceNodeClone,
getVisualDocument());
creationData = template.create(getPageContext(), sourceNodeClone,
getVisualDocument());
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-08-04
11:59:31 UTC (rev 9487)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-08-04
12:50:19 UTC (rev 9488)
@@ -1481,14 +1481,17 @@
if ((file != null)) {
// Node first((Element
- Node text = sourceNode.getFirstChild();
-
- if (text instanceof Text) {
- ((Text) text).setData(ElService.getInstance().replaceEl(file, ((TextImpl)
text).getData()));
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ 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)) {
- text = sourceNode.getFirstChild().getFirstChild();
- ((Text) text).setData(ElService.getInstance().replaceEl(file, ((TextImpl)
text).getData()));
+
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/util/ElService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-08-04
11:59:31 UTC (rev 9487)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-08-04
12:50:19 UTC (rev 9488)
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.common.meta.action.impl.handlers.ReplaceSignificanceMessageImpl;
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.css.ELReferenceList;
@@ -143,21 +144,21 @@
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;
- }
-
+// 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;
}
@@ -169,33 +170,41 @@
*/
private boolean findInResourcesBundle(VpePageContext pageContext, Node sourceNode) {
boolean rst = false;
-
+
BundleMap bundleMap = pageContext.getBundle();
if (bundleMap != null) {
String textValue = null;
- if ((sourceNode.getFirstChild() != null) &&
(sourceNode.getFirstChild().getNodeType() == Node.TEXT_NODE)) {
- textValue = sourceNode.getFirstChild().getNodeValue();
- }
- if ((textValue != null) && isContainsEl(textValue)) {
- final String newValue = bundleMap.getBundleValue(textValue, 0);
+
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ textValue = sourceNode.getNodeValue();
- if (!textValue.equals(newValue)) {
- rst = true;
+ if ((textValue != null) && isContainsEl(textValue)) {
+ final String newValue = bundleMap.getBundleValue(textValue, 0);
+
+ if (!textValue.equals(newValue)) {
+ rst = true;
+ }
}
}
- final NamedNodeMap nodeMap = sourceNode.getAttributes();
+// }else if ((sourceNode.getFirstChild() != null) &&
(sourceNode.getFirstChild().getNodeType() == Node.TEXT_NODE)) {
+// textValue = sourceNode.getFirstChild().getNodeValue();
+// }
- if (nodeMap != null && nodeMap.getLength() > 0) {
- for (int i = 0; i < nodeMap.getLength(); i++) {
- final Attr attr = (Attr) nodeMap.item(i);
- final String value = attr.getValue();
+ if (!rst) {
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
- if (value != null && isContainsEl(value)) {
- final String value2 = bundleMap.getBundleValue(value, 0);
+ if (nodeMap != null && nodeMap.getLength() > 0) {
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ final Attr attr = (Attr) nodeMap.item(i);
+ final String value = attr.getValue();
- if (!value2.equals(value)) {
- rst = true;
- break;
+ if (value != null && isContainsEl(value)) {
+ final String value2 = bundleMap.getBundleValue(value, 0);
+
+ if (!value2.equals(value)) {
+ rst = true;
+ break;
+ }
}
}
}
@@ -226,19 +235,19 @@
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 (!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;
+// }
+// }
+//
+// }
+// }
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if((rst = findForNode((Element) node, resourceFile))){
- break;
- }
- }
-
- }
- }
-
return rst;
}
@@ -254,14 +263,22 @@
final ResourceReference[] references =
ELReferenceList.getInstance().getAllResources(resourceFile);
String textValue = null;
- if (sourceNode.getFirstChild() != null &&
sourceNode.getFirstChild().getNodeType() == Node.TEXT_NODE) {
- textValue = sourceNode.getFirstChild().getNodeValue();
- }
- if (textValue != null) {
- if (isInReferenceResourcesList(references, textValue)) {
- return true;
+ if (sourceNode.getNodeType() == Node.TEXT_NODE/*
+ * sourceNode.getFirstChild
+ * () != null &&
+ * sourceNode
+ * .getFirstChild
+ * ().getNodeType() ==
+ * Node.TEXT_NODE
+ */) {
+ textValue = sourceNode.getNodeValue();
+ if (textValue != null) {
+ if (isInReferenceResourcesList(references, textValue)) {
+ return true;
+ }
}
}
+
if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
for (int i = 0; i < nodeMap.getLength(); i++) {
if (isInReferenceResourcesList(references, ((Attr)
nodeMap.item(i)).getValue())) {
@@ -307,7 +324,7 @@
final ResourceReference[] references =
ELReferenceList.getInstance().getAllResources(resourceFile);
- if ((references != null) && (references.length > 0)) {
+ if ((str != null) && (references != null) && (references.length
> 0)) {
for (ResourceReference rf : references) {
if (replacedString.contains(rf.getProperties())) {
str = str.replace(rf.getProperties(), rf.getLocation());
@@ -318,9 +335,15 @@
}
- public String replaceElAndResources(VpePageContext pageContext, Attr attributeNode)
{
+ public String replaceElAndResources(VpePageContext pageContext, Node attributeNode)
{
final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
- final String attribuString = attributeNode.getValue();
+
+ String attribuString = null;
+ if (attributeNode instanceof Attr) {
+ attribuString = ((Attr) attributeNode).getValue();
+ } else {
+ attribuString = attributeNode.getNodeValue();
+ }
String rst = attribuString;
rst = ResourceUtil.getBundleValue(pageContext, attributeNode);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-08-04
11:59:31 UTC (rev 9487)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-08-04
12:50:19 UTC (rev 9488)
@@ -49,7 +49,7 @@
*
* @return the string
*/
- String replaceElAndResources(VpePageContext pageContext, Attr attributeNode);
+ String replaceElAndResources(VpePageContext pageContext, Node attributeNode);
/**
* Reverse replace.
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-08-04
11:59:31 UTC (rev 9487)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java 2008-08-04
12:50:19 UTC (rev 9488)
@@ -15,6 +15,7 @@
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
@@ -50,5 +51,23 @@
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);
+ }
+ }
+
}