KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > MarkerAdapterFactory


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.jdt.internal.ui;
12
13 import org.eclipse.core.runtime.IAdapterFactory;
14
15 import org.eclipse.search.ui.ISearchPageScoreComputer;
16
17 import org.eclipse.jdt.internal.ui.search.JavaSearchPageScoreComputer;
18 import org.eclipse.jdt.internal.ui.search.SearchUtil;
19
20
21 /**
22  * Adapter factory to support basic UI operations for markers.
23  */

24 public class MarkerAdapterFactory implements IAdapterFactory {
25
26     private static Class JavaDoc[] PROPERTIES= new Class JavaDoc[0];
27     
28
29     private Object JavaDoc fSearchPageScoreComputer;
30     
31     public Class JavaDoc[] getAdapterList() {
32         updateLazyLoadedAdapters();
33         return PROPERTIES;
34     }
35     
36     public Object JavaDoc getAdapter(Object JavaDoc element, Class JavaDoc key) {
37         updateLazyLoadedAdapters();
38         if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key))
39             return fSearchPageScoreComputer;
40         return null;
41     }
42
43     private void updateLazyLoadedAdapters() {
44         if (fSearchPageScoreComputer == null && SearchUtil.isSearchPlugInActivated())
45             createSearchPageScoreComputer();
46     }
47     
48     private void createSearchPageScoreComputer() {
49         fSearchPageScoreComputer= new JavaSearchPageScoreComputer();
50         PROPERTIES= new Class JavaDoc[] {ISearchPageScoreComputer.class};
51     }
52 }
53
Popular Tags