KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > framelist > GoIntoAction


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.framelist;
12
13 import org.eclipse.ui.PlatformUI;
14 import org.eclipse.ui.internal.views.framelist.FrameListMessages;
15
16 /**
17  * Generic "Go Into" action which goes to the frame for the current selection.
18  */

19 public class GoIntoAction extends FrameAction {
20
21     /**
22      * Constructs a new action for the specified frame list.
23      *
24      * @param frameList the frame list
25      */

26     public GoIntoAction(FrameList frameList) {
27         super(frameList);
28         setText(FrameListMessages.GoInto_text);
29         setToolTipText(FrameListMessages.GoInto_toolTip);
30         PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
31                 IFrameListHelpContextIds.GO_INTO_ACTION);
32         update();
33     }
34
35     private Frame getSelectionFrame(int flags) {
36         return getFrameList().getSource().getFrame(
37                 IFrameSource.SELECTION_FRAME, flags);
38     }
39
40     /**
41      * Calls <code>gotoFrame</code> on the frame list with a frame
42      * representing the currently selected container.
43      */

44     public void run() {
45         Frame selectionFrame = getSelectionFrame(IFrameSource.FULL_CONTEXT);
46         if (selectionFrame != null) {
47             getFrameList().gotoFrame(selectionFrame);
48         }
49     }
50
51     /**
52      * Updates this action's enabled state.
53      * This action is enabled only when there is a frame for the current selection.
54      */

55     public void update() {
56         super.update();
57         Frame selectionFrame = getSelectionFrame(0);
58         setEnabled(selectionFrame != null);
59     }
60 }
61
Popular Tags