KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > search > internal > ui > SearchResultViewEntryAdapterFactory


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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
12 package org.eclipse.search.internal.ui;
13
14
15 import org.eclipse.core.resources.IMarker;
16 import org.eclipse.core.resources.IResource;
17 import org.eclipse.core.runtime.IAdapterFactory;
18
19 import org.eclipse.search.ui.ISearchResultViewEntry;
20
21 /**
22  * Implements basic UI support for Java elements.
23  * Implements handle to persistent support for Java elements.
24  * @deprecated old search
25  */

26 public class SearchResultViewEntryAdapterFactory implements IAdapterFactory {
27     
28     private static Class JavaDoc[] PROPERTIES= new Class JavaDoc[] {
29         IResource.class, IMarker.class,
30     };
31     
32
33     public Class JavaDoc[] getAdapterList() {
34         return PROPERTIES;
35     }
36     
37     public Object JavaDoc getAdapter(Object JavaDoc element, Class JavaDoc key) {
38         
39         ISearchResultViewEntry entry= (ISearchResultViewEntry) element;
40         
41         if (IMarker.class.equals(key)) {
42             return entry.getSelectedMarker();
43         }
44         if (IResource.class.equals(key)) {
45             IResource resource= entry.getResource();
46             /*
47              * This is a trick to filter out dummy markers that
48              * have been attached to a project because there is no
49              * corresponding resource in the workspace.
50              */

51             int type= resource.getType();
52             if (type != IResource.PROJECT && type != IResource.ROOT)
53                 return resource;
54         }
55         return null;
56     }
57 }
58
Popular Tags