KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > navigator > NavigatorFrameSource


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ui.views.navigator;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.jface.dialogs.MessageDialog;
16 import org.eclipse.osgi.util.NLS;
17 import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
18 import org.eclipse.ui.views.framelist.TreeFrame;
19 import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
20
21 /**
22  * Frame source for the resource navigator.
23  */

24 public class NavigatorFrameSource extends TreeViewerFrameSource {
25
26     private ResourceNavigator navigator;
27
28     /**
29      * Constructs a new frame source for the specified resource navigator.
30      *
31      * @param navigator the resource navigator
32      */

33     public NavigatorFrameSource(ResourceNavigator navigator) {
34         super(navigator.getTreeViewer());
35         this.navigator = navigator;
36     }
37
38     /**
39      * Returns a new frame. This implementation extends the super implementation
40      * by setting the frame's tool tip text to show the full path for the input
41      * element.
42      */

43     protected TreeFrame createFrame(Object JavaDoc input) {
44         TreeFrame frame = super.createFrame(input);
45         frame.setName(navigator.getFrameName(input));
46         frame.setToolTipText(navigator.getFrameToolTipText(input));
47         return frame;
48     }
49
50     /**
51      * Also updates the navigator's title.
52      */

53     protected void frameChanged(TreeFrame frame) {
54         IResource resource = (IResource) frame.getInput();
55         IProject project = resource.getProject();
56
57         if (project != null && project.isOpen() == false) {
58             MessageDialog
59                     .openInformation(
60                             navigator.getViewSite().getShell(),
61                             ResourceNavigatorMessages.NavigatorFrameSource_closedProject_title,
62                             NLS.bind(ResourceNavigatorMessages.NavigatorFrameSource_closedProject_message, project.getName()));
63             navigator.getFrameList().back();
64         } else {
65             super.frameChanged(frame);
66             navigator.updateTitle();
67         }
68     }
69 }
70
Popular Tags