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 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 41314 | jjdelcerro | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 41314 | jjdelcerro | * MA 02110-1301, USA.
|
20 | 40435 | jjdelcerro | *
|
21 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | package org.gvsig.andami.ui.mdiFrame; |
||
25 | |||
26 | import javax.swing.Action; |
||
27 | import javax.swing.Icon; |
||
28 | 41314 | jjdelcerro | import org.gvsig.andami.ui.mdiFrame.TranslatableButtonHelper.TranslatableButton; |
29 | 40435 | jjdelcerro | |
30 | 41314 | jjdelcerro | 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 | 40435 | jjdelcerro | } |