Author: mareshkau
Date: 2011-02-03 08:37:57 -0500 (Thu, 03 Feb 2011)
New Revision: 28972
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMapUtil.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.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/TextUtil.java
Log:
https://issues.jboss.org/browse/JBIDE-7003
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2011-02-03
13:34:40 UTC (rev 28971)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMap.java 2011-02-03
13:37:57 UTC (rev 28972)
@@ -157,9 +157,10 @@
if(project!=null) {
if (project.exists() && project.isOpen()) {
for (int i = 0; i < JSF_PROJECT_NATURES.length; i++) {
- if (project.hasNature(JSF_PROJECT_NATURES[i]))
+ if (project.hasNature(JSF_PROJECT_NATURES[i])){
hasJsfProjectNatureType = true;
break;
+ }
}
}
}
@@ -664,7 +665,4 @@
return bundles;
}
-// private IEditorInput getEditorInput() {
-// return editorInput;
-// }
}
Added:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMapUtil.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMapUtil.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/bundle/BundleMapUtil.java 2011-02-03
13:37:57 UTC (rev 28972)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 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.jst.jsp.bundle;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * Contains Uril functions
+ *
+ * @author mareshkau
+ *
+ */
+public class BundleMapUtil {
+ /**
+ * Checks if node contains text information from resource bundle
+ * @param pageContext
+ * @param sourceNode
+ * @return
+ */
+ public static boolean isInResourcesBundle(BundleMap bundleMap, Node sourceNode) {
+ boolean rst = findInResourcesBundle(bundleMap, sourceNode);
+ return rst;
+ }
+
+
+ /**
+ * @param pageContext
+ * @param sourceNode
+ * @return
+ */
+ private static boolean findInResourcesBundle(BundleMap bundleMap, Node sourceNode) {
+ boolean rst = false;
+
+ if (bundleMap != null) {
+ String textValue = null;
+
+ if (sourceNode.getNodeType() == Node.TEXT_NODE) {
+ textValue = sourceNode.getNodeValue();
+
+ if ((textValue != null) && isContainsEl(textValue)) {
+ final String newValue = bundleMap.getBundleValue(textValue);
+
+ if (!textValue.equals(newValue)) {
+ rst = true;
+ }
+ }
+ }
+
+ if (!rst) {
+ 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 && isContainsEl(value)) {
+ final String value2 = bundleMap.getBundleValue(value);
+
+ if (!value2.equals(value)) {
+ rst = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return rst;
+ }
+
+ /**
+ * @param value
+ * @return
+ */
+ public static boolean isContainsEl(final String value) {
+ return (value.contains("#{") || value.contains("${"));
//$NON-NLS-1$//$NON-NLS-2$
+ }
+}
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 2011-02-03
13:34:40 UTC (rev 28971)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2011-02-03
13:37:57 UTC (rev 28972)
@@ -23,6 +23,7 @@
import org.jboss.tools.common.el.core.GlobalELReferenceList;
import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.jst.jsp.bundle.BundleMap;
+import org.jboss.tools.jst.jsp.bundle.BundleMapUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
@@ -184,7 +185,7 @@
final IFile file = (IFile)
pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode,
file)))
- || isInResourcesBundle(pageContext, sourceNode)){
+ || BundleMapUtil.isInResourcesBundle(pageContext.getBundle(), sourceNode)){
rst = true;
}else if(Jsf2ResourceUtil.isContainJSFContextPath(sourceNode)){
rst = true;
@@ -230,68 +231,8 @@
}
return false;
}
- /**
- *
- * @param pageContext
- * @param sourceNode
- * @return
- */
- public boolean isInResourcesBundle(VpePageContext pageContext, Node sourceNode) {
- boolean rst = findInResourcesBundle(pageContext, sourceNode);
- return rst;
- }
-
/**
- * @param pageContext
- * @param sourceNode
- * @return
- */
- private boolean findInResourcesBundle(VpePageContext pageContext, Node sourceNode) {
- boolean rst = false;
-
- BundleMap bundleMap = pageContext.getBundle();
- if (bundleMap != null) {
- String textValue = null;
-
- if (sourceNode.getNodeType() == Node.TEXT_NODE) {
- textValue = sourceNode.getNodeValue();
-
- if ((textValue != null) && TextUtil.isContainsEl(textValue)) {
- final String newValue = bundleMap.getBundleValue(textValue);
-
- if (!textValue.equals(newValue)) {
- rst = true;
- }
- }
- }
-
- if (!rst) {
- 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 && TextUtil.isContainsEl(value)) {
- final String value2 = bundleMap.getBundleValue(value);
-
- if (!value2.equals(value)) {
- rst = true;
- break;
- }
- }
- }
- }
- }
- }
- return rst;
- }
-
-
-
- /**
* Checks if is available for node.
*
* @param resourceFile the resource file
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 2011-02-03
13:34:40 UTC (rev 28971)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2011-02-03
13:37:57 UTC (rev 28972)
@@ -13,6 +13,7 @@
import org.eclipse.core.resources.IFile;
+import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.w3c.dom.Node;
@@ -68,15 +69,4 @@
*/
public boolean isELNode(VpePageContext pageContext, Node 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, Node sourceNode);
-
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2011-02-03
13:34:40 UTC (rev 28971)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/TextUtil.java 2011-02-03
13:37:57 UTC (rev 28972)
@@ -457,13 +457,4 @@
}
return -1;
}
-
- /**
- * @param value
- * @return
- */
- public static boolean isContainsEl(final String value) {
- return (value.contains("#{") || value.contains("${"));
//$NON-NLS-1$//$NON-NLS-2$
- }
-
}