Author: mareshkau
Date: 2008-11-14 10:40:08 -0500 (Fri, 14 Nov 2008)
New Revision: 11791
Modified:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
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/VpePreviewDomBuilder.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/proxy/VpeNodeInvocationHandler.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
Log:
JBIDE-3144
Modified:
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2008-11-14
15:39:37 UTC (rev 11790)
+++
trunk/common/plugins/org.jboss.tools.common.resref.core/src/org/jboss/tools/common/resref/core/ResourceReferenceList.java 2008-11-14
15:40:08 UTC (rev 11791)
@@ -53,10 +53,15 @@
}
return -1;
}
-
+ /**
+ * Returns all resources for current file
+ * @param file
+ * @return
+ */
public ResourceReference[] getAllResources(IFile file) {
- Set locations = new HashSet();
- List css = new ArrayList();
+ Set<String> locations = new HashSet<String>();
+ List<ResourceReference> css = new ArrayList<ResourceReference>();
+
if(file.getProject() != null) {
String[] dcss = getDeclaredResources(file.getProject());
for (int i = 0; i < dcss.length; i++) {
@@ -86,7 +91,7 @@
locations.add(dcss[i]);
css.add(ref);
}
- return (ResourceReference[])css.toArray(new ResourceReference[0]);
+ return css.toArray(new ResourceReference[0]);
}
private String[] getDeclaredResources(IResource resource) {
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-11-14
15:39:37 UTC (rev 11790)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpePreviewDomBuilder.java 2008-11-14
15:40:08 UTC (rev 11791)
@@ -72,12 +72,12 @@
//FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if (ElService.getInstance().isCloneableNode(getPageContext(), sourceNode))
{
- final Node sourceNodeClone =
VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
+ if (ElService.getInstance().isELNode(getPageContext(), sourceNode)) {
+ final Node sourceNodeProxy =
VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
sourceNode);
try {
creationData = template.create(getPageContext(),
- sourceNodeClone, getVisualDocument());
+ sourceNodeProxy, getVisualDocument());
//Fix for JBIDE-3144, we use proxy and some template can
//try to cast for not supported interface
} catch(ClassCastException ex) {
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-14
15:39:37 UTC (rev 11790)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-11-14
15:40:08 UTC (rev 11791)
@@ -437,23 +437,23 @@
sourceNode, ifDependencySet);
VpeCreationData creationData = null;
- Node sourceNodeClone = null;
+ Node sourceNodeProxy = null;
// FIX FOR JBIDE-1568, added by Max Areshkau
try {
- if (ElService.getInstance().isCloneableNode(getPageContext(),
+ if (ElService.getInstance().isELNode(getPageContext(),
sourceNode)) {
- sourceNodeClone = VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
+ sourceNodeProxy = VpeProxyUtil.createProxyForELExpressionNode(getPageContext(),
sourceNode);
try {
creationData = template.create(getPageContext(),
- sourceNodeClone, getVisualDocument());
+ sourceNodeProxy, getVisualDocument());
//Fix for JBIDE-3144, we use proxy and some template can
//try to cast for not supported interface
} catch(ClassCastException ex) {
VpePlugin.reportProblem(ex);
- sourceNodeClone = null;
+ sourceNodeProxy = null;
//then we create template without using proxy
creationData = template.create(getPageContext(), sourceNode,
getVisualDocument());
@@ -520,7 +520,7 @@
final VpeElementData data = creationData.getElementData();
- if ((sourceNodeClone != null) && (data != null)
+ if ((sourceNodeProxy != null) && (data != null)
&& (data.getNodesData() != null)
&& (data.getNodesData().size() > 0)) {
Modified:
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 2008-11-14
15:39:37 UTC (rev 11790)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java 2008-11-14
15:40:08 UTC (rev 11791)
@@ -52,12 +52,18 @@
}
return result;
}
-
- protected String replaceEL(String toReplace) {
+ /**
+ * Replaced string with el value
+ * @param toReplace
+ * @return
+ */
+ private String replaceEL(String toReplace) {
+
String result = toReplace;
-
- //fix for JBIDE-3030
+
result = ResourceUtil.getBundleValue(pageContext, toReplace);
+
+ //fix for JBIDE-3030
if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
return result;
}
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-14
15:39:37 UTC (rev 11790)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-11-14
15:40:08 UTC (rev 11791)
@@ -138,7 +138,7 @@
*
* @return true, if is cloneable node
*/
- public boolean isCloneableNode(VpePageContext pageContext,Node sourceNode) {
+ public boolean isELNode(VpePageContext pageContext,Node sourceNode) {
boolean rst = false;
// fix for JBIDE-3030
if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
@@ -187,9 +187,6 @@
}
}
}
-// }else if ((sourceNode.getFirstChild() != null) &&
(sourceNode.getFirstChild().getNodeType() == Node.TEXT_NODE)) {
-// textValue = sourceNode.getFirstChild().getNodeValue();
-// }
if (!rst) {
final NamedNodeMap nodeMap = sourceNode.getAttributes();
@@ -237,19 +234,10 @@
*/
private boolean findForNode(Node sourceNode, IFile resourceFile) {
boolean rst = false;
- final NamedNodeMap nodeMap = sourceNode.getAttributes();
final ResourceReference[] references = getAllResources(resourceFile);
- //ELReferenceList.getInstance().getAllResources(resourceFile);
String textValue = null;
- if (sourceNode.getNodeType() == Node.TEXT_NODE/*
- * sourceNode.getFirstChild
- * () != null &&
- * sourceNode
- * .getFirstChild
- * ().getNodeType() ==
- * Node.TEXT_NODE
- */) {
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
textValue = sourceNode.getNodeValue();
if (textValue != null) {
if (isInReferenceResourcesList(references, textValue)) {
@@ -257,12 +245,12 @@
}
}
}
-
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
for (int i = 0; i < nodeMap.getLength(); i++) {
if (isInReferenceResourcesList(references, ((Attr)
nodeMap.item(i)).getValue())) {
- rst = true;
- break;
+ return true;
+
}
}
}
@@ -286,10 +274,6 @@
//FIXED FOR JBIDE-3149 by sdzmitrovich
if (equalsExppression(value, ref.getLocation()))
return true;
-
-// if (value.contains(ref.getLocation())) {
-// rst = true;
-// }
}
return rst;
}
@@ -331,20 +315,14 @@
int size = (gResources == null ? 0 : gResources.length);
size += (elResources == null ? 0 : elResources.length);
rst = new ResourceReference[size];
- int counter = 0;
+
if ((gResources != null) && (gResources.length > 0)) {
- for (ResourceReference r : gResources) {
- rst[counter] = r;
- counter++;
- }
+ System.arraycopy(gResources, 0, rst,0, gResources.length);
}
if ((elResources != null) && (elResources.length > 0)) {
- for (ResourceReference r : elResources) {
- rst[counter] = r;
- counter++;
- }
+ System.arraycopy(elResources, 0, rst, gResources==null?0:gResources.length,
elResources.length);
}
-
+
return rst;
}
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-11-14
15:39:37 UTC (rev 11790)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-11-14
15:40:08 UTC (rev 11791)
@@ -14,8 +14,6 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -36,7 +34,6 @@
*
* @return string where el values was substituted.
*/
- //@Deprecated
String replaceEl(IFile resourceFile, String resourceString);
/**
@@ -71,14 +68,15 @@
boolean isAvailable(IFile resourceFile);
/**
- * Checks if is cloneable node.
+ * Checks if is node contains el expressions which should be replaced
+ * from el or from resource bundles.
*
* @param sourceNode the source node
* @param pageContext the page context
*
* @return true, if is cloneable node
*/
- public boolean isCloneableNode(VpePageContext pageContext, Node sourceNode);
+ public boolean isELNode(VpePageContext pageContext, Node sourceNode);
/**
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-14
15:39:37 UTC (rev 11790)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2008-11-14
15:40:08 UTC (rev 11791)
@@ -43,7 +43,7 @@
nsIDOMNode visualNewTextNode = visualDocument
.createTextNode(visualText);
- //TODO Max Areshkau think may be we shouldn't use span
+ //Max Areshkau without this span, we can't select text element
nsIDOMElement element = visualDocument.createElement(HTML.TAG_SPAN);
element.appendChild(visualNewTextNode);