KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > outline > LocationProvider


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.editor.outline;
12
13 import org.eclipse.core.resources.IFile;
14 import org.eclipse.core.runtime.IPath;
15 import org.eclipse.ui.IEditorInput;
16 import org.eclipse.ui.IFileEditorInput;
17 import org.eclipse.ui.editors.text.ILocationProvider;
18
19 public class LocationProvider {
20     private IEditorInput fEditorInput;
21     
22     public LocationProvider(IEditorInput input) {
23         fEditorInput= input;
24     }
25
26     public IPath getLocation() {
27         if(fEditorInput instanceof IFileEditorInput) {
28             return ((IFileEditorInput)fEditorInput).getFile().getLocation();
29         } else if (fEditorInput instanceof ILocationProvider) {
30             return ((ILocationProvider)fEditorInput).getPath(fEditorInput);
31         }
32         return null;
33     }
34     
35     public IFile getFile() {
36         if(fEditorInput instanceof IFileEditorInput) {
37             return ((IFileEditorInput)fEditorInput).getFile();
38         }
39         return null;
40     }
41 }
42
Popular Tags