Revision 41314 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/JToolBarToggleButton.java
JToolBarToggleButton.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 JToolBarToggleButton extends javax.swing.JToggleButton implements EnableTextSupport{ |
|
30 |
/** |
|
31 |
* |
|
32 |
*/ |
|
33 |
public JToolBarToggleButton() { |
|
34 |
super(); |
|
35 |
// TODO Auto-generated constructor stub |
|
36 |
} |
|
37 |
/** |
|
38 |
* @param text |
|
39 |
*/ |
|
40 |
public JToolBarToggleButton(String text) { |
|
41 |
super(text); |
|
42 |
// TODO Auto-generated constructor stub |
|
43 |
} |
|
44 |
/** |
|
45 |
* @param text |
|
46 |
* @param selected |
|
47 |
*/ |
|
48 |
public JToolBarToggleButton(String text, boolean selected) { |
|
49 |
super(text, selected); |
|
50 |
// TODO Auto-generated constructor stub |
|
51 |
} |
|
52 |
/** |
|
53 |
* @param text |
|
54 |
* @param icon |
|
55 |
*/ |
|
56 |
public JToolBarToggleButton(String text, Icon icon) { |
|
57 |
super(text, icon); |
|
58 |
// TODO Auto-generated constructor stub |
|
59 |
} |
|
60 |
/** |
|
61 |
* @param text |
|
62 |
* @param icon |
|
63 |
* @param selected |
|
64 |
*/ |
|
65 |
public JToolBarToggleButton(String text, Icon icon, boolean selected) { |
|
66 |
super(text, icon, selected); |
|
67 |
// TODO Auto-generated constructor stub |
|
68 |
} |
|
69 |
/** |
|
70 |
* @param a |
|
71 |
*/ |
|
72 |
public JToolBarToggleButton(Action a) { |
|
73 |
super(a); |
|
74 |
// TODO Auto-generated constructor stub |
|
75 |
} |
|
76 |
/** |
|
77 |
* @param icon |
|
78 |
*/ |
|
79 |
public JToolBarToggleButton(Icon icon) { |
|
80 |
super(icon); |
|
81 |
// TODO Auto-generated constructor stub |
|
82 |
} |
|
83 |
/** |
|
84 |
* @param icon |
|
85 |
* @param selected |
|
86 |
*/ |
|
87 |
public JToolBarToggleButton(Icon icon, boolean selected) { |
|
88 |
super(icon, selected); |
|
89 |
// TODO Auto-generated constructor stub |
|
90 |
} |
|
91 |
private String enableText; |
|
92 |
private String toolTip; |
|
93 |
|
|
94 |
|
|
95 |
/** |
|
96 |
* @return Returns the enableText. |
|
97 |
*/ |
|
98 |
public String getEnableText() { |
|
99 |
return enableText; |
|
100 |
} |
|
101 |
/** |
|
102 |
* @param enableText The enableText to set. |
|
103 |
*/ |
|
104 |
public void setEnableText(String enableText) { |
|
105 |
this.enableText = enableText; |
|
106 |
} |
|
107 |
|
|
108 |
|
|
109 |
/** |
|
110 |
* @see java.awt.Component#setVisible(boolean) |
|
111 |
*/ |
|
112 |
public void setEnabled(boolean aFlag) { |
|
113 |
super.setEnabled(aFlag); |
|
114 |
if (aFlag){ |
|
115 |
setToolTipText(toolTip); |
|
116 |
}else{ |
|
117 |
setToolTipText(enableText); |
|
118 |
} |
|
119 |
} |
|
120 |
/** |
|
121 |
* @see javax.swing.JComponent#setToolTipText(java.lang.String) |
|
122 |
*/ |
|
123 |
public void setToolTip(String text) { |
|
124 |
toolTip = text; |
|
125 |
} |
|
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 |
|
|
126 | 111 |
} |
Also available in: Unified diff