|
From: <caw...@us...> - 2007-06-07 20:57:26
|
Revision: 2588
http://svn.sourceforge.net/rubyeclipse/?rev=2588&view=rev
Author: cawilliams
Date: 2007-06-07 13:57:17 -0700 (Thu, 07 Jun 2007)
Log Message:
-----------
add search for write references
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/FindWriteReferencesAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesInProjectAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesInWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/WriteReferencesSearchGroup.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-07 20:46:45 UTC (rev 2587)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -132,6 +132,7 @@
public static String group_search;
public static String group_occurrences;
public static String group_declarations;
+ public static String group_writeReferences;
public static String RubyElementAction_operationUnavailable_title;
public static String RubyElementAction_operationUnavailable_generic;
@@ -183,6 +184,13 @@
public static String Search_FindDeclarationsInWorkingSetAction_label;
public static String Search_FindDeclarationsInWorkingSetAction_tooltip;
+ public static String Search_FindWriteReferencesAction_label;
+ public static String Search_FindWriteReferencesAction_tooltip;
+ public static String Search_FindWriteReferencesInWorkingSetAction_label;
+ public static String Search_FindWriteReferencesInWorkingSetAction_tooltip;
+ public static String Search_FindWriteReferencesInProjectAction_label;
+ public static String Search_FindWriteReferencesInProjectAction_tooltip;
+
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-07 20:46:45 UTC (rev 2587)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/SearchMessages.properties 2007-06-07 20:57:17 UTC (rev 2588)
@@ -82,6 +82,7 @@
group_declarations= Dec&larations
group_references= Re&ferences
group_readReferences= &Read Access
+group_writeReferences= &Write Access
group_occurrences= Occurre&nces in File
RubyElementAction_operationUnavailable_title= Operation Unavailable
@@ -117,7 +118,6 @@
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
@@ -136,6 +136,15 @@
Search_FindReadReferencesInWorkingSetAction_label= Working &Set...
Search_FindReadReferencesInWorkingSetAction_tooltip= Search for Read References to the Selected Element in a Working Set
+Search_FindWriteReferencesAction_label= &Workspace
+Search_FindWriteReferencesAction_tooltip= Search for Write References to the Selected Element in the Workspace
+
+Search_FindWriteReferencesInProjectAction_label= &Project
+Search_FindWriteReferencesInProjectAction_tooltip= Search for Write References to the Selected Element in Resources in the Enclosing Project of the Selected Element
+
+Search_FindWriteReferencesInWorkingSetAction_label= Working &Set...
+Search_FindWriteReferencesInWorkingSetAction_tooltip= Search for Write References to the Selected Element in a Working Set
+
Search_FindOccurrencesInFile_shortLabel= &Identifier
Search_FindOccurrencesInFile_label= I&dentifiers in File
Search_FindOccurrencesInFile_tooltip= Find Occurrences of the Selected Element in the Editor
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesAction.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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 org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IField;
+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 field write accesses 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 2.0
+ */
+public class FindWriteReferencesAction extends FindReferencesAction {
+
+ /**
+ * Creates a new <code>FindWriteReferencesAction</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 FindWriteReferencesAction(IWorkbenchSite site) {
+ super(site);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public FindWriteReferencesAction(RubyEditor editor) {
+ super(editor);
+ }
+
+ Class[] getValidTypes() {
+ return new Class[] { IField.class };
+ }
+
+ void init() {
+ setText(SearchMessages.Search_FindWriteReferencesAction_label);
+ setToolTipText(SearchMessages.Search_FindWriteReferencesAction_tooltip);
+ setImageDescriptor(RubyPluginImages.DESC_OBJS_SEARCH_REF);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FIND_WRITE_REFERENCES_IN_WORKSPACE_ACTION);
+ }
+
+ int getLimitTo() {
+ return IRubySearchConstants.WRITE_ACCESSES;
+ }
+
+ String getOperationUnavailableMessage() {
+ return SearchMessages.RubyElementAction_operationUnavailable_field;
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesInProjectAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesInProjectAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesInProjectAction.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -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 field write accesses of the selected element in the enclosing project.
+ * The action is applicable to selections representing a Ruby field.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 3.0
+ */
+public class FindWriteReferencesInProjectAction extends FindWriteReferencesAction {
+
+ /**
+ * Creates a new <code>FindWriteReferencesInProjectAction</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 FindWriteReferencesInProjectAction(IWorkbenchSite site) {
+ super(site);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public FindWriteReferencesInProjectAction(RubyEditor editor) {
+ super(editor);
+ }
+
+ void init() {
+ setText(SearchMessages.Search_FindWriteReferencesInProjectAction_label);
+ setToolTipText(SearchMessages.Search_FindWriteReferencesInProjectAction_tooltip);
+ setImageDescriptor(RubyPluginImages.DESC_OBJS_SEARCH_REF);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FIND_WRITE_REFERENCES_IN_PROJECT_ACTION);
+ }
+
+ QuerySpecification createQuery(IRubyElement element) throws RubyModelException {
+ RubySearchScopeFactory factory= RubySearchScopeFactory.getInstance();
+ RubyEditor editor= getEditor();
+
+ IRubySearchScope scope;
+ String description;
+ boolean isInsideJRE= factory.isInsideJRE(element);
+ 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/FindWriteReferencesInWorkingSetAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesInWorkingSetAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/FindWriteReferencesInWorkingSetAction.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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 org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IField;
+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 field write accesses of the selected element in working sets.
+ * The action is applicable to selections representing a Ruby field.
+ *
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 2.0
+ */
+public class FindWriteReferencesInWorkingSetAction extends FindReferencesInWorkingSetAction {
+
+ /**
+ * Creates a new <code>FindWriteReferencesInWorkingSetAction</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 FindWriteReferencesInWorkingSetAction(IWorkbenchSite site) {
+ super(site);
+ }
+
+ /**
+ * Creates a new <code>FindWriteReferencesInWorkingSetAction</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 FindWriteReferencesInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
+ super(site, workingSets);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public FindWriteReferencesInWorkingSetAction(RubyEditor editor) {
+ super(editor);
+ }
+
+ /**
+ * 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 FindWriteReferencesInWorkingSetAction(RubyEditor editor, IWorkingSet[] workingSets) {
+ super(editor, workingSets);
+ }
+
+ Class[] getValidTypes() {
+ return new Class[] { IField.class };
+ }
+
+ void init() {
+ setText(SearchMessages.Search_FindWriteReferencesInWorkingSetAction_label);
+ setToolTipText(SearchMessages.Search_FindWriteReferencesInWorkingSetAction_tooltip);
+ setImageDescriptor(RubyPluginImages.DESC_OBJS_SEARCH_REF);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FIND_WRITE_REFERENCES_IN_WORKING_SET_ACTION);
+ }
+
+ int getLimitTo() {
+ return IRubySearchConstants.WRITE_ACCESSES;
+ }
+
+ String getOperationUnavailableMessage() {
+ return SearchMessages.RubyElementAction_operationUnavailable_field;
+ }
+}
+
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-07 20:46:45 UTC (rev 2587)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -116,6 +116,24 @@
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 -> write access in workspace action
+ * (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.write.access.in.workspace"</code>).
+ */
+ public static final String SEARCH_WRITE_ACCESS_IN_WORKSPACE= "org.rubypeople.rdt.ui.edit.text.ruby.search.write.access.in.workspace"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID of the search -> write access in project action
+ * (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.write.access.in.project"</code>).
+ */
+ public static final String SEARCH_WRITE_ACCESS_IN_PROJECT= "org.rubypeople.rdt.ui.edit.text.ruby.search.write.access.in.project"; //$NON-NLS-1$
+
+ /**
+ * Action definition ID of the search -> write access in working set action
+ * (value <code>"org.rubypeople.rdt.ui.edit.text.ruby.search.write.access.in.working.set"</code>).
+ */
+ public static final String SEARCH_WRITE_ACCESS_IN_WORKING_SET= "org.rubypeople.rdt.ui.edit.text.ruby.search.write.access.in.working.set"; //$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>).
*/
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-07 20:46:45 UTC (rev 2587)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RdtActionConstants.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -60,7 +60,6 @@
*/
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>).
@@ -79,4 +78,23 @@
*/
public static final String FIND_DECLARATIONS_IN_WORKING_SET= "org.rubypeople.rdt.ui.actions.DeclarationsInWorkingSet"; //$NON-NLS-1$
+ /**
+ * Search menu: name of standard Find Write Access in Workspace global action
+ * (value <code>"org.rubypeople.rdt.ui.actions.WriteAccessInWorkspace"</code>).
+ */
+ public static final String FIND_WRITE_ACCESS_IN_WORKSPACE= "org.rubypeople.rdt.ui.actions.WriteAccessInWorkspace"; //$NON-NLS-1$
+
+ /**
+ * Search menu: name of standard Find Write Access in Project global action
+ * (value <code>"org.rubypeople.rdt.ui.actions.WriteAccessInProject"</code>).
+ */
+ public static final String FIND_WRITE_ACCESS_IN_PROJECT= "org.rubypeople.rdt.ui.actions.WriteAccessInProject"; //$NON-NLS-1$
+
+ /**
+ * Search menu: name of standard Find Read Access in Working Set global action
+ * (value <code>"org.rubypeople.rdt.ui.actions.WriteAccessInWorkingSet"</code>).
+ */
+ public static final String FIND_WRITE_ACCESS_IN_WORKING_SET= "org.rubypeople.rdt.ui.actions.WriteAccessInWorkingSet"; //$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-07 20:46:45 UTC (rev 2587)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/RubySearchActionGroup.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -42,7 +42,7 @@
private ReferencesSearchGroup fReferencesGroup;
private ReadReferencesSearchGroup fReadAccessGroup;
-// private WriteReferencesSearchGroup fWriteAccessGroup;
+ private WriteReferencesSearchGroup fWriteAccessGroup;
private DeclarationsSearchGroup fDeclarationsGroup;
// private ImplementorsSearchGroup fImplementorsGroup;
private OccurrencesSearchGroup fOccurrencesGroup;
@@ -80,7 +80,7 @@
fReferencesGroup= new ReferencesSearchGroup(fEditor);
fReadAccessGroup= new ReadReferencesSearchGroup(fEditor);
-// fWriteAccessGroup= new WriteReferencesSearchGroup(fEditor);
+ fWriteAccessGroup= new WriteReferencesSearchGroup(fEditor);
fDeclarationsGroup= new DeclarationsSearchGroup(fEditor);
// fImplementorsGroup= new ImplementorsSearchGroup(fEditor);
fOccurrencesGroup= new OccurrencesSearchGroup(fEditor);
@@ -89,7 +89,7 @@
private RubySearchActionGroup(IWorkbenchSite site) {
fReferencesGroup= new ReferencesSearchGroup(site);
fReadAccessGroup= new ReadReferencesSearchGroup(site);
-// fWriteAccessGroup= new WriteReferencesSearchGroup(site);
+ fWriteAccessGroup= new WriteReferencesSearchGroup(site);
fDeclarationsGroup= new DeclarationsSearchGroup(site);
// fImplementorsGroup= new ImplementorsSearchGroup(site);
fOccurrencesGroup= new OccurrencesSearchGroup(site);
@@ -103,7 +103,7 @@
fDeclarationsGroup.setContext(context);
// fImplementorsGroup.setContext(context);
fReadAccessGroup.setContext(context);
-// fWriteAccessGroup.setContext(context);
+ fWriteAccessGroup.setContext(context);
fOccurrencesGroup.setContext(context);
}
@@ -116,7 +116,7 @@
fDeclarationsGroup.fillActionBars(actionBar);
// fImplementorsGroup.fillActionBars(actionBar);
fReadAccessGroup.fillActionBars(actionBar);
-// fWriteAccessGroup.fillActionBars(actionBar);
+ fWriteAccessGroup.fillActionBars(actionBar);
fOccurrencesGroup.fillActionBars(actionBar);
}
@@ -133,7 +133,7 @@
if (fEditor == null) {
// fImplementorsGroup.fillContextMenu(menu);
fReadAccessGroup.fillContextMenu(menu);
-// fWriteAccessGroup.fillContextMenu(menu);
+ fWriteAccessGroup.fillContextMenu(menu);
}
} else {
IMenuManager target= menu;
@@ -149,7 +149,7 @@
fDeclarationsGroup.fillContextMenu(target);
// fImplementorsGroup.fillContextMenu(target);
fReadAccessGroup.fillContextMenu(target);
-// fWriteAccessGroup.fillContextMenu(target);
+ fWriteAccessGroup.fillContextMenu(target);
if (searchSubMenu != null) {
fOccurrencesGroup.fillContextMenu(target);
@@ -171,7 +171,7 @@
fDeclarationsGroup.dispose();
// fImplementorsGroup.dispose();
fReadAccessGroup.dispose();
-// fWriteAccessGroup.dispose();
+ fWriteAccessGroup.dispose();
fOccurrencesGroup.dispose();
super.dispose();
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/WriteReferencesSearchGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/WriteReferencesSearchGroup.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/WriteReferencesSearchGroup.java 2007-06-07 20:57:17 UTC (rev 2588)
@@ -0,0 +1,201 @@
+/*******************************************************************************
+ * 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 write references 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 2.0
+ */
+public class WriteReferencesSearchGroup extends ActionGroup {
+
+ private static final String MENU_TEXT= SearchMessages.group_writeReferences;
+
+ private IWorkbenchSite fSite;
+ private RubyEditor fEditor;
+ private IActionBars fActionBars;
+
+ private String fGroupId;
+
+ private FindWriteReferencesAction fFindWriteReferencesAction;
+ private FindWriteReferencesInProjectAction fFindWriteReferencesInProjectAction;
+// private FindWriteReferencesInHierarchyAction fFindWriteReferencesInHierarchyAction;
+ private FindWriteReferencesInWorkingSetAction fFindWriteReferencesInWorkingSetAction;
+
+ /**
+ * Creates a new <code>WriteReferencesSearchGroup</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 view part that owns this action group
+ */
+ public WriteReferencesSearchGroup(IWorkbenchSite site) {
+ fSite= site;
+ fGroupId= IContextMenuConstants.GROUP_SEARCH;
+
+ fFindWriteReferencesAction= new FindWriteReferencesAction(site);
+ fFindWriteReferencesAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKSPACE);
+
+ fFindWriteReferencesInProjectAction= new FindWriteReferencesInProjectAction(site);
+ fFindWriteReferencesInProjectAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_PROJECT);
+
+// fFindWriteReferencesInHierarchyAction= new FindWriteReferencesInHierarchyAction(site);
+// fFindWriteReferencesInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_HIERARCHY);
+
+ fFindWriteReferencesInWorkingSetAction= new FindWriteReferencesInWorkingSetAction(site);
+ fFindWriteReferencesInWorkingSetAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKING_SET);
+
+ // register the actions as selection listeners
+ ISelectionProvider provider= fSite.getSelectionProvider();
+ ISelection selection= provider.getSelection();
+ registerAction(fFindWriteReferencesAction, provider, selection);
+ registerAction(fFindWriteReferencesInProjectAction, provider, selection);
+// registerAction(fFindWriteReferencesInHierarchyAction, provider, selection);
+ registerAction(fFindWriteReferencesInWorkingSetAction, provider, selection);
+ }
+
+ /**
+ * Note: This constructor is for internal use only. Clients should not call this constructor.
+ * @param editor the Ruby editor
+ */
+ public WriteReferencesSearchGroup(RubyEditor editor) {
+ fEditor= editor;
+ fSite= fEditor.getSite();
+ fGroupId= ITextEditorActionConstants.GROUP_FIND;
+
+ fFindWriteReferencesAction= new FindWriteReferencesAction(fEditor);
+ fFindWriteReferencesAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKSPACE);
+ fEditor.setAction("SearchWriteAccessInWorkspace", fFindWriteReferencesAction); //$NON-NLS-1$
+
+ fFindWriteReferencesInProjectAction= new FindWriteReferencesInProjectAction(fEditor);
+ fFindWriteReferencesInProjectAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_PROJECT);
+ fEditor.setAction("SearchWriteAccessInProject", fFindWriteReferencesInProjectAction); //$NON-NLS-1$
+
+// fFindWriteReferencesInHierarchyAction= new FindWriteReferencesInHierarchyAction(fEditor);
+// fFindWriteReferencesInHierarchyAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_HIERARCHY);
+// fEditor.setAction("SearchWriteAccessInHierarchy", fFindWriteReferencesInHierarchyAction); //$NON-NLS-1$
+
+ fFindWriteReferencesInWorkingSetAction= new FindWriteReferencesInWorkingSetAction(fEditor);
+ fFindWriteReferencesInWorkingSetAction.setActionDefinitionId(IRubyEditorActionDefinitionIds.SEARCH_WRITE_ACCESS_IN_WORKING_SET);
+ fEditor.setAction("SearchWriteAccessInWorkingSet", fFindWriteReferencesInWorkingSetAction); //$NON-NLS-1$
+ }
+
+ private void registerAction(SelectionDispatchAction action, ISelectionProvider provider, ISelection selection) {
+ action.update(selection);
+ provider.addSelectionChangedListener(action);
+ }
+
+ 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 FindWriteReferencesInWorkingSetAction(fEditor, workingSets), SearchUtil.toString(workingSets));
+ else
+ action= new WorkingSetFindAction(fSite, new FindWriteReferencesInWorkingSetAction(fSite, workingSets), SearchUtil.toString(workingSets));
+ action.update(getContext().getSelection());
+ addAction(action, manager);
+ }
+
+
+ /* (non-Rubydoc)
+ * Method declared on ActionGroup.
+ */
+ public void fillContextMenu(IMenuManager manager) {
+ MenuManager javaSearchMM= new MenuManager(MENU_TEXT, IContextMenuConstants.GROUP_SEARCH);
+ addAction(fFindWriteReferencesAction, javaSearchMM);
+ addAction(fFindWriteReferencesInProjectAction, javaSearchMM);
+// addAction(fFindWriteReferencesInHierarchyAction, javaSearchMM);
+
+ javaSearchMM.add(new Separator());
+
+ Iterator iter= SearchUtil.getLRUWorkingSets().sortedIterator();
+ while (iter.hasNext()) {
+ addWorkingSetAction((IWorkingSet[]) iter.next(), javaSearchMM);
+ }
+ addAction(fFindWriteReferencesInWorkingSetAction, javaSearchMM);
+
+ if (!javaSearchMM.isEmpty())
+ manager.appendToGroup(fGroupId, javaSearchMM);
+ }
+
+ /*
+ * Method declared on ActionGroup.
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ Assert.isNotNull(actionBars);
+ super.fillActionBars(actionBars);
+ fActionBars= actionBars;
+ updateGlobalActionHandlers();
+ }
+
+ /*
+ * Method declared on ActionGroup.
+ */
+ public void dispose() {
+ ISelectionProvider provider= fSite.getSelectionProvider();
+ if (provider != null) {
+ disposeAction(fFindWriteReferencesAction, provider);
+ disposeAction(fFindWriteReferencesInProjectAction, provider);
+// disposeAction(fFindWriteReferencesInHierarchyAction, provider);
+ disposeAction(fFindWriteReferencesInWorkingSetAction, provider);
+ }
+ fFindWriteReferencesAction= null;
+ fFindWriteReferencesInProjectAction= null;
+// fFindWriteReferencesInHierarchyAction= null;
+ fFindWriteReferencesInWorkingSetAction= null;
+ updateGlobalActionHandlers();
+ super.dispose();
+ }
+
+ private void updateGlobalActionHandlers() {
+ if (fActionBars != null) {
+ fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_WRITE_ACCESS_IN_WORKSPACE, fFindWriteReferencesAction);
+ fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_WRITE_ACCESS_IN_PROJECT, fFindWriteReferencesInProjectAction);
+// fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_WRITE_ACCESS_IN_HIERARCHY, fFindWriteReferencesInHierarchyAction);
+ fActionBars.setGlobalActionHandler(RdtActionConstants.FIND_WRITE_ACCESS_IN_WORKING_SET, fFindWriteReferencesInWorkingSetAction);
+ }
+ }
+
+ private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
+ if (action != null)
+ provider.removeSelectionChangedListener(action);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|