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.framelist;
11:
12: import org.eclipse.ui.PlatformUI;
13: import org.eclipse.ui.internal.views.framelist.FrameListMessages;
14:
15: /**
16: * Generic "Go Into" action which goes to the frame for the current selection.
17: */
18: public class GoIntoAction extends FrameAction {
19:
20: /**
21: * Constructs a new action for the specified frame list.
22: *
23: * @param frameList the frame list
24: */
25: public GoIntoAction(FrameList frameList) {
26: super (frameList);
27: setText(FrameListMessages.GoInto_text);
28: setToolTipText(FrameListMessages.GoInto_toolTip);
29: PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
30: IFrameListHelpContextIds.GO_INTO_ACTION);
31: update();
32: }
33:
34: private Frame getSelectionFrame(int flags) {
35: return getFrameList().getSource().getFrame(
36: IFrameSource.SELECTION_FRAME, flags);
37: }
38:
39: /**
40: * Calls <code>gotoFrame</code> on the frame list with a frame
41: * representing the currently selected container.
42: */
43: public void run() {
44: Frame selectionFrame = getSelectionFrame(IFrameSource.FULL_CONTEXT);
45: if (selectionFrame != null) {
46: getFrameList().gotoFrame(selectionFrame);
47: }
48: }
49:
50: /**
51: * Updates this action's enabled state.
52: * This action is enabled only when there is a frame for the current selection.
53: */
54: public void update() {
55: super .update();
56: Frame selectionFrame = getSelectionFrame(0);
57: setEnabled(selectionFrame != null);
58: }
59: }
|