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