Revision 2203
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.impl/src/main/java/org/gvsig/tools/swing/impl/DefaultToolsSwingManager.java | ||
---|---|---|
223 | 223 |
@Override |
224 | 224 |
public void translate(JComponent component) { |
225 | 225 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
226 |
String s = (String) call(component, "getText", (Object[]) null);
|
|
227 |
if (!StringUtils.isEmpty(s)) {
|
|
228 |
call(component, "setText", i18n.getTranslation(s));
|
|
226 |
String text = (String) call(component, "getText", (Object[]) null);
|
|
227 |
if (!StringUtils.isEmpty(text)) {
|
|
228 |
call(component, "setText", i18n.getTranslation(text));
|
|
229 | 229 |
} |
230 |
s = (String) call(component, "getToolTipText", (Object[]) null); |
|
231 |
if (!StringUtils.isEmpty(s)) { |
|
232 |
call(component, "setToolTipText", i18n.getTranslation(s)); |
|
230 |
text = (String) call(component, "getToolTipText", (Object[]) null); |
|
231 |
if (!StringUtils.isEmpty(text)) { |
|
232 |
text = i18n.getTranslation(text); |
|
233 |
call(component, "setToolTipText", toHTML(text)); |
|
233 | 234 |
} |
234 | 235 |
} |
235 | 236 |
|
236 | 237 |
@Override |
237 | 238 |
public void translate(AbstractButton component) { |
238 | 239 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
239 |
String s = component.getText();
|
|
240 |
if (!StringUtils.isEmpty(s)) {
|
|
241 |
component.setText(i18n.getTranslation(s));
|
|
240 |
String text= component.getText();
|
|
241 |
if (!StringUtils.isEmpty(text)) {
|
|
242 |
component.setText(i18n.getTranslation(text));
|
|
242 | 243 |
} |
243 |
s = component.getToolTipText(); |
|
244 |
if (!StringUtils.isEmpty(s)) { |
|
245 |
component.setToolTipText(i18n.getTranslation(s)); |
|
244 |
text = component.getToolTipText(); |
|
245 |
if (!StringUtils.isEmpty(text)) { |
|
246 |
text = i18n.getTranslation(text); |
|
247 |
component.setToolTipText(toHTML(text)); |
|
246 | 248 |
} |
247 | 249 |
} |
248 | 250 |
|
249 | 251 |
@Override |
250 | 252 |
public void translate(JLabel component) { |
251 | 253 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
252 |
String s = component.getText();
|
|
253 |
if (!StringUtils.isEmpty(s)) {
|
|
254 |
component.setText(i18n.getTranslation(s));
|
|
254 |
String text = component.getText();
|
|
255 |
if (!StringUtils.isEmpty(text)) {
|
|
256 |
component.setText(i18n.getTranslation(text));
|
|
255 | 257 |
} |
256 |
s = component.getToolTipText(); |
|
257 |
if (!StringUtils.isEmpty(s)) { |
|
258 |
component.setToolTipText(i18n.getTranslation(s)); |
|
258 |
text = component.getToolTipText(); |
|
259 |
if (!StringUtils.isEmpty(text)) { |
|
260 |
text = i18n.getTranslation(text); |
|
261 |
component.setToolTipText(toHTML(text)); |
|
259 | 262 |
} |
260 | 263 |
} |
261 | 264 |
|
... | ... | |
270 | 273 |
} |
271 | 274 |
text = component.getToolTipTextAt(i); |
272 | 275 |
if (!StringUtils.isEmpty(text)) { |
273 |
component.setToolTipTextAt(i, i18n.getTranslation(text)); |
|
276 |
text = i18n.getTranslation(text); |
|
277 |
component.setToolTipTextAt(i, toHTML(text)); |
|
274 | 278 |
} |
275 | 279 |
} |
276 | 280 |
} |
277 | 281 |
|
282 |
private String toHTML(String s) { |
|
283 |
s = StringUtils.replace(s, "\n", "\n<br>"); |
|
284 |
s = StringUtils.replace(s, "<html>", ""); |
|
285 |
s = StringUtils.replace(s, "</html>", ""); |
|
286 |
s = "<html>"+s+"</html>"; |
|
287 |
return s; |
|
288 |
} |
|
289 |
|
|
278 | 290 |
@Override |
279 | 291 |
public void setDefaultPopupMenu(final JTextComponent component) { |
280 | 292 |
this.setDefaultPopupMenu(component, null); |
Also available in: Unified diff