Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: d45ae29bd5700356e6b5a2ec087545dbb573c90c (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
/*******************************************************************************
 * Copyright (C) 2011, 2015 Bernard Leach <leachbj@bouncycastle.org> and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package org.eclipse.egit.ui.internal.staging;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jgit.lib.Repository;

/**
 * An adapter factory for <code>StagingEntry</code>s so that the property page
 * handler can open property pages on them correctly.
 */
public class StagingEntryAdapterFactory implements IAdapterFactory {

	@Override
	public Object getAdapter(Object adaptableObject, Class adapterType) {
		if (adaptableObject != null) {
			StagingEntry entry = (StagingEntry) adaptableObject;
			if (adapterType == IResource.class) {
				IResource resource = entry.getFile();
				if (resource != null && resource.isAccessible()) {
					return resource;
				}
			} else if (adapterType == IPath.class) {
				return entry.getLocation();
			} else if (adapterType == Repository.class) {
				return entry.getRepository();
			}
		}
		return null;
	}

	@Override
	public Class[] getAdapterList() {
		return new Class[] { IResource.class, IPath.class, Repository.class };
	}

}

Back to the top