Author: estherbin
Date: 2008-07-29 12:48:43 -0400 (Tue, 29 Jul 2008)
New Revision: 9402
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
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
Log:
Implements
https://jira.jboss.org/jira/browse/JBIDE-2582
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2008-07-29 16:32:33 UTC
(rev 9401)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/META-INF/MANIFEST.MF 2008-07-29 16:48:43 UTC
(rev 9402)
@@ -62,6 +62,7 @@
org.eclipse.ui.ide,
org.jboss.tools.vpe.xulrunner,
org.mozilla.xpcom,
- org.eclipse.draw2d
+ org.eclipse.draw2d,
+ org.jboss.tools.jsf.vpe.richfaces
Bundle-Version: 2.1.0
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-07-29
16:32:33 UTC (rev 9401)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2008-07-29
16:48:43 UTC (rev 9402)
@@ -1480,14 +1480,15 @@
public void beforeTemplateCreated(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument domDocument) {
final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
- if ((file != null) && ElService.getInstance().isAvailable(file)) {
+ if ((file != null)) {
// Node first((Element
Node text = sourceNode.getFirstChild();
- if(text instanceof Text){
- ((Text)text).setData(ElService.getInstance().replaceEl(file,
((TextImpl)text).getData()));
- }else if((sourceNode.getFirstChild()!=null) &&
(sourceNode.getFirstChild().getFirstChild() instanceof Text)){
+
+ if (text instanceof Text) {
+ ((Text) text).setData(ElService.getInstance().replaceEl(file, ((TextImpl)
text).getData()));
+ } else if ((sourceNode.getFirstChild() != null) &&
(sourceNode.getFirstChild().getFirstChild() instanceof Text)) {
text = sourceNode.getFirstChild().getFirstChild();
- ((Text)text).setData(ElService.getInstance().replaceEl(file,
((TextImpl)text).getData()));
+ ((Text) text).setData(ElService.getInstance().replaceEl(file, ((TextImpl)
text).getData()));
}
final NamedNodeMap nodeMap = sourceNode.getAttributes();
@@ -1495,7 +1496,7 @@
for (int i = 0; i < nodeMap.getLength(); i++) {
final Attr n = (Attr) nodeMap.item(i);
- n.setValue(ElService.getInstance().replaceEl(file, n.getValue()));
+
n.setValue(ElService.getInstance().replaceElAndResources(pageContext,n));
}
if ((sourceNode.getChildNodes() != null) &&
(sourceNode.getChildNodes().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-07-29
16:32:33 UTC (rev 9401)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-07-29
16:48:43 UTC (rev 9402)
@@ -1,12 +1,12 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+/*******************************************************************************
+ * 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.vpe.editor.util;
@@ -14,6 +14,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.css.ELReferenceList;
import org.jboss.tools.vpe.editor.css.ResourceReference;
@@ -31,7 +33,7 @@
public final class ElService implements IELService {
/** The Constant INSTANCE. */
- private static final ElService INSTANCE = new ElService();
+ private static final IELService INSTANCE = new ElService();
/**
* Checks if is available.
@@ -78,9 +80,10 @@
*
* @see IELService#getReplacedElValue(IFile, String)
*/
+ //@Deprecated
public String replaceEl(IFile resourceFile, String resourceString) {
// Assert.isNotNull(resourceString);
- if(resourceString == null){
+ if ((resourceString == null) || (resourceFile == null)) {
return "";
}
Assert.isNotNull(resourceFile);
@@ -126,13 +129,66 @@
boolean rst = false;
final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
- if(this.isAvailable(file) && this.isAvailableForNode(sourceNode,file)){
+ if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode,
file))) || isInResourcesBundle(pageContext, sourceNode)){
rst = true;
}
return rst;
}
+ /**
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @return
+ */
+ public boolean isInResourcesBundle(VpePageContext pageContext, Element sourceNode) {
+ boolean rst = false;
+ BundleMap bundleMap = pageContext.getBundle();
+
+ String textValue = null;
+ if (sourceNode.getFirstChild() != null &&
sourceNode.getFirstChild().getNodeType() == Node.TEXT_NODE) {
+ textValue = sourceNode.getFirstChild().getNodeValue();
+ }
+ if (textValue != null && textValue.contains("#{")) {
+ final String newValue = bundleMap.getBundleValue(sourceNode.getNodeValue(),
0);
+
+ if (!textValue.equals(newValue)) {
+ rst = true;
+ }
+ }
+ final NamedNodeMap nodeMap = sourceNode.getAttributes();
+
+ 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 (value != null && value.contains("#{")) {
+ final String value2 = bundleMap.getBundleValue(value, 0);
+
+ if (!value2.equals(value)) {
+ rst = true;
+ break;
+ }
+ }
+ }
+ }
+// final NamedNodeMap nodeMap = sourceNode.getAttributes();
+//
+// if ((nodeMap != null) && (nodeMap.getLength() > 0)) {
+// for (int i = 0; i < nodeMap.getLength(); i++) {
+// if (isInResourcesBundle(pageContext, sourceNode)) {
+// rst = true;
+// break;
+// }
+// }
+// }
+
+ return rst;
+ }
+
+
/**
* Checks if is available for node.
*
@@ -210,4 +266,23 @@
return str;
}
+
+ public String replaceElAndResources(VpePageContext pageContext, Attr attributeNode)
{
+ final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+ final String attribuString = attributeNode.getValue();
+ String rst = attribuString;
+
+ rst = ComponentUtil.getBundleValue(pageContext, attributeNode);
+
+ rst = replaceEl(file, rst);
+
+ return rst;
+ }
+
+// private String replaceResourceBundle(VpePageContext context,Attr 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-07-29
16:32:33 UTC (rev 9401)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-07-29
16:48:43 UTC (rev 9402)
@@ -1,10 +1,20 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
-
package org.jboss.tools.vpe.editor.util;
import org.eclipse.core.resources.IFile;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.w3c.dom.Attr;
import org.w3c.dom.Element;
@@ -25,10 +35,22 @@
*
* @return string where el values was substituted.
*/
+ //@Deprecated
String replaceEl(IFile resourceFile, String resourceString);
-
-
+
/**
+ * Replace el and resources.
+ *
+ * @param attributeNode the attribute node
+ * @param resourceFile the resource file
+ * @param resourceString the resource string
+ * @param pageContext the page context
+ *
+ * @return the string
+ */
+ String replaceElAndResources(VpePageContext pageContext, Attr attributeNode);
+
+ /**
* Reverse replace.
*
* @param resourceFile the resource file
@@ -36,7 +58,7 @@
*
* @return the string
*/
- String reverseReplace(IFile resourceFile,String replacedString);
+ String reverseReplace(IFile resourceFile, String replacedString);
/**
* Checks if is available.
@@ -56,5 +78,16 @@
* @return true, if is cloneable node
*/
public boolean isCloneableNode(VpePageContext pageContext, Element sourceNode);
+
+
+ /**
+ * Checks if is in resources bundle.
+ *
+ * @param sourceNode the source node
+ * @param pageContext the page context
+ *
+ * @return true, if is in resources bundle
+ */
+ boolean isInResourcesBundle(VpePageContext pageContext, Element sourceNode);
}