blob: ad274083f89145bc70fb689b980de489f2897199 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*******************************************************************************
* Copyright (c) 2000, 2015 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.ui.internal.editors.text;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.resources.IFile;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.ILocationProvider;
/**
* @since 3.0
*/
public class FileEditorInputAdapterFactory implements IAdapterFactory {
private static class LocationProvider implements ILocationProvider {
/*
* @see org.eclipse.ui.editors.text.ILocationProvider#getLocation(java.lang.Object)
*/
@Override
public IPath getPath(Object element) {
if (element instanceof IFileEditorInput) {
IFileEditorInput input= (IFileEditorInput) element;
return input.getFile().getFullPath();
}
return null;
}
}
/** The list of provided adapters. */
private static final Class<?>[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
/** The provided location provider */
private ILocationProvider fLocationProvider= new LocationProvider();
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (ILocationProvider.class.equals(adapterType)) {
if (adaptableObject instanceof IFile)
return (T) fLocationProvider;
}
return null;
}
@Override
public Class<?>[] getAdapterList() {
return ADAPTER_LIST;
}
}
|