Revision 41314 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/JMenuItem.java

View differences:

JMenuItem.java
10 10
 *
11 11
 * This program is distributed in the hope that it will be useful,
12 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14
 * GNU General Public License for more details.
15 15
 *
16 16
 * You should have received a copy of the GNU General Public License
17 17
 * along with this program; if not, write to the Free Software
18 18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
19
 * MA 02110-1301, USA.
20 20
 *
21 21
 * For any additional information, do not hesitate to contact us
22 22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
......
25 25

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

  
29
public class JMenuItem extends javax.swing.JMenuItem implements EnableTextSupport{
30
	/**
31
	 * 
32
	 */
33
	public JMenuItem() {
34
		super();
35
		// TODO Auto-generated constructor stub
36
	}
37
	/**
38
	 * @param text
39
	 */
40
	public JMenuItem(String text) {
41
		super(text);
42
		// TODO Auto-generated constructor stub
43
	}
44
	/**
45
	 * @param text
46
	 * @param mnemonic
47
	 */
48
	public JMenuItem(String text, int mnemonic) {
49
		super(text, mnemonic);
50
		// TODO Auto-generated constructor stub
51
	}
52
	/**
53
	 * @param text
54
	 * @param icon
55
	 */
56
	public JMenuItem(String text, Icon icon) {
57
		super(text, icon);
58
		// TODO Auto-generated constructor stub
59
	}
60
	/**
61
	 * @param a
62
	 */
63
	public JMenuItem(Action a) {
64
		super(a);
65
		// TODO Auto-generated constructor stub
66
	}
67
	/**
68
	 * @param icon
69
	 */
70
	public JMenuItem(Icon icon) {
71
		super(icon);
72
		// TODO Auto-generated constructor stub
73
	}
74
	private String enableText;
75
	private String toolTip = super.getToolTipText();
76
	
77
	
78
	/**
79
	 * @return Returns the enableText.
80
	 */
81
	public String getEnableText() {
82
		return enableText;
83
	}
84
	/**
85
	 * @param enableText The enableText to set.
86
	 */
87
	public void setEnableText(String enableText) {
88
		this.enableText = enableText;
89
	}
90
	
91
	
92
	/**
93
	 * @see java.awt.Component#setVisible(boolean)
94
	 */
95
	public void setEnabled(boolean aFlag) {
96
		super.setEnabled(aFlag);
97
		if (aFlag){
98
			setToolTipText(toolTip);
99
		}else{
100
			setToolTipText(enableText);
101
		}
102
	}
103
	/**
104
	 * @see javax.swing.JComponent#setToolTipText(java.lang.String)
105
	 */
106
	public void setToolTip(String text) {
107
		toolTip = text;
108
	}
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
    }
109 102
}

Also available in: Unified diff