KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > PluginSearchUIOperation


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

11 package org.eclipse.pde.internal.ui.search;
12
13 import org.eclipse.core.resources.IWorkspaceRunnable;
14 import org.eclipse.core.resources.ResourcesPlugin;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.core.runtime.OperationCanceledException;
18 import org.eclipse.jface.operation.*;
19 import org.eclipse.pde.internal.core.search.IPluginSearchResultCollector;
20 import org.eclipse.pde.internal.core.search.PluginSearchInput;
21 import org.eclipse.pde.internal.core.search.PluginSearchOperation;
22 import org.eclipse.pde.internal.ui.PDEPlugin;
23
24
25 public class PluginSearchUIOperation
26     extends PluginSearchOperation
27     implements IWorkspaceRunnable, IRunnableWithProgress {
28
29     private static final String JavaDoc KEY_MATCH = "Search.singleMatch"; //$NON-NLS-1$
30
private static final String JavaDoc KEY_MATCHES = "Search.multipleMatches"; //$NON-NLS-1$
31
public PluginSearchUIOperation(
32         PluginSearchInput input,
33         IPluginSearchResultCollector collector) {
34         super(input, collector);
35     }
36
37     public void run(IProgressMonitor monitor) {
38         try {
39             IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
40                 public void run(IProgressMonitor pm) throws CoreException {
41                     execute(pm);
42                 }
43             };
44             ResourcesPlugin.getWorkspace().run(
45                 workspaceRunnable,
46                 monitor);
47         } catch (CoreException e) {
48         } catch (OperationCanceledException e) {
49         }
50     }
51     
52     public String JavaDoc getPluralLabel() {
53         return input.getSearchString() + " - {0} " + PDEPlugin.getResourceString(KEY_MATCHES); //$NON-NLS-1$
54
}
55
56     public String JavaDoc getSingularLabel() {
57         return input.getSearchString() + " - 1 " + PDEPlugin.getResourceString(KEY_MATCH); //$NON-NLS-1$
58
}
59     
60
61 }
62
Popular Tags