01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.views.navigator;
11:
12: import org.eclipse.core.resources.IProject;
13: import org.eclipse.core.resources.IResource;
14: import org.eclipse.jface.dialogs.MessageDialog;
15: import org.eclipse.osgi.util.NLS;
16: import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
17: import org.eclipse.ui.views.framelist.TreeFrame;
18: import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
19:
20: /**
21: * Frame source for the resource navigator.
22: */
23: public class NavigatorFrameSource extends TreeViewerFrameSource {
24:
25: private ResourceNavigator navigator;
26:
27: /**
28: * Constructs a new frame source for the specified resource navigator.
29: *
30: * @param navigator the resource navigator
31: */
32: public NavigatorFrameSource(ResourceNavigator navigator) {
33: super (navigator.getTreeViewer());
34: this .navigator = navigator;
35: }
36:
37: /**
38: * Returns a new frame. This implementation extends the super implementation
39: * by setting the frame's tool tip text to show the full path for the input
40: * element.
41: */
42: protected TreeFrame createFrame(Object input) {
43: TreeFrame frame = super .createFrame(input);
44: frame.setName(navigator.getFrameName(input));
45: frame.setToolTipText(navigator.getFrameToolTipText(input));
46: return frame;
47: }
48:
49: /**
50: * Also updates the navigator's title.
51: */
52: protected void frameChanged(TreeFrame frame) {
53: IResource resource = (IResource) frame.getInput();
54: IProject project = resource.getProject();
55:
56: if (project != null && project.isOpen() == false) {
57: MessageDialog
58: .openInformation(
59: navigator.getViewSite().getShell(),
60: ResourceNavigatorMessages.NavigatorFrameSource_closedProject_title,
61: NLS
62: .bind(
63: ResourceNavigatorMessages.NavigatorFrameSource_closedProject_message,
64: project.getName()));
65: navigator.getFrameList().back();
66: } else {
67: super.frameChanged(frame);
68: navigator.updateTitle();
69: }
70: }
71: }
|