svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / ui / mdiFrame / JToolBarToggleButton.java @ 41314
History | View | Annotate | Download (3.01 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 JToolBarToggleButton extends javax.swing.JToggleButton implements EnableTextSupport, TranslatableButton { |
31 |
|
32 |
private TranslatableButtonHelper i18nHelper = new TranslatableButtonHelper(); |
33 |
private String enableText; |
34 |
private String toolTip; |
35 |
|
36 |
public JToolBarToggleButton() {
|
37 |
super();
|
38 |
} |
39 |
|
40 |
public JToolBarToggleButton(String text) { |
41 |
super(text);
|
42 |
} |
43 |
|
44 |
public JToolBarToggleButton(String text, boolean selected) { |
45 |
super(text, selected);
|
46 |
} |
47 |
|
48 |
public JToolBarToggleButton(String text, Icon icon) { |
49 |
super(text, icon);
|
50 |
} |
51 |
|
52 |
public JToolBarToggleButton(String text, Icon icon, boolean selected) { |
53 |
super(text, icon, selected);
|
54 |
} |
55 |
|
56 |
public JToolBarToggleButton(Action a) { |
57 |
super(a);
|
58 |
} |
59 |
|
60 |
public JToolBarToggleButton(Icon icon) { |
61 |
super(icon);
|
62 |
} |
63 |
|
64 |
public JToolBarToggleButton(Icon icon, boolean selected) { |
65 |
super(icon, selected);
|
66 |
} |
67 |
|
68 |
/**
|
69 |
* @return Returns the enableText.
|
70 |
*/
|
71 |
public String getEnableText() { |
72 |
return enableText;
|
73 |
} |
74 |
|
75 |
/**
|
76 |
* @param enableText The enableText to set.
|
77 |
*/
|
78 |
public void setEnableText(String enableText) { |
79 |
this.enableText = enableText;
|
80 |
} |
81 |
|
82 |
public void setEnabled(boolean aFlag) { |
83 |
super.setEnabled(aFlag);
|
84 |
if ( aFlag ) {
|
85 |
setToolTipText(toolTip); |
86 |
} else {
|
87 |
setToolTipText(enableText); |
88 |
} |
89 |
} |
90 |
|
91 |
public void setToolTip(String text) { |
92 |
toolTip = text; |
93 |
} |
94 |
|
95 |
public void setToolTipKey(String key) { |
96 |
this.i18nHelper.setTooltip(key);
|
97 |
} |
98 |
|
99 |
public void setTextKey(String key) { |
100 |
this.i18nHelper.setText(key);
|
101 |
} |
102 |
|
103 |
public void translate() { |
104 |
if ( this.i18nHelper.needTranslation() ) { |
105 |
this.i18nHelper.translate();
|
106 |
this.setText(this.i18nHelper.getText()); |
107 |
this.setToolTip(this.i18nHelper.getTooltip()); |
108 |
} |
109 |
} |
110 |
|
111 |
} |