KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > markers > internal > DefaultMarkerResourceAdapter


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.ui.views.markers.internal;
13
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.core.runtime.IAdaptable;
17 import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter;
18
19 /**
20  * The DefaultMarkerResourceAdapter is the default
21  * implementation of the IMarkerResourceAdapter used by the
22  * MarkerView for resource adaption.
23  */

24 class DefaultMarkerResourceAdapter implements ITaskListResourceAdapter {
25
26     private static ITaskListResourceAdapter singleton;
27
28     /**
29      * Constructor for DefaultMarkerResourceAdapter.
30      */

31     DefaultMarkerResourceAdapter() {
32         super();
33     }
34
35     /**
36      * Return the default instance used for MarkerView adapting.
37      */

38     static ITaskListResourceAdapter getDefault() {
39         if (singleton == null) {
40             singleton = new DefaultMarkerResourceAdapter();
41         }
42         return singleton;
43     }
44
45     /**
46      * @see IMarkerResourceAdapter#getAffectedResource(IAdaptable)
47      */

48     public IResource getAffectedResource(IAdaptable adaptable) {
49         IResource resource = (IResource) adaptable.getAdapter(IResource.class);
50
51         if (resource == null) {
52             return (IFile) adaptable.getAdapter(IFile.class);
53         } else {
54             return resource;
55         }
56     }
57 }
58
Popular Tags