Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4f934752ca55a9f21f2978d48fc9dd0680c17d50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*******************************************************************************
 * Copyright (c) 2006, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ui.history;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.history.HistoryPageSource;
import org.eclipse.team.ui.history.IHistoryPageSource;
import org.eclipse.ui.part.Page;

public class LocalHistoryPageSource extends HistoryPageSource {

	private static LocalHistoryPageSource instance;

	public static IFile getFile(Object object) {
		IResource resource = Utils.getResource(object);
		if (resource instanceof IFile) {
			return (IFile) resource;
		}
		return null;
	}
	
	@Override
	public boolean canShowHistoryFor(Object object) {
		return getFile(object) != null;
	}

	@Override
	public Page createPage(Object object) {
		LocalHistoryPage page = new LocalHistoryPage();
		return page;
	}

	public synchronized static IHistoryPageSource getInstance() {
		if (instance == null)
			instance = new LocalHistoryPageSource();
		return instance;
	}

}

Back to the top