KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > ui > history > HistoryPageSource


1 /*******************************************************************************
2  * Copyright (c) 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 package org.eclipse.team.ui.history;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.team.core.RepositoryProvider;
15 import org.eclipse.team.core.history.IFileHistoryProvider;
16 import org.eclipse.team.internal.ui.Utils;
17
18 /**
19  * Abstract HistoryPageSource class.
20  * @see IHistoryPageSource
21  * @since 3.2
22  */

23 public abstract class HistoryPageSource implements IHistoryPageSource {
24
25     /**
26      * Convenience method that returns the history page source for the
27      * given object. This method only finds a source. It does not query the source
28      * to see if the source can display history for the given object.
29      * @param object the object
30      * @return he history page source for the
31      * given object
32      */

33     public static IHistoryPageSource getHistoryPageSource(Object JavaDoc object) {
34         IResource resource = Utils.getResource(object);
35         if (resource != null) {
36             RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject());
37             if (provider != null) {
38                 IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
39                 if (fileHistoryProvider != null) {
40                     IHistoryPageSource pageSource = (IHistoryPageSource)Utils.getAdapter(fileHistoryProvider, IHistoryPageSource.class);
41                     if (pageSource != null)
42                         return pageSource;
43                 }
44                 IHistoryPageSource pageSource = (IHistoryPageSource)Utils.getAdapter(provider, IHistoryPageSource.class);
45                 if (pageSource != null)
46                     return pageSource;
47             }
48         }
49         IHistoryPageSource pageSource = (IHistoryPageSource)Utils.getAdapter(object, IHistoryPageSource.class);
50         return pageSource;
51     }
52     
53 }
54
Popular Tags