KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > ui > SearchUI


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.search.ui;
12
13 import org.eclipse.search.internal.ui.SearchMessages;
14 import org.eclipse.search.internal.ui.SearchPlugin;
15 import org.eclipse.search.internal.ui.SearchPluginImages;
16 import org.eclipse.search.internal.ui.SearchPreferencePage;
17 import org.eclipse.search.internal.ui.util.ExceptionHandler;
18
19 import org.eclipse.swt.graphics.Image;
20
21 import org.eclipse.ui.IViewPart;
22 import org.eclipse.ui.IWorkbenchWindow;
23 import org.eclipse.ui.PartInitException;
24 import org.eclipse.ui.PlatformUI;
25 import org.eclipse.ui.WorkbenchException;
26
27 /**
28  * The central class for access to the Search Plug-in's User Interface.
29  * This class cannot be instantiated; all functionality is provided by
30  * static methods.
31  *
32  * Features provided:
33  * <ul>
34  * <li>convenient access to the search result view of the active workbench
35  * window.</li>
36  * </ul>
37  *
38  * @see ISearchResultView
39  * @deprecated Part of the old ('classic') search. Since 3.0 clients can create their own search result view pages and use {@link org.eclipse.search.ui.NewSearchUI} instead.
40  */

41 public final class SearchUI {
42
43     /**
44      * Search Plug-in Id (value <code>"org.eclipse.search"</code>).
45      * @deprecated Use {@link NewSearchUI#PLUGIN_ID} instead.
46      */

47     public static final String JavaDoc PLUGIN_ID= NewSearchUI.PLUGIN_ID;
48
49     /**
50      * Search marker type (value <code>"org.eclipse.search.searchmarker"</code>).
51      *
52      * @see org.eclipse.core.resources.IMarker
53      * @deprecated Use {@link NewSearchUI#SEARCH_MARKER} instead.
54      */

55     public static final String JavaDoc SEARCH_MARKER= NewSearchUI.SEARCH_MARKER;
56
57     /**
58      * Line marker attribute (value <code>"line"</code>)
59      * The value of the marker attribute is the line which contains the text search match.
60      *
61      * @see org.eclipse.core.resources.IMarker#getAttribute(java.lang.String)
62      */

63     public static final String JavaDoc LINE= "line"; //$NON-NLS-1$
64

65     /**
66      * Potential match marker attribute
67      * (value <code>"potentialMatch"</code>).
68      * <p>
69      * This optional marker attribute tells whether a marker is
70      * a potential or an exact match.
71      * The marker is considered an exact match if the attribute is missing.
72      * </p>
73      * <p>
74      * Potential matches are shown with a different background color in
75      * the Search view. The color can be changed in the Search preferences.
76      * </p>
77      *
78      * @see org.eclipse.core.resources.IMarker#getAttribute(java.lang.String)
79      * @since 2.0
80      */

81     public static final String JavaDoc POTENTIAL_MATCH= "potentialMatch"; //$NON-NLS-1$
82

83     /**
84      * Id of the Search result view
85      * (value <code>"org.eclipse.search.SearchResultView"</code>).
86      */

87     public static final String JavaDoc SEARCH_RESULT_VIEW_ID= "org.eclipse.search.SearchResultView"; //$NON-NLS-1$
88

89     /**
90      * Id of the new Search view
91      * (value <code>"org.eclipse.search.ui.views.SearchView"</code>).
92      * @deprecated Use {@link NewSearchUI#SEARCH_VIEW_ID} instead.
93      */

94     public static final String JavaDoc SEARCH_VIEW_ID= NewSearchUI.SEARCH_VIEW_ID;
95     
96     /**
97      * Id of the Search action set
98      * (value <code>"org.eclipse.search.searchActionSet"</code>).
99      *
100      * @since 2.0
101      * @deprecated Use {@link NewSearchUI#ACTION_SET_ID} instead.
102      */

103     public static final String JavaDoc ACTION_SET_ID= NewSearchUI.ACTION_SET_ID;
104
105     /**
106      * Activates the search result view in the active page of the
107      * active workbench window. This call has no effect (but returns <code>true</code>
108      * if the search result view is already activated.
109      *
110      * @return <code>true</code> if the search result view could be activated
111      * @deprecated Use {@link NewSearchUI#activateSearchResultView()} instead.
112      */

113     public static boolean activateSearchResultView() {
114         String JavaDoc defaultPerspectiveId= SearchUI.getDefaultPerspectiveId();
115         if (defaultPerspectiveId != null) {
116             IWorkbenchWindow window= SearchPlugin.getActiveWorkbenchWindow();
117             if (window != null && window.getShell() != null && !window.getShell().isDisposed()) {
118                 try {
119                     PlatformUI.getWorkbench().showPerspective(defaultPerspectiveId, window);
120                 } catch (WorkbenchException ex) {
121                     // show view in current perspective
122
}
123             }
124         }
125
126         try {
127             IViewPart viewPart= SearchPlugin.getActivePage().findView(SearchUI.SEARCH_RESULT_VIEW_ID);
128             if (viewPart == null || SearchPreferencePage.isViewBroughtToFront()) {
129                 return (SearchPlugin.getActivePage().showView(SearchUI.SEARCH_RESULT_VIEW_ID) != null);
130             }
131             return true;
132         } catch (PartInitException ex) {
133             ExceptionHandler.handle(ex, SearchMessages.Search_Error_openResultView_title, SearchMessages.Search_Error_openResultView_message);
134             return false;
135         }
136     }
137
138     /**
139      * Opens the search dialog.
140      * If <code>pageId</code> is specified and a corresponding page
141      * is found then it is brought to top.
142      *
143      * @param window the given window
144      * @param pageId the page to select or <code>null</code>
145      * if the best fitting page should be selected
146      * @since 2.0
147      * @deprecated Use {@link NewSearchUI#openSearchDialog(IWorkbenchWindow, String)} instead.
148      */

149     public static void openSearchDialog(IWorkbenchWindow window, String JavaDoc pageId) {
150         NewSearchUI.openSearchDialog(window, pageId);
151     }
152     
153
154     /**
155      * Returns the search result view of the active page of the
156      * active workbench window.
157      *
158      * @return the search result view or <code>null</code>
159      * if there is no active search result view
160      * @deprecated Use {@link NewSearchUI#getSearchResultView()} instead.
161      */

162     public static ISearchResultView getSearchResultView() {
163         IViewPart part= SearchPlugin.getActivePage().findView(SearchUI.SEARCH_RESULT_VIEW_ID);
164         if (part instanceof ISearchResultView)
165             return (ISearchResultView) part;
166         return null;
167     }
168
169     /**
170      * Returns the shared search marker image.
171      * Normally, editors show this icon in their vertical ruler.
172      * This image is owned by the search UI plug-in and must not be disposed
173      * by clients.
174      *
175      * @return the shared image
176      */

177     public static Image getSearchMarkerImage() {
178         return SearchPluginImages.get(SearchPluginImages.IMG_OBJ_SEARCHMARKER);
179     }
180
181     /**
182      * Returns the preference whether editors should be reused
183      * when showing search results.
184      *
185      * The goto action can decide to use or ignore this preference.
186      *
187      * @return <code>true</code> if editors should be reused for showing search results
188      * @since 2.0
189      * @deprecated Use {@link NewSearchUI#reuseEditor()} instead.
190      */

191     public static boolean reuseEditor() {
192         return NewSearchUI.reuseEditor();
193     }
194
195     /**
196      * Returns the preference whether a search engine is
197      * allowed to report potential matches or not.
198      * <p>
199      * Search engines which can report inexact matches must
200      * respect this preference i.e. they should not report
201      * inexact matches if this method returns <code>true</code>
202      * </p>
203      * @return <code>true</code> if search engine must not report inexact matches
204      * @since 2.1
205      * @deprecated Use {@link NewSearchUI#arePotentialMatchesIgnored()} instead.
206      */

207     public static boolean arePotentialMatchesIgnored() {
208         return NewSearchUI.arePotentialMatchesIgnored();
209     }
210
211     /**
212      * Returns the ID of the default perspective.
213      * <p>
214      * The perspective with this ID will be used to show the Search view.
215      * If no default perspective is set then the Search view will
216      * appear in the current perspective.
217      * </p>
218      * @return the ID of the default perspective <code>null</code> if no default perspective is set
219      * @since 2.1
220      * @deprecated Use {@link NewSearchUI#getDefaultPerspectiveId()} instead.
221      */

222     public static String JavaDoc getDefaultPerspectiveId() {
223         return NewSearchUI.getDefaultPerspectiveId();
224     }
225
226     /**
227      * Block instantiation.
228      */

229     private SearchUI() {
230     }
231 }
232
Popular Tags