|
From: <caw...@us...> - 2007-06-07 20:46:49
|
Revision: 2587
http://svn.sourceforge.net/rubyeclipse/?rev=2587&view=rev
Author: cawilliams
Date: 2007-06-07 13:46:45 -0700 (Thu, 07 Jun 2007)
Log Message:
-----------
add in searching for declarations
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RubySearchActionGroup.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/DeclarationsSearchGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInProjectAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInWorkingSetAction.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java 2007-06-06 16:44:06 UTC (rev 2586)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -130,6 +130,8 @@
public static String group_references;
public static String group_readReferences;
public static String group_search;
+ public static String group_occurrences;
+ public static String group_declarations;
public static String RubyElementAction_operationUnavailable_title;
public static String RubyElementAction_operationUnavailable_generic;
@@ -171,11 +173,16 @@
public static String FindOccurrencesEngine_noSource_text;
public static String FindOccurrencesEngine_cannotParse_text;
+
+ public static String TextSearchLabelProvider_matchCountFormat;
- public static String group_occurrences;
+ public static String Search_FindDeclarationAction_label;
+ public static String Search_FindDeclarationAction_tooltip;
+ public static String Search_FindDeclarationsInProjectAction_label;
+ public static String Search_FindDeclarationsInProjectAction_tooltip;
+ public static String Search_FindDeclarationsInWorkingSetAction_label;
+ public static String Search_FindDeclarationsInWorkingSetAction_tooltip;
- public static String TextSearchLabelProvider_matchCountFormat;
-
static {
NLS.initializeMessages(BUNDLE_NAME, SearchMessages.class);
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties 2007-06-06 16:44:06 UTC (rev 2586)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties 2007-06-07 20:46:45 UTC (rev 2587)
@@ -79,6 +79,7 @@
RubySearchQuery_status_ok_message=Found {0} matches.
group_search=S&earch
+group_declarations= Dec&larations
group_references= Re&ferences
group_readReferences= &Read Access
group_occurrences= Occurre&nces in File
@@ -107,6 +108,16 @@
FindOccurrencesEngine_noSource_text= No source available. To perform this operation you need to attach source.
FindOccurrencesEngine_cannotParse_text= Cannot analyze the ruby script.
+Search_FindDeclarationAction_label= &Workspace
+Search_FindDeclarationAction_tooltip= Search for Declarations of the Selected Element in the Workspace
+
+Search_FindDeclarationsInProjectAction_label= &Project
+Search_FindDeclarationsInProjectAction_tooltip= Search for Declarations of the Selected Element in Resources in the Enclosing Project of the Selected Element
+
+Search_FindDeclarationsInWorkingSetAction_label= Working &Set...
+Search_FindDeclarationsInWorkingSetAction_tooltip= Search for Declarations of the Selected Element in a Working Set
+
+
Search_FindReferencesAction_label= &Workspace
Search_FindReferencesAction_tooltip= Search for References to the Selected Element in the Workspace
@@ -202,4 +213,4 @@
FiltersDialog_description_label=Filter Description:
FiltersDialog_limit_label=&Limit top level elements in Ruby search view to:
FiltersDialog_limit_error=Element limit must be a positive number
-FiltersDialogAction_label=&Filters...
\ No newline at end of file
+FiltersDialogAction_label=&Filters...
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/DeclarationsSearchGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/DeclarationsSearchGroup.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/DeclarationsSearchGroup.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import java.util.Iterator;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.search.ui.IContextMenuConstants;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
+import org.rubypeople.rdt.internal.ui.search.SearchMessages;
+import org.rubypeople.rdt.internal.ui.search.SearchUtil;
+
+/**
+ * Action group that adds the search for declarations actions to a
+ * context menu and the global menu bar.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 1.0
+ */
+public class DeclarationsSearchGroup extends ActionGroup {
+
+ private static final String MENU_TEXT= SearchMessages.group_declarations;
+
+ private IWorkbenchSite fSite;
+ private RubyEditor fEditor;
+ private IActionBars fActionBars;
+
+ private String fGroupId;
+
+ private FindDeclarationsAction fFindDeclarationsAction;
+ private FindDeclarationsInProjectAction fFindDeclarationsInProjectAction;
+ private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction;
+// private FindDeclarationsInHierarchyAction fFindDeclarationsInHierarchyAction;
+
+ /**
+ * Creates a new <code>DeclarationsSearchGroup</code>. The group requires
+ * that the selection provided by the site's selection provider is of type <code>
+ * IStructuredSelection</code>.
+ *
+ * @param site the workbench site that owns this action group
+ */
+ public DeclarationsSearchGroup(IWorkbenchSite site) {
+ fSite= site;
+ fGroupId= IContextMenuConstants.GROUP_SEARCH;
+
+ fFindDeclarationsAction= new FindDeclarationsAction(site);
+ fFindDeclarationsAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKSPACE);
+
+ fFindDeclarationsInProjectAction= new FindDeclarationsInProjectAction(site);
+ fFindDeclarationsInProjectAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_PROJECTS);
+
+// fFindDeclarationsInHierarchyAction= new FindDeclarationsInHierarchyAction(site);
+// fFindDeclarationsInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_HIERARCHY);
+
+ fFindDeclarationsInWorkingSetAction= new FindDeclarationsInWorkingSetAction(site);
+ fFindDeclarationsInWorkingSetAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKING_SET);
+
+ // register the actions as selection listeners
+ ISelectionProvider provider= fSite.getSelectionProvider();
+ ISelection selection= provider.getSelection();
+ registerAction(fFindDeclarationsAction, provider, selection);
+ registerAction(fFindDeclarationsInProjectAction, provider, selection);
+// registerAction(fFindDeclarationsInHierarchyAction, provider, selection);
+ registerAction(fFindDeclarationsInWorkingSetAction, provider, selection);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ *
+ * @param editor the Ruby editor
+ */
+ public DeclarationsSearchGroup(RubyEditor editor) {
+ Assert.isNotNull(editor);
+ fEditor= editor;
+ fSite= fEditor.getSite();
+ fGroupId= ITextEditorActionConstants.GROUP_FIND;
+
+ fFindDeclarationsAction= new FindDeclarationsAction(fEditor);
+ fFindDeclarationsAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKSPACE);
+ fEditor.setAction("SearchDeclarationsInWorkspace", fFindDeclarationsAction); //$NON-NLS-1$
+
+ fFindDeclarationsInProjectAction= new FindDeclarationsInProjectAction(fEditor);
+ fFindDeclarationsInProjectAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_PROJECTS);
+ fEditor.setAction("SearchDeclarationsInProjects", fFindDeclarationsInProjectAction); //$NON-NLS-1$
+
+// fFindDeclarationsInHierarchyAction= new FindDeclarationsInHierarchyAction(fEditor);
+// fFindDeclarationsInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_HIERARCHY);
+// fEditor.setAction("SearchDeclarationsInHierarchy", fFindDeclarationsInHierarchyAction); //$NON-NLS-1$
+
+ fFindDeclarationsInWorkingSetAction= new FindDeclarationsInWorkingSetAction(fEditor);
+ fFindDeclarationsInWorkingSetAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_DECLARATIONS_IN_WORKING_SET);
+ fEditor.setAction("SearchDeclarationsInWorkingSet", fFindDeclarationsInWorkingSetAction); //$NON-NLS-1$
+ }
+
+ private void registerAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection) {
+ action.update(selection);
+ provider.addSelectionChangedListener(action);
+ }
+
+ /* (non-Rubydoc)
+ * Method declared on ActionGroup.
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ Assert.isNotNull(actionBars);
+ super.fillActionBars(actionBars);
+ fActionBars= actionBars;
+ updateGlobalActionHandlers();
+ }
+
+ private void addAction(IAction action, IMenuManager manager) {
+ if (action.isEnabled()) {
+ manager.add(action);
+ }
+ }
+
+ private void addWorkingSetAction(IWorkingSet[] workingSets, IMenuManager manager) {
+ FindAction action;
+ if (fEditor != null)
+ action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), SearchUtil.toString(workingSets));
+ else
+ action= new WorkingSetFindAction(fSite, new FindDeclarationsInWorkingSetAction(fSite, workingSets), SearchUtil.toString(workingSets));
+ action.update(getContext().getSelection());
+ addAction(action, manager);
+ }
+
+
+ /* (non-Rubydoc)
+ * Method declared on ActionGroup.
+ */
+ public void fillContextMenu(IMenuManager manager) {
+ IMenuManager javaSearchMM= new MenuManager(MENU_TEXT, IContextMenuConstants.GROUP_SEARCH);
+ addAction(fFindDeclarationsAction, javaSearchMM);
+ addAction(fFindDeclarationsInProjectAction, javaSearchMM);
+// addAction(fFindDeclarationsInHierarchyAction, javaSearchMM);
+
+ javaSearchMM.add(new Separator());
+
+ Iterator iter= SearchUtil.getLRUWorkingSets().sortedIterator();
+ while (iter.hasNext()) {
+ addWorkingSetAction((IWorkingSet[]) iter.next(), javaSearchMM);
+ }
+ addAction(fFindDeclarationsInWorkingSetAction, javaSearchMM);
+
+ if (!javaSearchMM.isEmpty())
+ manager.appendToGroup(fGroupId, javaSearchMM);
+ }
+
+ /*
+ * Method declared on ActionGroup.
+ */
+ public void dispose() {
+ ISelectionProvider provider= fSite.getSelectionProvider();
+ if (provider != null) {
+ disposeAction(fFindDeclarationsAction, provider);
+ disposeAction(fFindDeclarationsInProjectAction, provider);
+// disposeAction(fFindDeclarationsInHierarchyAction, provider);
+ disposeAction(fFindDeclarationsInWorkingSetAction, provider);
+ }
+ fFindDeclarationsAction= null;
+ fFindDeclarationsInProjectAction= null;
+// fFindDeclarationsInHierarchyAction= null;
+ fFindDeclarationsInWorkingSetAction= null;
+ updateGlobalActionHandlers();
+ super.dispose();
+ }
+
+ private void updateGlobalActionHandlers() {
+ if (fActionBars != null) {
+ fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_DECLARATIONS_IN_WORKSPACE, fFindDeclarationsAction);
+ fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_DECLARATIONS_IN_PROJECT, fFindDeclarationsInProjectAction);
+// fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_DECLARATIONS_IN_HIERARCHY, fFindDeclarationsInHierarchyAction);
+ fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_DECLARATIONS_IN_WORKING_SET, fFindDeclarationsInWorkingSetAction);
+ }
+ }
+
+ private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
+ if (action != null)
+ provider.removeSelectionChangedListener(action);
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsAction.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IField;
+import org.rubypeople.rdt.core.IImportDeclaration;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
+import org.rubypeople.rdt.internal.ui.search.SearchMessages;
+
+/**
+ * Finds declarations of the selected element in the workspace.
+ * The action is applicable to selections representing a Ruby element.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 1.0
+ */
+public class FindDeclarationsAction extends FindAction {
+
+ /**
+ * Creates a new <code>FindDeclarationsAction</code>. The action requires
+ * that the selection provided by the site's selection provider is of type <code>
+ * org.eclipse.jface.viewers.IStructuredSelection</code>.
+ *
+ * @param site the site providing context information for this action
+ */
+ public FindDeclarationsAction(IWorkbenchSite site) {
+ super(site);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public FindDeclarationsAction(RubyEditor editor) {
+ super(editor);
+ }
+
+ void init() {
+ setText(SearchMessages.Search_FindDeclarationAction_label);
+ setToolTipText(SearchMessages.Search_FindDeclarationAction_tooltip);
+ setImageDescriptor(RubyPluginImages.DESC_OBJS_SEARCH_DECL);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FIND_DECLARATIONS_IN_WORKSPACE_ACTION);
+ }
+
+ Class[] getValidTypes() {
+ return new Class[] { IField.class, IMethod.class, IType.class, IRubyScript.class, IImportDeclaration.class, ISourceFolder.class };
+ }
+
+ int getLimitTo() {
+ return IRubySearchConstants.DECLARATIONS | IRubySearchConstants.IGNORE_DECLARING_TYPE ;
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInProjectAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInProjectAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInProjectAction.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
+import org.rubypeople.rdt.internal.ui.search.RubySearchScopeFactory;
+import org.rubypeople.rdt.internal.ui.search.SearchMessages;
+import org.rubypeople.rdt.ui.search.ElementQuerySpecification;
+import org.rubypeople.rdt.ui.search.QuerySpecification;
+
+/**
+ * Finds declarations of the selected element in the enclosing project
+ * of the selected element.
+ * The action is applicable to selections representing a Ruby element.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 1.0
+ */
+public class FindDeclarationsInProjectAction extends FindDeclarationsAction {
+
+ /**
+ * Creates a new <code>FindDeclarationsInProjectAction</code>. The action
+ * requires that the selection provided by the site's selection provider is of type
+ * <code>IStructuredSelection</code>.
+ *
+ * @param site the site providing context information for this action
+ */
+ public FindDeclarationsInProjectAction(IWorkbenchSite site) {
+ super(site);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public FindDeclarationsInProjectAction(RubyEditor editor) {
+ super(editor);
+ }
+
+ void init() {
+ setText(SearchMessages.Search_FindDeclarationsInProjectAction_label);
+ setToolTipText(SearchMessages.Search_FindDeclarationsInProjectAction_tooltip);
+ setImageDescriptor(RubyPluginImages.DESC_OBJS_SEARCH_DECL);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FIND_DECLARATIONS_IN_PROJECT_ACTION);
+ }
+
+ QuerySpecification createQuery(IRubyElement element) throws RubyModelException {
+ RubySearchScopeFactory factory= RubySearchScopeFactory.getInstance();
+ RubyEditor editor= getEditor();
+
+ IRubySearchScope scope;
+ String description;
+ boolean isInsideJRE= true;
+ if (editor != null) {
+ scope= factory.createRubyProjectSearchScope(editor.getEditorInput(), isInsideJRE);
+ description= factory.getProjectScopeDescription(editor.getEditorInput(), isInsideJRE);
+ } else {
+ scope= factory.createRubyProjectSearchScope(element.getRubyProject(), isInsideJRE);
+ description= factory.getProjectScopeDescription(element.getRubyProject(), isInsideJRE);
+ }
+ return new ElementQuerySpecification(element, getLimitTo(), scope, description);
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInWorkingSetAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInWorkingSetAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindDeclarationsInWorkingSetAction.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.ui.actions;
+
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
+import org.rubypeople.rdt.internal.ui.search.RubySearchScopeFactory;
+import org.rubypeople.rdt.internal.ui.search.SearchMessages;
+import org.rubypeople.rdt.internal.ui.search.SearchUtil;
+import org.rubypeople.rdt.ui.search.ElementQuerySpecification;
+import org.rubypeople.rdt.ui.search.QuerySpecification;
+
+/**
+ * Finds declarations of the selected element in working sets.
+ * The action is applicable to selections representing a Ruby element.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 2.0
+ */
+public class FindDeclarationsInWorkingSetAction extends FindDeclarationsAction {
+
+ private IWorkingSet[] fWorkingSet;
+
+ /**
+ * Creates a new <code>FindDeclarationsInWorkingSetAction</code>. The action
+ * requires that the selection provided by the site's selection provider is of type
+ * <code>org.eclipse.jface.viewers.IStructuredSelection</code>. The user will be
+ * prompted to select the working sets.
+ *
+ * @param site the site providing context information for this action
+ */
+ public FindDeclarationsInWorkingSetAction(IWorkbenchSite site) {
+ this(site, null);
+ }
+
+ /**
+ * Creates a new <code>FindDeclarationsInWorkingSetAction</code>. The action
+ * requires that the selection provided by the site's selection provider is of type
+ * <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
+ *
+ * @param site the site providing context information for this action
+ * @param workingSets the working sets to be used in the search
+ */
+ public FindDeclarationsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
+ super(site);
+ fWorkingSet= workingSets;
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public FindDeclarationsInWorkingSetAction(RubyEditor editor) {
+ this(editor, null);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ *
+ * @param editor the Ruby editor
+ * @param workingSets the working sets to be used in the search
+ */
+ public FindDeclarationsInWorkingSetAction(RubyEditor editor, IWorkingSet[] workingSets) {
+ super(editor);
+ fWorkingSet= workingSets;
+ }
+
+ void init() {
+ setText(SearchMessages.Search_FindDeclarationsInWorkingSetAction_label);
+ setToolTipText(SearchMessages.Search_FindDeclarationsInWorkingSetAction_tooltip);
+ setImageDescriptor(RubyPluginImages.DESC_OBJS_SEARCH_DECL);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FIND_DECLARATIONS_IN_WORKING_SET_ACTION);
+ }
+
+ QuerySpecification createQuery(IRubyElement element) throws RubyModelException {
+ RubySearchScopeFactory factory= RubySearchScopeFactory.getInstance();
+
+ IWorkingSet[] workingSets= fWorkingSet;
+ if (fWorkingSet == null) {
+ workingSets= factory.queryWorkingSets();
+ if (workingSets == null)
+ return null;
+ }
+ SearchUtil.updateLRUWorkingSets(workingSets);
+ IRubySearchScope scope= factory.createRubySearchScope(workingSets, true);
+ String description= factory.getWorkingSetScopeDescription(workingSets, true);
+ return new ElementQuerySpecification(element, getLimitTo(), scope, description);
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java 2007-06-06 16:44:06 UTC (rev 2586)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -114,6 +114,22 @@
* @since 1.0
*/
public static final String SEARCH_OCCURRENCES_IN_FILE= "org.rubypeople.rdt.ui.edit.text.ruby.search.occurrences.in.file"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID of the search -> declarations in workspace action
+ * (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.declarations.in.workspace"</code>).
+ */
+ public static final String SEARCH_DECLARATIONS_IN_WORKSPACE= "org.rubypeople.rdt.ui.edit.text.ruby.search.declarations.in.workspace"; //$NON-NLS-1$
+ /**
+ * Action definition ID of the search -> declarations in project action
+ * (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.declarations.in.project"</code>).
+ */
+ public static final String SEARCH_DECLARATIONS_IN_PROJECTS= "org.rubypeople.rdt.ui.edit.text.ruby.search.declarations.in.project"; //$NON-NLS-1$
+ /**
+ * Action definition ID of the search -> declarations in working set action
+ * (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.declarations.in.working.set"</code>).
+ */
+ public static final String SEARCH_DECLARATIONS_IN_WORKING_SET= "org.rubypeople.rdt.ui.edit.text.ruby.search.declarations.in.working.set"; //$NON-NLS-1$
+
-
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java 2007-06-06 16:44:06 UTC (rev 2586)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -60,4 +60,23 @@
*/
public static final String FIND_OCCURRENCES_IN_FILE= "org.rubypeople.rdt.ui.actions.OccurrencesInFile"; //$NON-NLS-1$
+
+ /**
+ * Search menu: name of standard Find Declarations in Workspace global action
+ * (value <code>"org.rubypeople.rdt.ui.actions.DeclarationsInWorkspace"</code>).
+ */
+ public static final String FIND_DECLARATIONS_IN_WORKSPACE= "org.rubypeople.rdt.ui.actions.DeclarationsInWorkspace"; //$NON-NLS-1$
+
+ /**
+ * Search menu: name of standard Find Declarations in Project global action
+ * (value <code>"org.rubypeople.rdt.ui.actions.DeclarationsInProject"</code>).
+ */
+ public static final String FIND_DECLARATIONS_IN_PROJECT= "org.rubypeople.rdt.ui.actions.DeclarationsInProject"; //$NON-NLS-1$
+
+ /**
+ * Search menu: name of standard Find Declarations in Working Set global action
+ * (value <code>"org.rubypeople.rdt.ui.actions.DeclarationsInWorkingSet"</code>).
+ */
+ public static final String FIND_DECLARATIONS_IN_WORKING_SET= "org.rubypeople.rdt.ui.actions.DeclarationsInWorkingSet"; //$NON-NLS-1$
+
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RubySearchActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RubySearchActionGroup.java 2007-06-06 16:44:06 UTC (rev 2586)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RubySearchActionGroup.java 2007-06-07 20:46:45 UTC (rev 2587)
@@ -43,7 +43,7 @@
private ReferencesSearchGroup fReferencesGroup;
private ReadReferencesSearchGroup fReadAccessGroup;
// private WriteReferencesSearchGroup fWriteAccessGroup;
-// private DeclarationsSearchGroup fDeclarationsGroup;
+ private DeclarationsSearchGroup fDeclarationsGroup;
// private ImplementorsSearchGroup fImplementorsGroup;
private OccurrencesSearchGroup fOccurrencesGroup;
@@ -81,7 +81,7 @@
fReferencesGroup= new ReferencesSearchGroup(fEditor);
fReadAccessGroup= new ReadReferencesSearchGroup(fEditor);
// fWriteAccessGroup= new WriteReferencesSearchGroup(fEditor);
-// fDeclarationsGroup= new DeclarationsSearchGroup(fEditor);
+ fDeclarationsGroup= new DeclarationsSearchGroup(fEditor);
// fImplementorsGroup= new ImplementorsSearchGroup(fEditor);
fOccurrencesGroup= new OccurrencesSearchGroup(fEditor);
}
@@ -90,7 +90,7 @@
fReferencesGroup= new ReferencesSearchGroup(site);
fReadAccessGroup= new ReadReferencesSearchGroup(site);
// fWriteAccessGroup= new WriteReferencesSearchGroup(site);
-// fDeclarationsGroup= new DeclarationsSearchGroup(site);
+ fDeclarationsGroup= new DeclarationsSearchGroup(site);
// fImplementorsGroup= new ImplementorsSearchGroup(site);
fOccurrencesGroup= new OccurrencesSearchGroup(site);
}
@@ -100,7 +100,7 @@
*/
public void setContext(ActionContext context) {
fReferencesGroup.setContext(context);
-// fDeclarationsGroup.setContext(context);
+ fDeclarationsGroup.setContext(context);
// fImplementorsGroup.setContext(context);
fReadAccessGroup.setContext(context);
// fWriteAccessGroup.setContext(context);
@@ -113,7 +113,7 @@
public void fillActionBars(IActionBars actionBar) {
super.fillActionBars(actionBar);
fReferencesGroup.fillActionBars(actionBar);
-// fDeclarationsGroup.fillActionBars(actionBar);
+ fDeclarationsGroup.fillActionBars(actionBar);
// fImplementorsGroup.fillActionBars(actionBar);
fReadAccessGroup.fillActionBars(actionBar);
// fWriteAccessGroup.fillActionBars(actionBar);
@@ -128,7 +128,7 @@
if(PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.SEARCH_USE_REDUCED_MENU)) {
fReferencesGroup.fillContextMenu(menu);
-// fDeclarationsGroup.fillContextMenu(menu);
+ fDeclarationsGroup.fillContextMenu(menu);
if (fEditor == null) {
// fImplementorsGroup.fillContextMenu(menu);
@@ -146,7 +146,7 @@
}
fReferencesGroup.fillContextMenu(target);
-// fDeclarationsGroup.fillContextMenu(target);
+ fDeclarationsGroup.fillContextMenu(target);
// fImplementorsGroup.fillContextMenu(target);
fReadAccessGroup.fillContextMenu(target);
// fWriteAccessGroup.fillContextMenu(target);
@@ -168,7 +168,7 @@
*/
public void dispose() {
fReferencesGroup.dispose();
-// fDeclarationsGroup.dispose();
+ fDeclarationsGroup.dispose();
// fImplementorsGroup.dispose();
fReadAccessGroup.dispose();
// fWriteAccessGroup.dispose();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|