Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / ui / mdiFrame / JMenuItem.java @ 41314

History | View | Annotate | Download (2.74 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA 02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.andami.ui.mdiFrame;
25

    
26
import javax.swing.Action;
27
import javax.swing.Icon;
28
import org.gvsig.andami.ui.mdiFrame.TranslatableButtonHelper.TranslatableButton;
29

    
30
public class JMenuItem extends javax.swing.JMenuItem implements EnableTextSupport, TranslatableButton {
31

    
32
    private TranslatableButtonHelper i18nHelper = new TranslatableButtonHelper();
33
    private String enableText;
34
    private String toolTip = super.getToolTipText();
35

    
36
    public JMenuItem() {
37
        super();
38
    }
39

    
40
    public JMenuItem(String text) {
41
        super(text);
42
    }
43

    
44
    public JMenuItem(String text, int mnemonic) {
45
        super(text, mnemonic);
46
    }
47

    
48
    public JMenuItem(String text, Icon icon) {
49
        super(text, icon);
50
    }
51

    
52
    public JMenuItem(Action a) {
53
        super(a);
54
    }
55

    
56
    public JMenuItem(Icon icon) {
57
        super(icon);
58
    }
59

    
60
    /**
61
     * @return Returns the enableText.
62
     */
63
    public String getEnableText() {
64
        return enableText;
65
    }
66

    
67
    /**
68
     * @param enableText The enableText to set.
69
     */
70
    public void setEnableText(String enableText) {
71
        this.enableText = enableText;
72
    }
73

    
74
    public void setEnabled(boolean aFlag) {
75
        super.setEnabled(aFlag);
76
        if ( aFlag ) {
77
            setToolTipText(toolTip);
78
        } else {
79
            setToolTipText(enableText);
80
        }
81
    }
82

    
83
    public void setToolTip(String text) {
84
        toolTip = text;
85
    }
86

    
87
    public void setToolTipKey(String key) {
88
        this.i18nHelper.setTooltip(key);
89
    }
90

    
91
    public void setTextKey(String key) {
92
        this.i18nHelper.setText(key);
93
    }
94

    
95
    public void translate() {
96
        if ( this.i18nHelper.needTranslation() ) {
97
            this.i18nHelper.translate();
98
            this.setText(this.i18nHelper.getText());
99
            this.setToolTip(this.i18nHelper.getTooltip());
100
        }
101
    }
102
}