Author: vrubezhny
Date: 2008-12-03 14:18:44 -0500 (Wed, 03 Dec 2008)
New Revision: 12263
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/properties/SeamELAttributeContentProposalProvider.java
Log:
JBIDE-3133 New icons for proposals in JSF/Seam Code Assist.
The icons support and a set of common icons are added to the Seam CA.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2008-12-03
19:16:20 UTC (rev 12262)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/text/java/SeamELProposalProcessor.java 2008-12-03
19:18:44 UTC (rev 12263)
@@ -94,20 +94,31 @@
private final int fOffset;
private int fNewPosition;
+ private Image fImage;
+
public Proposal(String string, String prefix, int offset) {
this(string, prefix, offset, offset + string.length());
}
public Proposal(String string, String prefix, int offset, int newPosition) {
- this(string, prefix, prefix, offset, offset + string.length());
+ this(string, prefix, prefix, offset, offset + string.length(), null);
}
+ public Proposal(String string, String prefix, int offset, int newPosition, Image image)
{
+ this(string, prefix, prefix, offset, offset + string.length(), image);
+ }
+
public Proposal(String string, String prefix, String newPrefix, int offset, int
newPosition) {
+ this(string, prefix, newPrefix, offset, newPosition, null);
+ }
+
+ public Proposal(String string, String prefix, String newPrefix, int offset, int
newPosition, Image image) {
fString = string;
fPrefix = prefix;
fNewPrefix = newPrefix;
fOffset = offset;
fNewPosition = newPosition;
+ fImage = image;
}
/*
@@ -153,7 +164,9 @@
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
*/
public Image getImage() {
- return
SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE);
+ return fImage == null ?
+ SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE)
:
+ fImage;
}
/*
@@ -424,14 +437,17 @@
ElVarSearcher varSearcher = new ElVarSearcher(engine);
List<Var> vars = varSearcher.findAllVars(viewer, offset);
- //TODO
-
SeamELCompletionEngine fEngine= new SeamELCompletionEngine(seamProject);
- List<String> suggestions = fEngine.getCompletions(file, document, prefix, offset
+ proposalPrefix.length() - prefix.length(), false, vars, start, end);
- List<String> uniqueSuggestions = fEngine.makeUnique(suggestions);
+ List<KbProposal> suggestions = fEngine.getCompletions(file, document, prefix,
offset + proposalPrefix.length() - prefix.length(), false, vars, start, end);
+ List<KbProposal> uniqueSuggestions = fEngine.makeKbUnique(suggestions);
List<ICompletionProposal> result= new ArrayList<ICompletionProposal>();
- for (String string : uniqueSuggestions) {
+ for (KbProposal kbProposal : uniqueSuggestions) {
+ String string = kbProposal.getReplacementString();
+ Image image = kbProposal.hasImage() ?
+ kbProposal.getImage() :
+ SeamCorePlugin.getDefault().getImage(SeamCorePlugin.CA_SEAM_EL_IMAGE_PATH);
+
if (string.length() >= 0) {
string = proposalPrefix + string + proposalSufix;
if (string.length() > 0 && ('#' == string.charAt(0) ||
'$' == string.charAt(0)))
@@ -439,9 +455,9 @@
if (string.startsWith("['") &&
string.endsWith("']") && prefix != null &&
prefix.endsWith(".")) {
String newPrefix = prefix.substring(0, prefix.length() - 1);
- result.add(new Proposal(string, prefix, newPrefix, offset, offset - 1 +
string.length() - proposalSufix.length()));
+ result.add(new Proposal(string, prefix, newPrefix, offset, offset - 1 +
string.length() - proposalSufix.length(), image));
} else {
- result.add(new Proposal(string, prefix, offset, offset + string.length() -
proposalSufix.length()));
+ result.add(new Proposal(string, prefix, offset, offset + string.length() -
proposalSufix.length(), image));
}
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/properties/SeamELAttributeContentProposalProvider.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/properties/SeamELAttributeContentProposalProvider.java 2008-12-03
19:16:20 UTC (rev 12262)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/properties/SeamELAttributeContentProposalProvider.java 2008-12-03
19:18:44 UTC (rev 12263)
@@ -25,6 +25,7 @@
import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.core.model.ELUtil;
+import org.jboss.tools.common.kb.KbProposal;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.attribute.IAttributeContentProposalProvider;
@@ -107,7 +108,7 @@
if(prefix == null) prefix = "";
- List<String> suggestions = null;
+ List<KbProposal> suggestions = null;
try {
suggestions = engine.getCompletions(file, null, prefix, position, false, null, 0,
contents.length());
} catch (BadLocationException e) {
@@ -116,12 +117,12 @@
if(suggestions == null) {
return EMPTY;
}
- List<String> uniqueSuggestions = engine.makeUnique(suggestions);
+ List<KbProposal> uniqueSuggestions = engine.makeKbUnique(suggestions);
List<IContentProposal> list = new ArrayList<IContentProposal>();
- for (String p: uniqueSuggestions) {
- String label = prefix + p;
- IContentProposal cp = makeContentProposal(p, label);
+ for (KbProposal p: uniqueSuggestions) {
+ String label = prefix + p.getReplacementString();
+ IContentProposal cp = makeContentProposal(p.getReplacementString(), label);
list.add(cp);
}
return list.toArray(new IContentProposal[0]);