KickJava   Java API By Example, From Geeks To Geeks.

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


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.compare.ITypedElement;
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.team.core.TeamException;
16 import org.eclipse.team.internal.ui.history.EditionHistoryPage;
17 import org.eclipse.ui.part.Page;
18
19 /**
20  * A history page source that can create history pages for a sub-element of a file.
21  * @since 3.3
22  */

23 public abstract class ElementLocalHistoryPageSource extends HistoryPageSource {
24
25     /**
26      * Return the previous edition from the local history of the given element located in the given
27      * file. A <code>null</code> is returned if a previous edition could not be found.
28      * @param file the file containing the element
29      * @param element the element
30      * @return the previous edition of the element from the local history or <code>null</code>
31      * @throws TeamException
32      */

33     public static ITypedElement getPreviousEdition(IFile file, Object JavaDoc element) throws TeamException {
34         return EditionHistoryPage.getPreviousState(file, element);
35     }
36     
37     /**
38      * Create an instance of the page source.
39      */

40     public ElementLocalHistoryPageSource() {
41         super();
42     }
43
44     /* (non-Javadoc)
45      * @see org.eclipse.team.ui.history.IHistoryPageSource#canShowHistoryFor(java.lang.Object)
46      */

47     public final boolean canShowHistoryFor(Object JavaDoc object) {
48         return getFile(object) != null;
49     }
50     
51     /* (non-Javadoc)
52      * @see org.eclipse.team.ui.history.IHistoryPageSource#createPage(java.lang.Object)
53      */

54     public final Page createPage(Object JavaDoc object) {
55         return new EditionHistoryPage(getFile(object), object);
56     }
57     
58     /**
59      * Return the file that contains the given element of <code>null</code>
60      * if this page source can not show history for the given element.
61      * @param element the element
62      * @return the file that contains the given element of <code>null</code>
63      */

64     protected abstract IFile getFile(Object JavaDoc element);
65     
66 }
67
Popular Tags