[jbosstools-commits] JBoss Tools SVN: r36102 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core and 1 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Oct 31 21:12:17 EDT 2011


Author: scabanovich
Date: 2011-10-31 21:12:16 -0400 (Mon, 31 Oct 2011)
New Revision: 36102

Modified:
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamMessages.java
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessages.java
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesComponent.java
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
Log:
JBIDE-9910
https://issues.jboss.org/browse/JBIDE-9910
Property objects are bound to proposals for 'messages' component.

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamMessages.java	2011-11-01 00:37:39 UTC (rev 36101)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamMessages.java	2011-11-01 01:12:16 UTC (rev 36102)
@@ -11,9 +11,11 @@
 package org.jboss.tools.seam.core;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 
 import org.eclipse.core.resources.IResource;
+import org.jboss.tools.common.model.XModelObject;
 
 /**
  * @author Viacheslav Kabanovich
@@ -32,10 +34,11 @@
 	 */
 	public Collection<ISeamProperty> getProperties();
 
-	/** 
+	/**
+	 * Intruduced instead of getProperties() - as much more lightweight in implementation.
 	 * 
-	 * @return map of properties and corresponding resources
+	 * @return
 	 */
-	public Map<String, IResource> getResourcesMap();
+	public Map<String, List<XModelObject>> getPropertiesMap();
 
 }

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessages.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessages.java	2011-11-01 00:37:39 UTC (rev 36101)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessages.java	2011-11-01 01:12:16 UTC (rev 36102)
@@ -16,6 +16,7 @@
 import java.util.Properties;
 
 import org.eclipse.core.resources.IResource;
+import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.project.ext.event.Change;
 import org.jboss.tools.seam.core.ISeamElement;
 import org.jboss.tools.seam.core.ISeamMessages;
@@ -38,14 +39,14 @@
 		return messagesLoader.getProperties();
 	}
 
+	public Map<String, List<XModelObject>> getPropertiesMap() {
+		return messagesLoader.getPropertiesMap();
+	}
+
 	public Collection<String> getPropertyNames() {
-		return messagesLoader.getPropertyNames();
+		return messagesLoader.getPropertiesMap().keySet();
 	}
 	
-	public Map<String, IResource> getResourcesMap() {
-		return messagesLoader.getResources();
-	}
-
 	public SeamMessages clone() throws CloneNotSupportedException {
 		SeamMessages c = (SeamMessages)super.clone();
 		return c;

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesComponent.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesComponent.java	2011-11-01 00:37:39 UTC (rev 36101)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesComponent.java	2011-11-01 01:12:16 UTC (rev 36102)
@@ -16,6 +16,7 @@
 import java.util.Properties;
 
 import org.eclipse.core.resources.IResource;
+import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.project.ext.event.Change;
 import org.jboss.tools.seam.core.ISeamElement;
 import org.jboss.tools.seam.core.ISeamMessages;
@@ -34,9 +35,13 @@
 	}
 	
 	public Collection<String> getPropertyNames() {
-		return messagesLoader.getPropertyNames();
+		return messagesLoader.getPropertiesMap().keySet();
 	}
 
+	public Map<String, List<XModelObject>> getPropertiesMap() {
+		return messagesLoader.getPropertiesMap();
+	}
+
 	public SeamMessagesComponent clone() throws CloneNotSupportedException {
 		return this;
 	}
@@ -52,8 +57,4 @@
 		return changes;
 	}
 	
-	public Map<String, IResource> getResourcesMap() {
-		return messagesLoader.getResources();
-	}
-
 }

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java	2011-11-01 00:37:39 UTC (rev 36101)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamMessagesLoader.java	2011-11-01 01:12:16 UTC (rev 36102)
@@ -10,23 +10,20 @@
   ******************************************************************************/
 package org.jboss.tools.seam.internal.core;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
 
 import org.eclipse.core.resources.IContainer;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.jboss.tools.seam.core.ISeamComponent;
 import org.jboss.tools.seam.core.ISeamElement;
