Author: vrubezhny
Date: 2008-03-14 15:05:23 -0400 (Fri, 14 Mar 2008)
New Revision: 6943
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/FindSeamAction.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/SeamFindQuickAssistProcessor.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
Log:
http://jira.jboss.org/jira/browse/JBIDE-1912 ctrl+1 Find seam references should tell what
it will actually search for
Issue is fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-03-14 19:02:55 UTC (rev
6942)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-03-14 19:05:23 UTC (rev
6943)
@@ -450,7 +450,7 @@
class="org.jboss.tools.seam.ui.actions.FindSeamDeclarationsAction"
definitionId="org.jboss.tools.seam.ui.find.declarations"
helpContextId="org.eclipse.jdt.ui.find_declarations_action"
- icon="icons/open_seam_component.gif"
+ icon="icons/find_seam_declarations.gif"
id="findDeclarations"
label="Find Seam Declarations"
menubarPath="navigate/open.ext2"
@@ -461,7 +461,7 @@
class="org.jboss.tools.seam.ui.actions.FindSeamReferencesAction"
definitionId="org.jboss.tools.seam.ui.find.references"
helpContextId="org.eclipse.jdt.ui.find_references_action"
- icon="icons/open_seam_component.gif"
+ icon="icons/find_seam_references.gif"
id="findReferences"
label="Find Seam References"
menubarPath="navigate/open.ext2"
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-03-14
19:02:55 UTC (rev 6942)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-03-14
19:05:23 UTC (rev 6943)
@@ -449,6 +449,11 @@
public static String SeamSearchVisitor_scanning;
+ public static String SeamSearch;
+
+ public static String SeamQuickFixFindDeclarations;
+ public static String SeamQuickFixFindReferences;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SeamUIMessages.class);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/FindSeamAction.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/FindSeamAction.java 2008-03-14
19:02:55 UTC (rev 6942)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/FindSeamAction.java 2008-03-14
19:05:23 UTC (rev 6943)
@@ -107,18 +107,12 @@
if (seamProject == null)
return;
- int elStart = getELStart(document, selectionOffset);
-
- if (elStart == -1)
- elStart = selectionOffset;
+ List<ELOperandToken> tokens = findTokensAtOffset(document, selectionOffset);
- SeamELOperandTokenizerForward tokenizer = new SeamELOperandTokenizerForward(document,
elStart);
- List<ELOperandToken> tokens = tokenizer.getTokens();
-
- if (tokens == null || tokens.size() == 0)
+ if (tokens == null)
return; // No EL Operand found
- String[] varNamesToSearch = findVariableNames(seamProject, document, tokens, elStart);
+ String[] varNamesToSearch = findVariableNames(seamProject, document, tokens);
if (varNamesToSearch != null) {
try {
@@ -168,7 +162,19 @@
}
}
- private String[] findVariableNames(ISeamProject seamProject, IDocument document,
List<ELOperandToken> tokens, int elStartOffset) {
+ public static List<ELOperandToken> findTokensAtOffset(IDocument document, int
offset) {
+ int elStart = getELStart(document, offset);
+
+ if (elStart == -1)
+ elStart = offset;
+
+ SeamELOperandTokenizerForward tokenizer = new SeamELOperandTokenizerForward(document,
elStart);
+ List<ELOperandToken> tokens = tokenizer.getTokens();
+
+ return (tokens == null || tokens.size() == 0) ? null : tokens;
+ }
+
+ public static String[] findVariableNames(ISeamProject seamProject, IDocument document,
List<ELOperandToken> tokens) {
String[] varNames = null;
List<List<ELOperandToken>> variations =
SeamELCompletionEngine.getPossibleVarsFromPrefix(tokens);
@@ -202,8 +208,6 @@
return varNames;
}
-
-
// ---- IWorkbenchWindowActionDelegate
// ------------------------------------------------
@@ -239,7 +243,7 @@
* Scans the document from the offset to the beginning to find start of Seam EL operand
* Returns the start position of first Seam EL operand token
*/
- private int getELStart(IDocument document, int offset) {
+ private static int getELStart(IDocument document, int offset) {
SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizer(document, offset);
List<ELOperandToken> tokens = tokenizer.getTokens();
@@ -254,7 +258,7 @@
* Scans the document from the offset to the beginning to find start of Seam EL operand
* Returns the end position of last Seam EL operand token
*/
- private int getELEnd(IDocument document, int offset) {
+ private static int getELEnd(IDocument document, int offset) {
SeamELOperandTokenizer tokenizer = new SeamELOperandTokenizerForward(document,
offset);
List<ELOperandToken> tokens = tokenizer.getTokens();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/SeamFindQuickAssistProcessor.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/SeamFindQuickAssistProcessor.java 2008-03-14
19:02:55 UTC (rev 6942)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/SeamFindQuickAssistProcessor.java 2008-03-14
19:05:23 UTC (rev 6943)
@@ -1,5 +1,7 @@
package org.jboss.tools.seam.ui.actions;
+import java.util.List;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -16,12 +18,15 @@
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.search.internal.ui.Messages;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.part.FileEditorInput;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.el.ELOperandToken;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
+import org.jboss.tools.seam.ui.SeamUIMessages;
import org.jboss.tools.seam.ui.SeamUiImages;
public class SeamFindQuickAssistProcessor implements IQuickAssistProcessor {
@@ -30,18 +35,41 @@
}
public boolean hasAssists(IInvocationContext context) throws CoreException {
+ ISeamProject seamProject = getSeamProject(context);
+ if (seamProject==null)
+ return false;
+
+ IDocument document = getDocument( context.getCompilationUnit() );
+
+ String[] varNames = getVariableNames(seamProject, document,
context.getSelectionOffset());
+
+ return (varNames != null && varNames.length != 0);
+ }
+
+ private ISeamProject getSeamProject(IInvocationContext context) {
ICompilationUnit cu = context.getCompilationUnit();
if (cu == null)
- return false;
+ return null;
IResource javaFile = cu.getResource();
if (javaFile == null)
- return false;
+ return null;
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(javaFile.getProject(), true);
- return (seamProject!=null);
+ return SeamCorePlugin.getSeamProject(javaFile.getProject(), true);
}
-
+
+ private String[] getVariableNames(ISeamProject seamProject, IDocument document, int
offset) {
+ List<ELOperandToken> tokens = FindSeamAction.findTokensAtOffset(
+ document,
+ offset);
+
+ if (tokens == null)
+ return null;
+
+ return FindSeamAction.findVariableNames(seamProject,
+ document, tokens);
+ }
+
public IJavaCompletionProposal[] getAssists(IInvocationContext context,
IProblemLocation[] locations) throws CoreException {
@@ -51,14 +79,46 @@
IDocument document = getDocument( context.getCompilationUnit() );
try {
String contents = document.get( context.getSelectionOffset(),
context.getSelectionLength() );
+ String searchString = "";
+
+ ISeamProject seamProject = getSeamProject(context);
+ if (seamProject == null)
+ return result;
+
+ String[] variables = getVariableNames(seamProject, document,
context.getSelectionOffset());
+
+ if (variables == null)
+ return result;
+
+ StringBuffer buf= new StringBuffer();
+ for (int i= 0; i < variables.length; i++) {
+ if (i > 0) {
+ buf.append(", "); //$NON-NLS-1$
+ }
+ buf.append(variables[i]);
+ }
+ searchString = buf.toString();
+
result = new IJavaCompletionProposal[2];
- result[0] = new ExternalActionQuickAssistProposal(contents,
SeamUiImages.getImage("find_seam_declarations.gif"), "Find Seam
Declarations", context) {
+ result[0] = new ExternalActionQuickAssistProposal(
+ contents,
+ SeamUiImages.getImage("find_seam_declarations.gif"),
+ Messages.format(
+ SeamUIMessages.SeamQuickFixFindDeclarations,
+ new Object[] {searchString}),
+ context) {
public void apply(IDocument target) {
new FindSeamDeclarationsAction().run();
}
};
- result[1] = new ExternalActionQuickAssistProposal(contents,
SeamUiImages.getImage("find_seam_references.gif"), "Find Seam
References", context) {
+ result[1] = new ExternalActionQuickAssistProposal(
+ contents,
+ SeamUiImages.getImage("find_seam_references.gif"),
+ Messages.format(
+ SeamUIMessages.SeamQuickFixFindReferences,
+ new Object[] {searchString}),
+ context) {
public void apply(IDocument target) {
new FindSeamReferencesAction().run();
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-03-14
19:02:55 UTC (rev 6942)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-03-14
19:05:23 UTC (rev 6943)
@@ -233,3 +233,6 @@
# The first argument will be replaced by the pattern, the second by the scope
SeamSearchQuery_singularLabel= ''{0}'' - 1 match in {1} ({2})
SeamSearchVisitor_scanning= Scanning Seam project {1} of {2}: {0}
+SeamSearch="Seam Search - "
+SeamQuickFixFindDeclarations=Find Seam declarations for ''{0}''
+SeamQuickFixFindReferences=Find Seam references for ''{0}''
\ No newline at end of file