Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Aeschlimann2005-02-02 11:38:29 +0000
committerMartin Aeschlimann2005-02-02 11:38:29 +0000
commit5bcd22c537ca5fc37d1f64e0d1a59c86ded6f5d8 (patch)
treefd25ba6252d0c0e917e0f5f553d7ece941a589fd /org.eclipse.jdt.ui.examples.javafamily
parentc5204c4701797f3f1231fadcd717fc398c7ce13b (diff)
downloadeclipse.jdt.ui-5bcd22c537ca5fc37d1f64e0d1a59c86ded6f5d8.tar.gz
eclipse.jdt.ui-5bcd22c537ca5fc37d1f64e0d1a59c86ded6f5d8.tar.xz
eclipse.jdt.ui-5bcd22c537ca5fc37d1f64e0d1a59c86ded6f5d8.zip
javafamily search UI removed (completly outdated)
Diffstat (limited to 'org.eclipse.jdt.ui.examples.javafamily')
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/icons/full/clcl16/search_sortmatch.gifbin160 -> 0 bytes
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/icons/full/obj16/jsearch_obj.gifbin248 -> 0 bytes
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/plugin.properties34
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/plugin.xml51
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GotoMarkerAction.java189
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GroupByKeyComputer.java66
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchOperation.java198
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchPage2.java731
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultCollector.java229
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultLabelProvider.java175
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.java64
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.properties162
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchUtil.java400
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewActionGroup.java32
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewAdapter.java138
-rw-r--r--org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewSiteAdapter.java163
16 files changed, 0 insertions, 2632 deletions
diff --git a/org.eclipse.jdt.ui.examples.javafamily/icons/full/clcl16/search_sortmatch.gif b/org.eclipse.jdt.ui.examples.javafamily/icons/full/clcl16/search_sortmatch.gif
deleted file mode 100644
index 9ed470d02f..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/icons/full/clcl16/search_sortmatch.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.ui.examples.javafamily/icons/full/obj16/jsearch_obj.gif b/org.eclipse.jdt.ui.examples.javafamily/icons/full/obj16/jsearch_obj.gif
deleted file mode 100644
index ee75bdb293..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/icons/full/obj16/jsearch_obj.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.jdt.ui.examples.javafamily/plugin.properties b/org.eclipse.jdt.ui.examples.javafamily/plugin.properties
index 6a6c7de475..4b207d43bd 100644
--- a/org.eclipse.jdt.ui.examples.javafamily/plugin.properties
+++ b/org.eclipse.jdt.ui.examples.javafamily/plugin.properties
@@ -13,40 +13,6 @@ pluginName= Java Development Tools JavaFamily Example
providerName= Eclipse.org
##########################################################################
-# Java Search
-##########################################################################
-JavaSearchPage.label= Java/JSP Search
-openJavaSearchPageAction.label= &Java...
-ElementNameSorter.label= &Name
-ElementNameSorter.tooltip= Sort the view by Java Element Name
-ParentNameSorter.label= &Parent Name
-ParentNameSorter.tooltip= Sort the view by Java Element Parent Name
-PathNameSorter.label= P&ath
-PathNameSorter.tooltip= Sort the view by Resource Path
-PositionSorter.label= &Line number
-PositionSorter.tooltip= Sort the view by location
-
-# Action sets
-JavaSearchActionSet.label= Java Search
-JavaSearchActionSet.description= Action set containing search related Java actions
-
-# Menus
-searchMenu.label= Se&arch
-OccurrencesInFile.label=Occurrences in File
-declarationsSubMenu.label= Dec&larations
-referencesSubMenu.label= R&eferences
-implementorsSubMenu.label= &Implementors
-readAccessSubMenu.label= &Read Access
-writeAccessSubMenu.label= &Write Access
-
-ReferencesInWorkspace.label= &Workspace
-DeclarationsInWorkspace.label= &Workspace
-
-InWorkspace.label= &Workspace
-InHierarchy.label= &Hierarchy
-InWorkingSet.label= Working &Set...
-
-##########################################################################
# JSP Editor
##########################################################################
jspEditorName= JSP Editor
diff --git a/org.eclipse.jdt.ui.examples.javafamily/plugin.xml b/org.eclipse.jdt.ui.examples.javafamily/plugin.xml
index c8fba944d7..8b942a1ad7 100644
--- a/org.eclipse.jdt.ui.examples.javafamily/plugin.xml
+++ b/org.eclipse.jdt.ui.examples.javafamily/plugin.xml
@@ -21,7 +21,6 @@
<import plugin="org.eclipse.ui.workbench.texteditor"/>
<import plugin="org.eclipse.ui.editors"/>
<import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.search"/>
<import plugin="org.eclipse.jdt.core"/>
<import plugin="org.eclipse.jdt.ui"/>
<import plugin="org.eclipse.debug.core"/>
@@ -55,56 +54,6 @@
</extension>
<!-- =========================================================================== -->
- <!-- Java Search Page -->
- <!-- =========================================================================== -->
- <extension point="org.eclipse.search.searchPages">
- <page id="org.eclipse.jdt.ui.JavaSearchPage2"
- icon="icons/full/obj16/jsearch_obj.gif"
- label="%JavaSearchPage.label"
- sizeHint="460,160"
- extensions="java:90, jav:90"
- showScopeSection="true"
- class="org.eclipse.jdt.internal.ui.search2.JavaSearchPage2">
- </page>
- </extension>
-
- <extension point="org.eclipse.search.searchResultSorters">
- <sorter
- id="org.eclipse.search.internal.ui.ElementNameSorter"
- pageId="org.eclipse.jdt.ui.JavaSearchPage2"
- label="%ElementNameSorter.label"
- tooltip="%ElementNameSorter.tooltip"
- icon="icons/full/clcl16/search_sortmatch.gif"
- class="org.eclipse.jdt.internal.ui.search.ElementNameSorter">
- </sorter>
- <sorter
- id="org.eclipse.search.internal.ui.ParentNameSorter"
- pageId="org.eclipse.jdt.ui.JavaSearchPage2"
- label="%ParentNameSorter.label"
- tooltip="%ParentNameSorter.tooltip"
- icon="icons/full/clcl16/search_sortmatch.gif"
- class="org.eclipse.jdt.internal.ui.search.ParentNameSorter">
- </sorter>
- <sorter
- id="org.eclipse.search.internal.ui.PathNameSorter"
- pageId="org.eclipse.jdt.ui.JavaSearchPage2"
- label="%PathNameSorter.label"
- tooltip="%PathNameSorter.tooltip"
- icon="icons/full/clcl16/search_sortmatch.gif"
- class="org.eclipse.jdt.internal.ui.search.PathNameSorter">
- </sorter>
- <sorter
- id="org.eclipse.search.internal.ui.MatchPositionSorter"
- pageId="org.eclipse.jdt.ui.JavaFileSearch2"
- label="%PositionSorter.label"
- tooltip="%PositionSorter.tooltip"
- icon="icons/full/clcl16/search_sortmatch.gif"
- class="org.eclipse.jdt.internal.ui.search.MatchPositionSorter">
- </sorter>
-
- </extension>
-
- <!-- =========================================================================== -->
<!-- JSP Editor -->
<!-- =========================================================================== -->
<extension
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GotoMarkerAction.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GotoMarkerAction.java
deleted file mode 100644
index 7a12b03e52..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GotoMarkerAction.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IReusableEditor;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.part.FileEditorInput;
-
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMember;
-
-import org.eclipse.jdt.ui.IPackagesViewPart;
-import org.eclipse.jdt.ui.JavaUI;
-
-import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput;
-import org.eclipse.jdt.internal.ui.search.SearchUtil;
-import org.eclipse.jdt.internal.ui.util.SelectionUtil;
-
-public class GotoMarkerAction extends Action {
-
- private IEditorPart fEditor;
-
- public GotoMarkerAction(){
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.GOTO_MARKER_ACTION);
- }
-
- public void run() {
- ISearchResultView view= SearchUI.getSearchResultView();
- Object element= SelectionUtil.getSingleElement(view.getSelection());
- if (element instanceof ISearchResultViewEntry) {
- ISearchResultViewEntry entry= (ISearchResultViewEntry)element;
- show(entry.getSelectedMarker());
- }
- }
-
- private void show(IMarker marker) {
- IResource resource= marker.getResource();
- if (resource == null || !resource.exists())
- return;
- IWorkbenchPage wbPage= JavaPlugin.getActivePage();
- IJavaElement javaElement= SearchUtil.getJavaElement(marker);
-
- if (javaElement != null && javaElement.getElementType() == IJavaElement.PACKAGE_FRAGMENT)
- gotoPackagesView(javaElement, wbPage);
- else {
- if (NewSearchUI.reuseEditor())
- showWithReuse(marker, resource, javaElement, wbPage);
- else
- showWithoutReuse(marker, javaElement, wbPage);
- }
- }
-
- private void showWithoutReuse(IMarker marker, IJavaElement javaElement, IWorkbenchPage wbPage) {
- IEditorPart editor= null;
- try {
- Object objectToOpen= javaElement;
- if (objectToOpen == null)
- objectToOpen= marker.getResource();
- editor= EditorUtility.openInEditor(objectToOpen, false);
- } catch (CoreException ex) {
- MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), "Search Error", "Could not open the editor");
- }
- if (editor != null)
- IDE.gotoMarker(editor, marker);
- }
-
- private void showWithReuse(IMarker marker, IResource resource, IJavaElement javaElement, IWorkbenchPage wbPage) {
- if (javaElement == null || !isBinary(javaElement)) {
- if (resource instanceof IFile)
- showInEditor(marker, wbPage, new FileEditorInput((IFile)resource), JavaUI.ID_CU_EDITOR);
- }
- else {
- IClassFile cf= getClassFile(javaElement);
- if (cf != null)
- showInEditor(marker, wbPage, new InternalClassFileEditorInput(cf), JavaUI.ID_CF_EDITOR);
- }
- }
-
- private boolean isPinned(IEditorPart editor) {
- if (editor == null)
- return false;
-
- IEditorReference[] editorRefs= editor.getEditorSite().getPage().getEditorReferences();
- int i= 0;
- while (i < editorRefs.length) {
- if (editor.equals(editorRefs[i].getEditor(false)))
- return editorRefs[i].isPinned();
- i++;
- }
- return false;
- }
-
- private void showInEditor(IMarker marker, IWorkbenchPage page, IEditorInput input, String editorId) {
- IEditorPart editor= page.findEditor(input);
- if (editor != null)
- page.bringToTop(editor);
- else {
- boolean isOpen= false;
- if (fEditor != null) {
- IEditorReference[] parts= page.getEditorReferences();
- int i= 0;
- while (!isOpen && i < parts.length)
- isOpen= fEditor == parts[i++].getEditor(false);
- }
-
- boolean canBeReused= isOpen && !fEditor.isDirty() && !isPinned(fEditor);
- boolean showsSameInputType= fEditor != null && fEditor.getSite().getId().equals(editorId);
- if (canBeReused && !showsSameInputType) {
- page.closeEditor(fEditor, false);
- fEditor= null;
- }
-
- if (canBeReused && showsSameInputType) {
- ((IReusableEditor)fEditor).setInput(input);
- page.bringToTop(fEditor);
- editor= fEditor;
- } else {
- try {
- editor= page.openEditor(input, editorId, false);
- if (editor instanceof IReusableEditor)
- fEditor= editor;
- else
- fEditor= null;
- } catch (PartInitException ex) {
- MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), "Search Error", "Could not open the editor");
- return;
- }
- }
- }
-
- if (editor != null) {
- IDE.gotoMarker(editor, marker);
- }
- }
-
- private void gotoPackagesView(IJavaElement javaElement, IWorkbenchPage wbPage) {
- try {
- IViewPart view= wbPage.showView(JavaUI.ID_PACKAGES);
- if (view instanceof IPackagesViewPart)
- ((IPackagesViewPart)view).selectAndReveal(javaElement);
- } catch (PartInitException ex) {
- MessageDialog.openError(JavaPlugin.getActiveWorkbenchShell(), "Search Error", "Could not open the editor");
- }
- }
-
- private IClassFile getClassFile(IJavaElement jElement) {
- if (jElement instanceof IMember)
- return ((IMember)jElement).getClassFile();
- return null;
- }
-
- private boolean isBinary(IJavaElement jElement) {
- if (jElement instanceof IMember)
- return ((IMember)jElement).isBinary();
- return false;
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GroupByKeyComputer.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GroupByKeyComputer.java
deleted file mode 100644
index dc96978286..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/GroupByKeyComputer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IJavaElement;
-
-import org.eclipse.jdt.internal.ui.search.IJavaSearchUIConstants;
-import org.eclipse.jdt.internal.ui.search.SearchUtil;
-import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.search.ui.IGroupByKeyComputer;
-
-public class GroupByKeyComputer implements IGroupByKeyComputer {
-
- IJavaElement fLastJavaElement= null;
- String fLastHandle= null;
-
- public Object computeGroupByKey(IMarker marker) {
- if (marker == null)
- return null;
-
- IJavaElement jElement= getJavaElement(marker);
- if (jElement != null && jElement.exists()) {
- // no help from JavaModel to rename yet
- // return getJavaElement(marker);
- return fLastHandle;
- }
- return null;
- }
-
- private String getJavaElementHandleId(IMarker marker) {
- try {
- return (String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID);
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, "Search Error", "An error occurred while accessing a marker attribute");
- return null;
- }
- }
-
- private IJavaElement getJavaElement(IMarker marker) {
- String handle= getJavaElementHandleId(marker);
- if (handle == null) {
- fLastHandle= null;
- fLastJavaElement= null;
- return null;
- }
-
- if (!handle.equals(fLastHandle)) {
- fLastJavaElement= SearchUtil.getJavaElement(marker);
- if (fLastJavaElement != null)
- fLastHandle= fLastJavaElement.getHandleIdentifier();
- else
- fLastHandle= null;
- }
- return fLastJavaElement;
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchOperation.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchOperation.java
deleted file mode 100644
index 29a185d5e7..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchOperation.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jsp.*;
-import org.eclipse.jsp.JspTypeQuery;
-
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.search.IJavaSearchConstants;
-import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.SearchEngine;
-
-import org.eclipse.jdt.ui.JavaUI;
-
-import org.eclipse.jdt.internal.ui.JavaPluginImages;
-import org.eclipse.jdt.internal.ui.search.PrettySignature;
-
-
-public class JavaSearchOperation extends WorkspaceModifyOperation {
-
- private IWorkspace fWorkspace;
- private IJavaElement fElementPattern;
- private int fLimitTo;
- private String fStringPattern;
- private boolean fIsCaseSensitive;
- private int fSearchFor;
- private IJavaSearchScope fScope;
- private String fScopeDescription;
- private JavaSearchResultCollector fCollector;
-
- protected JavaSearchOperation(
- IWorkspace workspace,
- int limitTo,
- IJavaSearchScope scope,
- String scopeDescription,
- JavaSearchResultCollector collector) {
- super(null);
- fWorkspace= workspace;
- fLimitTo= limitTo;
- fScope= scope;
- fScopeDescription= scopeDescription;
- fCollector= collector;
- fCollector.setOperation(this);
- }
-
- public JavaSearchOperation(
- IWorkspace workspace,
- IJavaElement pattern,
- int limitTo,
- IJavaSearchScope scope,
- String scopeDescription,
- JavaSearchResultCollector collector) {
- this(workspace, limitTo, scope, scopeDescription, collector);
- fElementPattern= pattern;
- }
-
- public JavaSearchOperation(
- IWorkspace workspace,
- String pattern,
- boolean caseSensitive,
- int searchFor,
- int limitTo,
- IJavaSearchScope scope,
- String scopeDescription,
- JavaSearchResultCollector collector) {
- this(workspace, limitTo, scope, scopeDescription, collector);
- fStringPattern= pattern;
- fIsCaseSensitive= caseSensitive;
- fSearchFor= searchFor;
- }
-
- protected void execute(IProgressMonitor monitor) throws CoreException {
- fCollector.setProgressMonitor(monitor);
-
- // A hack to temporarily disable the aboutToStart and done methods
- IJavaSearchResultCollector collector= new IJavaSearchResultCollector() {
- public void aboutToStart() {
- // empty implementation
- }
- public void accept(IResource resource, int start, int end, IJavaElement enclosingElement, int accuracy) throws CoreException {
- fCollector.accept(resource, start, end, enclosingElement, accuracy);
- }
- public void done() {
- // empty implementation
- }
- public IProgressMonitor getProgressMonitor() {
- return fCollector.getProgressMonitor();
- }
- };
-
- fCollector.aboutToStart();
-
- // Also search working copies
- SearchEngine engine= new SearchEngine(JavaUI.getSharedWorkingCopiesOnClasspath());
-
- if (fElementPattern != null)
- engine.search(fWorkspace, fElementPattern, fLimitTo, fScope, collector);
- else
- engine.search(fWorkspace, SearchEngine.createSearchPattern(fStringPattern, fSearchFor, fLimitTo, fIsCaseSensitive), fScope, collector);
-
- if (fElementPattern instanceof IType)
- JspSearchEngine.search(collector, new JspTypeQuery((IType)fElementPattern), monitor);
-
- fCollector.done();
- }
-
- String getSingularLabel() {
- String desc= null;
- if (fElementPattern != null) {
- if (fLimitTo == IJavaSearchConstants.REFERENCES
- && fElementPattern.getElementType() == IJavaElement.METHOD)
- desc= PrettySignature.getUnqualifiedMethodSignature((IMethod)fElementPattern);
- else
- desc= fElementPattern.getElementName();
- if ("".equals(desc) && fElementPattern.getElementType() == IJavaElement.PACKAGE_FRAGMENT)
- desc= "(default package)";
- }
- else
- desc= fStringPattern;
-
- String[] args= new String[] {desc, fScopeDescription}; //$NON-NLS-1$
- switch (fLimitTo) {
- case IJavaSearchConstants.IMPLEMENTORS:
- return "{0} - 1 Implementor in {1}";
- case IJavaSearchConstants.DECLARATIONS:
- return "{0} - 1 Declaration in {1}";
- case IJavaSearchConstants.REFERENCES:
- return "{0} - 1 Reference in {1}";
- case IJavaSearchConstants.ALL_OCCURRENCES:
- return "{0} - 1 Occurrence in {1}";
- case IJavaSearchConstants.READ_ACCESSES:
- return "{0} - 1 Read Reference in {1}";
- case IJavaSearchConstants.WRITE_ACCESSES:
- return "{0} - 1 Write Reference in {1}";
- default:
- return "{0} - 1 Occurrence in {1}";
- }
- }
-
- String getPluralLabelPattern() {
- String desc= null;
- if (fElementPattern != null) {
- if (fLimitTo == IJavaSearchConstants.REFERENCES
- && fElementPattern.getElementType() == IJavaElement.METHOD)
- desc= PrettySignature.getUnqualifiedMethodSignature((IMethod)fElementPattern);
- else
- desc= fElementPattern.getElementName();
- if ("".equals(desc) && fElementPattern.getElementType() == IJavaElement.PACKAGE_FRAGMENT)
- desc= "(default package)";
- }
- else
- desc= fStringPattern;
-
- String[] args= new String[] {desc, "{0}", fScopeDescription};
- switch (fLimitTo) {
- case IJavaSearchConstants.IMPLEMENTORS:
- return "{0} - {1} Implementors in {2}";
- case IJavaSearchConstants.DECLARATIONS:
- return "{0} - {1} Declarations in {2}";
- case IJavaSearchConstants.REFERENCES:
- return "{0} - {1} References in {2}";
- case IJavaSearchConstants.ALL_OCCURRENCES:
- return "{0} - {1} Occurrences in {2}";
- case IJavaSearchConstants.READ_ACCESSES:
- return "{0} - {1} Read References in {2}";
- case IJavaSearchConstants.WRITE_ACCESSES:
- return "{0} - {1} Write References in {2}";
- default:
- return "{0} - {1} Occurrences in {2}";
- }
- }
-
- ImageDescriptor getImageDescriptor() {
- if (fLimitTo == IJavaSearchConstants.IMPLEMENTORS || fLimitTo == IJavaSearchConstants.DECLARATIONS)
- return JavaPluginImages.DESC_OBJS_SEARCH_DECL;
- else
- return JavaPluginImages.DESC_OBJS_SEARCH_REF;
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchPage2.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchPage2.java
deleted file mode 100644
index 697a42e210..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchPage2.java
+++ /dev/null
@@ -1,731 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jsp.JspUIPlugin;
-import org.eclipse.search.ui.ISearchPage;
-import org.eclipse.search.ui.ISearchPageContainer;
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IAdaptable;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IImportDeclaration;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.search.IJavaSearchConstants;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.SearchEngine;
-
-import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.jdt.internal.ui.browsing.LogicalPackage;
-import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
-import org.eclipse.jdt.internal.ui.search.PrettySignature;
-import org.eclipse.jdt.internal.ui.search.SearchUtil;
-import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.jdt.internal.ui.util.RowLayouter;
-
-public class JavaSearchPage2 extends DialogPage implements ISearchPage, IJavaSearchConstants {
-
- public static final String EXTENSION_POINT_ID= "org.eclipse.jdt.ui.JavaSearchPage";
-
- // Dialog store id constants
- private final static String PAGE_NAME= "JavaSearchPage";
- private final static String STORE_CASE_SENSITIVE= PAGE_NAME + "CASE_SENSITIVE";
-
-
- private static List fgPreviousSearchPatterns= new ArrayList(20);
-
- private SearchPatternData fInitialData;
- private IStructuredSelection fStructuredSelection;
- private IJavaElement fJavaElement;
- private boolean fFirstTime= true;
- private IDialogSettings fDialogSettings;
- private boolean fIsCaseSensitive;
-
- private Combo fPattern;
- private ISearchPageContainer fContainer;
- private Button fCaseSensitive;
-
- private Button[] fSearchFor;
- private String[] fSearchForText= {
- "&Type",
- "&Method",
- "&Package",
- "Co&nstructor",
- "&Field"};
-
- private Button[] fLimitTo;
- private String[] fLimitToText= {
- "Dec&larations",
- "&Implementors",
- "&References",
- "All &Occurrences",
- "Read A&ccess",
- "Writ&e Access"};
-
-
- private static class SearchPatternData {
- int searchFor;
- int limitTo;
- String pattern;
- boolean isCaseSensitive;
- IJavaElement javaElement;
- int scope;
- IWorkingSet[] workingSets;
-
- public SearchPatternData(int s, int l, boolean i, String p, IJavaElement element) {
- this(s, l, p, i, element, ISearchPageContainer.WORKSPACE_SCOPE, null);
- }
-
- public SearchPatternData(int s, int l, String p, boolean i, IJavaElement element, int scope0, IWorkingSet[] workingSets0) {
- searchFor= s;
- limitTo= l;
- pattern= p;
- isCaseSensitive= i;
- javaElement= element;
- this.scope= scope0;
- this.workingSets= workingSets0;
- }
- }
-
- //---- Action Handling ------------------------------------------------
-
- public boolean performAction() {
- SearchUI.activateSearchResultView();
-
- SearchPatternData data= getPatternData();
- IWorkspace workspace= JavaPlugin.getWorkspace();
-
- // Setup search scope
- IJavaSearchScope scope= null;
- String scopeDescription= "";
- switch (getContainer().getSelectedScope()) {
- case ISearchPageContainer.WORKSPACE_SCOPE:
- scopeDescription= "Workspace";
- scope= SearchEngine.createWorkspaceScope();
- break;
- case ISearchPageContainer.SELECTION_SCOPE:
- scopeDescription= "Selection";
- scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(fStructuredSelection, true);
- break;
- case ISearchPageContainer.WORKING_SET_SCOPE:
- IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
- // should not happen - just to be sure
- if (workingSets == null || workingSets.length < 1)
- return false;
- scopeDescription= "Working Set - {0}";
- scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(getContainer().getSelectedWorkingSets(), true);
- SearchUtil.updateLRUWorkingSets(getContainer().getSelectedWorkingSets());
- }
-
- JavaSearchResultCollector collector= new JavaSearchResultCollector();
- JavaSearchOperation op= null;
- if (data.javaElement != null && getPattern().equals(fInitialData.pattern)) {
- op= new JavaSearchOperation(workspace, data.javaElement, data.limitTo, scope, scopeDescription, collector);
- if (data.limitTo == IJavaSearchConstants.REFERENCES)
- SearchUtil.warnIfBinaryConstant(data.javaElement, getShell());
- } else {
- data.javaElement= null;
- op= new JavaSearchOperation(workspace, data.pattern, data.isCaseSensitive, data.searchFor, data.limitTo, scope, scopeDescription, collector);
- }
- Shell shell= getControl().getShell();
- try {
- getContainer().getRunnableContext().run(true, true, op);
- } catch (InvocationTargetException ex) {
- ExceptionHandler.handle(ex, shell, "Search Error", "An error occurred during the search operation");
- return false;
- } catch (InterruptedException ex) {
- return false;
- }
- return true;
- }
-
- private int getLimitTo() {
- for (int i= 0; i < fLimitTo.length; i++) {
- if (fLimitTo[i].getSelection())
- return i;
- }
- return -1;
- }
-
- private void setLimitTo(int searchFor) {
- fLimitTo[DECLARATIONS].setEnabled(true);
- fLimitTo[IMPLEMENTORS].setEnabled(false);
- fLimitTo[REFERENCES].setEnabled(true);
- fLimitTo[ALL_OCCURRENCES].setEnabled(true);
- fLimitTo[READ_ACCESSES].setEnabled(false);
- fLimitTo[WRITE_ACCESSES].setEnabled(false);
-
- if (!(searchFor == TYPE || searchFor == INTERFACE) && fLimitTo[IMPLEMENTORS].getSelection()) {
- fLimitTo[IMPLEMENTORS].setSelection(false);
- fLimitTo[REFERENCES].setSelection(true);
- }
-
- if (!(searchFor == FIELD) && (getLimitTo() == READ_ACCESSES || getLimitTo() == WRITE_ACCESSES)) {
- fLimitTo[getLimitTo()].setSelection(false);
- fLimitTo[REFERENCES].setSelection(true);
- }
-
- switch (searchFor) {
- case TYPE:
- case INTERFACE:
- fLimitTo[IMPLEMENTORS].setEnabled(true);
- break;
- case FIELD:
- fLimitTo[READ_ACCESSES].setEnabled(true);
- fLimitTo[WRITE_ACCESSES].setEnabled(true);
- break;
- default :
- break;
- }
- }
-
- private String[] getPreviousSearchPatterns() {
- // Search results are not persistent
- int patternCount= fgPreviousSearchPatterns.size();
- String [] patterns= new String[patternCount];
- for (int i= 0; i < patternCount; i++)
- patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).pattern;
- return patterns;
- }
-
- private int getSearchFor() {
- for (int i= 0; i < fSearchFor.length; i++) {
- if (fSearchFor[i].getSelection())
- return i;
- }
- Assert.isTrue(false, "shouldNeverHappen");
- return -1;
- }
-
- private String getPattern() {
- return fPattern.getText();
- }
-
- /**
- * Return search pattern data and update previous searches.
- * An existing entry will be updated.
- */
- private SearchPatternData getPatternData() {
- String pattern= getPattern();
- SearchPatternData match= null;
- int i= 0;
- int size= fgPreviousSearchPatterns.size();
- while (match == null && i < size) {
- match= (SearchPatternData) fgPreviousSearchPatterns.get(i);
- i++;
- if (!pattern.equals(match.pattern))
- match= null;
- }
- if (match == null) {
- match= new SearchPatternData(
- getSearchFor(),
- getLimitTo(),
- pattern,
- fCaseSensitive.getSelection(),
- fJavaElement,
- getContainer().getSelectedScope(),
- getContainer().getSelectedWorkingSets());
- fgPreviousSearchPatterns.add(match);
- }
- else {
- match.searchFor= getSearchFor();
- match.limitTo= getLimitTo();
- match.isCaseSensitive= fCaseSensitive.getSelection();
- match.javaElement= fJavaElement;
- match.scope= getContainer().getSelectedScope();
- match.workingSets= getContainer().getSelectedWorkingSets();
- }
- return match;
- }
-
- /*
- * Implements method from IDialogPage
- */
- public void setVisible(boolean visible) {
- if (visible && fPattern != null) {
- if (fFirstTime) {
- fFirstTime= false;
- // Set item and text here to prevent page from resizing
- fPattern.setItems(getPreviousSearchPatterns());
- initSelections();
- }
- fPattern.setFocus();
- getContainer().setPerformActionEnabled(fPattern.getText().length() > 0);
- }
- super.setVisible(visible);
- }
-
- public boolean isValid() {
- return true;
- }
-
- //---- Widget creation ------------------------------------------------
-
- /**
- * Creates the page's content.
- */
- public void createControl(Composite parent) {
- initializeDialogUnits(parent);
- readConfiguration();
-
- GridData gd;
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout(2, false);
- layout.horizontalSpacing= 10;
- result.setLayout(layout);
- result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- RowLayouter layouter= new RowLayouter(layout.numColumns);
- gd= new GridData();
- gd.horizontalAlignment= GridData.FILL;
- gd.verticalAlignment= GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
-
- layouter.setDefaultGridData(gd, 0);
- layouter.setDefaultGridData(gd, 1);
- layouter.setDefaultSpan();
-
- layouter.perform(createExpression(result));
- layouter.perform(createSearchFor(result), createLimitTo(result), -1);
-
- SelectionAdapter javaElementInitializer= new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- if (getSearchFor() == fInitialData.searchFor)
- fJavaElement= fInitialData.javaElement;
- else
- fJavaElement= null;
- setLimitTo(getSearchFor());
- updateCaseSensitiveCheckbox();
- }
- };
-
- fSearchFor[TYPE].addSelectionListener(javaElementInitializer);
- fSearchFor[METHOD].addSelectionListener(javaElementInitializer);
- fSearchFor[FIELD].addSelectionListener(javaElementInitializer);
- fSearchFor[CONSTRUCTOR].addSelectionListener(javaElementInitializer);
- fSearchFor[PACKAGE].addSelectionListener(javaElementInitializer);
-
- setControl(result);
-
- Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(result, IJavaHelpContextIds.JAVA_SEARCH_PAGE);
- }
-
- private Control createExpression(Composite parent) {
- Composite result= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout(2, false);
- result.setLayout(layout);
- GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
- gd.horizontalSpan= 2;
- gd.horizontalIndent= 0;
- result.setLayoutData(gd);
-
- // Pattern text + info
- Label label= new Label(result, SWT.LEFT);
- label.setText("Se&arch string (* = any string, ? = any character):");
- gd= new GridData(GridData.BEGINNING);
- gd.horizontalSpan= 2;
-// gd.horizontalIndent= -gd.horizontalIndent;
- label.setLayoutData(gd);
-
- // Pattern combo
- fPattern= new Combo(result, SWT.SINGLE | SWT.BORDER);
- fPattern.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handlePatternSelected();
- }
- });
- fPattern.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getContainer().setPerformActionEnabled(getPattern().length() > 0);
- updateCaseSensitiveCheckbox();
- }
- });
- gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
- gd.horizontalIndent= -gd.horizontalIndent;
- fPattern.setLayoutData(gd);
-
-
- // Ignore case checkbox
- fCaseSensitive= new Button(result, SWT.CHECK);
- fCaseSensitive.setText("Case sens&itive");
- gd= new GridData();
- fCaseSensitive.setLayoutData(gd);
- fCaseSensitive.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- fIsCaseSensitive= fCaseSensitive.getSelection();
- writeConfiguration();
- }
- });
-
- return result;
- }
-
- private void updateCaseSensitiveCheckbox() {
- if (fInitialData != null && getPattern().equals(fInitialData.pattern) && fJavaElement != null) {
- fCaseSensitive.setEnabled(false);
- fCaseSensitive.setSelection(true);
- }
- else {
- fCaseSensitive.setEnabled(true);
- fCaseSensitive.setSelection(fIsCaseSensitive);
- }
- }
-
- private void handlePatternSelected() {
- if (fPattern.getSelectionIndex() < 0)
- return;
- int index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex();
- fInitialData= (SearchPatternData) fgPreviousSearchPatterns.get(index);
- for (int i= 0; i < fSearchFor.length; i++)
- fSearchFor[i].setSelection(false);
- for (int i= 0; i < fLimitTo.length; i++)
- fLimitTo[i].setSelection(false);
- fSearchFor[fInitialData.searchFor].setSelection(true);
- setLimitTo(fInitialData.searchFor);
- fLimitTo[fInitialData.limitTo].setSelection(true);
-
- fPattern.setText(fInitialData.pattern);
- fIsCaseSensitive= fInitialData.isCaseSensitive;
- fJavaElement= fInitialData.javaElement;
- fCaseSensitive.setEnabled(fJavaElement == null);
- fCaseSensitive.setSelection(fInitialData.isCaseSensitive);
-
- if (fInitialData.workingSets != null)
- getContainer().setSelectedWorkingSets(fInitialData.workingSets);
- else
- getContainer().setSelectedScope(fInitialData.scope);
- }
-
- private Control createSearchFor(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setText("Search For");
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
- result.setLayout(layout);
-
- fSearchFor= new Button[fSearchForText.length];
- for (int i= 0; i < fSearchForText.length; i++) {
- Button button= new Button(result, SWT.RADIO);
- button.setText(fSearchForText[i]);
- fSearchFor[i]= button;
- }
-
- // Fill with dummy radio buttons
- Button filler= new Button(result, SWT.RADIO);
- filler.setVisible(false);
- filler= new Button(result, SWT.RADIO);
- filler.setVisible(false);
-
- return result;
- }
-
- private Control createLimitTo(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setText("Limit To");
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- result.setLayout(layout);
-
- fLimitTo= new Button[fLimitToText.length];
- for (int i= 0; i < fLimitToText.length; i++) {
- Button button= new Button(result, SWT.RADIO);
- button.setText(fLimitToText[i]);
- fLimitTo[i]= button;
- }
- return result;
- }
-
- private void initSelections() {
- fStructuredSelection= asStructuredSelection();
- fInitialData= tryStructuredSelection(fStructuredSelection);
- if (fInitialData == null)
- fInitialData= trySimpleTextSelection(getContainer().getSelection());
- if (fInitialData == null)
- fInitialData= getDefaultInitValues();
-
- fJavaElement= fInitialData.javaElement;
- fCaseSensitive.setSelection(fInitialData.isCaseSensitive);
- fCaseSensitive.setEnabled(fInitialData.javaElement == null);
- fSearchFor[fInitialData.searchFor].setSelection(true);
- setLimitTo(fInitialData.searchFor);
- fLimitTo[fInitialData.limitTo].setSelection(true);
- fPattern.setText(fInitialData.pattern);
- }
-
- private SearchPatternData tryStructuredSelection(IStructuredSelection selection) {
- if (selection == null || selection.size() > 1)
- return null;
-
- Object o= selection.getFirstElement();
- if (o instanceof IJavaElement) {
- return determineInitValuesFrom((IJavaElement)o);
- } else if (o instanceof ISearchResultViewEntry) {
- IJavaElement element= SearchUtil.getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker());
- return determineInitValuesFrom(element);
- } else if (o instanceof LogicalPackage) {
- LogicalPackage lp= (LogicalPackage)o;
- return new SearchPatternData(PACKAGE, REFERENCES, fIsCaseSensitive, lp.getElementName(), null);
- } else if (o instanceof IAdaptable) {
- IJavaElement element= (IJavaElement)((IAdaptable)o).getAdapter(IJavaElement.class);
- if (element != null) {
- return determineInitValuesFrom(element);
- } else {
- IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class);
- if (adapter != null)
- return new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, adapter.getLabel(o), null);
- }
- }
- return null;
- }
-
- private SearchPatternData determineInitValuesFrom(IJavaElement element) {
- if (element == null)
- return null;
- int searchFor= UNKNOWN;
- int limitTo= UNKNOWN;
- String pattern= null;
- switch (element.getElementType()) {
- case IJavaElement.PACKAGE_FRAGMENT:
- searchFor= PACKAGE;
- limitTo= REFERENCES;
- pattern= element.getElementName();
- break;
- case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- searchFor= PACKAGE;
- limitTo= REFERENCES;
- pattern= element.getElementName();
- break;
- case IJavaElement.PACKAGE_DECLARATION:
- searchFor= PACKAGE;
- limitTo= REFERENCES;
- pattern= element.getElementName();
- break;
- case IJavaElement.IMPORT_DECLARATION:
- pattern= element.getElementName();
- IImportDeclaration declaration= (IImportDeclaration)element;
- if (declaration.isOnDemand()) {
- searchFor= PACKAGE;
- int index= pattern.lastIndexOf('.');
- pattern= pattern.substring(0, index);
- } else {
- searchFor= TYPE;
- }
- limitTo= DECLARATIONS;
- break;
- case IJavaElement.TYPE:
- searchFor= TYPE;
- limitTo= REFERENCES;
- pattern= JavaModelUtil.getFullyQualifiedName((IType)element);
- break;
- case IJavaElement.COMPILATION_UNIT:
- ICompilationUnit cu= (ICompilationUnit)element;
- String mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf("."));
- IType mainType= cu.getType(mainTypeName);
- mainTypeName= JavaModelUtil.getTypeQualifiedName(mainType);
- try {
- mainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName);
- if (mainType == null) {
- // fetch type which is declared first in the file
- IType[] types= cu.getTypes();
- if (types.length > 0)
- mainType= types[0];
- else
- break;
- }
- } catch (JavaModelException ex) {
- ExceptionHandler.handle(ex, "Search Error", "An error occurred while accessing a Java element");
- break;
- }
- searchFor= TYPE;
- element= mainType;
- limitTo= REFERENCES;
- pattern= JavaModelUtil.getFullyQualifiedName(mainType);
- break;
- case IJavaElement.CLASS_FILE:
- IClassFile cf= (IClassFile)element;
- try {
- mainType= cf.getType();
- } catch (JavaModelException ex) {
- ExceptionHandler.handle(ex, "Search Error", "An error occurred while accessing a Java element");
- break;
- }
- if (mainType == null)
- break;
- element= mainType;
- searchFor= TYPE;
- limitTo= REFERENCES;
- pattern= JavaModelUtil.getFullyQualifiedName(mainType);
- break;
- case IJavaElement.FIELD:
- searchFor= FIELD;
- limitTo= REFERENCES;
- IType type= ((IField)element).getDeclaringType();
- StringBuffer buffer= new StringBuffer();
- buffer.append(JavaModelUtil.getFullyQualifiedName(type));
- buffer.append('.');
- buffer.append(element.getElementName());
- pattern= buffer.toString();
- break;
- case IJavaElement.METHOD:
- searchFor= METHOD;
- try {
- IMethod method= (IMethod)element;
- if (method.isConstructor())
- searchFor= CONSTRUCTOR;
- } catch (JavaModelException ex) {
- ExceptionHandler.handle(ex, "Search Error", "An error occurred while accessing a Java element");
- break;
- }
- limitTo= REFERENCES;
- pattern= PrettySignature.getMethodSignature((IMethod)element);
- break;
- }
- if (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null)
- return new SearchPatternData(searchFor, limitTo, true, pattern, element);
-
- return null;
- }
-
- private SearchPatternData trySimpleTextSelection(ISelection selection) {
- SearchPatternData result= null;
- if (selection instanceof ITextSelection) {
- BufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText()));
- String text;
- try {
- text= reader.readLine();
- if (text == null)
- text= "";
- } catch (IOException ex) {
- text= "";
- }
- result= new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, text, null);
- }
- return result;
- }
-
- private SearchPatternData getDefaultInitValues() {
- return new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, "", null);
- }
-
- /*
- * Implements method from ISearchPage
- */
- public void setContainer(ISearchPageContainer container) {
- fContainer= container;
- }
-
- /**
- * Returns the search page's container.
- */
- private ISearchPageContainer getContainer() {
- return fContainer;
- }
-
- /**
- * Returns the structured selection from the selection.
- */
- private IStructuredSelection asStructuredSelection() {
- IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (wbWindow != null) {
- IWorkbenchPage page= wbWindow.getActivePage();
- if (page != null) {
- IWorkbenchPart part= page.getActivePart();
- if (part != null)
- try {
- return SelectionConverter.getStructuredSelection(part);
- } catch (JavaModelException ex) {
- JspUIPlugin.log("internal error", ex);
- }
- }
- }
- return StructuredSelection.EMPTY;
- }
-
- //--------------- Configuration handling --------------
-
- /**
- * Returns the page settings for this Java search page.
- *
- * @return the page settings to be used
- */
- private IDialogSettings getDialogSettings() {
- IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
- fDialogSettings= settings.getSection(PAGE_NAME);
- if (fDialogSettings == null)
- fDialogSettings= settings.addNewSection(PAGE_NAME);
- return fDialogSettings;
- }
-
- /**
- * Initializes itself from the stored page settings.
- */
- private void readConfiguration() {
- IDialogSettings s= getDialogSettings();
- fIsCaseSensitive= s.getBoolean(STORE_CASE_SENSITIVE);
- }
-
- /**
- * Stores it current configuration in the dialog store.
- */
- private void writeConfiguration() {
- IDialogSettings s= getDialogSettings();
- s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive);
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultCollector.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultCollector.java
deleted file mode 100644
index 82c219ddfa..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultCollector.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-
-import org.eclipse.search.ui.IActionGroupFactory;
-import org.eclipse.search.ui.ISearchResultView;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.ActionGroup;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.search.IJavaSearchResultCollector;
-
-import org.eclipse.jdt.ui.JavaUI;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog;
-import org.eclipse.jdt.internal.ui.search.IJavaSearchUIConstants;
-
-
-public class JavaSearchResultCollector implements IJavaSearchResultCollector {
-
- private static final String MATCH= "1 match";
- private static final String MATCHES= "{0} matches";
- private static final String DONE= "Search done: {0}.";
- private static final String SEARCHING= "";
- private static final Boolean POTENTIAL_MATCH_VALUE= new Boolean(true);
- private static final String POTENTIAL_MATCH_DIALOG_ID= "Search.PotentialMatchDialog";
-
- private IProgressMonitor fMonitor;
- private ISearchResultView fView;
- private JavaSearchOperation fOperation;
- private int fMatchCount= 0;
- private int fPotentialMatchCount= 0;
- private long fLastUpdateTime;
- private Integer[] fMessageFormatArgs= new Integer[1];
-
- private class ActionGroupFactory implements IActionGroupFactory {
- public ActionGroup createActionGroup(ISearchResultView part) {
- return new SearchViewActionGroup(part);
- }
- }
-
- public JavaSearchResultCollector() {
- // This ensures that the image class is loaded correctly
- JavaPlugin.getDefault().getImageRegistry();
- }
-
- /**
- * @see IJavaSearchResultCollector#aboutToStart().
- */
- public void aboutToStart() {
- fPotentialMatchCount= 0;
- fView= SearchUI.getSearchResultView();
- fMatchCount= 0;
- fLastUpdateTime= 0;
- if (fView != null) {
- fView.searchStarted(
- new ActionGroupFactory(),
- fOperation.getSingularLabel(),
- fOperation.getPluralLabelPattern(),
- fOperation.getImageDescriptor(),
- JavaSearchPage2.EXTENSION_POINT_ID,
- new JavaSearchResultLabelProvider(),
- new GotoMarkerAction(),
- new GroupByKeyComputer(),
- fOperation);
- }
- if (!getProgressMonitor().isCanceled())
- getProgressMonitor().subTask(SEARCHING);
- }
-
- /**
- * @see IJavaSearchResultCollector#accept
- */
- public void accept(IResource resource, int start, int end, IJavaElement enclosingElement, int accuracy) throws CoreException {
-
- if (enclosingElement == null) { // non-Java match
- IMarker marker= resource.createMarker(SearchUI.SEARCH_MARKER);
-
- String description= resource.getFullPath().lastSegment();
- if (description == null)
- description= "";
-
- HashMap attributes= new HashMap(3);
- attributes.put(IMarker.CHAR_START, new Integer(Math.max(start, 0)));
- attributes.put(IMarker.CHAR_END, new Integer(Math.max(end, 0)));
- marker.setAttributes(attributes);
-
- fView.addMatch(description, resource, resource, marker);
- fMatchCount++;
-
- if (!getProgressMonitor().isCanceled() && System.currentTimeMillis() - fLastUpdateTime > 1000) {
- getProgressMonitor().subTask(getFormattedMatchesString(fMatchCount));
- fLastUpdateTime= System.currentTimeMillis();
- }
-
- return;
- }
-
- if (accuracy == POTENTIAL_MATCH && SearchUI.arePotentialMatchesIgnored())
- return;
-
- IMarker marker= resource.createMarker(SearchUI.SEARCH_MARKER);
- HashMap attributes;
- Object groupKey= enclosingElement;
- attributes= new HashMap(7);
- if (accuracy == POTENTIAL_MATCH) {
- fPotentialMatchCount++;
- attributes.put(SearchUI.POTENTIAL_MATCH, POTENTIAL_MATCH_VALUE);
- if (groupKey == null)
- groupKey= "?:null";
- else
- groupKey= "?:" + enclosingElement.getHandleIdentifier();
- }
- ICompilationUnit cu= SearchUtil.findCompilationUnit(enclosingElement);
- if (cu != null && cu.isWorkingCopy())
- attributes.put(IJavaSearchUIConstants.ATT_IS_WORKING_COPY, new Boolean(true)); //$NON-NLS-1$
-
- JavaCore.addJavaElementMarkerAttributes(attributes, enclosingElement);
- attributes.put(IJavaSearchUIConstants.ATT_JE_HANDLE_ID, enclosingElement.getHandleIdentifier());
- attributes.put(IMarker.CHAR_START, new Integer(Math.max(start, 0)));
- attributes.put(IMarker.CHAR_END, new Integer(Math.max(end, 0)));
- if (enclosingElement instanceof IMember && ((IMember)enclosingElement).isBinary())
- attributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CF_EDITOR);
- else
- attributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CU_EDITOR);
- marker.setAttributes(attributes);
-
- fView.addMatch(enclosingElement.getElementName(), groupKey, resource, marker);
- fMatchCount++;
- if (!getProgressMonitor().isCanceled() && System.currentTimeMillis() - fLastUpdateTime > 1000) {
- getProgressMonitor().subTask(getFormattedMatchesString(fMatchCount));
- fLastUpdateTime= System.currentTimeMillis();
- }
- }
-
- /**
- * @see IJavaSearchResultCollector#done().
- */
- public void done() {
- if (!getProgressMonitor().isCanceled()) {
- String matchesString= getFormattedMatchesString(fMatchCount);
- getProgressMonitor().setTaskName(MessageFormat.format(DONE, new String[]{matchesString}));
- }
-
- if (fView != null) {
- if (fPotentialMatchCount > 0)
- explainPotentialMatch(fPotentialMatchCount);
- fView.searchFinished();
- }
-
- // Cut no longer unused references because the collector might be re-used
- fView= null;
- fMonitor= null;
- }
-
- private void explainPotentialMatch(final int potentialMatchCount) {
- // Make sure we are doing it in the right thread.
- final Shell shell= fView.getSite().getShell();
- final String title;
- if (potentialMatchCount == 1)
- title= new String("Search: Found 1 Inexact Match");
- else
- title= new String("Search: Found {0} Inexact Matches");
-
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- OptionalMessageDialog.open(
- POTENTIAL_MATCH_DIALOG_ID, //$NON-NLS-1$,
- shell,
- title,
- null,
- "Inexact matches were found and will be displayed with a different\nforeground color. This can be configured on the Search preferences page.",
- MessageDialog.INFORMATION,
- new String[] { IDialogConstants.OK_LABEL },
- 0);
- }
- });
- }
-
- /*
- * @see IJavaSearchResultCollector#getProgressMonitor().
- */
- public IProgressMonitor getProgressMonitor() {
- return fMonitor;
- }
-
- void setProgressMonitor(IProgressMonitor pm) {
- fMonitor= pm;
- }
-
- void setOperation(JavaSearchOperation operation) {
- fOperation= operation;
- }
-
- private String getFormattedMatchesString(int count) {
- if (fMatchCount == 1)
- return MATCH;
- fMessageFormatArgs[0]= new Integer(count);
- return MessageFormat.format(MATCHES, fMessageFormatArgs);
-
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultLabelProvider.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultLabelProvider.java
deleted file mode 100644
index 770050673e..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/JavaSearchResultLabelProvider.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.core.resources.IMarker;
-
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.PlatformUI;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-import org.eclipse.search.ui.SearchUI;
-
-import org.eclipse.jdt.core.IImportDeclaration;
-import org.eclipse.jdt.core.IJavaElement;
-
-import org.eclipse.jdt.ui.JavaElementLabels;
-import org.eclipse.jdt.ui.ProblemsLabelDecorator;
-
-import org.eclipse.jdt.internal.ui.JavaPluginImages;
-import org.eclipse.jdt.internal.ui.search.IJavaSearchUIConstants;
-import org.eclipse.jdt.internal.ui.search.SearchUtil;
-import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-
-public class JavaSearchResultLabelProvider extends LabelProvider {
- public static final int SHOW_ELEMENT_CONTAINER= 1;
- public static final int SHOW_CONTAINER_ELEMENT= 2;
- public static final int SHOW_PATH= 3;
-
- public static final String POTENTIAL_MATCH= " (inexact)";
-
- private AppearanceAwareLabelProvider fLabelProvider;
- private ILabelDecorator fDecorator;
-
- // Cache
- private IMarker fLastMarker;
- private IJavaElement fLastJavaElement;
-
- public JavaSearchResultLabelProvider() {
- fDecorator= PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator();
- fLabelProvider=
- new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED,
- AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS);
- fLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
- }
-
- public String getText(Object o) {
- fLastMarker= null; // reset cache
- IJavaElement javaElement= getJavaElement(o); // sets fLastMarker as side effect
- boolean isPotentialMatch= fLastMarker != null && fLastMarker.getAttribute(SearchUI.POTENTIAL_MATCH, false);
- if (javaElement == null) {
- if (fLastMarker != null) {
- if (isPotentialMatch)
- return super.getText(fLastMarker.getResource()) + POTENTIAL_MATCH;
- else
- return super.getText(fLastMarker.getResource());
- }
- else
- return ""; //$NON-NLS-1$
- }
-
- if (javaElement instanceof IImportDeclaration)
- javaElement= ((IImportDeclaration)javaElement).getParent().getParent();
-
- String text= ""; //$NON-NLS-1$
- if (isPotentialMatch)
- text= fLabelProvider.getText(javaElement) + POTENTIAL_MATCH;
- else
- text= fLabelProvider.getText(javaElement);
-
- if (fDecorator != null) {
- String decoratedText= fDecorator.decorateText(text, javaElement);
- if (decoratedText != null)
- return decoratedText;
- }
- return text;
- }
-
- public Image getImage(Object o) {
- IJavaElement javaElement= getJavaElement(o);
-
- Image image= fLabelProvider.getImage(o);
- if (image == null)
- return JavaPluginImages.get(JavaPluginImages.IMG_OBJS_UNKNOWN);
-
- if (fDecorator != null && javaElement != null) {
- Image decoratedImage= fDecorator.decorateImage(image, javaElement);
- if (decoratedImage != null)
- return decoratedImage;
- }
- return image;
- }
-
- public void setAppearance(int appearanceFlag) {
- long flags= AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.P_COMPRESSED;
- if (appearanceFlag == SHOW_ELEMENT_CONTAINER)
- flags |= JavaElementLabels.F_POST_QUALIFIED | JavaElementLabels.M_POST_QUALIFIED | JavaElementLabels.I_POST_QUALIFIED | JavaElementLabels.M_PARAMETER_TYPES
- | JavaElementLabels.T_POST_QUALIFIED | JavaElementLabels.D_POST_QUALIFIED | JavaElementLabels.CF_POST_QUALIFIED | JavaElementLabels.CU_POST_QUALIFIED;
-
- else if (appearanceFlag == SHOW_CONTAINER_ELEMENT)
- flags |= JavaElementLabels.F_FULLY_QUALIFIED | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.I_FULLY_QUALIFIED | JavaElementLabels.M_PARAMETER_TYPES
- | JavaElementLabels.T_FULLY_QUALIFIED | JavaElementLabels.D_QUALIFIED | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED;
- else if (appearanceFlag == SHOW_PATH) {
- flags |= JavaElementLabels.F_FULLY_QUALIFIED | JavaElementLabels.M_FULLY_QUALIFIED | JavaElementLabels.I_FULLY_QUALIFIED | JavaElementLabels.M_PARAMETER_TYPES
- | JavaElementLabels.T_FULLY_QUALIFIED | JavaElementLabels.D_QUALIFIED | JavaElementLabels.CF_QUALIFIED | JavaElementLabels.CU_QUALIFIED;
- flags |= JavaElementLabels.PREPEND_ROOT_PATH;
- }
- fLabelProvider.setTextFlags(flags);
- }
-
-
- private IJavaElement getJavaElement(Object o) {
- if (o instanceof IJavaElement)
- return (IJavaElement)o;
-
- IMarker marker= getMarker(o);
- if (marker == null)
- return null;
-
- return getJavaElement(marker, (ISearchResultViewEntry)o);
- }
-
- protected IMarker getMarker(Object o) {
- if (!(o instanceof ISearchResultViewEntry))
- return null;
- return ((ISearchResultViewEntry)o).getSelectedMarker();
- }
-
- private IJavaElement getJavaElement(IMarker marker, ISearchResultViewEntry entry) {
- if (fLastMarker != marker) {
- boolean canUseGroupByKey= !marker.getAttribute(SearchUI.POTENTIAL_MATCH, false)
- && !marker.getAttribute(IJavaSearchUIConstants.ATT_IS_WORKING_COPY, false)
- && !marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID_CHANGED, false);
-
- if (canUseGroupByKey && entry.getGroupByKey() instanceof IJavaElement)
- fLastJavaElement= (IJavaElement)entry.getGroupByKey();
- else
- fLastJavaElement= SearchUtil.getJavaElement(marker);
- fLastMarker= marker;
- }
- return fLastJavaElement;
- }
-
- public void addListener(ILabelProviderListener listener) {
- super.addListener(listener);
- fLabelProvider.addListener(listener);
- }
-
- public void dispose() {
- super.dispose();
- fLabelProvider.dispose();
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return fLabelProvider.isLabelProperty(element, property);
- }
-
- public void removeListener(ILabelProviderListener listener) {
- super.removeListener(listener);
- fLabelProvider.removeListener(listener);
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.java
deleted file mode 100644
index 34a4aa90c4..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class SearchMessages {
-
- private static final String RESOURCE_BUNDLE= SearchMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private SearchMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object arg) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- if (arg == null)
- arg= ""; //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { arg });
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.properties b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.properties
deleted file mode 100644
index 8f5d952d56..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchMessages.properties
+++ /dev/null
@@ -1,162 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-group.search=S&earch
-group.declarations= Dec&larations
-group.references= Re&ferences
-group.readReferences= &Read Access
-group.writeReferences= &Write Access
-group.implementors= &Implementors
-
-Search.Error.search.title=Search Error
-Search.Error.search.message=An error occurred during the search operation
-
-Search.Error.javaElementAccess.title=Search Error
-Search.Error.javaElementAccess.message=An error occurred while accessing a Java element
-
-Search.Error.markerAttributeAccess.title=Search Error
-Search.Error.markerAttributeAccess.message=An error occurred while accessing a marker attribute
-
-Search.Error.createJavaElement.title=Search Error
-Search.Error.createJavaElement.message=An error occurred while creating a Java element
-
-Search.Error.openEditor.title=Search Error
-Search.Error.openEditor.message=Could not open the editor
-
-Search.Error.codeResolve= Code resolve error
-
-Search.Error.setDescription.title=Search Error
-Search.Error.setDescription.message=Cannot save workspace description
-
-SearchElementSelectionDialog.title=Search
-SearchElementSelectionDialog.message=Select the element to search for.
-
-SearchResultCollector.match= 1 match
-SearchResultCollector.matches= {0} matches
-SearchResultCollector.done= Search done: {0}.
-SearchResultCollector.searching= Searching...
-
-Search.potentialMatchDialog.title.foundPotentialMatch= Search: Found 1 Inexact Match
-Search.potentialMatchDialog.title.foundPotentialMatches= Search: Found {0} Inexact Matches
-Search.potentialMatchDialog.message= Inexact matches were found and will be displayed with a different\nforeground color. This can be configured on the Search preference page.
-
-SearchPage.searchFor.label= Search For
-SearchPage.searchFor.type= &Type
-SearchPage.searchFor.method= &Method
-SearchPage.searchFor.field= &Field
-SearchPage.searchFor.package= &Package
-SearchPage.searchFor.constructor= Co&nstructor
-
-SearchPage.limitTo.label= Limit To
-SearchPage.limitTo.declarations= Dec&larations
-SearchPage.limitTo.implementors= &Implementors
-SearchPage.limitTo.references= &References
-SearchPage.limitTo.allOccurrences= All &Occurrences
-SearchPage.limitTo.readReferences= Read A&ccess
-SearchPage.limitTo.writeReferences= Writ&e Access
-
-SearchPage.expression.label= Se&arch string (* = any string, ? = any character):
-SearchPage.expression.caseSensitive= Case sens&itive
-
-# Concatenate two working set names e.g. "Source, Lib"
-SearchUtil.workingSetConcatenation= {0}, {1}
-
-Search.FindDeclarationAction.label= &Workspace
-Search.FindDeclarationAction.tooltip= Search for Declarations of the Selected Element in the Workspace
-
-Search.FindDeclarationsInWorkingSetAction.label= Working &Set...
-Search.FindDeclarationsInWorkingSetAction.tooltip= Search for Declarations of the Selected Element in a Working Set
-
-Search.FindHierarchyDeclarationsAction.label= &Hierarchy
-Search.FindHierarchyDeclarationsAction.tooltip= Search for Declarations of the Selected Element in its Hierarchy
-
-Search.FindImplementorsAction.label= &Workspace
-Search.FindImplementorsAction.tooltip= Search for Implementors of the Selected Interface
-
-Search.FindImplementorsInWorkingSetAction.label= Working &Set...
-Search.FindImplementorsInWorkingSetAction.tooltip= Search for Implementors of the Selected Interface in a Working Set
-
-Search.FindReferencesAction.label= &Workspace
-Search.FindReferencesAction.tooltip= Search for References to the Selected Element in the Workspace
-
-Search.FindReferencesAction.BinPrimConstWarnDialog.title= Search for References to a Binary Constant
-Search.FindReferencesAction.BinPrimConstWarnDialog.message= Matches to this constant will only be discovered in source files and binary files where the constant value is not inlined.
-
-Search.FindReferencesInWorkingSetAction.label= Working &Set...
-Search.FindReferencesInWorkingSetAction.tooltip= Search for References to the Selected Element in a Working Set
-
-Search.FindHierarchyReferencesAction.label= &Hierarchy
-Search.FindHierarchyReferencesAction.tooltip= Search for References of the Selected Element in its Hierarchy
-
-Search.FindReadReferencesAction.label= &Workspace
-Search.FindReadReferencesAction.tooltip= Search for Read References to the Selected Element in the Workspace
-
-Search.FindReadReferencesInWorkingSetAction.label= Working &Set...
-Search.FindReadReferencesInWorkingSetAction.tooltip= Search for Read References to the Selected Element in a Working Set
-
-Search.FindReadReferencesInHierarchyAction.label= &Hierarchy
-Search.FindReadReferencesInHierarchyAction.tooltip= Search for Read References of the Selected Element in its Hierarchy
-
-Search.FindWriteReferencesAction.label= &Workspace
-Search.FindWriteReferencesAction.tooltip= Search for Write References to the Selected Element in the Workspace
-
-Search.FindWriteReferencesInWorkingSetAction.label= Working &Set...
-Search.FindWriteReferencesInWorkingSetAction.tooltip= Search for Write References to the Selected Element in a Working Set
-
-Search.FindWriteReferencesInHierarchyAction.label= &Hierarchy
-Search.FindWriteReferencesInHierarchyAction.tooltip= Search for Write References of the Selected Element in its Hierarchy
-
-Search.FindOccurrencesInFile.label= Occurre&nces in File
-Search.FindOccurrencesInFile.tooltip= Find occurrences of selected element in the editor
-
-FindOccurrencesEngine.noSource.text= No source available. To perform this operation you need to attach source.
-FindOccurrencesEngine.noJavaElement.text= Cannot search for the current selection. Please select a valid Java element name.
-FindOccurrencesEngine.cannotParse.text= Cannot analyze the compilation unit or class file.
-
-
-JavaSearchOperation.default_package=(default package)
-
-# The first argument will be replaced by the pattern and the second by the scope
-JavaSearchOperation.singularDeclarationsPostfix={0} - 1 Declaration in {1}
-JavaSearchOperation.singularReferencesPostfix={0} - 1 Reference in {1}
-JavaSearchOperation.singularReadReferencesPostfix={0} - 1 Read Reference in {1}
-JavaSearchOperation.singularWriteReferencesPostfix={0} - 1 Write Reference in {1}
-JavaSearchOperation.singularImplementorsPostfix={0} - 1 Implementor in {1}
-JavaSearchOperation.singularOccurrencesPostfix={0} - 1 Occurrence in {1}
-
-# The first argument will be replaced by the pattern, the second by the count and the last by the scope
-JavaSearchOperation.pluralDeclarationsPostfix={0} - {1} Declarations in {2}
-JavaSearchOperation.pluralReferencesPostfix={0} - {1} References in {2}
-JavaSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
-JavaSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
-JavaSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
-JavaSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
-
-# The first argument will be replaced by the element name and the second one by the file name
-JavaSearchInFile.singularPostfix={0} - 1 Occurrence in {1}
-# The first argument will be replaced by the element name, the second by the count and the last by the file name
-JavaSearchInFile.pluralPostfix={0} - {1} Occurrences in {2}
-
-JavaElementAction.typeSelectionDialog.title=Search
-JavaElementAction.typeSelectionDialog.message=&Select the type to search:
-JavaElementAction.error.open.message=An exception occurred while opening the type.
-
-JavaElementAction.operationUnavailable.title= Operation Unavailable
-JavaElementAction.operationUnavailable.generic= The operation is unavailable on the current selection. Please select a valid Java element name.
-JavaElementAction.operationUnavailable.field= The operation is unavailable on the current selection. Please select the name of a field.
-JavaElementAction.operationUnavailable.interface= The operation is unavailable on the current selection. Please select the name of an interface.
-
-JavaSearchResultLabelProvider.potentialMatch= \ (inexact)
-
-WorkspaceScope= Workspace
-WorkingSetScope= Working Set - {0}
-SelectionScope= Selection
-HierarchyScope= Hierarchy - {0}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchUtil.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchUtil.java
deleted file mode 100644
index b55d9f9692..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchUtil.java
+++ /dev/null
@@ -1,400 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PlatformUI;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-
-import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.dialogs.OptionalMessageDialog;
-import org.eclipse.jdt.internal.ui.search.IJavaSearchUIConstants;
-import org.eclipse.jdt.internal.ui.search.LRUWorkingSetsList;
-import org.eclipse.jdt.internal.ui.search.WorkingSetComparator;
-import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
-
-/**
- * This class contains some utility methods for J Search.
- */
-/**
- * This class contains some utility methods for J Search.
- */
-public class SearchUtil {
-
- // LRU working sets
- public static int LRU_WORKINGSET_LIST_SIZE= 3;
- private static LRUWorkingSetsList fgLRUWorkingSets;
-
- // Settings store
- private static final String DIALOG_SETTINGS_KEY= "JavaElementSearchActions"; //$NON-NLS-1$
- private static final String STORE_LRU_WORKING_SET_NAMES= "lastUsedWorkingSetNames"; //$NON-NLS-1$
-
- private static IDialogSettings fgSettingsStore;
-
- private static final String BIN_PRIM_CONST_WARN_DIALOG_ID= "BinaryPrimitiveConstantWarningDialog"; //$NON-NLS-1$
-
-
- public static IJavaElement getJavaElement(IMarker marker) {
- if (marker == null || !marker.exists())
- return null;
- try {
- String handleId= (String)marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID);
- IJavaElement je= JavaCore.create(handleId);
- if (je == null)
- return null;
-
- if (!marker.getAttribute(IJavaSearchUIConstants.ATT_IS_WORKING_COPY, false)) {
- if (je.exists())
- return je;
- }
-
- ICompilationUnit cu= (ICompilationUnit) je.getAncestor(IJavaElement.COMPILATION_UNIT);
- if (cu == null) {
- return je;
- }
- if (!cu.exists()) {
- IResource res= marker.getResource();
- if (res instanceof IFile) {
- cu= JavaCore.createCompilationUnitFrom((IFile) res);
- if (cu == null) {
- return je;
- }
-
- }
- }
-
- if (!JavaPlugin.USE_WORKING_COPY_OWNERS) {
- IJavaElement wcElem= JavaModelUtil.toWorkingCopy(je);
- if (wcElem.exists()) {
- return wcElem;
- }
- }
-
- if (!je.exists()) {
- IJavaElement[] jElements= cu.findElements(je);
- if (jElements == null || jElements.length == 0)
- je= cu.getElementAt(marker.getAttribute(IMarker.CHAR_START, 0));
- else
- je= jElements[0];
- }
- return je;
- } catch (JavaModelException ex) {
- if (!ex.isDoesNotExist())
- ExceptionHandler.handle(ex, "Search Error", "An error occurred while creating a Java element"); //$NON-NLS-2$ //$NON-NLS-1$
- return null;
- } catch (CoreException ex) {
- ExceptionHandler.handle(ex, "Search Error", "An error occurred while creating a Java element"); //$NON-NLS-2$ //$NON-NLS-1$
- return null;
- }
- }
-
- public static IJavaElement getJavaElement(Object entry) {
- if (entry != null && isISearchResultViewEntry(entry))
- return getJavaElement((ISearchResultViewEntry)entry);
- return null;
- }
-
- public static IResource getResource(Object entry) {
- if (entry != null && isISearchResultViewEntry(entry))
- return ((ISearchResultViewEntry)entry).getResource();
- return null;
- }
-
- public static IJavaElement getJavaElement(ISearchResultViewEntry entry) {
- if (entry != null)
- return getJavaElement(entry.getSelectedMarker());
- return null;
- }
-
- public static boolean isSearchPlugInActivated() {
- return Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.search").isPluginActivated(); //$NON-NLS-1$
- }
-
- public static boolean isISearchResultViewEntry(Object object) {
- return object != null && isSearchPlugInActivated() && (object instanceof ISearchResultViewEntry);
- }
-
- /**
- * Returns the compilation unit for the given java element.
- *
- * @param element the java element whose compilation unit is searched for
- * @return the compilation unit of the given java element
- */
- static ICompilationUnit findCompilationUnit(IJavaElement element) {
- if (element == null)
- return null;
- return (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
- }
-
- /*
- * Copied from JavaModelUtil and patched to allow members which do not exist.
- * The only case where this is a problem is for methods which have same name and
- * paramters as a constructor. The constructor will win in such a situation.
- *
- * @see JavaModelUtil#findMemberInCompilationUnit(ICompilationUnit, IMember)
- */
- public static IMember findInCompilationUnit(ICompilationUnit cu, IMember member) throws JavaModelException {
- if (member.getElementType() == IJavaElement.TYPE) {
- return JavaModelUtil.findTypeInCompilationUnit(cu, JavaModelUtil.getTypeQualifiedName((IType)member));
- } else {
- IType declaringType= JavaModelUtil.findTypeInCompilationUnit(cu, JavaModelUtil.getTypeQualifiedName(member.getDeclaringType()));
- if (declaringType != null) {
- IMember result= null;
- switch (member.getElementType()) {
- case IJavaElement.FIELD:
- result= declaringType.getField(member.getElementName());
- break;
- case IJavaElement.METHOD:
- IMethod meth= (IMethod) member;
- // XXX: Begin patch ---------------------
- boolean isConstructor;
- if (meth.exists())
- isConstructor= meth.isConstructor();
- else
- isConstructor= declaringType.getElementName().equals(meth.getElementName());
- // XXX: End patch -----------------------
- result= JavaModelUtil.findMethod(meth.getElementName(), meth.getParameterTypes(), isConstructor, declaringType);
- break;
- case IJavaElement.INITIALIZER:
- result= declaringType.getInitializer(1);
- break;
- }
- if (result != null && result.exists()) {
- return result;
- }
- }
- }
- return null;
- }
-
- /*
- * XXX: Unchanged copy from JavaModelUtil
- */
- public static IJavaElement findInCompilationUnit(ICompilationUnit cu, IJavaElement element) throws JavaModelException {
-
- if (element instanceof IMember)
- return findInCompilationUnit(cu, (IMember)element);
-
- int type= element.getElementType();
- switch (type) {
- case IJavaElement.IMPORT_CONTAINER:
- return cu.getImportContainer();
-
- case IJavaElement.PACKAGE_DECLARATION:
- return find(cu.getPackageDeclarations(), element.getElementName());
-
- case IJavaElement.IMPORT_DECLARATION:
- return find(cu.getImports(), element.getElementName());
-
- case IJavaElement.COMPILATION_UNIT:
- return cu;
- }
-
- return null;
- }
-
- /*
- * XXX: Unchanged copy from JavaModelUtil
- */
- private static IJavaElement find(IJavaElement[] elements, String name) {
- if (elements == null || name == null)
- return null;
-
- for (int i= 0; i < elements.length; i++) {
- if (name.equals(elements[i].getElementName()))
- return elements[i];
- }
-
- return null;
- }
-
- public static String toString(IWorkingSet[] workingSets) {
- Arrays.sort(workingSets, new WorkingSetComparator());
- String result= ""; //$NON-NLS-1$
- if (workingSets != null && workingSets.length > 0) {
- boolean firstFound= false;
- for (int i= 0; i < workingSets.length; i++) {
- String workingSetName= workingSets[i].getName();
- if (firstFound)
- result= "{0}, {1}"; //$NON-NLS-1$
- else {
- result= workingSetName;
- firstFound= true;
- }
- }
- }
- return result;
- }
-
- // ---------- LRU working set handling ----------
-
- /**
- * Updates the LRU list of working sets.
- *
- * @param workingSets the workings sets to be added to the LRU list
- */
- public static void updateLRUWorkingSets(IWorkingSet[] workingSets) {
- if (workingSets == null || workingSets.length < 1)
- return;
-
- getLRUWorkingSets().add(workingSets);
- saveState();
- }
-
- private static void saveState() {
- IWorkingSet[] workingSets;
- Iterator iter= fgLRUWorkingSets.iterator();
- int i= 0;
- while (iter.hasNext()) {
- workingSets= (IWorkingSet[])iter.next();
- String[] names= new String[workingSets.length];
- for (int j= 0; j < workingSets.length; j++)
- names[j]= workingSets[j].getName();
- fgSettingsStore.put(STORE_LRU_WORKING_SET_NAMES + i, names);
- i++;
- }
- }
-
- public static LRUWorkingSetsList getLRUWorkingSets() {
- if (fgLRUWorkingSets == null) {
- restoreState();
- }
- return fgLRUWorkingSets;
- }
-
- static void restoreState() {
- fgLRUWorkingSets= new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE);
- fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
- if (fgSettingsStore == null)
- fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS_KEY);
-
- boolean foundLRU= false;
- for (int i= LRU_WORKINGSET_LIST_SIZE - 1; i >= 0; i--) {
- String[] lruWorkingSetNames= fgSettingsStore.getArray(STORE_LRU_WORKING_SET_NAMES + i);
- if (lruWorkingSetNames != null) {
- Set workingSets= new HashSet(2);
- for (int j= 0; j < lruWorkingSetNames.length; j++) {
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[j]);
- if (workingSet != null) {
- workingSets.add(workingSet);
- }
- }
- foundLRU= true;
- if (!workingSets.isEmpty())
- fgLRUWorkingSets.add((IWorkingSet[])workingSets.toArray(new IWorkingSet[workingSets.size()]));
- }
- }
- if (!foundLRU)
- // try old preference format
- restoreFromOldFormat();
- }
-
- private static void restoreFromOldFormat() {
- fgLRUWorkingSets= new LRUWorkingSetsList(LRU_WORKINGSET_LIST_SIZE);
- fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY);
- if (fgSettingsStore == null)
- fgSettingsStore= JavaPlugin.getDefault().getDialogSettings().addNewSection(DIALOG_SETTINGS_KEY);
-
- boolean foundLRU= false;
- String[] lruWorkingSetNames= fgSettingsStore.getArray(STORE_LRU_WORKING_SET_NAMES);
- if (lruWorkingSetNames != null) {
- for (int i= lruWorkingSetNames.length - 1; i >= 0; i--) {
- IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(lruWorkingSetNames[i]);
- if (workingSet != null) {
- foundLRU= true;
- fgLRUWorkingSets.add(new IWorkingSet[]{workingSet});
- }
- }
- }
- if (foundLRU)
- // save in new format
- saveState();
- }
-
- public static void warnIfBinaryConstant(IJavaElement element, Shell shell) {
- if (isBinaryPrimitveConstantOrString(element))
- OptionalMessageDialog.open(
- BIN_PRIM_CONST_WARN_DIALOG_ID,
- shell,
- "Search for References to a Binary Constant", //$NON-NLS-1$
- null,
- "Matches to this constant will only be discovered in source files and binary files where the constant value is not inlined.", //$NON-NLS-1$
- MessageDialog.INFORMATION,
- new String[] { IDialogConstants.OK_LABEL },
- 0);
- }
-
- private static boolean isBinaryPrimitveConstantOrString(IJavaElement element) {
- if (element != null && element.getElementType() == IJavaElement.FIELD) {
- IField field= (IField)element;
- int flags;
- try {
- flags= field.getFlags();
- } catch (JavaModelException ex) {
- return false;
- }
- return field.isBinary() && Flags.isStatic(flags) && Flags.isFinal(flags) && isPrimitiveOrString(field);
- }
- return false;
- }
-
- private static boolean isPrimitiveOrString(IField field) {
- String fieldType;
- try {
- fieldType= field.getTypeSignature();
- } catch (JavaModelException ex) {
- return false;
- }
- char first= fieldType.charAt(0);
- return (first != Signature.C_RESOLVED && first != Signature.C_UNRESOLVED && first != Signature.C_ARRAY)
- || (first == Signature.C_RESOLVED && fieldType.substring(1, fieldType.length() - 1).equals(String.class.getName()));
- }
-
- public static String getProjectScopeDescription(IType type) {
- IJavaProject project= type.getJavaProject();
- if (project != null)
- return "Project {0}"; //$NON-NLS-1$
- else
- return "Project {0}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewActionGroup.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewActionGroup.java
deleted file mode 100644
index 82ace6c97a..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewActionGroup.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.actions.ActionGroup;
-
-import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
-import org.eclipse.jdt.ui.actions.NavigateActionGroup;
-
-import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup;
-
-class SearchViewActionGroup extends CompositeActionGroup {
-
- public SearchViewActionGroup(IViewPart part) {
- Assert.isNotNull(part);
- setGroups(new ActionGroup[] {
- new JavaSearchActionGroup(part),
- new NavigateActionGroup(new SearchViewAdapter(new SearchViewSiteAdapter(part.getSite())))});
- }
-}
-
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewAdapter.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewAdapter.java
deleted file mode 100644
index 4b47c98065..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewAdapter.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PartInitException;
-
-/**
- * This class adapts a Search view to return an adapted Search view site.
- *
- * @since 2.1
- */
-class SearchViewAdapter implements IViewPart {
-
- private IWorkbenchPartSite fSite;
-
- /**
- * Constructor for SearchViewAdapter.
- */
- public SearchViewAdapter(IWorkbenchPartSite site) {
- fSite= site;
- }
-
- /**
- * @see org.eclipse.ui.IWorkbenchPart#getSite()
- */
- public IWorkbenchPartSite getSite() {
- return fSite;
- }
-
- // --------- only empty stubs below ---------
-
- /*
- * @see org.eclipse.ui.IViewPart#getViewSite()
- */
- public IViewSite getViewSite() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IViewPart#init(IViewSite)
- */
- public void init(IViewSite site) throws PartInitException {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IViewPart#init(IViewSite, IMemento)
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IViewPart#saveState(IMemento)
- */
- public void saveState(IMemento memento) {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(IPropertyListener)
- */
- public void addPropertyListener(IPropertyListener listener) {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#createPartControl(Composite)
- */
- public void createPartControl(Composite parent) {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- public void dispose() {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#getTitle()
- */
- public String getTitle() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
- */
- public Image getTitleImage() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip()
- */
- public String getTitleToolTip() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(IPropertyListener)
- */
- public void removePropertyListener(IPropertyListener listener) {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
- */
- public Object getAdapter(Class adapter) {
- return null;
- }
-}
diff --git a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewSiteAdapter.java b/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewSiteAdapter.java
deleted file mode 100644
index 9ae31957a3..0000000000
--- a/org.eclipse.jdt.ui.examples.javafamily/src/org/eclipse/jdt/internal/ui/search2/SearchViewSiteAdapter.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jdt.internal.ui.search2;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.MenuManager;
-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.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-
-import org.eclipse.ui.IKeyBindingService;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.IWorkbenchWindow;
-
-import org.eclipse.search.ui.ISearchResultViewEntry;
-
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.JavaCore;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.search.IJavaSearchUIConstants;
-import org.eclipse.jdt.internal.ui.search.SearchMessages;
-import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.jdt.internal.ui.util.SelectionUtil;
-
-/**
- * This class adapts a Search view site.
- * It converts selection of Search view entries to
- * be a selection of Java elements.
- *
- * @since 2.0
- */
-class SearchViewSiteAdapter extends PlatformObject implements IWorkbenchPartSite {
-
- private ISelectionProvider fProvider;
- private IWorkbenchSite fSite;
-
- private ISelectionChangedListener fListener;
-
- public SearchViewSiteAdapter(IWorkbenchSite site){
- fSite= site;
- setSelectionProvider(site.getSelectionProvider());
- }
-
- public IWorkbenchPage getPage() {
- return fSite.getPage();
- }
-
- public ISelectionProvider getSelectionProvider() {
- return fProvider;
- }
-
- public Shell getShell() {
- return JavaPlugin.getActiveWorkbenchShell();
- }
-
- public IWorkbenchWindow getWorkbenchWindow() {
- return fSite.getWorkbenchWindow();
- }
-
- public void setSelectionProvider(final ISelectionProvider provider) {
- Assert.isNotNull(provider);
- fProvider=
- new ISelectionProvider() {
- public void addSelectionChangedListener(final ISelectionChangedListener listener) {
- fListener=
- new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- listener.selectionChanged(new SelectionChangedEvent(fProvider, convertSelection(event.getSelection())));
- }
- };
- provider.addSelectionChangedListener(fListener);
- }
- public ISelection getSelection() {
- return convertSelection(provider.getSelection());
- }
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- provider.removeSelectionChangedListener(fListener);
- }
- public void setSelection(ISelection selection) {
- // empty implementation
- }
- };
- }
-
- private ISelection convertSelection(ISelection selection) {
- Object element= SelectionUtil.getSingleElement(selection);
- if (element instanceof ISearchResultViewEntry) {
- IMarker marker= ((ISearchResultViewEntry)element).getSelectedMarker();
- if (marker != null && marker.exists())
- try {
- IJavaElement je= JavaCore.create((String) marker.getAttribute(IJavaSearchUIConstants.ATT_JE_HANDLE_ID));
- if (je != null)
- return new StructuredSelection(je);
- } catch (CoreException ex) {
- ExceptionHandler.log(ex, SearchMessages.getString("Search.Error.createJavaElement.message")); //$NON-NLS-1$
- }
- }
- return StructuredSelection.EMPTY;
- }
-
- // --------- only empty stubs below ---------
-
- /*
- * @see org.eclipse.ui.IWorkbenchPartSite#getId()
- */
- public String getId() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPartSite#getKeyBindingService()
- */
- public IKeyBindingService getKeyBindingService() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPartSite#getPluginId()
- */
- public String getPluginId() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPartSite#getRegisteredName()
- */
- public String getRegisteredName() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPartSite#registerContextMenu(MenuManager, ISelectionProvider)
- */
- public void registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider) {
- // empty implementation
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchPartSite#registerContextMenu(String, MenuManager, ISelectionProvider)
- */
- public void registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider) {
- // empty implementation
- }
-}

Back to the top