mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-03 14:25:37 +02:00
Patch for Bogdan:
UI - This patch changes the search context menu in the CEditor, CContentPage and CView: Search > C/C++ Search... File Search > Workspace WorkingSets - C/C++ Search pops up the search dialog with the chosen element filled out. - File Search does a text based file search on the Workspace or a chosen WorkingSet Core - Added some error checking to the dependency generator.
This commit is contained in:
parent
af12903eaa
commit
b3898357e2
12 changed files with 292 additions and 20 deletions
|
@ -1,3 +1,7 @@
|
|||
2003-09-11 Bogdan Gheorghe
|
||||
- Added null guard to DependencyManager.getDependencyTree(),
|
||||
DependencyTree.getFileDependencies()
|
||||
|
||||
2003-09-08 Andrew Niefer
|
||||
- Modified calls to ParserFactory to specify which language to use
|
||||
- Modified IDependencyTree.add to take ParserLanguage as a parameter so that it can
|
||||
|
@ -24,5 +28,5 @@
|
|||
* src/org/eclipse/cdt/internal/core/sourcedependency/impl/InMemoryTree.java
|
||||
* src/org/eclipse/cdt/internal/core/sourcedependency/impl/Node.java
|
||||
|
||||
|
||||
-
|
||||
|
|
@ -98,10 +98,12 @@ public class DependencyManager extends JobManager implements ISourceDependency {
|
|||
IPath path =project.getFullPath();
|
||||
IDependencyTree dTree= this.getDependencyTree(path,true,false);
|
||||
try{
|
||||
if (dTree != null) {
|
||||
//dTree.printIncludeEntries();
|
||||
//dTree.printIndexedFiles();
|
||||
String[] files = dTree.getFileDependencies(file.getFullPath());
|
||||
return files;
|
||||
}
|
||||
}
|
||||
catch(Exception e){}
|
||||
return null;
|
||||
|
|
|
@ -145,6 +145,10 @@ public class DependencyTree implements IDependencyTree {
|
|||
public String[] getFileDependencies(IPath filePath) throws IOException {
|
||||
List tempFileReturn = new ArrayList();
|
||||
IndexedFile indexFile = addsTree.getIndexedFile(filePath.toString());
|
||||
|
||||
if (indexFile == null)
|
||||
return new String[0];
|
||||
|
||||
int fileNum = indexFile.getFileNumber();
|
||||
IncludeEntry[] tempEntries = addsTree.getIncludeEntries();
|
||||
for (int i=0; i<tempEntries.length; i++)
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2003-09-11 Bogdan Gheorghe
|
||||
- Added Search Menu to CView.java
|
||||
- Added queryWorkingSets to CSearchScopeFactory to bring up the working
|
||||
set dialog
|
||||
- Modified Search Menu in CEditor.java, CContentOutlinePage.java
|
||||
- Added new action FileSearchActionInWorkingSet
|
||||
- Modified actions FileSearchAction, SearchDialogAction
|
||||
|
||||
2003-09-10 Sean Evoy
|
||||
Work completed to resolve [Bug 41412] Restore Default in Managed Build
|
||||
project's settings Not Working. Added an event handler to reset the selected
|
||||
|
|
|
@ -293,13 +293,19 @@ OpenIncludeAction.description=Open the selected include in the editor
|
|||
OpenIncludeAction.dialog.title=Open Include
|
||||
OpenIncludeAction.dialog.message=Select the file to open
|
||||
|
||||
# ------- SearchForReferencesAction ---------------
|
||||
SearchForReferencesAction.label=File Search
|
||||
SearchForReferencesAction.tooltip=Performs a text based file search for element in workspace
|
||||
SearchForReferencesAction.description=Performs a text based file search for element in workspace
|
||||
# ------- 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.label=C/C++ Search Dialog
|
||||
SearchDialogAction.label=C/C++ Search Dialog...
|
||||
SearchDialogAction.tooltip=Opens C/C++ Search Dialog
|
||||
SearchDialogAction.description=Opens C/C++ Search Dialog
|
||||
|
||||
|
|
|
@ -21,8 +21,14 @@ import org.eclipse.cdt.core.model.IParent;
|
|||
import org.eclipse.cdt.core.model.ISourceReference;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.resources.MakeUtil;
|
||||
import org.eclipse.cdt.internal.core.model.CProject;
|
||||
import org.eclipse.cdt.internal.core.model.TranslationUnit;
|
||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
|
||||
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.SearchDialogAction;
|
||||
import org.eclipse.cdt.internal.ui.makeview.MakeAction;
|
||||
import org.eclipse.cdt.internal.ui.makeview.MakeTarget;
|
||||
import org.eclipse.cdt.internal.ui.makeview.MakeTargetAction;
|
||||
|
@ -174,6 +180,11 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
// Collapsing
|
||||
CollapseAllAction collapseAllAction;
|
||||
|
||||
//Search
|
||||
FileSearchAction fFileSearchAction;
|
||||
FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
|
||||
SearchDialogAction fSearchDialogAction;
|
||||
|
||||
// Persistance tags.
|
||||
static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
|
||||
static final String TAG_EXPANDED= "expanded"; //$NON-NLS-1$
|
||||
|
@ -636,6 +647,10 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.CLOSE_PROJECT, closeProjectAction);
|
||||
|
||||
collapseAllAction = new CollapseAllAction(this);
|
||||
|
||||
fFileSearchAction = new FileSearchAction(viewer);
|
||||
fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(viewer);
|
||||
fSearchDialogAction = new SearchDialogAction(viewer, this.getViewSite().getWorkbenchWindow());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -743,6 +758,8 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
addIOMenu(menu, selection);
|
||||
menu.add(new Separator());
|
||||
addBookMarkMenu (menu, selection);
|
||||
menu.add(new Separator());
|
||||
addSearchMenu(menu, selection);
|
||||
//menu.add(new Separator());
|
||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
|
||||
|
@ -1303,4 +1320,28 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addSearchMenu(IMenuManager menu, IStructuredSelection selection) {
|
||||
IAdaptable element = (IAdaptable)selection.getFirstElement();
|
||||
|
||||
if (element instanceof TranslationUnit ||
|
||||
element instanceof CProject)
|
||||
return;
|
||||
|
||||
MenuManager search = new MenuManager("Search", IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
|
||||
|
||||
if (SearchDialogAction.canActionBeAdded(selection)){
|
||||
search.add(fSearchDialogAction);
|
||||
}
|
||||
|
||||
if (FileSearchAction.canActionBeAdded(selection)) {
|
||||
MenuManager fileSearch = new MenuManager("File Search");
|
||||
fileSearch.add(fFileSearchAction);
|
||||
fileSearch.add(fFileSearchActionInWorkingSet);
|
||||
search.add(fileSearch);
|
||||
}
|
||||
|
||||
menu.add(search);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
private String fContextMenuId;
|
||||
|
||||
private OpenIncludeAction fOpenIncludeAction;
|
||||
private SearchForReferencesAction fSearchForReferencesAction;
|
||||
private FileSearchAction fFileSearchAction;
|
||||
private FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
|
||||
private SearchDialogAction fSearchDialogAction;
|
||||
|
||||
private MemberFilterActionGroup fMemberFilterActionGroup;
|
||||
|
@ -77,7 +78,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
fTogglePresentation.setEditor(editor);
|
||||
|
||||
fOpenIncludeAction= new OpenIncludeAction(this);
|
||||
fSearchForReferencesAction= new SearchForReferencesAction(this);
|
||||
fFileSearchAction= new FileSearchAction(this);
|
||||
fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(this);
|
||||
fSearchDialogAction = new SearchDialogAction(this, editor);
|
||||
}
|
||||
|
||||
|
@ -143,8 +145,11 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
menu.add(fSearchDialogAction);
|
||||
}
|
||||
|
||||
if (SearchForReferencesAction.canActionBeAdded(getSelection())) {
|
||||
menu.add(fSearchForReferencesAction);
|
||||
if (FileSearchAction.canActionBeAdded(getSelection())) {
|
||||
MenuManager fileSearch = new MenuManager("File Search");
|
||||
fileSearch.add(fFileSearchAction);
|
||||
fileSearch.add(fFileSearchActionInWorkingSet);
|
||||
menu.add(fileSearch);
|
||||
}
|
||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
|
||||
|
|
|
@ -96,8 +96,10 @@ public class CEditor extends TextEditor implements ISelectionChangedListener {
|
|||
/** The outline page */
|
||||
protected CContentOutlinePage fOutlinePage;
|
||||
|
||||
private SearchForReferencesAction fSearchForReferencesAction;
|
||||
private FileSearchAction fFileSearchAction;
|
||||
|
||||
private FileSearchActionInWorkingSet fFileSearchActionInWorkingSet;
|
||||
|
||||
private SearchDialogAction fSearchDialogAction;
|
||||
|
||||
protected ISelectionChangedListener fStatusLineClearer;
|
||||
|
@ -427,7 +429,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener {
|
|||
setAction("AddIncludeOnSelection", new AddIncludeOnSelectionAction(this)); //$NON-NLS-1$
|
||||
setAction("OpenDeclarations", new OpenDeclarationsAction(this));
|
||||
|
||||
fSearchForReferencesAction = new SearchForReferencesAction(getSelectionProvider());
|
||||
fFileSearchAction = new FileSearchAction(getSelectionProvider());
|
||||
|
||||
fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(getSelectionProvider());
|
||||
|
||||
fSearchDialogAction = new SearchDialogAction(getSelectionProvider(), this);
|
||||
}
|
||||
|
@ -452,8 +456,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener {
|
|||
search.add(fSearchDialogAction);
|
||||
}
|
||||
|
||||
if (SearchForReferencesAction.canActionBeAdded(getSelectionProvider().getSelection())) {
|
||||
search.add(fSearchForReferencesAction);
|
||||
if (FileSearchAction.canActionBeAdded(getSelectionProvider().getSelection())) {
|
||||
MenuManager fileSearch = new MenuManager("File Search");
|
||||
fileSearch.add(fFileSearchAction);
|
||||
fileSearch.add(fFileSearchActionInWorkingSet);
|
||||
search.add(fileSearch);
|
||||
}
|
||||
|
||||
addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$
|
||||
|
|
|
@ -32,14 +32,14 @@ import org.eclipse.ui.PlatformUI;
|
|||
|
||||
|
||||
|
||||
public class SearchForReferencesAction extends Action {
|
||||
public class FileSearchAction extends Action {
|
||||
|
||||
|
||||
private static final String PREFIX= "SearchForReferencesAction.";
|
||||
private static final String PREFIX= "FileSearchAction.";
|
||||
|
||||
private ISelectionProvider fSelectionProvider;
|
||||
|
||||
public SearchForReferencesAction(ISelectionProvider provider) {
|
||||
public FileSearchAction(ISelectionProvider provider) {
|
||||
super(CUIPlugin.getResourceString(PREFIX + "label"));
|
||||
setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
|
||||
setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* 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.";
|
||||
|
||||
private ISelectionProvider fSelectionProvider;
|
||||
|
||||
public FileSearchActionInWorkingSet(ISelectionProvider provider) {
|
||||
super(CUIPlugin.getResourceString(PREFIX + "label"));
|
||||
setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
|
||||
setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
|
||||
|
||||
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",(IResource []) result);
|
||||
|
||||
|
||||
TextSearchOperation op= new TextSearchOperation(
|
||||
CUIPlugin.getWorkspace(),
|
||||
search_name,
|
||||
"",
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|||
import org.eclipse.search.ui.SearchUI;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
|
@ -29,12 +30,12 @@ import org.eclipse.ui.texteditor.ITextEditor;
|
|||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class SearchDialogAction extends Action {
|
||||
|
||||
private static final String PREFIX= "SearchDialogAction.";
|
||||
private static final String C_SEARCH_PAGE_ID= "org.eclipse.cdt.ui.CSearchPage";
|
||||
|
||||
private ISelectionProvider fSelectionProvider;
|
||||
private ITextEditor fEditor;
|
||||
private IWorkbenchWindow fWorkbenchWindow;
|
||||
|
||||
public SearchDialogAction(ISelectionProvider provider, CEditor editor) {
|
||||
super(CUIPlugin.getResourceString(PREFIX + "label"));
|
||||
|
@ -48,6 +49,20 @@ public class SearchDialogAction extends Action {
|
|||
fSelectionProvider= provider;
|
||||
fEditor = editor;
|
||||
}
|
||||
|
||||
public SearchDialogAction(ISelectionProvider provider, IWorkbenchWindow window) {
|
||||
|
||||
super(CUIPlugin.getResourceString(PREFIX + "label"));
|
||||
setDescription(CUIPlugin.getResourceString(PREFIX + "description"));
|
||||
setToolTipText(CUIPlugin.getResourceString(PREFIX + "tooltip"));
|
||||
|
||||
if(provider instanceof CContentOutlinePage) {
|
||||
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_OPEN_INCLUDE);
|
||||
}
|
||||
|
||||
fSelectionProvider= provider;
|
||||
fWorkbenchWindow = window;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String search_name;
|
||||
|
@ -64,8 +79,12 @@ public class SearchDialogAction extends Action {
|
|||
search_name = element.getElementName();
|
||||
}
|
||||
|
||||
SearchUI.openSearchDialog(fEditor.getEditorSite().getWorkbenchWindow(),C_SEARCH_PAGE_ID);
|
||||
|
||||
if (fEditor != null){
|
||||
SearchUI.openSearchDialog(fEditor.getEditorSite().getWorkbenchWindow(),C_SEARCH_PAGE_ID);
|
||||
}
|
||||
else if (fWorkbenchWindow != null){
|
||||
SearchUI.openSearchDialog(fWorkbenchWindow,C_SEARCH_PAGE_ID);
|
||||
}
|
||||
// // @@@ 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.
|
||||
|
|
|
@ -20,9 +20,14 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.core.search.SearchEngine;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkingSet;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
|
@ -116,4 +121,18 @@ public class CSearchScopeFactory {
|
|||
return createCSearchScope( cElements );
|
||||
}
|
||||
|
||||
|
||||
public IWorkingSet[] queryWorkingSets() {
|
||||
Shell shell= CUIPlugin.getDefault().getActiveWorkbenchShell();
|
||||
if (shell == null)
|
||||
return null;
|
||||
IWorkingSetSelectionDialog dialog= PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(shell, true);
|
||||
if (dialog.open() == Window.OK) {
|
||||
IWorkingSet[] workingSets= dialog.getSelection();
|
||||
if (workingSets.length > 0)
|
||||
return workingSets;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue