KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > NavigationLocation


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
12 package org.eclipse.ui;
13
14 /**
15  * Default implementation of INavigationLocation.
16  *
17  * @since 2.1
18  */

19 public abstract class NavigationLocation implements INavigationLocation {
20
21     private IWorkbenchPage page;
22
23     private IEditorInput input;
24
25     /**
26      * Constructs a NavigationLocation with its editor part.
27      *
28      * @param editorPart
29      */

30     protected NavigationLocation(IEditorPart editorPart) {
31         this.page = editorPart.getSite().getPage();
32         this.input = editorPart.getEditorInput();
33     }
34
35     /**
36      * Returns the part that the receiver holds the location for.
37      *
38      * @return IEditorPart
39      */

40     protected IEditorPart getEditorPart() {
41         if (input == null) {
42             return null;
43         }
44         return page.findEditor(input);
45     }
46
47     /*
48      * (non-Javadoc)
49      * Method declared on INavigationLocation.
50      */

51     public Object JavaDoc getInput() {
52         return input;
53     }
54
55     /*
56      * (non-Javadoc)
57      * Method declared on INavigationLocation.
58      */

59     public String JavaDoc getText() {
60         IEditorPart part = getEditorPart();
61         if (part == null) {
62             return new String JavaDoc();
63         }
64         return part.getTitle();
65     }
66
67     /*
68      * (non-Javadoc)
69      * Method declared on INavigationLocation.
70      */

71     public void setInput(Object JavaDoc input) {
72         this.input = (IEditorInput) input;
73     }
74
75     /**
76      * May be extended by clients.
77      *
78      * @see org.eclipse.ui.INavigationLocation#dispose()
79      */

80     public void dispose() {
81         releaseState();
82     }
83
84     /**
85      * May be extended by clients.
86      *
87      * @see org.eclipse.ui.INavigationLocation#releaseState()
88      */

89     public void releaseState() {
90         input = null;
91     }
92 }
93
Popular Tags