Author: vrubezhny
Date: 2008-03-13 13:35:34 -0400 (Thu, 13 Mar 2008)
New Revision: 6914
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/SeamFindQuickAssistProcessor.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
Log:
http://jira.jboss.org/jira/browse/JBIDE-1860 Seam find references is not using the right
extensionpoint/shortcut
Ctrl-G/Ctrl-Shift-G Seam Find actions are moved to Ctrl-1 quick fix dialog for the Java
Editor.
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-03-13 15:28:37 UTC (rev
6913)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-03-13 17:35:34 UTC (rev
6914)
@@ -480,13 +480,13 @@
</command>
<command
categoryId="org.eclipse.ui.category.navigate"
- description="Find Declarations"
+ description="Find Seam Declarations"
id="org.jboss.tools.seam.ui.find.declarations"
name="Find Seam Declarations">
</command>
<command
categoryId="org.eclipse.ui.category.navigate"
- description="Find References"
+ description="Find Seam References"
id="org.jboss.tools.seam.ui.find.references"
name="Find Seam References">
</command>
@@ -498,7 +498,7 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+M2+Z">
</key>
- <key
+ <!-- key
commandId="org.jboss.tools.seam.ui.find.declarations"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+G">
@@ -507,7 +507,7 @@
commandId="org.jboss.tools.seam.ui.find.references"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+M2+G">
- </key>
+ </key -->
</extension>
<extension
@@ -519,4 +519,24 @@
class="org.jboss.tools.seam.ui.search.SeamSearchResultPage">
</viewPage>
</extension>
+
+ <extension
+ point="org.eclipse.jdt.ui.quickAssistProcessors">
+ <quickAssistProcessor
+
class="org.jboss.tools.seam.ui.actions.SeamFindQuickAssistProcessor"
+ id="org.jboss.tools.seam.ui.seamfindquickassist"
+ name="Seam Find"/>
+ </extension>
+
+ <!--======================================================================================-->
+ <!-- queryParticipant to participate in java seraches
-->
+ <!--======================================================================================-->
+ <!-- extension point="org.eclipse.jdt.ui.queryParticipants">
+ <queryParticipant
+ name="Seam Query Participant"
+ nature="org.eclipse.jdt.core.javanature"
+ class="org.jboss.tools.seam.ui.search.SeamQueryParticipant"
+ id="org.jboss.tools.seam.ui.search.SeamQueryParticipant" />
+ </extension -->
+
</plugin>
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/SeamFindQuickAssistProcessor.java 2008-03-13
17:35:34 UTC (rev 6914)
@@ -0,0 +1,131 @@
+package org.jboss.tools.seam.ui.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jdt.ui.text.java.IInvocationContext;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jdt.ui.text.java.IProblemLocation;
+import org.eclipse.jdt.ui.text.java.IQuickAssistProcessor;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.part.FileEditorInput;
+import org.hibernate.console.ImageConstants;
+import org.hibernate.eclipse.console.HibernateConsolePlugin;
+import org.hibernate.eclipse.console.utils.EclipseImages;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+public class SeamFindQuickAssistProcessor implements IQuickAssistProcessor {
+
+ public SeamFindQuickAssistProcessor() {
+ }
+
+ public boolean hasAssists(IInvocationContext context) throws CoreException {
+ ICompilationUnit cu = context.getCompilationUnit();
+ if (cu == null)
+ return false;
+
+ IResource javaFile = cu.getResource();
+ if (javaFile == null)
+ return false;
+
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(javaFile.getProject(), true);
+ return (seamProject!=null);
+ }
+
+ public IJavaCompletionProposal[] getAssists(IInvocationContext context,
+ IProblemLocation[] locations) throws CoreException {
+
+ IJavaCompletionProposal[] result = new IJavaCompletionProposal[0];
+ if(!hasAssists( context )) return result;
+
+ IDocument document = getDocument( context.getCompilationUnit() );
+ try {
+ String contents = document.get( context.getSelectionOffset(),
context.getSelectionLength() );
+ result = new IJavaCompletionProposal[2];
+
+ result[0] = new ExternalActionQuickAssistProposal(contents,
EclipseImages.getImage(ImageConstants.CRITERIA_EDITOR), "Find Seam
Declarations", context) {
+ public void apply(IDocument target) {
+ new FindSeamDeclarationsAction().run();
+ }
+ };
+ result[1] = new ExternalActionQuickAssistProposal(contents,
EclipseImages.getImage(ImageConstants.CRITERIA_EDITOR), "Find Seam References",
context) {
+ public void apply(IDocument target) {
+ new FindSeamReferencesAction().run();
+ }
+ };
+ }
+ catch (BadLocationException e) {
+ HibernateConsolePlugin.getDefault().logErrorMessage( "Could not get document
contents for CriteriaQuickAssist", e );
+ }
+ return result;
+ }
+
+ private IDocument getDocument(ICompilationUnit cu) throws JavaModelException {
+ IFile file= (IFile) cu.getResource();
+ IDocument document= JavaUI.getDocumentProvider().getDocument(new
FileEditorInput(file));
+ if (document == null) {
+ return new Document(cu.getSource()); // only used by test cases
+ }
+ return document;
+ }
+
+ public abstract class ExternalActionQuickAssistProposal implements
+ IJavaCompletionProposal {
+
+ private String contents;
+ private ICompletionProposal proposal;
+
+ public ExternalActionQuickAssistProposal(String contents, Image image, String
description, IInvocationContext context) {
+ this.contents = contents;
+
+ proposal = new
CompletionProposal("",context.getSelectionLength(),0,context.getSelectionOffset()+context.getSelectionLength(),
image, description, null,null);
+ }
+
+ public String getContents() {
+ return contents;
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public int getRelevance() {
+ return 0;
+ }
+
+ abstract public void apply(IDocument document);
+
+ public String getAdditionalProposalInfo() {
+ return proposal.getAdditionalProposalInfo();
+ }
+
+ public IContextInformation getContextInformation() {
+ return proposal.getContextInformation();
+ }
+
+ public String getDisplayString() {
+ return proposal.getDisplayString();
+ }
+
+ public Image getImage() {
+ return proposal.getImage();
+ }
+
+ public Point getSelection(IDocument document) {
+ return proposal.getSelection( document );
+ }
+ }
+
+}
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/SeamFindQuickAssistProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain