Skip to main content
summaryrefslogtreecommitdiffstats
blob: ed8eff7e89c3d6a4f2c40f02779cab7bfb33c066 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*******************************************************************************
 * Copyright (c) 2007 Pascal Essiembre.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Pascal Essiembre - initial API and implementation
 ******************************************************************************/
package org.eclipse.babel.editor.actions;

import org.eclipse.babel.editor.internal.MessagesEditor;
import org.eclipse.babel.editor.internal.MessagesEditorChangeAdapter;
import org.eclipse.babel.editor.util.UIUtils;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;

/**
 * @author Pascal Essiembre
 * 
 */
public class KeyTreeVisibleAction extends Action {

    private MessagesEditor editor;

    /**
     * 
     */
    public KeyTreeVisibleAction() {
        super("Show/Hide Key Tree", IAction.AS_CHECK_BOX);
        // setText();
        setToolTipText("Show/hide the key tree");
        setImageDescriptor(UIUtils.getImageDescriptor(UIUtils.IMAGE_VIEW_LEFT));
    }

    // TODO RBEditor hold such an action registry. Then move this method to
    // constructor
    public void setEditor(MessagesEditor editor) {
        this.editor = editor;
        editor.addChangeListener(new MessagesEditorChangeAdapter() {
            public void keyTreeVisibleChanged(boolean visible) {
                setChecked(visible);
            }
        });
        setChecked(editor.getI18NPage().isKeyTreeVisible());
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
    public void run() {
        editor.getI18NPage().setKeyTreeVisible(
                !editor.getI18NPage().isKeyTreeVisible());
    }

}

Back to the top