KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > ui > internal > search > WebSearchScopeFactory


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.help.ui.internal.search;
12
13 import java.util.Dictionary JavaDoc;
14
15 import org.eclipse.help.internal.search.WebSearch;
16 import org.eclipse.help.search.*;
17 import org.eclipse.help.ui.ISearchScopeFactory;
18 import org.eclipse.jface.preference.IPreferenceStore;
19
20 /**
21  * Factory for creating scope objects for the generic web search engine
22  */

23 public class WebSearchScopeFactory implements ISearchScopeFactory {
24     public final static String JavaDoc P_URL = "url"; //$NON-NLS-1$
25

26     /* (non-Javadoc)
27      * @see org.eclipse.help.ui.ISearchScopeFactory#createSearchScope(org.eclipse.jface.preference.IPreferenceStore)
28      */

29     public ISearchScope createSearchScope(IPreferenceStore store, String JavaDoc engineId, Dictionary JavaDoc parameters) {
30         String JavaDoc urlTemplate = getProperty(store, engineId, parameters);
31         return new WebSearch.Scope(urlTemplate);
32     }
33     
34     private String JavaDoc getProperty(IPreferenceStore store, String JavaDoc engineId, Dictionary JavaDoc parameters) {
35         // try the store first
36
String JavaDoc value = store.getString(engineId+"."+P_URL); //$NON-NLS-1$
37
if (value!=null && value.length()>0) return value;
38         // try the parameters
39
return (String JavaDoc)parameters.get(P_URL);
40     }
41 }
42
Popular Tags