KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.internal.ui.sourcelookup;
12
13 import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
14 import org.eclipse.ui.IEditorInput;
15
16 /**
17  * The result of a source lookup contains the source element, editor id, and
18  * editor input resolved for a debug artifact.
19  *
20  * @since 3.1
21  */

22 public class SourceLookupResult implements ISourceLookupResult {
23     
24     /**
25      * Element that source was resolved for.
26      */

27     private Object JavaDoc fArtifact;
28     /**
29      * Corresponding source element, or <code>null</code>
30      * if unknown.
31      */

32     private Object JavaDoc fSourceElement;
33     /**
34      * Associated editor id, used to display the source element,
35      * or <code>null</code> if unknown.
36      */

37     private String JavaDoc fEditorId;
38     /**
39      * Associated editor input, used to display the source element,
40      * or <code>null</code> if unknown.
41      */

42     private IEditorInput fEditorInput;
43
44     /**
45      * Creates a source lookup result on the given artifact, source element,
46      * editor id, and editor input.
47      */

48     public SourceLookupResult(Object JavaDoc artifact, Object JavaDoc sourceElement, String JavaDoc editorId, IEditorInput editorInput) {
49         fArtifact = artifact;
50         setSourceElement(sourceElement);
51         setEditorId(editorId);
52         setEditorInput(editorInput);
53     }
54     
55     /* (non-Javadoc)
56      * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getArtifact()
57      */

58     public Object JavaDoc getArtifact() {
59         return fArtifact;
60     }
61     
62     /* (non-Javadoc)
63      * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getSourceElement()
64      */

65     public Object JavaDoc getSourceElement() {
66         return fSourceElement;
67     }
68     
69     /**
70      * Sets the source element resolved for the artifact that source
71      * lookup was performed for, or <code>null</code> if a source element
72      * was not resolved.
73      *
74      * @param element resolved source element or <code>null</code> if unknown
75      */

76     protected void setSourceElement(Object JavaDoc element) {
77         fSourceElement = element;
78     }
79     
80     /* (non-Javadoc)
81      * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getEditorId()
82      */

83     public String JavaDoc getEditorId() {
84         return fEditorId;
85     }
86     
87     /**
88      * Sets the identifier of the editor used to display this source
89      * lookup result's source element, or <code>null</code> if unknown.
90      *
91      * @param id the identifier of the editor used to display this source
92      * lookup result's source element, or <code>null</code> if unknown
93      */

94     protected void setEditorId(String JavaDoc id) {
95         fEditorId = id;
96     }
97
98     /* (non-Javadoc)
99      * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getEditorInput()
100      */

101     public IEditorInput getEditorInput() {
102         return fEditorInput;
103     }
104     
105     /**
106      * Sets the editor input used to display this source lookup
107      * result's source element, or <code>null</code> if unknown.
108      *
109      * @param input the editor input used to display this source lookup
110      * result's source element, or <code>null</code> if unknown
111      */

112     protected void setEditorInput(IEditorInput input) {
113         fEditorInput = input;
114     }
115     
116     /**
117      * Updates the artifact to refer to the given artifact
118      * if equal. For example, when a source lookup result is reused
119      * for the same stack frame, we still need to update in case
120      * the stack frame is not identical.
121      *
122      * @param artifact new artifact state
123      */

124     public void updateArtifact(Object JavaDoc artifact) {
125         if (fArtifact.equals(artifact)) {
126             fArtifact = artifact;
127         }
128     }
129 }
130
Popular Tags