KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > common > ui > URIEditorInput


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: URIEditorInput.java,v 1.3 2005/06/08 06:24:33 nickb Exp $
16  */

17 package org.eclipse.emf.common.ui;
18
19
20 import java.io.File JavaDoc;
21
22 import org.eclipse.jface.resource.ImageDescriptor;
23 import org.eclipse.ui.IEditorInput;
24 import org.eclipse.ui.IPersistableElement;
25
26 import org.eclipse.emf.common.util.URI;
27
28
29 /**
30  * Very simple implementation of an {@link org.eclipse.ui.IEditorInput} to wrap
31  * one {@link org.eclipse.emf.common.util.URI}.
32  */

33 public class URIEditorInput implements IEditorInput
34 {
35   private URI uri;
36
37   public URIEditorInput(URI uri)
38   {
39     this.uri = uri;
40   }
41   
42   /**
43    * @return the uri
44    */

45   public URI getURI()
46   {
47     return uri;
48   }
49
50   /**
51    * Returns <b>true</b> only if the URI represents a file and if
52    * this file exists.
53    * @see org.eclipse.ui.IEditorInput#exists()
54    */

55   public boolean exists()
56   {
57     if (getURI().isFile())
58     {
59       return new File JavaDoc(getURI().toFileString()).exists();
60     }
61     else
62     {
63       return false;
64     }
65   }
66
67   /**
68    * Returns the <i>toString</i> value of the associated URI.
69    * @see org.eclipse.ui.IEditorInput#getName()
70    */

71   public String JavaDoc getName()
72   {
73     return getURI().toString();
74   }
75   
76   /*
77    * @see org.eclipse.ui.IEditorInput#getToolTipText()
78    */

79   public String JavaDoc getToolTipText()
80   {
81       return getName();
82   }
83
84   /* (non-Javadoc)
85    * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
86    */

87   public ImageDescriptor getImageDescriptor()
88   {
89     return null;
90   }
91
92   /* (non-Javadoc)
93    * @see org.eclipse.ui.IEditorInput#getPersistable()
94    */

95   public IPersistableElement getPersistable()
96   {
97     return null;
98   }
99
100   /* (non-Javadoc)
101    * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
102    */

103   public Object JavaDoc getAdapter(Class JavaDoc adapter)
104   {
105     return null;
106   }
107 }
Popular Tags