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

View differences:

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

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

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

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

  
44
    public JToolBarButton(String text, Icon icon) {
45
        super(text, icon);
46
    }
47

  
48
    public JToolBarButton(Action a) {
49
        super(a);
50
    }
51

  
52
    public JToolBarButton(Icon icon) {
53
        super(icon);
54
    }
55

  
56
    /**
57
     * @return Returns the enableText.
58
     */
59
    public String getEnableText() {
60
        return enableText;
61
    }
62

  
63
    /**
64
     * @param enableText The enableText to set.
65
     */
66
    public void setEnableText(String enableText) {
67
        this.enableText = enableText;
68
    }
69

  
70
    public void setEnabled(boolean aFlag) {
71
        super.setEnabled(aFlag);
72
        if ( aFlag ) {
73
            setToolTipText(toolTip);
74
        } else {
75
            setToolTipText(enableText);
76
        }
77
    }
78

  
79
    public void setToolTip(String text) {
80
        toolTip = text;
81
    }
82

  
83
    public void setToolTipKey(String key) {
84
        this.i18nHelper.setTooltip(key);
85
    }
86

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

  
91
    public void translate() {
92
        if ( this.i18nHelper.needTranslation() ) {
93
            this.i18nHelper.translate();
94
            this.setText(this.i18nHelper.getText());
95
            this.setToolTip(this.i18nHelper.getTooltip());
96
        }
97
    }
98

  
101 99
}

Also available in: Unified diff