KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 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.internal.ui.sourcelookup;
12
13 import java.text.MessageFormat JavaDoc;
14
15 import org.eclipse.core.runtime.PlatformObject;
16 import org.eclipse.debug.ui.DebugUITools;
17 import org.eclipse.debug.ui.IDebugModelPresentation;
18 import org.eclipse.jface.resource.ImageDescriptor;
19 import org.eclipse.ui.IEditorInput;
20 import org.eclipse.ui.IPersistableElement;
21
22 /**
23  * Editor input for the <code>CommonSourceNotFoundEditor</code>. The editor
24  * input can be created on a debug element or breakpoint.
25  *
26  * @see CommonSourceNotFoundEditor
27  *
28  * @since 3.0
29  */

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

35     protected String JavaDoc fLabel;
36     /**
37      * the object that the editor is being brought up for
38      */

39     protected Object JavaDoc fObject;
40     
41     /**
42      * Constructs an editor input for the given debug element
43      * or breakpoint.
44      *
45      * @param object debug element or breakpoint
46      */

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

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

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

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

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

90     public String JavaDoc getToolTipText() {
91         return MessageFormat.format(SourceLookupUIMessages.addSourceLocation_editorMessage, new String JavaDoc[] { fLabel }); //$NON-NLS-1$
92
}
93         
94     /**
95      * Returns the object that was the reason why source was being searched for (i.e., it was clicked on)
96      * @return the object.
97      */

98     public Object JavaDoc getObject(){
99         return fObject;
100     }
101     
102 }
103
Popular Tags