KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > ui > sourcelookup > CommonSourceNotFoundEditorInput


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

11 package org.eclipse.debug.ui.sourcelookup;
12
13 import com.ibm.icu.text.MessageFormat;
14
15 import org.eclipse.core.runtime.PlatformObject;
16 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages;
17 import org.eclipse.debug.ui.DebugUITools;
18 import org.eclipse.debug.ui.IDebugModelPresentation;
19 import org.eclipse.jface.resource.ImageDescriptor;
20 import org.eclipse.ui.IEditorInput;
21 import org.eclipse.ui.IPersistableElement;
22
23 /**
24  * Editor input for the <code>CommonSourceNotFoundEditor</code>. The editor
25  * input can be created on an artifact that has a source association.
26  * <p>
27  * This class may be instantiated and subclassed.
28  * </p>
29  * @see CommonSourceNotFoundEditor
30  * @since 3.2
31  */

32 public class CommonSourceNotFoundEditorInput extends PlatformObject implements IEditorInput {
33     
34     /**
35      * input element label (cached on creation)
36      */

37     private String JavaDoc fLabel;
38     /**
39      * the artifact that the editor is being opened for
40      */

41     private Object JavaDoc fArtifact;
42     
43     /**
44      * Constructs an editor input for the given artifact associated with source.
45      *
46      * @param artifact artifact associated with source
47      */

48     public CommonSourceNotFoundEditorInput(Object JavaDoc artifact) {
49         fArtifact = artifact;
50         if (artifact != null) {
51             IDebugModelPresentation pres = DebugUITools.newDebugModelPresentation();
52             fLabel = pres.getText(artifact);
53             pres.dispose();
54         }
55         if (fLabel == null) {
56             fLabel = ""; //$NON-NLS-1$
57
}
58     }
59     
60     /* (non-Javadoc)
61      * @see org.eclipse.ui.IEditorInput#exists()
62      */

63     public boolean exists() {
64         return false;
65     }
66     
67     /* (non-Javadoc)
68      * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
69      */

70     public ImageDescriptor getImageDescriptor() {
71         return DebugUITools.getDefaultImageDescriptor(fArtifact);
72     }
73     
74     /* (non-Javadoc)
75      * @see org.eclipse.ui.IEditorInput#getName()
76      */

77     public String JavaDoc getName() {
78         return fLabel;
79     }
80     
81     /* (non-Javadoc)
82      * @see org.eclipse.ui.IEditorInput#getPersistable()
83      */

84     public IPersistableElement getPersistable() {
85         return null;
86     }
87     
88     /* (non-Javadoc)
89      * @see org.eclipse.ui.IEditorInput#getToolTipText()
90      */

91     public String JavaDoc getToolTipText() {
92         return MessageFormat.format(SourceLookupUIMessages.addSourceLocation_editorMessage, new String JavaDoc[] { fLabel });
93     }
94         
95     /**
96      * Returns the artifact that source was not found for.
97      *
98      * @return artifact that source was not found for
99      */

100     public Object JavaDoc getArtifact(){
101         return fArtifact;
102     }
103     
104 }
105
Popular Tags