@@ -42,10 +39,19 @@
  * @author Viacheslav Kabanovich
  */
 public class SeamMessagesLoader {
-	static Map<String, IResource> EMPTY = new HashMap<String, IResource>();
-	Map<String, IResource> resources = EMPTY; // Maps the bundleName to the IResource
+	static class MessageBundle {
+		String bundle;
+		List<XModelObject> files = new ArrayList<XModelObject>();
+		 MessageBundle(String bundle, List<XModelObject> files) {
+			 this.bundle = bundle;
+			 this.files = files;
+		 }
+	}
+	static List<MessageBundle> EMPTY = new ArrayList<MessageBundle>();
+	List<MessageBundle> resources = EMPTY; // Maps the bundleName to the IResource
 	Map<String, Long> timestamps = null;
 	Set<String> keys = null;
+	Map<String, List<XModelObject>> properties = null;
 	
 	ISeamElement object;
 	
@@ -61,40 +67,55 @@
 	}
 
 	public void revalidate() {
-		Map<String, IResource> resources2 = getResources();
+		List<MessageBundle> resources2 = getResources();
 		if(changed(resources2)) {
 			timestamps = new HashMap<String, Long>();
-			for (String n : resources2.keySet()) {
-				IResource r = resources2.get(n);
-				timestamps.put(n, r.getLocalTimeStamp());
+			for (int i = 0; i < resources2.size(); i++) {
+				List<XModelObject> r = resources2.get(i).files;
+				long q = 0;
+				for (XModelObject o: r) q += o.getTimeStamp();
+				timestamps.put(resources2.get(i).bundle, q);
 			}
 			resources = resources2;
 			keys = null;
+			properties = null;
 		}
 	}
 	
-	private boolean changed(Map<String, IResource> resources2) {
+	private boolean changed(List<MessageBundle> resources2) {
 		if(resources == resources2) return false;
 		if(resources2.size() != resources.size()) return true;
 		if(timestamps == null) return true;
-		for (String s: resources2.keySet()) {
-			IResource r2 = resources2.get(s);
-			IResource r1 = resources.get(s);
-			if(r1 == null || !r2.equals(r1)) return true;
-			long l1 = r1.getLocalTimeStamp();
-			Long l2 = timestamps.get(s);
+		for (int i = 0; i < resources2.size(); i++) {
+			List<XModelObject> r2 = resources2.get(i).files;
+			List<XModelObject> r1 = resources.get(i).files;
+			if(r1 == null || r2.size() == r1.size()) return true;
+			long l1 = 0;
+			for (XModelObject o: r1) l1 += o.getTimeStamp();
+			Long l2 = timestamps.get(resources2.get(i).bundle);
 			if(l2 == null || l1 != l2.longValue()) return true;
 		}
 		
 		return false;		
 	}	
 	
-	public Map<String, IResource> getResources() {
+	public List<MessageBundle> getResources() {
 		ISeamProject p = object.getSeamProject();
 		if(p == null) return EMPTY;
 		IResource[] srcs = EclipseResourceUtil.getJavaSourceRoots(p.getProject());
+		List<String> names = getNames();
+		return names.isEmpty() ? EMPTY : getResources(names, srcs);
+	}
+
+	private List<String> getNames() {
+		ISeamProject p = object.getSeamProject();
+		if(p == null) {
+			return new ArrayList<String>();
+		}
 		ISeamComponent c = p.getComponent(resourceComponent);
-		if(c == null) return EMPTY;
+		if(c == null) {
+			return new ArrayList<String>();
+		}
 		List<String> names = new ArrayList<String>();
 		Set<ISeamXmlComponentDeclaration> ds = c.getXmlDeclarations();
 		for (ISeamXmlComponentDeclaration d: ds) {
@@ -123,46 +144,37 @@
 		if(ds.isEmpty()) {
 			names.add("messages");
 		}
-		return getResources(names, srcs);
+		return names;
 	}
 
 	public Collection<ISeamProperty> getProperties() {
 		throw new IllegalStateException("Not implemented");
 	}
 
-	public Collection<String> getPropertyNames() {
-		if(keys == null) {
-			keys = new HashSet<String>();
-			for (IResource r: resources.values()) {
-				IPath p = r.getLocation();
-				if(p == null) continue;
-				File f = p.toFile();
-				Properties properties = new Properties();
-				FileInputStream is = null;
-				try {
-					is = new FileInputStream(f); 
-					properties.load(is);
-				} catch (IOException e) {
-					//ignore 
-					//TODO keep error for validation
-				} finally {
-					if(is!=null) {
-						try {
-							is.close();
-						} catch (IOException e) {
-							// ignore
+	public Map<String, List<XModelObject>> getPropertiesMap() {
+		if(properties == null) {
+			properties = new HashMap<String, List<XModelObject>>();
+			for (int i = 0; i < resources.size(); i++) {
+				List<XModelObject> list = resources.get(i).files;
+				for (XModelObject o: list) {
+					XModelObject[] ps = o.getChildren();
+					for (XModelObject p: ps) {
+						String propertyName = p.getAttributeValue(XModelObjectConstants.ATTR_NAME);
+						List<XModelObject> vs = properties.get(propertyName);
+						if(vs == null) {
+							vs = new ArrayList<XModelObject>();
+							properties.put(propertyName, vs);
 						}
+						vs.add(p);
 					}
 				}
-				Set<?> s = properties.keySet();
-				for (Object o : s) keys.add((String)o);
 			}
 		}
-		return keys;
+		return properties;
 	}
 	
-	private Map<String, IResource> getResources(List<String> names, IResource[] srcs) {
-		Map<String, IResource> rs = new HashMap<String, IResource>();
+	private List<MessageBundle> getResources(List<String> names, IResource[] srcs) {
+		List<MessageBundle> rs = new ArrayList<MessageBundle>();
 		for (String name: names) {
 			String n = name.replace('.', '/');
 			int k = n.lastIndexOf('/');
@@ -173,7 +185,19 @@
 				result = find(p, n, srcs[j]);
 			}
 			if(result != null) {
-				rs.put(name, result);
+				List<XModelObject> l = new ArrayList<XModelObject>();
+				XModelObject o = EclipseResourceUtil.createObjectForResource(result);
+				if(o != null) {
+					XModelObject[] os = o.getParent().getChildren();
+					String dn = o.getAttributeValue(XModelObjectConstants.ATTR_NAME);
+					for (XModelObject c: os) {
+						String fileName = FileAnyImpl.toFileName(c);
+						if(fileName.endsWith(".properties") && (c == o || fileName.startsWith(dn + "_"))) {
+							l.add(c);
+						}
+					}
+					rs.add(new MessageBundle(name, l));
+				}
 			}
 		}
 		return rs;

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java	2011-11-01 00:37:39 UTC (rev 36101)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java	2011-11-01 01:12:16 UTC (rev 36102)
@@ -14,6 +14,7 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -26,6 +27,7 @@
 import org.eclipse.swt.graphics.Image;
 import org.jboss.tools.common.el.core.ca.AbstractELCompletionEngine;
 import org.jboss.tools.common.el.core.ca.MessagesELTextProposal;
+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;
@@ -36,18 +38,18 @@
 import org.jboss.tools.common.el.core.parser.ELParserFactory;
 import org.jboss.tools.common.el.core.parser.ELParserUtil;
 import org.jboss.tools.common.el.core.resolver.ELResolution;
+import org.jboss.tools.common.el.core.resolver.ELResolutionImpl;
 import org.jboss.tools.common.el.core.resolver.ELSegment;
 import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
 import org.jboss.tools.common.el.core.resolver.JavaMemberELSegment;
 import org.jboss.tools.common.el.core.resolver.TypeInfoCollector;
 import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.MemberInfo;
 import org.jboss.tools.common.el.core.resolver.Var;
-import org.jboss.tools.common.model.XModel;
 import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.project.IModelNature;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
 import org.jboss.tools.common.text.TextProposal;
-import org.jboss.tools.jsf.model.helpers.converter.OpenKeyHelper;
+import org.jboss.tools.jst.web.kb.el.MessagePropertyELSegmentImpl;
 import org.jboss.tools.seam.core.IBijectedAttribute;
 import org.jboss.tools.seam.core.ISeamComponent;
 import org.jboss.tools.seam.core.ISeamContextShortVariable;
@@ -190,39 +192,190 @@
 		return (mbr instanceof MessagesInfo);
 	}
 
+	protected void resolveLastSegment(ELInvocationExpression expr, 
+			List<TypeInfoCollector.MemberInfo> members,
+			ELResolutionImpl resolution,
+			boolean returnEqualedVariablesOnly, boolean varIsUsed) {
+		if(resolveLastSegmentInMessages(expr, members, resolution, returnEqualedVariablesOnly, varIsUsed)) {
+			return;
+		} else {
+			super.resolveLastSegment(expr, members, resolution, returnEqualedVariablesOnly, varIsUsed);
+		}
+	}
+
+	private boolean resolveLastSegmentInMessages(ELInvocationExpression expr, 
+			List<TypeInfoCollector.MemberInfo> members,
+			ELResolutionImpl resolution,
+			boolean returnEqualedVariablesOnly, boolean varIsUsed) {
+		if(members.isEmpty() || !(members.get(0) instanceof MessagesInfo)) {
+			return false;
+		}
+		MessagesInfo messagesInfo = ((MessagesInfo)members.get(0));
+		MessagePropertyELSegmentImpl segment = null;
+		if(expr instanceof ELPropertyInvocation) {
+			segment = new MessagePropertyELSegmentImpl(((ELPropertyInvocation)expr).getName());
+		} else if (expr instanceof ELArgumentInvocation) {
+			segment = new MessagePropertyELSegmentImpl(((ELArgumentInvocation)expr).getArgument().getOpenArgumentToken().getNextToken());
+		}
+		if(segment.getToken() == null) {
+			return false;
+		}
+		
+		Set<TextProposal> kbProposals = new TreeSet<TextProposal>(TextProposal.KB_PROPOSAL_ORDER);
+
+		String propertyName = segment.getToken().getText();
+		Map<String, List<XModelObject>> properties = messagesInfo.getPropertiesMap();
+		List<XModelObject> os = properties.get(propertyName);
+		if(os != null) {
+			for(XModelObject o: os) {
+				segment.addObject(o);
+			}
+			if(!os.isEmpty()) {
+				segment.setBaseName(getBundle(os.get(0)));
+			} else {
+				segment.setBaseName("messages");
+			}
+		}
+		
+		if(segment.getToken()!=null) {
+			resolution.addSegment(segment);
+		}
+			resolution.setProposals(kbProposals);
+			if (expr.getType() == ELObjectType.EL_PROPERTY_INVOCATION && ((ELPropertyInvocation)expr).getName() == null) {
+			// return all the methods + properties
+			for (TypeInfoCollector.MemberInfo mbr : members) {
+				processSingularMember(mbr, kbProposals);
+			}
+		} else
+			if(expr.getType() != ELObjectType.EL_ARGUMENT_INVOCATION) {
+			Set<String> proposalsToFilter = new TreeSet<String>(); 
+			for (TypeInfoCollector.MemberInfo mbr : members) {
+					filterSingularMember((MessagesInfo)mbr, proposalsToFilter);
+			}
+			for (String proposal : proposalsToFilter) {
+				// We do expect nothing but name for method tokens (No round brackets)
+				String filter = expr.getMemberName();
+				if(filter == null) filter = ""; //$NON-NLS-1$
+				if(returnEqualedVariablesOnly) {
+					// This is used for validation.
+					if (proposal.equals(filter)) {
+						MessagesELTextProposal kbProposal = createProposal(messagesInfo, proposal);
+						kbProposals.add(kbProposal);
+						break;
+					}
+				} else if (proposal.startsWith(filter)) {
+					// This is used for CA.
+					MessagesELTextProposal kbProposal = createProposal(messagesInfo, proposal);
+					kbProposal.setReplacementString(proposal.substring(filter.length()));
+					kbProposals.add(kbProposal);
+				}
+			}
+		} else if(expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION) {
+			Set<String> proposalsToFilter = new TreeSet<String>();
+			boolean isMessages = false;
+			for (TypeInfoCollector.MemberInfo mbr : members) {
+				isMessages = true;
+				filterSingularMember((MessagesInfo)mbr, proposalsToFilter);
+			}
+			String filter = expr.getMemberName();
+			boolean bSurroundWithQuotes = false;
+			if(filter == null) {
+				filter = ""; //$NON-NLS-1$
+				bSurroundWithQuotes = true;
+			} else {
+				boolean b = filter.startsWith("'") || filter.startsWith("\""); //$NON-NLS-1$ //$NON-NLS-2$
+				boolean e = filter.endsWith("'") || filter.endsWith("\""); //$NON-NLS-1$ //$NON-NLS-2$
+				if((b) && (e)) {
+					filter = filter.length() == 1 ? "" : filter.substring(1, filter.length() - 1); //$NON-NLS-1$
+				} else if(b && !returnEqualedVariablesOnly) {
+					filter = filter.substring(1);
+				} else {
+					//Value is set as expression itself, we cannot compute it
+					if(isMessages) {
+						resolution.setMapOrCollectionOrBundleAmoungTheTokens(true);
+					}
+					return true;
+				}
+			}
+
+			for (String proposal : proposalsToFilter) {
+				if(returnEqualedVariablesOnly) {
+					// This is used for validation.
+					if (proposal.equals(filter)) {
+						MessagesELTextProposal kbProposal = createProposal(messagesInfo, proposal);
+						kbProposals.add(kbProposal);
+						break;
+					}
+				} else if (proposal.startsWith(filter)) {
+					// This is used for CA.
+					MessagesELTextProposal kbProposal = createProposal(messagesInfo, proposal);
+					String replacementString = proposal.substring(filter.length());
+					if (bSurroundWithQuotes) {
+						replacementString = "'" + replacementString + "']"; //$NON-NLS-1$ //$NON-NLS-2$
+					}
+					kbProposal.setReplacementString(replacementString);
+						kbProposals.add(kbProposal);
+				}
+			}
+		}
+		segment.setResolved(!kbProposals.isEmpty());
+		if (resolution.isResolved()){
+			resolution.setLastResolvedToken(expr);
+		}			
+		return true;
+	}
+
 	protected void processSingularMember(TypeInfoCollector.MemberInfo mbr, Set<TextProposal> kbProposals) {
 		if (mbr instanceof MessagesInfo) {
-			// Surround the "long" keys containing the dots with [' '] 
+			// Surround the "long" keys containing the dots with [' ']
+			Map<String, List<XModelObject>> properties = ((MessagesInfo)mbr).getPropertiesMap();
 			TreeSet<String> keys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
-			keys.addAll(((MessagesInfo)mbr).getKeys());
+			keys.addAll(properties.keySet());
 			Iterator<String> sortedKeys = keys.iterator();
 			while(sortedKeys.hasNext()) {
 				String key = sortedKeys.next();
 				if (key == null || key.length() == 0)
 					continue;
-				
-				MessagesELTextProposal proposal = new MessagesELTextProposal();
-				if (key.indexOf('.') != -1) {
-					proposal.setReplacementString("['" + key + "']");
-					proposal.setLabel("['" + key + "']");
-				} else {
-					proposal.setReplacementString(key);
-					proposal.setLabel(key);
-				}
-				proposal.setImage(SEAM_MESSAGES_PROPOSAL_IMAGE);
-
-				/* Setup basename, propertyName and List<XModelObject> describing the property here:
-				 *  
-				proposal.setBaseName(mbr.basename);
-				proposal.setPropertyName(key);
-				proposal.setObjects(objects);
-				*/
-				
+				MessagesELTextProposal proposal = createProposal((MessagesInfo)mbr, key);
 				kbProposals.add(proposal);
 			}
 		}
 	}
 
+	private MessagesELTextProposal createProposal(MessagesInfo mbr, String proposal) {
+		Map<String, List<XModelObject>> properties = mbr.getPropertiesMap();
+		List<XModelObject> ps = properties.get(proposal);
+		String bundle = ps.isEmpty() ? "messages" : getBundle(ps.get(0));
+		
+		MessagesELTextProposal kbProposal = new MessagesELTextProposal();
+		kbProposal.setBaseName(bundle);
+		kbProposal.setObjects(ps);
+
+		if (proposal.indexOf('.') != -1) {
+			kbProposal.setReplacementString("['" + proposal + "']");
+			kbProposal.setLabel("['" + proposal + "']");
+		} else {
+			kbProposal.setReplacementString(proposal);
+			kbProposal.setLabel(proposal);
+		}
+		kbProposal.setImage(SEAM_MESSAGES_PROPOSAL_IMAGE);
+		return kbProposal;
+	}
+
+	private String getBundle(XModelObject o) {
+		StringBuilder sb = new StringBuilder();
+		XModelObject f = FileSystemsHelper.getFile(o);
+		if(f != null) {
+			sb.append(f.getAttributeValue(XModelObjectConstants.ATTR_NAME));
+			f = f.getParent();
+			while(f != null && f.getFileType() == XModelObject.FOLDER) {
+				sb.insert(0,  ".").insert(0, f.getAttributeValue(XModelObjectConstants.ATTR_NAME));
+				f = f.getParent();
+			}
+		}
+		return sb.toString();
+	}
+
 	protected void filterSingularMember(TypeInfoCollector.MemberInfo mbr, Set<TypeInfoCollector.MemberPresentation> proposalsToFilter) {
 		Collection<String> keys = ((MessagesInfo)mbr).getKeys();
 		for (String key : keys) {
@@ -230,6 +383,13 @@
 		}
 	}
 
+	protected void filterSingularMember(MessagesInfo mbr, Set<String> proposalsToFilter) {
+		Collection<String> keys = ((MessagesInfo)mbr).getKeys();
+		for (String key : keys) {
+			proposalsToFilter.add(key);
+		}
+	}
+
 	/**
 	 *  Returns scope for the resource
 	 * @param project

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java	2011-11-01 00:37:39 UTC (rev 36101)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamExpressionResolver.java	2011-11-01 01:12:16 UTC (rev 36102)
@@ -15,6 +15,7 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.eclipse.core.resources.IFile;
@@ -39,6 +40,7 @@
 import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.TypeInfo;
 import org.jboss.tools.common.el.core.resolver.TypeInfoCollector.TypeMemberInfo;
 import org.jboss.tools.common.java.IJavaSourceReference;
+import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.jboss.tools.seam.core.BijectedAttributeType;
 import org.jboss.tools.seam.core.IBijectedAttribute;
@@ -253,6 +255,16 @@
 		public Collection<String> getKeys() {
 			return messages.getPropertyNames();
 		}
+		
+		/**
+		 * Returns mapping of property name to all model objects that represent it, 
+		 * for all locales and all bundles.
+		 * 
+		 * @return
+		 */
+		public Map<String, List<XModelObject>> getPropertiesMap() {
+			return messages.getPropertiesMap();
+		}
 	}
 
 	/**



More information about the jbosstools-commits mailing list