svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / ui / mdiFrame / TranslatableButtonHelper.java @ 41314
History | View | Annotate | Download (2.55 KB)
1 |
/*
|
---|---|
2 |
/**
|
3 |
* gvSIG. Desktop Geographic Information System.
|
4 |
*
|
5 |
* Copyright (C) 2007-2013 gvSIG Association.
|
6 |
*
|
7 |
* This program is free software; you can redistribute it and/or
|
8 |
* modify it under the terms of the GNU General Public License
|
9 |
* as published by the Free Software Foundation; either version 3
|
10 |
* of the License, or (at your option) any later version.
|
11 |
*
|
12 |
* This program is distributed in the hope that it will be useful,
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
* GNU General Public License for more details.
|
16 |
*
|
17 |
* You should have received a copy of the GNU General Public License
|
18 |
* along with this program; if not, write to the Free Software
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
20 |
* MA 02110-1301, USA.
|
21 |
*
|
22 |
* For any additional information, do not hesitate to contact us
|
23 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
24 |
*/
|
25 |
package org.gvsig.andami.ui.mdiFrame; |
26 |
|
27 |
import java.util.Locale; |
28 |
import org.gvsig.andami.PluginsLocator; |
29 |
import org.gvsig.andami.PluginsManager; |
30 |
|
31 |
public class TranslatableButtonHelper { |
32 |
|
33 |
public interface TranslatableButton { |
34 |
|
35 |
public void setTextKey(String key); |
36 |
|
37 |
public void setToolTipKey(String key); |
38 |
|
39 |
public void translate(); |
40 |
} |
41 |
|
42 |
private String keyText = null; |
43 |
private String keyToolTip = null; |
44 |
private String text = null; |
45 |
private String tooltip = null; |
46 |
|
47 |
private Locale locale = null; |
48 |
private static PluginsManager pluginsManager = null; |
49 |
|
50 |
public void setText(String keyText) { |
51 |
this.keyText = keyText;
|
52 |
} |
53 |
|
54 |
public void setTooltip(String keyTooltip) { |
55 |
this.keyToolTip = keyTooltip;
|
56 |
} |
57 |
|
58 |
public String getText() { |
59 |
return this.text; |
60 |
} |
61 |
|
62 |
public String getTooltip() { |
63 |
return this.tooltip; |
64 |
} |
65 |
|
66 |
private PluginsManager getPluginsManager() {
|
67 |
if ( pluginsManager == null ) { |
68 |
pluginsManager = PluginsLocator.getManager(); |
69 |
} |
70 |
return pluginsManager;
|
71 |
} |
72 |
|
73 |
public void translate() { |
74 |
if ( this.keyText != null ) { |
75 |
this.text = getPluginsManager().translate(this.keyText); |
76 |
} |
77 |
if ( this.keyToolTip != null ) { |
78 |
this.tooltip = getPluginsManager().translate(this.keyToolTip); |
79 |
} |
80 |
locale = Locale.getDefault();
|
81 |
} |
82 |
|
83 |
public boolean needTranslation() { |
84 |
if ( this.locale == null ) { |
85 |
return true; |
86 |
} |
87 |
if ( this.locale.equals(Locale.getDefault()) ) { |
88 |
return false; |
89 |
} |
90 |
return true; |
91 |
} |
92 |
} |