1 14 package org.eclipse.search2.internal.ui; 15 16 import com.ibm.icu.text.MessageFormat; 17 import java.util.HashMap ; 18 import java.util.Iterator ; 19 import java.util.Map ; 20 21 import org.eclipse.core.runtime.IStatus; 22 import org.eclipse.core.runtime.Status; 23 24 import org.eclipse.osgi.util.NLS; 25 26 import org.eclipse.swt.SWT; 27 import org.eclipse.swt.graphics.Image; 28 import org.eclipse.swt.widgets.Composite; 29 import org.eclipse.swt.widgets.Control; 30 import org.eclipse.swt.widgets.Tree; 31 32 import org.eclipse.jface.action.GroupMarker; 33 import org.eclipse.jface.action.IMenuManager; 34 import org.eclipse.jface.action.IToolBarManager; 35 import org.eclipse.jface.action.MenuManager; 36 import org.eclipse.jface.action.Separator; 37 import org.eclipse.jface.viewers.ISelection; 38 39 import org.eclipse.ui.IMemento; 40 import org.eclipse.ui.IPropertyListener; 41 import org.eclipse.ui.IViewSite; 42 import org.eclipse.ui.IWorkbenchActionConstants; 43 import org.eclipse.ui.IWorkbenchPart; 44 import org.eclipse.ui.IWorkbenchPartSite; 45 import org.eclipse.ui.PartInitException; 46 import org.eclipse.ui.PlatformUI; 47 import org.eclipse.ui.actions.ActionFactory; 48 import org.eclipse.ui.actions.ContributionItemFactory; 49 import org.eclipse.ui.keys.IBindingService; 50 import org.eclipse.ui.part.IPage; 51 import org.eclipse.ui.part.IPageBookViewPage; 52 import org.eclipse.ui.part.IPageSite; 53 import org.eclipse.ui.part.IShowInSource; 54 import org.eclipse.ui.part.Page; 55 import org.eclipse.ui.part.PageBook; 56 import org.eclipse.ui.part.PageBookView; 57 import org.eclipse.ui.part.ShowInContext; 58 import org.eclipse.ui.progress.IWorkbenchSiteProgressService; 59 60 import org.eclipse.search.ui.IContextMenuConstants; 61 import org.eclipse.search.ui.IQueryListener; 62 import org.eclipse.search.ui.ISearchQuery; 63 import org.eclipse.search.ui.ISearchResult; 64 import org.eclipse.search.ui.ISearchResultPage; 65 import org.eclipse.search.ui.ISearchResultViewPart; 66 67 import org.eclipse.search.internal.ui.ISearchHelpContextIds; 68 import org.eclipse.search.internal.ui.SearchPlugin; 69 70 public class SearchView extends PageBookView implements ISearchResultViewPart, IQueryListener { 71 72 private static final String MEMENTO_TYPE= "view"; private static final String MEMENTO_KEY_IS_PINNED= "isPinned"; private static final String MEMENTO_KEY_LAST_ACTIVATION= "org.eclipse.search.lastActivation"; private static final String MEMENTO_KEY_RESTORE= "org.eclipse.search.restore"; private HashMap fPartsToPages; 77 private HashMap fPagesToParts; 78 private HashMap fSearchViewStates; 79 private SearchPageRegistry fSearchViewPageService; 80 private SearchHistoryDropDownAction fSearchesDropDownAction; 81 private ISearchResult fCurrentSearch; 82 private DummyPart fDefaultPart; 83 private SearchAgainAction fSearchAgainAction; 84 private CancelSearchAction fCancelAction; 85 private PinSearchViewAction fPinSearchViewAction; 86 87 private IMemento fPageState; 88 private boolean fIsPinned; 89 private int fActivationCount= 0; 90 private String fDefaultPartName; 91 92 97 public static void createContextMenuGroups(IMenuManager menu) { 98 menu.add(new Separator(IContextMenuConstants.GROUP_NEW)); 99 menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO)); 100 menu.add(new GroupMarker(IContextMenuConstants.GROUP_OPEN)); 101 menu.add(new Separator(IContextMenuConstants.GROUP_SHOW)); 102 menu.add(new Separator(IContextMenuConstants.GROUP_EDIT)); 103 menu.add(new GroupMarker(IContextMenuConstants.GROUP_REMOVE_MATCHES)); 104 menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE)); 105 menu.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE)); 106 menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); 107 menu.add(new Separator(IContextMenuConstants.GROUP_BUILD)); 108 menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); 109 menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); 110 menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); 111 } 112 113 118 private static void createViewMenuGroups(IMenuManager menu) { 119 menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); 120 menu.add(new Separator(IContextMenuConstants.GROUP_NEW)); 121 menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO)); 122 menu.add(new GroupMarker(IContextMenuConstants.GROUP_OPEN)); 123 menu.add(new Separator(IContextMenuConstants.GROUP_SHOW)); 124 menu.add(new Separator(IContextMenuConstants.GROUP_EDIT)); 125 menu.add(new GroupMarker(IContextMenuConstants.GROUP_REMOVE_MATCHES)); 126 menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE)); 127 menu.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE)); 128 menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); 129 menu.add(new Separator(IContextMenuConstants.GROUP_BUILD)); 130 menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); 131 menu.add(new Separator(IContextMenuConstants.GROUP_FILTERING)); 132 menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); 133 } 134 135 141 public static void createToolBarGroups(IToolBarManager toolbar) { 142 toolbar.add(new Separator(IContextMenuConstants.GROUP_NEW)); 143 toolbar.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO)); 144 toolbar.add(new GroupMarker(IContextMenuConstants.GROUP_OPEN)); 145 toolbar.add(new Separator(IContextMenuConstants.GROUP_SHOW)); 146 toolbar.add(new Separator(IContextMenuConstants.GROUP_BUILD)); 147 toolbar.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE)); 148 toolbar.add(new Separator(IContextMenuConstants.GROUP_EDIT)); 149 toolbar.add(new GroupMarker(IContextMenuConstants.GROUP_REMOVE_MATCHES)); 150 toolbar.add(new GroupMarker(IContextMenuConstants.GROUP_GENERATE)); 151 toolbar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); 152 toolbar.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); 153 toolbar.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); 154 toolbar.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); 155 } 156 157 static class DummyPart implements IWorkbenchPart { 158 private int fLastActivation= 0; 159 public void setLastActivation(int lastActivation) { 160 fLastActivation= lastActivation; 161 } 162 public int getLastActivation() { 163 return fLastActivation; 164 } 165 public void addPropertyListener(IPropertyListener listener) {} 166 public void createPartControl(Composite parent) {} 167 public void dispose() {} 168 public IWorkbenchPartSite getSite() { return null; } 169 public String getTitle() { return null; } 170 public Image getTitleImage() { return null; } 171 public String getTitleToolTip() { return null; } 172 public void removePropertyListener(IPropertyListener listener) {} 173 public void setFocus() {} 174 public Object getAdapter(Class adapter) { return null; } 175 } 176 177 class EmptySearchView extends Page implements ISearchResultPage { 178 Control fControl; 179 private String fId; 180 181 public void createControl(Composite parent) { 182 fControl= new Tree(parent, SWT.NONE); 183 } 185 186 public Control getControl() { 187 return fControl; 188 } 189 190 public void setFocus() { 191 if (fControl != null) 192 fControl.setFocus(); 193 } 194 195 198 public void setInput(ISearchResult search, Object viewState) { 199 } 201 202 205 public void setViewPart(ISearchResultViewPart part) { 206 } 208 209 public Object getUIState() { 210 return null; 212 } 213 214 215 public void init(IPageSite pageSite) { 216 super.init(pageSite); 217 getSite().setSelectionProvider(null); 218 IMenuManager menuManager= pageSite.getActionBars().getMenuManager(); 220 menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new OpenSearchPreferencesAction()); 221 } 222 223 226 public void saveState(IMemento memento) { 227 229 } 230 231 234 public void restoreState(IMemento memento) { 235 } 237 238 241 public void setID(String id) { 242 fId= id; 243 } 244 245
|