01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui;
11:
12: /**
13: * Default implementation of INavigationLocation.
14: *
15: * @since 2.1
16: */
17: public abstract class NavigationLocation implements INavigationLocation {
18:
19: private IWorkbenchPage page;
20:
21: private IEditorInput input;
22:
23: /**
24: * Constructs a NavigationLocation with its editor part.
25: *
26: * @param editorPart
27: */
28: protected NavigationLocation(IEditorPart editorPart) {
29: this .page = editorPart.getSite().getPage();
30: this .input = editorPart.getEditorInput();
31: }
32:
33: /**
34: * Returns the part that the receiver holds the location for.
35: *
36: * @return IEditorPart
37: */
38: protected IEditorPart getEditorPart() {
39: if (input == null) {
40: return null;
41: }
42: return page.findEditor(input);
43: }
44:
45: /*
46: * (non-Javadoc)
47: * Method declared on INavigationLocation.
48: */
49: public Object getInput() {
50: return input;
51: }
52:
53: /*
54: * (non-Javadoc)
55: * Method declared on INavigationLocation.
56: */
57: public String getText() {
58: IEditorPart part = getEditorPart();
59: if (part == null) {
60: return new String();
61: }
62: return part.getTitle();
63: }
64:
65: /*
66: * (non-Javadoc)
67: * Method declared on INavigationLocation.
68: */
69: public void setInput(Object input) {
70: this .input = (IEditorInput) input;
71: }
72:
73: /**
74: * May be extended by clients.
75: *
76: * @see org.eclipse.ui.INavigationLocation#dispose()
77: */
78: public void dispose() {
79: releaseState();
80: }
81:
82: /**
83: * May be extended by clients.
84: *
85: * @see org.eclipse.ui.INavigationLocation#releaseState()
86: */
87: public void releaseState() {
88: input = null;
89: }
90: }
|