private void performNewSearch(final IErlElement element) { final ErlangExternalFunctionCallRef ref = SearchUtil.getRefFromErlElement(element); final ErlSearchQuery query = new ErlSearchQuery( ref, IErlSearchConstants.REFERENCES, IErlSearchConstants.FUNCTION, getScope()); if (query.canRunInBackground()) { /* * This indirection with Object as parameter is needed to prevent * the loading of the Search plug-in: the VM verifies the method * call and hence loads the types used in the method signature, * eventually triggering the loading of a plug-in (in this case * ISearchQuery results in Search plug-in being loaded). */ NewSearchUI.runQueryInBackground(query); } else { final IProgressService progressService = PlatformUI.getWorkbench().getProgressService(); /* * This indirection with Object as parameter is needed to prevent * the loading of the Search plug-in: the VM verifies the method * call and hence loads the types used in the method signature, * eventually triggering the loading of a plug-in (in this case it * would be ISearchQuery). */ final IStatus status = NewSearchUI.runQueryInForeground(progressService, query); if (status.matches(IStatus.ERROR | IStatus.INFO | IStatus.WARNING)) { ErrorDialog.openError( getShell(), "SearchMessages.Search_Error_search_title", "SearchMessages.Search_Error_search_message", status); } } }
/** Clears the ResultPage of the Analyze-Plugin */ private static void clearAnalyzeResultPage() { ISearchQuery[] querry = NewSearchUI.getQueries(); for (int i = 0; i < querry.length; i++) { NewSearchUI.removeQuery(querry[i]); } }
@Override public void run() { ISearchQuery searchJob = null; ISelection selection = getSelection(); if (selection instanceof IStructuredSelection) { Object object = ((IStructuredSelection) selection).getFirstElement(); if (object instanceof ISourceReference) searchJob = createQuery((ISourceReference) object); } else if (selection instanceof ITextSelection) { ITextSelection selNode = (ITextSelection) selection; ICElement element = fEditor.getInputCElement(); while (element != null && !(element instanceof ITranslationUnit)) element = element.getParent(); if (element != null) { if (selNode.getLength() == 0) { IDocument document = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput()); IRegion reg = CWordFinder.findWord(document, selNode.getOffset()); selNode = new TextSelection(document, reg.getOffset(), reg.getLength()); } searchJob = createQuery(element, selNode); } } if (searchJob == null) { showStatusLineMessage(CSearchMessages.CSearchOperation_operationUnavailable_message); return; } clearStatusLine(); NewSearchUI.activateSearchResultView(); NewSearchUI.runQueryInBackground(searchJob); }
@Override protected void doRun(ICElement[] elements) { if (elements.length == 0) { StatusLineHandler.showStatusLineMessage( fSite, CSearchMessages.CSearchOperation_operationUnavailable_message); return; } ISearchQuery searchJob = new CSearchUnresolvedIncludesQuery(elements); StatusLineHandler.clearStatusLine(fSite); NewSearchUI.activateSearchResultView(); NewSearchUI.runQueryInBackground(searchJob); }
public void run(IAction action) { if (fWindow == null || fWindow.getActivePage() == null) { return; } NewSearchUI.openSearchDialog(fWindow, SearchPage.ID); }
private void doSearch(ISelection sel) { IPackageFragment frag = getPackageFragment(sel); if (frag != null) { FindReferencesAction action = new FindReferencesAction(getPage().getEditorSite()); action.run(frag); } else if (sel instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) sel; PackageObject exportObject = (PackageObject) selection.getFirstElement(); NewSearchUI.runQueryInBackground(new BlankQuery(exportObject)); } }
@Override public boolean performAction() { try { source.saveState(DBeaverCore.getGlobalPreferenceStore()); NewSearchUI.runQueryInBackground(createQueryAdapter(source.createQuery())); } catch (Exception e) { UIUtils.showErrorDialog(getControl().getShell(), "Search", "Can't perform search", e); return false; } return true; }
/** * This helper method with Object as parameter is needed to prevent the loading of the Search * plug-in: the Interpreter verifies the method call and hence loads the types used in the method * signature, eventually triggering the loading of a plug-in (in this case ISearchQuery results in * Search plug-in being loaded). */ public static IStatus runQueryInForeground(IRunnableContext context, Object query) { return NewSearchUI.runQueryInForeground(context, (ISearchQuery) query); }
/** * This helper method with Object as parameter is needed to prevent the loading of the Search * plug-in: the Interpreter verifies the method call and hence loads the types used in the method * signature, eventually triggering the loading of a plug-in (in this case ISearchQuery results in * Search plug-in being loaded). */ public static void runQueryInBackground(Object query) { NewSearchUI.runQueryInBackground((ISearchQuery) query); }
/** * Here, all the editors available will be gotten and searched (if possible). * * <p>Note that editors that are not in the workspace may not be searched (it should be possible * to do, but one may have to reimplement large portions of the search for that to work). */ public static void findInOpenDocuments( final String searchText, final boolean caseSensitive, final boolean wholeWord, final boolean isRegEx, IStatusLineManager statusLineManager) { IWorkbenchWindow window = EditorUtils.getActiveWorkbenchWindow(); if (window == null) { if (statusLineManager != null) statusLineManager.setErrorMessage("Active workbench window is null."); return; } IWorkbenchPage activePage = window.getActivePage(); if (activePage == null) { if (statusLineManager != null) statusLineManager.setErrorMessage("Active page is null."); return; } IEditorReference editorsArray[] = activePage.getEditorReferences(); final List<IFile> files = new ArrayList<IFile>(); for (int i = 0; i < editorsArray.length; i++) { IEditorPart realEditor = editorsArray[i].getEditor(true); if (realEditor != null) { if (realEditor instanceof MultiPageEditorPart) { try { Method getPageCount = MultiPageEditorPart.class.getDeclaredMethod("getPageCount"); getPageCount.setAccessible(true); Method getEditor = MultiPageEditorPart.class.getDeclaredMethod("getEditor", int.class); getEditor.setAccessible(true); Integer pageCount = (Integer) getPageCount.invoke(realEditor); for (int j = 0; j < pageCount; j++) { IEditorPart part = (IEditorPart) getEditor.invoke(realEditor, j); if (part != null) { IEditorInput input = part.getEditorInput(); if (input != null) { IFile file = (IFile) input.getAdapter(IFile.class); if (file != null) { files.add(file); } } } } } catch (Throwable e1) { // Log it but keep going on. Log.log(e1); } } else { IEditorInput input = realEditor.getEditorInput(); if (input != null) { IFile file = (IFile) input.getAdapter(IFile.class); if (file != null) { files.add(file); } else { // it has input, but it's not adaptable to an IFile! if (statusLineManager != null) statusLineManager.setMessage( "Warning: Editors not in the workspace cannot be searched."); // but we keep on going... } } } } } if (files.size() == 0) { if (statusLineManager != null) statusLineManager.setMessage( "No file was found to perform the search (editors not in the workspace cannot be searched)."); return; } try { ISearchQuery query = TextSearchQueryProvider.getPreferred() .createQuery( new TextSearchInput() { public boolean isRegExSearch() { return isRegEx; } public boolean isCaseSensitiveSearch() { return caseSensitive; } public String getSearchText() { return searchText; } public FileTextSearchScope getScope() { return FileTextSearchScope.newSearchScope( files.toArray(new IResource[files.size()]), new String[] {"*"}, true); } }); NewSearchUI.runQueryInBackground(query); } catch (CoreException e1) { Log.log(e1); } }
public void createControl(Composite parent) { fViewerContainer = new Composite(parent, SWT.NULL); fViewerContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); fViewerContainer.setSize(100, 100); fViewerContainer.setLayout(new FillLayout()); fTreeViewer = new TreeViewer(fViewerContainer, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); fTreeViewer.setContentProvider( new ITreeContentProvider() { public void dispose() {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { viewer.refresh(); } public Object[] getChildren(Object parentElement) { return new Object[0]; } public Object getParent(Object element) { return null; } public boolean hasChildren(Object element) { return false; } public Object[] getElements(Object inputElement) { if (fQuery == null) return new Object[0]; else { return ((MemorySearchResult) fQuery.getSearchResult()).getMatches(); } } }); fTreeViewer.setInput(new Object()); fTreeViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { if (event.getSelection() instanceof StructuredSelection) { IMemoryRenderingContainer containers[] = ((IMemorySearchQuery) fQuery).getMemoryView().getMemoryRenderingContainers(); MemoryMatch match = (MemoryMatch) ((StructuredSelection) event.getSelection()).getFirstElement(); if (match != null) { for (int i = 0; i < containers.length; i++) { IMemoryRendering rendering = containers[i].getActiveRendering(); if (rendering instanceof IRepositionableMemoryRendering) { try { ((IRepositionableMemoryRendering) rendering) .goToAddress(match.getStartAddress()); } catch (DebugException e) { MemorySearchPlugin.logError( Messages.getString( "MemorySearchResultsPage.RepositioningMemoryViewFailed"), e); //$NON-NLS-1$ } } if (rendering != null) { // Temporary, until platform accepts/adds new interface for setting the // selection try { Method m = rendering .getClass() .getMethod( "setSelection", new Class[] {BigInteger.class, BigInteger.class}); // $NON-NLS-1$ if (m != null) m.invoke(rendering, match.getStartAddress(), match.getEndAddress()); } catch (Exception e) { // do nothing } } } } } } }); fTreeViewer.setLabelProvider( new ILabelProvider() { public String getText(Object element) { if (element instanceof MemoryMatch) return "0x" + ((MemoryMatch) element).getStartAddress().toString(16); // $NON-NLS-1$ return element.toString(); } public Image getImage(Object element) { return null; } public void addListener(ILabelProviderListener listener) {} public void dispose() {} public boolean isLabelProperty(Object element, String property) { return false; } public void removeListener(ILabelProviderListener listener) {} }); fQueryListener = createQueryListener(); NewSearchUI.addQueryListener(fQueryListener); }
public void run(IAction action) { NewSearchUI.openSearchDialog(window, MERCURIAL_ECLIPSE_SEARCH_PAGE); }
public Object execute(ExecutionEvent event) throws ExecutionException { NewSearchUI.openSearchDialog( HandlerUtil.getActiveWorkbenchWindow(event), MERCURIAL_ECLIPSE_SEARCH_PAGE); return null; }
public static void search(String scopeName, IType[] accessorClasses, IFile[] propertieFiles) { NLSSearchQuery query = new NLSSearchQuery( accessorClasses, propertieFiles, SearchEngine.createWorkspaceScope(), scopeName); NewSearchUI.runQueryInBackground(query); }