KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mountainminds > eclemma > internal > ui > wizards > ExternalFileEditorInput


1 /*******************************************************************************
2  * Copyright (c) 2006 Mountainminds GmbH & Co. KG
3  * This software is provided under the terms of the Eclipse Public License v1.0
4  * See http://www.eclipse.org/legal/epl-v10.html.
5  *
6  * $Id: ExternalFileEditorInput.java 67 2006-09-12 15:36:18Z mho $
7  ******************************************************************************/

8 package com.mountainminds.eclemma.internal.ui.wizards;
9
10 import java.io.File JavaDoc;
11
12 import org.eclipse.core.runtime.IPath;
13 import org.eclipse.core.runtime.Path;
14 import org.eclipse.core.runtime.PlatformObject;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.ui.IPathEditorInput;
17 import org.eclipse.ui.IPersistableElement;
18 import org.eclipse.ui.editors.text.ILocationProvider;
19
20 /**
21  * Editor input for external files.
22  *
23  * @author Marc R. Hoffmann
24  * @version $Revision: 67 $
25  */

26 public class ExternalFileEditorInput extends PlatformObject implements
27     IPathEditorInput, ILocationProvider {
28
29   private File JavaDoc file;
30
31   public ExternalFileEditorInput(File JavaDoc file) {
32     this.file = file;
33   }
34
35   public boolean equals(Object JavaDoc o) {
36     if (o instanceof IPathEditorInput) {
37       IPathEditorInput input = (IPathEditorInput) o;
38       return getPath().equals(input.getPath());
39     }
40     return false;
41   }
42
43   public int hashCode() {
44     return file.hashCode();
45   }
46
47   // IEditorInput implementation
48

49   public boolean exists() {
50     return file.exists();
51   }
52
53   public ImageDescriptor getImageDescriptor() {
54     return null;
55   }
56
57   public String JavaDoc getName() {
58     return file.getName();
59   }
60
61   public IPersistableElement getPersistable() {
62     return null;
63   }
64
65   public String JavaDoc getToolTipText() {
66     return file.getAbsolutePath();
67   }
68
69   // IPathEditorInput implementation
70

71   public IPath getPath() {
72     return Path.fromOSString(file.getAbsolutePath());
73   }
74
75   // ILocationProvider implementation
76

77   public IPath getPath(Object JavaDoc element) {
78     if (element instanceof ExternalFileEditorInput) {
79       return ((ExternalFileEditorInput) element).getPath();
80     } else {
81       return null;
82     }
83   }
84
85 }
86
Popular Tags