Author: vrubezhny
Date: 2011-03-03 16:37:07 -0500 (Thu, 03 Mar 2011)
New Revision: 29482
Added:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesBundleHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPBundleHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegment.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegmentImpl.java
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPLoadBundleHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesLoadBundleHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleHyperlink.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPBundleHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/JavaSource/resources.properties
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/pages/inputname.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
Log:
JBIDE-8281
OpenOn doesn't work for #{msgs.prompt} in JSF2 project.
Issue is fixed
JUnit test is added
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegment.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegment.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegment.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -29,6 +29,11 @@
IResource getMessageBundleResource();
/**
+ * @return true if the segment presents message bundle. In this case isProperty() always
returns false;
+ */
+ boolean isBundle();
+
+ /**
* @return true if the segment presents message property.
*/
boolean isProperty();
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegmentImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegmentImpl.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/MessagePropertyELSegmentImpl.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -23,6 +23,7 @@
private ITextSourceReference messagePropertySourceReference = null;
private int propertyStart=0, propertyLength=0;
private String baseName=null;
+ private boolean isBundle = false;
public IResource getMessageBundleResource() {
return messageBundleResource;
@@ -32,8 +33,16 @@
messageBundleResource = resource;
}
+ public void setBundleOnlySegment(boolean set) {
+ isBundle = set;
+ }
+
+ public boolean isBundle() {
+ return isBundle;
+ }
+
public boolean isProperty() {
- return messagePropertySourceReference != null;
+ return !isBundle && (messagePropertySourceReference != null);
}
public ITextSourceReference getMessagePropertySourceReference() {
Modified:
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/common/plugins/org.jboss.tools.common.text.ext/src/org/jboss/tools/common/text/ext/hyperlink/XModelBasedHyperlink.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -31,6 +31,7 @@
* @author Jeremy
*/
public abstract class XModelBasedHyperlink extends AbstractHyperlink {
+ protected Properties requestProperties = null;
/**
* @see
com.ibm.sse.editor.AbstractHyperlink#doHyperlink(org.eclipse.jface.text.IRegion)
@@ -45,15 +46,15 @@
IPromptingProvider provider = PromptingProviderFactory.WEB;
- Properties p = getRequestProperties(region);
- p.put(IPromptingProvider.FILE, documentFile);
+ requestProperties = getRequestProperties(region);
+ requestProperties.put(IPromptingProvider.FILE, documentFile);
- List list = provider.getList(xModel, getRequestMethod(),
p.getProperty("prefix"), p); //$NON-NLS-1$
+ List list = provider.getList(xModel, getRequestMethod(),
requestProperties.getProperty("prefix"), requestProperties); //$NON-NLS-1$
if (list != null && list.size() >= 1) {
openFileInEditor((String)list.get(0));
return;
}
- String error = p.getProperty(IPromptingProvider.ERROR);
+ String error = requestProperties.getProperty(IPromptingProvider.ERROR);
if ( error != null && error.length() > 0) {
openFileFailed();
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
+ * Copyright (c) 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,
@@ -19,14 +19,13 @@
import java.util.TreeSet;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.graphics.Image;
-import org.jboss.tools.common.el.core.ELCorePlugin;
import org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine;
+import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
import org.jboss.tools.common.el.core.model.ELExpression;
import org.jboss.tools.common.el.core.model.ELInstance;
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
@@ -49,7 +48,6 @@
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.common.text.ext.util.Utils;
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.jsf.JSFModelPlugin;
import org.jboss.tools.jsf.model.helpers.converter.OpenKeyHelper;
@@ -190,6 +188,19 @@
true); // is Final and equal names are because of
// we have no more to resolve the parts of expression,
// but we have to resolve arguments of probably a message component
+ if (resolvedVariables != null && !resolvedVariables.isEmpty()) {
+ resolution.setLastResolvedToken(left);
+
+ ELSegmentImpl segment = new MessagePropertyELSegmentImpl();
+ segment.setToken(left.getFirstToken());
+ processMessageBundleSegment(expr, (MessagePropertyELSegmentImpl)segment,
resolvedVariables);
+
+ segment.setResolved(true);
+ for (Variable variable : resolvedVariables) {
+ segment.getVariables().add(variable);
+ }
+ resolution.addSegment(segment);
+ }
} else if (expr.getLeft() == null && isIncomplete) {
resolvedVariables = resolveVariables(file, expr, bundles, true,
returnEqualedVariablesOnly);
@@ -203,8 +214,10 @@
resolvedVariables = resolvedVars;
resolution.setLastResolvedToken(left);
- ELSegmentImpl segment = new ELSegmentImpl();
+ ELSegmentImpl segment = new MessagePropertyELSegmentImpl();
segment.setToken(left.getFirstToken());
+ processMessageBundleSegment(expr, (MessagePropertyELSegmentImpl)segment,
resolvedVariables);
+
segment.setResolved(true);
for (Variable variable : resolvedVars) {
segment.getVariables().add(variable);
@@ -226,8 +239,10 @@
resolvedVariables = resolveVariables(file, expr, bundles, true,
returnEqualedVariablesOnly);
Set<TextProposal> proposals = new
TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
- ELSegmentImpl segment = new ELSegmentImpl();
- segment.setToken(expr.getFirstToken());
+ ELSegmentImpl segment = new MessagePropertyELSegmentImpl();
+ segment.setToken(left.getFirstToken());
+ processMessageBundleSegment(expr, (MessagePropertyELSegmentImpl)segment,
resolvedVariables);
+
segment.setResolved(false);
resolution.addSegment(segment);
@@ -339,7 +354,7 @@
protected void setImage(TextProposal kbProposal) {
kbProposal.setImage(getELProposalImage());
}
-
+
protected void resolveLastSegment(ELInvocationExpression expr,
List<Variable> members,
ELResolutionImpl resolution,
@@ -352,6 +367,10 @@
segment = new MessagePropertyELSegmentImpl();
segment.setToken(((ELPropertyInvocation)expr).getName());
processMessagePropertySegment(expr, (MessagePropertyELSegmentImpl)segment, members);
+ } else if (expr instanceof ELArgumentInvocation) {
+ segment = new MessagePropertyELSegmentImpl();
+ segment.setToken(((ELArgumentInvocation)expr).getArgument().getOpenArgumentToken().getNextToken());
+ processMessagePropertySegment(expr, (MessagePropertyELSegmentImpl)segment, members);
} else {
segment.setToken(expr.getFirstToken());
}
@@ -462,6 +481,30 @@
}
}
+ private void processMessageBundleSegment(ELInvocationExpression expr,
MessagePropertyELSegmentImpl segment, List<Variable> variables) {
+ if(segment.getToken() == null)
+ return;
+ for(Variable variable : variables){
+ if(expr.getFirstToken().getText().equals(variable.name)){
+
+ IModelNature n = EclipseResourceUtil.getModelNature(variable.f.getProject());
+ if(n == null)
+ return;
+ XModel model = n.getModel();
+ if(model == null)
+ return;
+
+ OpenKeyHelper keyHelper = new OpenKeyHelper();
+ XModelObject[] properties = keyHelper.findBundles(model, variable.basename, null);
+ if(properties == null)
+ return;
+
+ segment.setBaseName(variable.basename);
+ segment.setBundleOnlySegment(true);
+ }
+ }
+ }
+
private void processMessagePropertySegment(ELInvocationExpression expr,
MessagePropertyELSegmentImpl segment, List<Variable> variables){
if(segment.getToken() == null)
return;
@@ -486,7 +529,7 @@
if(propFile == null)
continue;
segment.setMessageBundleResource(propFile);
- XModelObject property = p.getChildByPath(segment.getToken().getText());
+ XModelObject property = p.getChildByPath(trimQuotes(segment.getToken().getText()));
if(property != null){
try {
String content = FileUtil.readStream(propFile);
@@ -502,6 +545,20 @@
}
}
+ private String trimQuotes(String value) {
+ if(value == null)
+ return null;
+
+ if(value.startsWith("'") || value.startsWith("\"")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ value = value.substring(1);
+ }
+
+ if(value.endsWith("'") || value.endsWith("\"")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ value = value.substring(0, value.length() - 1);
+ }
+ return value;
+ }
+
public boolean findPropertyLocation(XModelObject property, String content,
MessagePropertyELSegmentImpl segment) {
String name = property.getAttributeValue("name"); //$NON-NLS-1$
String nvs = property.getAttributeValue("name-value-separator");
//$NON-NLS-1$
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml 2011-03-03 21:32:48 UTC (rev
29481)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/plugin.xml 2011-03-03 21:37:07 UTC (rev
29482)
@@ -792,8 +792,18 @@
<contentType id="org.eclipse.jst.jsp.core.jspsource">
<partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
</contentType>
+ <!-- these CTs were copied from the JsfJSPBundleHyperlinkPartitioner -->
+ <contentType id="org.eclipse.wst.html.core.htmlsource">
+ <partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
+ </contentType>
+ <contentType id="jsf.facelet">
+ <partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
+ </contentType>
+ <contentType id="jsf.facelet.composite">
+ <partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
+ </contentType>
</hyperlinkPartitioner>
- <hyperlinkPartitioner
+ <!-- hyperlinkPartitioner
id="org.jboss.tools.common.text.ext.jsf.hyperlink.JsfJSPBundleHyperlinkPartitioner"
class="org.jboss.tools.jsf.text.ext.hyperlink.JsfJSPBundleHyperlinkPartitioner">
<contentType id="org.eclipse.wst.html.core.htmlsource">
@@ -805,7 +815,7 @@
<contentType id="jsf.facelet.composite">
<partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
</contentType>
- </hyperlinkPartitioner>
+ </hyperlinkPartitioner -->
<hyperlinkPartitioner
id="org.jboss.tools.common.text.ext.jsf.hyperlink.JSPClassHyperlinkPartitioner"
@@ -1066,8 +1076,18 @@
<contenttypeidentifier id="org.eclipse.jst.jsp.core.jspsource">
<partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE" />
</contenttypeidentifier>
+ <contenttypeidentifier id="org.eclipse.wst.html.core.htmlsource">
+ <partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE" />
+ </contenttypeidentifier>
+ <contenttypeidentifier id="jsf.facelet">
+ <partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE" />
+ </contenttypeidentifier>
+ <contenttypeidentifier id="jsf.facelet.composite">
+ <partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE" />
+ </contenttypeidentifier>
</hyperlink>
- <hyperlink
+
+ <!-- hyperlink
class="org.jboss.tools.jsf.text.ext.hyperlink.JsfBundleHyperlink"
id="org.jboss.tools.common.text.ext.jsf.hyperlink.JsfBundleHyperlink">
<contenttypeidentifier id="org.eclipse.wst.html.core.htmlsource">
@@ -1079,7 +1099,7 @@
<contenttypeidentifier id="jsf.facelet.composite">
<partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_BUNDLE" />
</contenttypeidentifier>
- </hyperlink>
+ </hyperlink -->
<hyperlink
class="org.jboss.tools.jsf.text.ext.hyperlink.BundleBasenameHyperlink"
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleHyperlink.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/BundleHyperlink.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,163 +1,42 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
+/*******************************************************************************
+ * Copyright (c) 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.jsf.text.ext.hyperlink;
import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
import java.util.Properties;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.ui.IEditorPart;
-import org.jboss.tools.common.model.XModel;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.ELResolution;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.el.core.resolver.ELSegment;
+import org.jboss.tools.common.el.core.resolver.MessagePropertyELSegment;
import org.jboss.tools.common.text.ext.hyperlink.XModelBasedHyperlink;
import org.jboss.tools.common.text.ext.hyperlink.xpl.Messages;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import
org.jboss.tools.jsf.text.ext.hyperlink.JSPExprHyperlinkPartitioner.ExpressionStructure;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* @author Jeremy
*/
public class BundleHyperlink extends XModelBasedHyperlink {
-
- private String getBundleProperty(IRegion region) {
- if(getDocument() == null) return null;
- try {
- String fullText = getDocument().get(region.getOffset(), region.getLength());
-
- // get var name
- int dotIndex = fullText.indexOf("."); //$NON-NLS-1$
- int bracketIndex = fullText.indexOf("["); //$NON-NLS-1$
-
- boolean useDot = false;
- boolean useBracket = false;
-
- if (dotIndex != -1) useDot = true;
- if (bracketIndex != -1) {
- if (!useDot || (useDot && dotIndex > bracketIndex))
- useBracket = true;
- useDot = false;
- }
- if (useDot && fullText.indexOf(".", dotIndex + 1) != -1)
//$NON-NLS-1$
- useDot = false;
-
- if (!useDot && !useBracket) return null;
-
- String sProp = null;
- if (useDot) {
- sProp = fullText.substring(dotIndex + 1);
- }
- if (useBracket) {
- int startProp = bracketIndex + 1;
- int endProp = fullText.indexOf("]"); //$NON-NLS-1$
- if (endProp == -1) endProp = fullText.length() - 1;
- sProp = Utils.trimQuotes(fullText.substring(startProp, endProp));
- }
- return sProp;
- } catch (BadLocationException x) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- }
-
- }
- private String getBundleBasename(IRegion region) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(getDocument());
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- String bundleProp = getDocument().get(region.getOffset(), region.getLength());
-
- String[] prefixes = getLoadBundleTagPrefixes(region);
- if(prefixes == null) return null;
-
- // Find loadBundle tag
- List<Element> lbTags = new ArrayList<Element>();
- for (String prefix : prefixes) {
- NodeList list = xmlDocument.getElementsByTagName(prefix + ":loadBundle");
//$NON-NLS-1$
- for (int i = 0; list != null && i < list.getLength(); i++) {
- Element el = (Element)list.item(i);
- int end = Utils.getValueEnd(el);
- if (end >= 0 && end < region.getOffset()) {
- lbTags.add(el);
- }
- }
- }
- for (int i = 0; i < lbTags.size(); i++) {
- Element el = (Element)lbTags.get(i);
- Attr var = el.getAttributeNode("var"); //$NON-NLS-1$
- if (bundleProp.startsWith("" + var.getValue() + ".")
//$NON-NLS-1$ //$NON-NLS-2$
- || bundleProp.startsWith("" + var.getValue() + "['")
//$NON-NLS-1$ //$NON-NLS-2$
- || bundleProp.equals(var.getValue())) {
- return ((Attr) el.getAttributeNode("basename")).getNodeValue();
//$NON-NLS-1$
- }
- }
- String bundleVar = bundleProp;
- if(bundleVar.indexOf('.') >= 0) bundleVar = bundleVar.substring(0,
bundleVar.indexOf('.'));
- if(bundleVar.indexOf("['") >= 0) bundleVar = bundleVar.substring(0,
bundleVar.indexOf("['")); //$NON-NLS-1$ //$NON-NLS-2$
- XModel xmodel = smw.getXModel();
- List list2 = WebPromptingProvider.getInstance().getList(xmodel,
WebPromptingProvider.JSF_REGISTERED_BUNDLES, null, new Properties());
- if(list2 == null || list2.size() < 1) return null;
- Map map = (Map)list2.get(0);
- return (String)map.get(bundleVar);
- } catch (BadLocationException x) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
- }
- }
-
- protected String[] getLoadBundleTagPrefixes(IRegion region) {
- TaglibManagerWrapper tmw = new TaglibManagerWrapper();
- tmw.init(getDocument(), region.getOffset());
- if(tmw.exists()) {
- return new String[] { tmw.getCorePrefix() };
- } else {
- VpeTaglibManager taglibManager = getTaglibManager();
- if(taglibManager == null) return null;
- TaglibData[] data = (TaglibData[])taglibManager.getTagLibs().toArray(new
TaglibData[0]);
- ArrayList<String> prefixes = new ArrayList<String>();
- for (int i = 0; i < data.length; i++) {
-
if("http://java.sun.com/jsf/core".equals(data[i].getUri())) //$NON-NLS-1$
- prefixes.add(data[i].getPrefix());
- }
- }
- return null;
- }
-
- private VpeTaglibManager getTaglibManager() {
- IEditorPart editor =
JSFExtensionsPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if(editor instanceof VpeTaglibManagerProvider) {
- return ((VpeTaglibManagerProvider)editor).getTaglibManager();
- }
- return null;
- }
-
private static final String VIEW_TAGNAME = "view"; //$NON-NLS-1$
private static final String LOCALE_ATTRNAME = "locale"; //$NON-NLS-1$
private static final String PREFIX_SEPARATOR = ":"; //$NON-NLS-1$
@@ -171,26 +50,21 @@
Document xmlDocument = smw.getDocument();
if (xmlDocument == null) return null;
- String[] prefixes = getLoadBundleTagPrefixes(region);
- if(prefixes == null) return null;
-
Node n = Utils.findNodeForOffset(xmlDocument, region.getOffset());
if (!(n instanceof Attr) ) return null;
Element el = ((Attr)n).getOwnerElement();
Element jsfCoreViewTag = null;
- for (String prefix : prefixes) {
- String nodeToFind = prefix + PREFIX_SEPARATOR + VIEW_TAGNAME;
+ String nodeToFind = PREFIX_SEPARATOR + VIEW_TAGNAME;
- while (el != null) {
- if (nodeToFind.equals(el.getNodeName())) {
- jsfCoreViewTag = el;
- break;
- }
- Node parent = el.getParentNode();
- el = (parent instanceof Element ? (Element)parent : null);
+ while (el != null) {
+ if (el.getNodeName() != null && el.getNodeName().endsWith(nodeToFind)) {
+ jsfCoreViewTag = el;
+ break;
}
+ Node parent = el.getParentNode();
+ el = (parent instanceof Element ? (Element)parent : null);
}
if (jsfCoreViewTag == null || !jsfCoreViewTag.hasAttribute(LOCALE_ATTRNAME)) return
null;
@@ -214,37 +88,76 @@
}
protected String getRequestMethod() {
- return WebPromptingProvider.JSF_OPEN_KEY;
+ return requestProperties != null &&
requestProperties.getProperty(WebPromptingProvider.KEY) == null ?
+ WebPromptingProvider.JSF_OPEN_BUNDLE : WebPromptingProvider.JSF_OPEN_KEY;
}
protected Properties getRequestProperties(IRegion region) {
- Properties p = new Properties();
- String value = getBundleBasename(region);
- if (value != null) {
- p.put(WebPromptingProvider.BUNDLE, value);
+ ELContext context = JSPExprHyperlinkPartitioner.getELContext(getDocument());
+ if(context != null){
+ ExpressionStructure eStructure = JSPExprHyperlinkPartitioner.getExpression(context,
getOffset());
+ if(eStructure != null){
+ ELInvocationExpression invocationExpression =
JSPExprHyperlinkPartitioner.getInvocationExpression(eStructure.reference,
eStructure.expression, getOffset());
+ if(invocationExpression != null){
+ for(ELResolver resolver : context.getElResolvers()){
+ ELResolution resolution = resolver.resolve(context, invocationExpression,
getOffset());
+ if(resolution==null) {
+ continue;
+ }
+ ELSegment segment =
resolution.findSegmentByOffset(getOffset()-eStructure.reference.getStartPosition());
+
+ if (segment != null && segment.isResolved() && segment instanceof
MessagePropertyELSegment) {
+ MessagePropertyELSegment mpSegment = (MessagePropertyELSegment)segment;
+ String bundleBasename = mpSegment.getBaseName();
+ String property = mpSegment.isBundle() ? null :
trimQuotes(mpSegment.getToken().getText());
+ String locale = getPageLocale(region);
+
+ Properties p = new Properties();
+ if (bundleBasename != null) {
+ p.put(WebPromptingProvider.BUNDLE, bundleBasename);
+ }
+
+ if (property != null) {
+ p.put(WebPromptingProvider.KEY, property);
+ }
+
+ if (locale != null) {
+ p.setProperty(WebPromptingProvider.LOCALE, locale);
+ }
+
+ return p;
+ }
+ }
+ }
+ }
}
+ return null;
+ }
+
+ private String trimQuotes(String value) {
+ if(value == null)
+ return null;
+
+ if(value.startsWith("'") || value.startsWith("\"")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ value = value.substring(1);
+ }
- value = getBundleProperty(region);
- if (value != null) {
- p.put(WebPromptingProvider.KEY, value);
+ if(value.endsWith("'") || value.endsWith("\"")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ value = value.substring(0, value.length() - 1);
}
-
- value = getPageLocale(region);
- if (value != null) {
- p.setProperty(WebPromptingProvider.LOCALE, value);
- }
+ return value;
+ }
- return p;
- }
- /*
- * (non-Javadoc)
+ /**
+ * Returns the text to be shown for Open action
*
* @see IHyperlink#getHyperlinkText()
*/
public String getHyperlinkText() {
- String baseName = getBundleBasename(fLastRegion);
- String propertyName = getBundleProperty(fLastRegion);
+ Properties p = getRequestProperties(fLastRegion);
+ String baseName = p == null ? null : p.getProperty(WebPromptingProvider.BUNDLE);
+ String propertyName = p == null ? null : p.getProperty(WebPromptingProvider.KEY);
if (baseName == null || propertyName == null)
return MessageFormat.format(Messages.OpenA, Messages.BundleProperty);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPBundleHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPBundleHyperlinkPartitioner.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPBundleHyperlinkPartitioner.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,36 +1,33 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
+/*******************************************************************************
+ * Copyright (c) 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.jsf.text.ext.hyperlink;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+import org.jboss.tools.common.el.core.resolver.ELContext;
+import org.jboss.tools.common.el.core.resolver.ELResolution;
+import org.jboss.tools.common.el.core.resolver.ELResolver;
+import org.jboss.tools.common.el.core.resolver.ELSegment;
+import org.jboss.tools.common.el.core.resolver.MessagePropertyELSegment;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkPartitionRecognizer;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.StructuredModelWrapper;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
import org.jboss.tools.common.text.ext.util.Utils;
+import
org.jboss.tools.jsf.text.ext.hyperlink.JSPExprHyperlinkPartitioner.ExpressionStructure;
import org.jboss.tools.jst.text.ext.hyperlink.jsp.JSPRootHyperlinkPartitioner;
-import org.jboss.tools.jsf.text.ext.JSFExtensionsPlugin;
+import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
+import org.w3c.dom.Document;
/**
* @author Jeremy
@@ -76,61 +73,39 @@
}
return superRegion.getAxis();
}
-
+
public static IHyperlinkRegion getRegion(IDocument document, final int offset) {
- StructuredModelWrapper smw = new StructuredModelWrapper();
- smw.init(document);
- try {
- Document xmlDocument = smw.getDocument();
- if (xmlDocument == null) return null;
-
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
-
- if (n == null || !(n instanceof Attr || n instanceof Text)) return null;
-
- int start = Utils.getValueStart(n);
- int end = Utils.getValueEnd(n);
- if(start < 0 || start > end || start > offset) return null;
- String attrText = document.get(start, end - start);
-
- StringBuffer sb = new StringBuffer(attrText);
- //find start of bean property
- int bStart = offset - start;
- while (bStart >= 0) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bStart)) &&
- sb.charAt(bStart) != '.' && sb.charAt(bStart) != '['
&& sb.charAt(bStart) != ']' &&
- sb.charAt(bStart) != '\'') {
- bStart++;
- break;
+ ELContext context = JSPExprHyperlinkPartitioner.getELContext(document);
+ if(context != null){
+ ExpressionStructure eStructure = JSPExprHyperlinkPartitioner.getExpression(context,
offset);
+ if(eStructure != null){
+ ELInvocationExpression invocationExpression =
JSPExprHyperlinkPartitioner.getInvocationExpression(eStructure.reference,
eStructure.expression, offset);
+ if(invocationExpression != null){
+ ELSegment segment = decide(context, eStructure.expression, invocationExpression,
offset-eStructure.reference.getStartPosition(), offset);
+ if (segment != null) {
+ IHyperlinkRegion region = new
HyperlinkRegion(eStructure.reference.getStartPosition() +
segment.getSourceReference().getStartPosition(), segment.getSourceReference().getLength(),
null, null, null);
+ return region;
+ }
}
-
- if (bStart == 0) break;
- bStart--;
}
- // find end of bean property
- int bEnd = offset - start;
- while (bEnd < sb.length()) {
- if (!Character.isJavaIdentifierPart(sb.charAt(bEnd)) &&
- sb.charAt(bEnd) != '.' && sb.charAt(bEnd) != '[' &&
sb.charAt(bEnd) != ']' &&
- sb.charAt(bEnd) != '\'')
- break;
- bEnd++;
+ }
+ return null;
+ }
+
+ private static ELSegment decide(ELContext context, ELExpression expression,
ELInvocationExpression invocationExpression, int offset, int globalOffset){
+ for(ELResolver resolver : context.getElResolvers()){
+ ELResolution resolution = resolver.resolve(context, invocationExpression,
globalOffset);
+ if(resolution==null) {
+ continue;
}
-
- int propStart = bStart + start;
- int propLength = bEnd - bStart;
-
- if (propStart > offset || propStart + propLength < offset) return null;
-
- IHyperlinkRegion region = new HyperlinkRegion(propStart, propLength, null, null,
null);
- return region;
- } catch (BadLocationException x) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return null;
- } finally {
- smw.dispose();
+ ELSegment segment = resolution.findSegmentByOffset(offset);
+ if(segment != null && segment.isResolved()){
+ if (segment != null && segment.isResolved() && segment instanceof
MessagePropertyELSegment) {
+ return segment;
+ }
+ }
}
-
+ return null;
}
/**
@@ -145,81 +120,15 @@
Utils.findNodeForOffset(xmlDocument, region.getOffset());
- IHyperlinkRegion r = getRegion(document, region.getOffset());
- if (r == null) return false;
-
- String bundleProp = document.get(r.getOffset(), r.getLength());
-
- // get var name
- int dotIndex = bundleProp.indexOf("."); //$NON-NLS-1$
- int bracketIndex = bundleProp.indexOf("["); //$NON-NLS-1$
-
- boolean useDot = false;
- boolean useBracket = false;
-
- if (dotIndex != -1) useDot = true;
- if (bracketIndex != -1) {
- if (!useDot || (useDot && dotIndex > bracketIndex))
- useBracket = true;
- }
- if (useDot && bundleProp.indexOf(".", dotIndex + 1) != -1)
//$NON-NLS-1$
- useDot = false;
-
- if (!useDot && !useBracket) return false;
-
- String sVar = null;
- String sProp = null;
- if (useDot) {
- sVar = bundleProp.substring(0, dotIndex);
- sProp = bundleProp.substring(dotIndex + 1);
- }
- if (useBracket) {
- sVar = bundleProp.substring(0, bracketIndex);
- int startProp = bracketIndex + 1;
- int endProp = bundleProp.indexOf("]"); //$NON-NLS-1$
- if (endProp == -1) endProp = bundleProp.length() - 1;
- sProp = Utils.trimQuotes(bundleProp.substring(startProp, endProp));
- }
-
-
- if (sVar == null || sProp == null) return false;
-
- String[] prefixes = getLoadBundleTagPrefixes(document, region.getOffset());
- if (prefixes == null) return false;
-
- for (String prefix : prefixes) {
- // Find loadBundle tag
- List<Element> lbTags = new ArrayList<Element>();
- NodeList list = xmlDocument.getElementsByTagName(prefix + ":loadBundle");
//$NON-NLS-1$
- for (int i = 0; list != null && i < list.getLength(); i++) {
- Element el = (Element)list.item(i);
- int end = Utils.getValueEnd(el);
- if (end >= 0 && end < region.getOffset()) {
- lbTags.add(el);
- }
- }
-
- Element lbTag = null;
- for (int i = 0; i < lbTags.size(); i++) {
- Element el = lbTags.get(i);
- Attr var = el.getAttributeNode("var"); //$NON-NLS-1$
-
- if (sVar.equals(var.getValue())) {
- lbTag = el;
- break;
- }
- }
- if (lbTag != null) return true;
- }
- return false;
- } catch (BadLocationException x) {
- JSFExtensionsPlugin.log("", x); //$NON-NLS-1$
- return false;
+ return (getRegion(document, region.getOffset()) != null);
} finally {
smw.dispose();
}
}
+ /**
+ * @deprecated
+ */
protected String[] getLoadBundleTagPrefixes(IDocument document, int offset) {
TaglibManagerWrapper tmw = new TaglibManagerWrapper();
tmw.init(document, offset);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JSPExprHyperlinkPartitioner.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,12 +1,12 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and 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
+/*******************************************************************************
+ * Copyright (c) 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.jsf.text.ext.hyperlink;
@@ -21,6 +21,7 @@
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELSegment;
import org.jboss.tools.common.el.core.resolver.JavaMemberELSegment;
+import org.jboss.tools.common.el.core.resolver.MessagePropertyELSegment;
import org.jboss.tools.common.text.ext.hyperlink.AbstractHyperlinkPartitioner;
import org.jboss.tools.common.text.ext.hyperlink.HyperlinkRegion;
import org.jboss.tools.common.text.ext.hyperlink.IExclusiblePartitionerRecognition;
@@ -91,14 +92,14 @@
if(invocationExpression != null){
jspExpression = decide(context, eStructure.expression, invocationExpression,
offset-eStructure.reference.getStartPosition(), offset);
if(jspExpression){
- IHyperlinkRegion region = new
HyperlinkRegion(invocationExpression.getStartPosition(), invocationExpression.getLength(),
null, null, null);
+ IHyperlinkRegion region = new
HyperlinkRegion(eStructure.reference.getStartPosition() +
invocationExpression.getStartPosition(), invocationExpression.getLength(), null, null,
null);
return region;
}
+ dotExpression = checkDot(document, offset, context, eStructure.expression,
invocationExpression, offset-eStructure.reference.getStartPosition());
+
+ IHyperlinkRegion region = new
HyperlinkRegion(eStructure.reference.getStartPosition() +
invocationExpression.getStartPosition(), eStructure.expression.getLength(), null, null,
null);
+ return region;
}
- dotExpression = checkDot(document, offset, context, eStructure.expression,
invocationExpression, offset-eStructure.reference.getStartPosition());
-
- IHyperlinkRegion region = new
HyperlinkRegion(eStructure.expression.getStartPosition(),
eStructure.expression.getLength(), null, null, null);
- return region;
}
}
return null;
@@ -154,6 +155,9 @@
return true;
}
}
+ if (segment instanceof MessagePropertyELSegment) {
+ return false;
+ }
}
}
return false;
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfBundleHyperlink.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.jsf.text.ext.hyperlink;
-
-import org.eclipse.jface.text.IRegion;
-
-/**
- *
- * @author Jeremy
- *
- */
-public class JsfBundleHyperlink extends BundleHyperlink {
-
- @Override
- protected String[] getLoadBundleTagPrefixes(IRegion region) {
- return JsfJSPBundleHyperlinkPartitioner.getLoadBundleTagPrefixes(getDocument(),
region);
- }
-
-}
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext/src/org/jboss/tools/jsf/text/ext/hyperlink/JsfJSPBundleHyperlinkPartitioner.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.jsf.text.ext.hyperlink;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.jboss.tools.common.text.ext.util.Utils;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- *
- * @author Jeremy
- *
- */
-public class JsfJSPBundleHyperlinkPartitioner extends JSPBundleHyperlinkPartitioner {
-
- private static final String JSF_CORE_URI = "http://java.sun.com/jsf/core";
//$NON-NLS-1$
-
- protected String[] getLoadBundleTagPrefixes(IDocument document, int offset) {
- return getLoadBundleTagPrefixes(document, new Region(offset, 0));
- }
-
- static String[] getLoadBundleTagPrefixes(IDocument document, IRegion region) {
- Map<String, Set<String>> namespaces = getNameSpaces(document,
region.getOffset());
-
- if (namespaces == null)
- return null;
-
- Set<String> prefixes = namespaces.get(JSF_CORE_URI);
- if (prefixes == null)
- return null;
-
- return prefixes.toArray(new String[prefixes.size()]);
- }
-
- /**
- * Method collects the namespaces used in the document
- *
- * @param document
- * @param offset
- * @return
- */
- static public Map<String, Set<String>> getNameSpaces(IDocument document, int
offset) {
- IStructuredModel sModel = StructuredModelManager
- .getModelManager()
- .getExistingModelForRead(document);
-
- try {
- if (sModel == null)
- return null;
-
- Document xmlDocument = (sModel instanceof IDOMModel) ? ((IDOMModel) sModel)
- .getDocument()
- : null;
-
- if (xmlDocument == null)
- return null;
-
- Map<String, Set<String>> namespaces = new
HashMap<String,Set<String>>();
- Node n = Utils.findNodeForOffset(xmlDocument, offset);
- while (n != null) {
- if (!(n instanceof Element)) {
- if (n instanceof Attr) {
- n = ((Attr) n).getOwnerElement();
- } else {
- n = n.getParentNode();
- }
- continue;
- }
-
- NamedNodeMap attrs = n.getAttributes();
- for (int j = 0; attrs != null && j < attrs.getLength(); j++) {
- Attr a = (Attr) attrs.item(j);
- String name = a.getName();
- if (name.startsWith("xmlns:")) { //$NON-NLS-1$
- final String prefix = name.substring("xmlns:".length()); //$NON-NLS-1$
- final String uri = a.getValue();
- if (prefix != null && prefix.trim().length() > 0 &&
- uri != null && uri.trim().length() > 0) {
-
- Set<String> prefixes = namespaces.get(uri.trim());
- if (prefixes == null) {
- prefixes = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- namespaces.put(uri.trim(), prefixes);
- }
- prefixes.add(prefix.trim());
- }
- }
- }
-
- n = n.getParentNode();
- }
-
- return namespaces;
- } finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- }
-}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2011-03-03
21:32:48 UTC (rev 29481)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/plugin.xml 2011-03-03
21:37:07 UTC (rev 29482)
@@ -343,7 +343,7 @@
</hyperlinkPartitioner>
- <hyperlinkPartitioner
+ <!-- hyperlinkPartitioner
id="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesJSPBundleHyperlinkPartitioner"
class="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesJSPBundleHyperlinkPartitioner">
<contentType id="org.eclipse.jst.jsp.core.jspsource">
@@ -362,7 +362,7 @@
<partitionType
id="org.jboss.tools.common.text.ext.jsp.FACELETS_ATTRIBUTE_VALUE_WITH_EXPR"
/>
<partitionType
id="org.jboss.tools.common.text.ext.jsp.JSP_EXPRESSION" />
</contentType>
- </hyperlinkPartitioner>
+ </hyperlinkPartitioner -->
<hyperlinkPartitioner
id="org.jboss.tools.common.text.ext.jsf.hyperlink.JSPForIDHyperlinkPartitioner"
@@ -1007,7 +1007,7 @@
</contenttypeidentifier>
</hyperlink>
- <hyperlink
+ <!-- hyperlink
class="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesBundleHyperlink"
id="org.jboss.tools.jsf.text.ext.richfaces.hyperlink.RichfacesBundleHyperlink">
<contenttypeidentifier id="org.eclipse.jst.jsp.core.jspsource">
@@ -1022,7 +1022,7 @@
<contenttypeidentifier id="jsf.facelet.composite">
<partitiontype
id="org.jboss.tools.common.text.ext.jsp.JSP_RICHFACES_BUNDLE" />
</contenttypeidentifier>
- </hyperlink>
+ </hyperlink -->
</extension>
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesBundleHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesBundleHyperlink.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesBundleHyperlink.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Exadel, Inc. and 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
- ******************************************************************************/
-
-package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.ui.IEditorPart;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
-import org.jboss.tools.jsf.text.ext.hyperlink.BundleHyperlink;
-import org.jboss.tools.jsf.text.ext.richfaces.RichfacesExtensionsPlugin;
-import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibManager;
-import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
-
-/**
- *
- * @author Victor Rubezhny
- *
- */
-public class RichfacesBundleHyperlink extends BundleHyperlink {
-
- protected String[] getLoadBundleTagPrefixes(IRegion region) {
- ArrayList<String> prefixes = new ArrayList<String>();
- TaglibManagerWrapper tmw = new TaglibManagerWrapper();
- tmw.init(getDocument(), region.getOffset());
- if(tmw.exists()) {
- for (String uri : RichfacesJSPBundleHyperlinkPartitioner.LoadBundleURIs) {
- String prefix = tmw.getPrefix(uri);
- if (prefix != null)
- prefixes.add(prefix);
- }
- } else {
- VpeTaglibManager taglibManager = getTaglibManager();
- if(taglibManager == null) return null;
- TaglibData[] data = (TaglibData[])taglibManager.getTagLibs().toArray(new
TaglibData[0]);
- for (int i = 0; i < data.length; i++) {
- for (String uri : RichfacesJSPBundleHyperlinkPartitioner.LoadBundleURIs) {
- if(uri.equals(data[i].getUri()))
- prefixes.add(data[i].getPrefix());
- }
- }
- }
- return (String[])prefixes.toArray(new String[prefixes.size()]);
- }
-
- private VpeTaglibManager getTaglibManager() {
- IEditorPart editor =
RichfacesExtensionsPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if(editor instanceof VpeTaglibManagerProvider) {
- return ((VpeTaglibManagerProvider)editor).getTaglibManager();
- }
- return null;
- }
-
-}
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPBundleHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPBundleHyperlinkPartitioner.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPBundleHyperlinkPartitioner.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Exadel, Inc. and 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
- ******************************************************************************/
-
-package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
-
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.text.IDocument;
-import org.jboss.tools.jst.text.ext.util.TaglibManagerWrapper;
-import org.jboss.tools.jsf.text.ext.hyperlink.JSPBundleHyperlinkPartitioner;
-import org.jboss.tools.jsf.text.ext.hyperlink.JsfJSPBundleHyperlinkPartitioner;
-
-/**
- *
- * @author Victor Rubezhny
- *
- */
-public class RichfacesJSPBundleHyperlinkPartitioner extends JSPBundleHyperlinkPartitioner
{
- public static final String JSP_RICHFACES_BUNDLE_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_RICHFACES_BUNDLE"; //$NON-NLS-1$
-
- public final static String[] LoadBundleURIs = {
- "http://richfaces.org/a4j", //$NON-NLS-1$
- "https://ajax4jsf.dev.java.net/ajax" //$NON-NLS-1$
- };
-
- /**
- * @Override
- */
- protected String getPartitionType() {
- return JSP_RICHFACES_BUNDLE_PARTITION;
- }
-
- /**
- * @Override
- */
- protected String[] getLoadBundleTagPrefixes(IDocument document, int offset) {
- ArrayList<String> prefixes = new ArrayList<String>();
- TaglibManagerWrapper tmw = new TaglibManagerWrapper();
- tmw.init(document, offset);
- if(tmw.exists()) {
- for (String uri : LoadBundleURIs) {
- String prefix = tmw.getPrefix(uri);
- if (prefix != null)
- prefixes.add(prefix);
- }
- }
- // JBIDE-4559: For XHTML pages we should use alternate way to get the prefixes
- Map<String, Set<String>> namespaces =
JsfJSPBundleHyperlinkPartitioner.getNameSpaces(document, offset);
-
- if (namespaces != null) {
- for (String uri : LoadBundleURIs) {
- Set<String> altPrefixes = namespaces.get(uri);
- if (altPrefixes != null)
- prefixes.addAll(altPrefixes);
- }
- }
-
- return (prefixes.size() == 0 ? null : (String[])prefixes.toArray(new
String[prefixes.size()]));
- }
-
-}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPLoadBundleHyperlinkPartitioner.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPLoadBundleHyperlinkPartitioner.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesJSPLoadBundleHyperlinkPartitioner.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
@@ -27,6 +27,11 @@
public static final String JSP_RICHFACES_LOADBUNDLE_PARTITION =
"org.jboss.tools.common.text.ext.jsp.JSP_RICHFACES_LOADBUNDLE"; //$NON-NLS-1$
+ public final static String[] LoadBundleURIs = {
+ "http://richfaces.org/a4j", //$NON-NLS-1$
+ "https://ajax4jsf.dev.java.net/ajax" //$NON-NLS-1$ // @deprecated URI
+ };
+
/**
* @Override
*/
@@ -43,7 +48,7 @@
if(!tmw.exists()) return null;
ArrayList<String> prefixes = new ArrayList<String>();
- for (String uri : RichfacesJSPBundleHyperlinkPartitioner.LoadBundleURIs) {
+ for (String uri : LoadBundleURIs) {
String prefix = tmw.getPrefix(uri);
if (prefix != null)
prefixes.add(prefix);
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesLoadBundleHyperlink.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesLoadBundleHyperlink.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.text.ext.richfaces/src/org/jboss/tools/jsf/text/ext/richfaces/hyperlink/RichfacesLoadBundleHyperlink.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2009 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jsf.text.ext.richfaces.hyperlink;
@@ -34,7 +34,7 @@
TaglibManagerWrapper tmw = new TaglibManagerWrapper();
tmw.init(getDocument(), region.getOffset());
if(tmw.exists()) {
- for (String uri : RichfacesJSPBundleHyperlinkPartitioner.LoadBundleURIs) {
+ for (String uri : RichfacesJSPLoadBundleHyperlinkPartitioner.LoadBundleURIs) {
String prefix = tmw.getPrefix(uri);
if (prefix != null)
prefixes.add(prefix);
@@ -44,7 +44,7 @@
if(taglibManager == null) return null;
TaglibData[] data = (TaglibData[])taglibManager.getTagLibs().toArray(new
TaglibData[0]);
for (int i = 0; i < data.length; i++) {
- for (String uri : RichfacesJSPBundleHyperlinkPartitioner.LoadBundleURIs) {
+ for (String uri : RichfacesJSPLoadBundleHyperlinkPartitioner.LoadBundleURIs) {
if(uri.equals(data[i].getUri()))
prefixes.add(data[i].getPrefix());
}
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/JavaSource/resources.properties
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/JavaSource/resources.properties 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/JavaSource/resources.properties 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,2 +1,3 @@
prompt=Your Name\:
greeting=Hello
+demo.long.named.property=A Long Named Property
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/WEB-INF/faces-config.xml 2011-03-03
21:37:07 UTC (rev 29482)
@@ -21,6 +21,10 @@
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<locale-config/>
+ <resource-bundle>
+ <base-name>resources</base-name>
+ <var>registeredMsgs</var>
+ </resource-bundle>
</application>
<factory/>
<lifecycle/>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/pages/inputname.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/pages/inputname.xhtml 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/projects/JSF2CompositeOpenOn/WebContent/pages/inputname.xhtml 2011-03-03
21:37:07 UTC (rev 29482)
@@ -6,7 +6,7 @@
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ez="http://java.sun.com/jsf/composite/demo">
-<f:loadBundle basename="resources" var="msg" />
+<f:loadBundle basename="resources" var="pageMsgs" />
<ui:composition template="/templates/common.xhtml"
xmlns:jar="http://java.sun.com/jsf/composite/jarPage"
@@ -17,7 +17,10 @@
<ui:define name="pageHeader">Facelets Hello
Application</ui:define>
<ui:define name="body">
- <ez:input id="inputname" label="${msgs.prompt}"
value="#{user.name}" action="#{user.sayHello}" submitlabel="Say
Hello"/>
+ <ez:input id="inputname" label="${registeredMsgs.prompt}"
value="#{user.name}" action="#{user.sayHello}" submitlabel="Say
Hello"/>
+ <h:outputText
value="${registeredMsgs['demo.long.named.property']}" />
+ <h:outputText value="${pageMsgs.prompt}" />
+ <h:outputText value="${pageMsgs['demo.long.named.property']}"
/>
<form>
<jar:echo1 echo="Hello" />
<jar:echo echo="Hello" />
Added:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Exadel, Inc. and 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
+ ******************************************************************************/
+package org.jboss.tools.jsf.text.ext.test;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.WorkbenchUtils;
+
+/**
+ *
+ * @author jeremy
+ *
+ */
+public class JSF2MessagesOpenOnTest extends TestCase {
+ private static final String PROJECT_NAME = "JSF2CompositeOpenOn";
+ private static final String PAGE_NAME =
PROJECT_NAME+"/WebContent/pages/inputname.xhtml";
+
+ public IProject project = null;
+
+ protected void setUp() {
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+ PROJECT_NAME);
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ JobUtils.waitForIdle();
+ }
+
+ protected void tearDown() {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ }
+
+ public JSF2MessagesOpenOnTest() {
+ super("JSF2 OpenOn on messages test");
+ }
+
+ public void testRegisteredBundle() throws PartInitException, BadLocationException {
+ doTextBundlePropertyOpenOn("resources.properties",
"registeredMsgs.prompt", "registeredMsgs");
+ }
+ public void testRegisteredBundleProperty() throws PartInitException,
BadLocationException {
+ doTextBundlePropertyOpenOn("resources.properties",
"registeredMsgs.prompt", "prompt");
+ }
+ public void testRegisteredLongNamedBundleProperty() throws PartInitException,
BadLocationException {
+ doTextBundlePropertyOpenOn("resources.properties",
"registeredMsgs['demo.long.named.property']",
"demo.long.named.property");
+ }
+ public void testPageLoadedBundle() throws PartInitException, BadLocationException {
+ doTextBundlePropertyOpenOn("resources.properties",
"pageMsgs.prompt", "pageMsgs");
+ }
+ public void testPageLoadedBundleProperty() throws PartInitException,
BadLocationException {
+ doTextBundlePropertyOpenOn("resources.properties",
"pageMsgs.prompt", "prompt");
+ }
+ public void testPageLoadedLongNamedBundleProperty() throws PartInitException,
BadLocationException {
+ doTextBundlePropertyOpenOn("resources.properties",
"pageMsgs['demo.long.named.property']",
"demo.long.named.property");
+ }
+
+ private void doTextBundlePropertyOpenOn(String editorName, String propertyQualifiedName,
String property) throws PartInitException, BadLocationException {
+ IEditorPart editor = WorkbenchUtils.openEditor(PAGE_NAME);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JobUtils.waitForIdle();
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+
+ IDocument document = viewer.getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
+ propertyQualifiedName, true, true, false, false);
+ assertNotNull("Property:"+propertyQualifiedName+" not found",reg);
+
+ reg = new FindReplaceDocumentAdapter(document).find(reg.getOffset(),
+ property, true, true, false, false);
+ assertNotNull("Property:"+property+" not found",reg);
+
+ IHyperlink[] links = HyperlinkDetector.getInstance().detectHyperlinks(viewer, reg,
true); // new Region(reg.getOffset() + reg.getLength(), 0)
+
+ assertNotNull("Hyperlinks for property:"+propertyQualifiedName+" are not
found",links);
+
+ assertTrue("Hyperlinks for property:"+propertyQualifiedName+" are not
found",links.length!=0);
+
+ boolean found = false;
+ for(IHyperlink link : links){
+ assertNotNull(link.toString());
+
+ link.open();
+ JobUtils.waitForIdle(2000);
+
+ IEditorPart resultEditor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editorName.equals(resultEditor.getTitle())){
+ found = true;
+ return;
+ }
+ }
+ assertTrue("OpenOn have not opened "+editorName+" editor",found);
+ }
+
+
+ public void testRegisteredBundlePropertyOpenOn() throws PartInitException,
BadLocationException {
+ final String editorName = "resources.properties";
+ final String propertyName = "registeredMsgs.prompt";
+ IEditorPart editor = WorkbenchUtils.openEditor(PAGE_NAME);
+ assertTrue(editor instanceof JSPMultiPageEditor);
+ JobUtils.waitForIdle();
+ JSPMultiPageEditor jspMultyPageEditor = (JSPMultiPageEditor) editor;
+ ISourceViewer viewer = jspMultyPageEditor.getSourceEditor().getTextViewer();
+
+ IDocument document = viewer.getDocument();
+ IRegion reg = new FindReplaceDocumentAdapter(document).find(0,
+ propertyName, true, true, false, false);
+
+ assertNotNull("Property:"+propertyName+" not found",reg);
+
+ IHyperlink[] links = HyperlinkDetector.getInstance().detectHyperlinks(viewer, reg,
true); // new Region(reg.getOffset() + reg.getLength(), 0)
+
+ assertNotNull("Hyperlinks for property:"+propertyName+" are not
found",links);
+
+ assertTrue("Hyperlinks for property:"+propertyName+" are not
found",links.length!=0);
+
+ boolean found = false;
+ for(IHyperlink link : links){
+ assertNotNull(link.toString());
+
+ link.open();
+ JobUtils.waitForIdle(2000);
+
+ IEditorPart resultEditor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(editorName.equals(resultEditor.getTitle())){
+ found = true;
+ return;
+ }
+ }
+ assertTrue("OpenOn have not opened "+editorName+" editor",found);
+ }
+
+}
+
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JSF2MessagesOpenOnTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java 2011-03-03
21:32:48 UTC (rev 29481)
+++
trunk/jsf/tests/org.jboss.tools.jsf.text.ext.test/src/org/jboss/tools/jsf/text/ext/test/JsfTextExtAllTests.java 2011-03-03
21:37:07 UTC (rev 29482)
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jsf.text.ext.test;
@@ -27,6 +27,10 @@
"org.jboss.tools.jsf.text.ext.test",
new String[]{"projects/JSF2CompositeOpenOn"},
new String[]{"JSF2CompositeOpenOn"}));
+ suite.addTest(new ProjectImportTestSetup(new TestSuite(JSF2MessagesOpenOnTest.class),
+ "org.jboss.tools.jsf.text.ext.test",
+ new String[]{"projects/JSF2CompositeOpenOn"},
+ new String[]{"JSF2CompositeOpenOn"}));
return suite;
}
}
\ No newline at end of file