Skip to main content
summaryrefslogtreecommitdiffstats
blob: 00cb990fdd1092a5891efe96bd96eff985739e29 (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
/*******************************************************************************
 * 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.i18n.actions;

import org.eclipse.babel.editor.i18n.I18NEntry;
import org.eclipse.babel.editor.util.UIUtils;
import org.eclipse.jface.action.Action;

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

    private final I18NEntry i18NEntry;
    private boolean expanded;

    /**
     * 
     */
    public FoldingAction(I18NEntry i18NEntry) {
        super();
        this.i18NEntry = i18NEntry;
        this.expanded = i18NEntry.getExpanded();
        setText("Collapse");
        setImageDescriptor(UIUtils.getImageDescriptor("minus.gif"));
        setToolTipText("TODO put something here"); // TODO put tooltip
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.IAction#run()
     */
    public void run() {
        if (i18NEntry.getExpanded()) {
            setImageDescriptor(UIUtils.getImageDescriptor("plus.gif"));
            i18NEntry.setExpanded(false);
        } else {
            setImageDescriptor(UIUtils.getImageDescriptor("minus.gif"));
            i18NEntry.setExpanded(true);
        }
    }

}

Back to the top