mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Removed FileSearchAction, FileSearchActionInWorkingSet + related properties
This commit is contained in:
parent
13677b0555
commit
66ef2bac23
6 changed files with 11 additions and 333 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
2004-05-12 Bogdan Gheorghe
|
||||||
|
|
||||||
|
Removed FileSearchAction, FileSearchActionInWorkingSet + related properties
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/FileSearchAction.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/FileSearchActionInWorkingSet.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties
|
||||||
|
* src/org/eclipse/cdt/internal/ui/CPluginResources.proerties
|
||||||
|
|
||||||
2004-05-11 Andrew Niefer
|
2004-05-11 Andrew Niefer
|
||||||
- content assist bug 60298:
|
- content assist bug 60298:
|
||||||
* src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java
|
* src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionEngine.java
|
||||||
|
|
|
@ -299,17 +299,6 @@ OpenIncludeAction.description=Open the selected include in the editor
|
||||||
OpenIncludeAction.dialog.title=Open Include
|
OpenIncludeAction.dialog.title=Open Include
|
||||||
OpenIncludeAction.dialog.message=Select the file to open
|
OpenIncludeAction.dialog.message=Select the file to open
|
||||||
|
|
||||||
# ------- FileSearchAction ---------------
|
|
||||||
FileSearchAction.label=Workspace
|
|
||||||
FileSearchAction.tooltip=Performs a text based file search for element in workspace
|
|
||||||
FileSearchAction.description=Performs a text based file search for element in workspace
|
|
||||||
|
|
||||||
# ------- FileSearchActionInWorkingSet ---------------
|
|
||||||
FileSearchActionInWorkingSet.label=Working Set...
|
|
||||||
FileSearchActionInWorkingSet.tooltip=Performs a text based file search for element in the selected working set
|
|
||||||
FileSearchActionInWorkingSet.description=Performs a text based file search for element in the selected working set
|
|
||||||
|
|
||||||
|
|
||||||
# ------- SearchDialogAction ---------------
|
# ------- SearchDialogAction ---------------
|
||||||
SearchDialogAction.label=C/C++ Search...
|
SearchDialogAction.label=C/C++ Search...
|
||||||
SearchDialogAction.tooltip=Opens C/C++ Search Dialog
|
SearchDialogAction.tooltip=Opens C/C++ Search Dialog
|
||||||
|
|
|
@ -44,7 +44,7 @@ ToggleLinkingAction.toolTip=Link with Editor
|
||||||
ToggleLinkingAction.description=Link with active editor
|
ToggleLinkingAction.description=Link with active editor
|
||||||
|
|
||||||
SearchAction.label=Search For
|
SearchAction.label=Search For
|
||||||
FileSearchAction.label=Search
|
|
||||||
|
|
||||||
FilterSelectionAction.label= Filters ...
|
FilterSelectionAction.label= Filters ...
|
||||||
ShowLibrariesAction.label = Show Reference Libs
|
ShowLibrariesAction.label = Show Reference Libs
|
||||||
|
|
|
@ -13,10 +13,7 @@ package org.eclipse.cdt.internal.ui.cview;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||||
import org.eclipse.cdt.internal.ui.editor.FileSearchAction;
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.FileSearchActionInWorkingSet;
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
|
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
|
||||||
import org.eclipse.cdt.internal.ui.editor.SearchDialogAction;
|
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||||
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
|
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
|
||||||
import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
|
import org.eclipse.cdt.ui.actions.RefactoringActionGroup;
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (c) Copyright QNX Software Systems Ltd. 2002.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.List;
|
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
|
||||||
import org.eclipse.jface.operation.IRunnableContext;
|
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
//import org.eclipse.search.internal.core.text.TextSearchEngine;
|
|
||||||
import org.eclipse.search.internal.core.text.TextSearchScope;
|
|
||||||
import org.eclipse.search.internal.ui.text.TextSearchOperation;
|
|
||||||
import org.eclipse.search.internal.ui.text.TextSearchResultCollector;
|
|
||||||
import org.eclipse.search.internal.ui.util.ExceptionHandler;
|
|
||||||
import org.eclipse.search.ui.SearchUI;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.IEditorDescriptor;
|
|
||||||
import org.eclipse.ui.IEditorRegistry;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class FileSearchAction extends Action {
|
|
||||||
|
|
||||||
|
|
||||||
private static final String PREFIX= "FileSearchAction."; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private ISelectionProvider fSelectionProvider;
|
|
||||||
|
|
||||||
public FileSearchAction(ISelectionProvider provider) {
|
|
||||||
super(CUIPlugin.getResourceString(PREFIX + "label")); //$NON-NLS-1$
|
|
||||||
setDescription(CUIPlugin.getResourceString(PREFIX + "description")); //$NON-NLS-1$
|
|
||||||
setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip")); //$NON-NLS-1$
|
|
||||||
|
|
||||||
if(provider instanceof CContentOutlinePage) {
|
|
||||||
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
|
|
||||||
//setText("Search for References"); // $NON-NLS
|
|
||||||
}
|
|
||||||
|
|
||||||
fSelectionProvider= provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
String search_name;
|
|
||||||
|
|
||||||
ISelection selection= fSelectionProvider.getSelection();
|
|
||||||
if(selection instanceof ITextSelection) {
|
|
||||||
search_name = ((ITextSelection)selection).getText();
|
|
||||||
if(search_name.length() == 0) return;
|
|
||||||
} else {
|
|
||||||
ICElement element= getElement(selection);
|
|
||||||
if (element == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
search_name = element.getElementName();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @@@ we rely on the internal functions of the Search plugin, since
|
|
||||||
// none of these are actually exported. This is probably going to change
|
|
||||||
// with 2.0.
|
|
||||||
TextSearchResultCollector col = new TextSearchResultCollector();
|
|
||||||
try {
|
|
||||||
//TextSearchPage
|
|
||||||
//ProgressMonitor monitor = new ProgressMonitor();
|
|
||||||
//col.setProgressMonitor(monitor)
|
|
||||||
SearchUI.activateSearchResultView();
|
|
||||||
//col.aboutToStart();
|
|
||||||
|
|
||||||
// We now have the element, start a search on the string
|
|
||||||
//TextSearchEngine engine = new TextSearchEngine();
|
|
||||||
TextSearchScope scope= TextSearchScope.newWorkspaceScope();
|
|
||||||
// Add the extensions from the C editor definition for now
|
|
||||||
// FIXME: For C/C++ not all files rely on extension to be C++ for <cstring>
|
|
||||||
String[] patterns = CoreModel.getDefault().getTranslationUnitExtensions();
|
|
||||||
for (int i = 0; i < patterns.length; i++) {
|
|
||||||
//scope.addExtension("*." + cexts[i]); //$NON-NLS-1$
|
|
||||||
scope.addExtension(patterns[i]);
|
|
||||||
}
|
|
||||||
// scope.addExtension("*.c");
|
|
||||||
// scope.addExtension("*.h");
|
|
||||||
// scope.addExtension("*.cc");
|
|
||||||
// scope.addExtension("*.hh");
|
|
||||||
|
|
||||||
TextSearchOperation op= new TextSearchOperation(
|
|
||||||
CUIPlugin.getWorkspace(),
|
|
||||||
search_name,
|
|
||||||
"", //$NON-NLS-1$
|
|
||||||
scope,
|
|
||||||
col);
|
|
||||||
|
|
||||||
|
|
||||||
//engine.search(CUIPlugin.getWorkspace(), element.getName(),
|
|
||||||
// null, scope, col);
|
|
||||||
IRunnableContext context= null;
|
|
||||||
//context= getContainer().getRunnableContext();
|
|
||||||
|
|
||||||
Shell shell= new Shell(); // getShell();
|
|
||||||
if (context == null)
|
|
||||||
context= new ProgressMonitorDialog(shell);
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
context.run(true, true, op);
|
|
||||||
} catch (InvocationTargetException ex) {
|
|
||||||
ExceptionHandler.handle(ex, "Error","Error"); //$NON-NLS-2$ //$NON-NLS-1$
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
} catch (Exception e) {}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static ICElement getElement(ISelection sel) {
|
|
||||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
|
||||||
List list= ((IStructuredSelection)sel).toList();
|
|
||||||
if (list.size() == 1) {
|
|
||||||
Object element= list.get(0);
|
|
||||||
if (element instanceof ICElement) {
|
|
||||||
return (ICElement)element;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canActionBeAdded(ISelection selection) {
|
|
||||||
if(selection instanceof ITextSelection) {
|
|
||||||
return (((ITextSelection)selection).getLength() > 0);
|
|
||||||
} else {
|
|
||||||
return getElement(selection) != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String getEditorID(String name) {
|
|
||||||
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
|
||||||
if (registry != null) {
|
|
||||||
IEditorDescriptor descriptor = registry.getDefaultEditor(name);
|
|
||||||
if (descriptor != null) {
|
|
||||||
return descriptor.getId();
|
|
||||||
} else {
|
|
||||||
return registry.getDefaultEditor().getId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,157 +0,0 @@
|
||||||
/*
|
|
||||||
* Created on Sep 9, 2003
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
|
||||||
import org.eclipse.cdt.internal.ui.search.CSearchScopeFactory;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
|
||||||
import org.eclipse.jface.operation.IRunnableContext;
|
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.search.internal.core.SearchScope;
|
|
||||||
import org.eclipse.search.internal.ui.text.TextSearchOperation;
|
|
||||||
import org.eclipse.search.internal.ui.text.TextSearchResultCollector;
|
|
||||||
import org.eclipse.search.internal.ui.util.ExceptionHandler;
|
|
||||||
import org.eclipse.search.ui.SearchUI;
|
|
||||||
import org.eclipse.swt.widgets.Shell;
|
|
||||||
import org.eclipse.ui.IEditorDescriptor;
|
|
||||||
import org.eclipse.ui.IEditorRegistry;
|
|
||||||
import org.eclipse.ui.IWorkingSet;
|
|
||||||
import org.eclipse.ui.PlatformUI;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author bgheorgh
|
|
||||||
*/
|
|
||||||
public class FileSearchActionInWorkingSet extends Action {
|
|
||||||
|
|
||||||
|
|
||||||
private static final String PREFIX= "FileSearchActionInWorkingSet."; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private ISelectionProvider fSelectionProvider;
|
|
||||||
|
|
||||||
public FileSearchActionInWorkingSet(ISelectionProvider provider) {
|
|
||||||
super(CUIPlugin.getResourceString(PREFIX + "label")); //$NON-NLS-1$
|
|
||||||
setDescription(CUIPlugin.getResourceString(PREFIX + "description")); //$NON-NLS-1$
|
|
||||||
setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip")); //$NON-NLS-1$
|
|
||||||
|
|
||||||
if(provider instanceof CContentOutlinePage) {
|
|
||||||
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
fSelectionProvider= provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
String search_name;
|
|
||||||
|
|
||||||
ISelection selection= fSelectionProvider.getSelection();
|
|
||||||
if(selection instanceof ITextSelection) {
|
|
||||||
search_name = ((ITextSelection)selection).getText();
|
|
||||||
if(search_name.length() == 0) return;
|
|
||||||
} else {
|
|
||||||
ICElement element= getElement(selection);
|
|
||||||
if (element == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
search_name = element.getElementName();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @@@ we rely on the internal functions of the Search plugin, since
|
|
||||||
// none of these are actually exported. This is probably going to change
|
|
||||||
// with 2.0.
|
|
||||||
TextSearchResultCollector col = new TextSearchResultCollector();
|
|
||||||
try {
|
|
||||||
SearchUI.activateSearchResultView();
|
|
||||||
|
|
||||||
IWorkingSet[] workingSets= CSearchScopeFactory.getInstance().queryWorkingSets();
|
|
||||||
ArrayList resourceList = new ArrayList();
|
|
||||||
for (int i=0; i<workingSets.length; i++){
|
|
||||||
IAdaptable[] elements = workingSets[i].getElements();
|
|
||||||
|
|
||||||
for (int j=0; j< elements.length; j++){
|
|
||||||
IResource resource= (IResource)elements[j].getAdapter(IResource.class);
|
|
||||||
if (resource != null){
|
|
||||||
resourceList.add(resource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IResource[] result = new IResource[resourceList.size()];
|
|
||||||
resourceList.toArray(result);
|
|
||||||
|
|
||||||
SearchScope scope= new SearchScope("File Search", result); //$NON-NLS-1$
|
|
||||||
|
|
||||||
|
|
||||||
TextSearchOperation op= new TextSearchOperation(
|
|
||||||
CUIPlugin.getWorkspace(),
|
|
||||||
search_name,
|
|
||||||
"", //$NON-NLS-1$
|
|
||||||
scope,
|
|
||||||
col);
|
|
||||||
|
|
||||||
IRunnableContext context= null;
|
|
||||||
|
|
||||||
Shell shell= new Shell(); // getShell();
|
|
||||||
if (context == null)
|
|
||||||
context= new ProgressMonitorDialog(shell);
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
context.run(true, true, op);
|
|
||||||
} catch (InvocationTargetException ex) {
|
|
||||||
ExceptionHandler.handle(ex, "Error","Error"); //$NON-NLS-2$ //$NON-NLS-1$
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
} catch (Exception e) {}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static ICElement getElement(ISelection sel) {
|
|
||||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
|
||||||
List list= ((IStructuredSelection)sel).toList();
|
|
||||||
if (list.size() == 1) {
|
|
||||||
Object element= list.get(0);
|
|
||||||
if (element instanceof ICElement) {
|
|
||||||
return (ICElement)element;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canActionBeAdded(ISelection selection) {
|
|
||||||
if(selection instanceof ITextSelection) {
|
|
||||||
return (((ITextSelection)selection).getLength() > 0);
|
|
||||||
} else {
|
|
||||||
return getElement(selection) != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String getEditorID(String name) {
|
|
||||||
IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
|
||||||
if (registry != null) {
|
|
||||||
IEditorDescriptor descriptor = registry.getDefaultEditor(name);
|
|
||||||
if (descriptor != null) {
|
|
||||||
return descriptor.getId();
|
|
||||||
} else {
|
|
||||||
return registry.getDefaultEditor().getId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue