Project

General

Profile

Download (2.63 KB) Statistics
| Branch: | Tag: | Revision:
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.osgi.util.NLS;
14
import org.eclipse.ui.ISharedImages;
15
import org.eclipse.ui.PlatformUI;
16

    
17
/**
18
 * Generic "Forward" action which goes forward one frame.
19
 * @since 3.4
20
 */
21
public class ForwardAction extends FrameAction {
22

    
23
	private static final String ID = "org.eclipse.ui.framelist.forward"; //$NON-NLS-1$
24

    
25
	/**
26
     * Constructs a new action for the specified frame list.
27
     * 
28
     * @param frameList the frame list
29
     */
30
    public ForwardAction(FrameList frameList) {
31
        super(frameList);
32
        setId(ID);
33
        setText(FrameListMessages.Forward_text);
34
        ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
35
        setImageDescriptor(images
36
                .getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD));
37
        setDisabledImageDescriptor(images
38
                .getImageDescriptor(ISharedImages.IMG_TOOL_FORWARD_DISABLED));
39
        PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
40
				IFrameListHelpContextIds.FORWARD_ACTION);
41
        update();
42
    }
43

    
44
    private Frame getNextFrame() {
45
        FrameList list = getFrameList();
46
        return list.getFrame(list.getCurrentIndex() + 1);
47
    }
48

    
49
    private String getToolTipText(Frame nextFrame) {
50
        if (nextFrame != null) {
51
            String text = nextFrame.getToolTipText();
52
            if (text != null && text.length() > 0) {
53
                return NLS.bind(FrameListMessages.Forward_toolTipOneArg, text);
54
            }
55
        }
56
        return FrameListMessages.Forward_toolTip;
57
    }
58

    
59
    /**
60
     * Calls <code>forward()</code> on the frame list.
61
     */
62
    public void run() {
63
        getFrameList().forward();
64
    }
65

    
66
    /**
67
     * Updates this action's enabled state and tool tip text.
68
     * This action is enabled only when there is a next frame in the frame list.
69
     * The tool tip text is "Forward to " plus the tool tip text for the next
70
     * frame.
71
     */
72
    public void update() {
73
        super.update();
74
        Frame nextFrame = getNextFrame();
75
        setEnabled(nextFrame != null);
76
        setToolTipText(getToolTipText(nextFrame));
77
    }
78

    
79
}
(2-2/15)