Revision 42351 trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/MDIFrame.java
MDIFrame.java | ||
---|---|---|
50 | 50 |
import java.util.StringTokenizer; |
51 | 51 |
import java.util.Vector; |
52 | 52 |
|
53 |
import javax.sql.rowset.spi.SyncResolver; |
|
54 | 53 |
import javax.swing.AbstractButton; |
55 | 54 |
import javax.swing.ButtonGroup; |
56 | 55 |
import javax.swing.ImageIcon; |
... | ... | |
300 | 299 |
super.setTitle(titlePrefix + " : " + title); |
301 | 300 |
} |
302 | 301 |
|
302 |
private SelectableToolBar getToolBar(final String toolBarName) { |
|
303 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(toolBarName); |
|
304 |
if ( jtb == null ) { |
|
305 |
jtb = new SelectableToolBar(toolBarName); |
|
306 |
jtb.setRollover(true); |
|
307 |
jtb.setAndamiVisibility(true); |
|
308 |
toolBarMap.put(toolBarName, jtb); |
|
309 |
toolBars.add(jtb); |
|
310 |
} |
|
311 |
return jtb; |
|
312 |
} |
|
313 |
|
|
303 | 314 |
public void addTool(final PluginClassLoader loader, final SkinExtensionType ext, |
304 | 315 |
final ToolBar toolBar, final SelectableTool selectableTool) |
305 | 316 |
throws ClassNotFoundException { |
... | ... | |
339 | 350 |
|
340 | 351 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
341 | 352 |
|
342 |
JToolBarToggleButton btn; |
|
343 |
ImageIcon image |
|
344 |
= PluginServices.getIconTheme().get(selectableTool.getIcon()); |
|
345 |
|
|
353 |
ImageIcon image = PluginServices.getIconTheme().get(selectableTool.getIcon()); |
|
346 | 354 |
if ( image != null ) { |
347 |
btn = new JToolBarToggleButton(selectableTool.getText(), image); |
|
348 |
} else { |
|
349 | 355 |
logger.warn("Unable to find icon '" + selectableTool.getIcon() + "'."); |
350 |
btn |
|
351 |
= new JToolBarToggleButton(selectableTool.getText(), |
|
352 |
PluginServices.getIconTheme().get(noIcon)); |
|
356 |
image = PluginServices.getIconTheme().get(noIcon); |
|
353 | 357 |
} |
354 |
|
|
355 |
org.gvsig.andami.ui.mdiFrame.ToggleButtonModel buttonModel
|
|
356 |
= new org.gvsig.andami.ui.mdiFrame.ToggleButtonModel();
|
|
358 |
|
|
359 |
ToggleButtonModel buttonModel = new ToggleButtonModel();
|
|
360 |
JToolBarToggleButton btn = new JToolBarToggleButton(selectableTool.getText(), image);
|
|
357 | 361 |
btn.setModel(buttonModel); |
358 | 362 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
359 | 363 |
btn.addMouseListener(tooltipListener); |
... | ... | |
364 | 368 |
btn.setEnabled(false); |
365 | 369 |
btn.setVisible(false); |
366 | 370 |
|
367 |
ButtonGroup group; |
|
368 |
if ( buttonGroupMap.containsKey(selectableTool.getGroup()) ) { |
|
369 |
group = (ButtonGroup) buttonGroupMap.get(selectableTool.getGroup()); |
|
370 |
} else { |
|
371 |
ButtonGroup group = (ButtonGroup) buttonGroupMap.get(selectableTool.getGroup()); |
|
372 |
if ( group == null ) { |
|
371 | 373 |
group = new ButtonGroup(); |
372 | 374 |
buttonGroupMap.put(selectableTool.getGroup(), group); |
373 |
|
|
374 | 375 |
} |
376 |
|
|
375 | 377 |
jtb.addButton(group, btn); |
378 |
|
|
376 | 379 |
buttonModel.setGroupName(selectableTool.getGroup()); |
377 |
|
|
378 | 380 |
if ( selectableTool.getIsDefault() ) { |
379 | 381 |
btn.setSelected(true); |
380 | 382 |
initialSelectedTools.put(selectableTool.getGroup(), |
... | ... | |
401 | 403 |
} |
402 | 404 |
} |
403 | 405 |
|
404 |
/** |
|
405 |
* Add a button to the toolbar. |
|
406 |
* |
|
407 |
* @param ext |
|
408 |
* Texto del boton, si es null no aparece texto |
|
409 |
* @param ext |
|
410 |
* Extension asociada al control |
|
411 |
* @param toolBar |
|
412 |
* Icono del boton, si es null no aparece texto |
|
413 |
* @param actionTool |
|
414 |
* Tooltip de la barra de herramientas |
|
415 |
* |
|
416 |
* @throws ClassNotFoundException |
|
417 |
* @throws RuntimeException |
|
418 |
*/ |
|
419 | 406 |
public void addTool(final PluginClassLoader loader, final SkinExtensionType ext, |
420 | 407 |
final ToolBar toolBar, final ActionTool actionTool) throws ClassNotFoundException { |
421 | 408 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
... | ... | |
455 | 442 |
|
456 | 443 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
457 | 444 |
|
458 |
JToolBarButton btn; |
|
459 | 445 |
ImageIcon image = IconThemeHelper.getImageIcon(actionTool.getIcon()); |
460 |
|
|
461 | 446 |
if ( image != null ) { |
462 |
btn = new JToolBarButton(actionTool.getText(), image); |
|
463 |
} else { |
|
464 | 447 |
logger.warn("Unable to find icon '" + actionTool.getIcon() + "'."); |
465 |
btn |
|
466 |
= new JToolBarButton(actionTool.getText(), PluginServices |
|
467 |
.getIconTheme().get(noIcon)); |
|
448 |
image = PluginServices.getIconTheme().get(noIcon); |
|
468 | 449 |
} |
469 | 450 |
|
451 |
JToolBarButton btn = new JToolBarButton(actionTool.getText(), image); |
|
470 | 452 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
471 | 453 |
btn.addMouseListener(tooltipListener); |
472 | 454 |
btn.addActionListener(this); |
... | ... | |
475 | 457 |
btn.setEnabled(false); |
476 | 458 |
btn.setVisible(false); |
477 | 459 |
|
478 |
|
|
479 | 460 |
jtb.add(btn); |
480 | 461 |
|
481 | 462 |
addControl(btn); |
... | ... | |
498 | 479 |
} |
499 | 480 |
} |
500 | 481 |
|
501 |
private SelectableToolBar getToolBar(final String toolBarName) { |
|
502 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(toolBarName); |
|
503 |
if ( jtb == null ) { |
|
504 |
jtb = new SelectableToolBar(toolBarName); |
|
505 |
jtb.setRollover(true); |
|
506 |
jtb.setAndamiVisibility(true); |
|
507 |
toolBarMap.put(toolBarName, jtb); |
|
508 |
toolBars.add(jtb); |
|
509 |
} |
|
510 |
return jtb; |
|
511 |
} |
|
512 |
|
|
513 | 482 |
public void addTool(final ActionInfo action, final String toolBarName, final String dropDownName) { |
514 | 483 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
515 | 484 |
SwingUtilities.invokeLater(new Runnable() { |
... | ... | |
528 | 497 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
529 | 498 |
dropDownButton.add(actionManager.getTranslated(action)); |
530 | 499 |
} |
500 |
public void addTool(final ActionInfo action, final String toolBarName) { |
|
501 |
addTool(action, toolBarName, false); |
|
502 |
} |
|
531 | 503 |
|
532 |
public void addTool(final ActionInfo action, final String toolBarName) { |
|
504 |
public void addTool(final ActionInfo action, final String toolBarName, final boolean useText) {
|
|
533 | 505 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
534 | 506 |
|
535 | 507 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
536 | 508 |
SwingUtilities.invokeLater(new Runnable() { |
537 | 509 |
public void run() { |
538 |
addTool(action, toolBarName); |
|
510 |
addTool(action, toolBarName, useText);
|
|
539 | 511 |
} |
540 | 512 |
}); |
541 | 513 |
return; |
... | ... | |
549 | 521 |
btn.setEnabled(false); |
550 | 522 |
btn.setVisible(false); |
551 | 523 |
btn.setName(action.getName()); |
524 |
if( useText ) { |
|
525 |
btn.setText(action.getLabel()); |
|
526 |
} |
|
552 | 527 |
if ( action.getTooltip() != null ) { |
553 | 528 |
btn.setToolTip(i18nManager.getTranslation(action.getTooltip())); |
554 | 529 |
btn.setToolTipKey(action.getTooltip()); |
... | ... | |
560 | 535 |
addControl(btn); |
561 | 536 |
|
562 | 537 |
} |
563 |
|
|
538 |
|
|
539 |
public void addSelectableTool(final ActionInfo action, final String toolBarName, final String groupName, final boolean useText) { |
|
540 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
541 |
|
|
542 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
|
543 |
SwingUtilities.invokeLater(new Runnable() { |
|
544 |
public void run() { |
|
545 |
addSelectableTool(action, toolBarName,groupName,useText); |
|
546 |
} |
|
547 |
}); |
|
548 |
return; |
|
549 |
} |
|
550 |
|
|
551 |
ButtonGroup group = (ButtonGroup) buttonGroupMap.get(groupName); |
|
552 |
if ( group == null ) { |
|
553 |
group = new ButtonGroup(); |
|
554 |
buttonGroupMap.put(groupName, group); |
|
555 |
} |
|
556 |
ToggleButtonModel buttonModel = new ToggleButtonModel(); |
|
557 |
buttonModel.setGroupName(groupName); |
|
558 |
|
|
559 |
JToolBarToggleButton btn = new JToolBarToggleButton(action.getIcon()); |
|
560 |
btn.setModel(buttonModel); |
|
561 |
btn.setMargin(new Insets(0, 0, 0, 0)); |
|
562 |
btn.addMouseListener(tooltipListener); |
|
563 |
btn.addActionListener(this); |
|
564 |
btn.setFocusable(false); |
|
565 |
btn.setActionCommand(action.getCommand()); |
|
566 |
btn.setEnabled(false); |
|
567 |
btn.setVisible(false); |
|
568 |
btn.setName(action.getName()); |
|
569 |
if( useText ) { |
|
570 |
btn.setText(action.getLabel()); |
|
571 |
} |
|
572 |
if ( action.getTooltip() != null ) { |
|
573 |
btn.setToolTip(i18nManager.getTranslation(action.getTooltip())); |
|
574 |
btn.setToolTipKey(action.getTooltip()); |
|
575 |
} |
|
576 |
|
|
577 |
SelectableToolBar jtb = getToolBar(toolBarName); |
|
578 |
jtb.addButton(group, btn); |
|
579 |
|
|
580 |
addControl(btn); |
|
581 |
|
|
582 |
} |
|
583 |
|
|
564 | 584 |
/** |
565 | 585 |
* Creates the needed menu structure to add the menu to the bar. |
566 | 586 |
* Returns the father which must hold the menu which was |
... | ... | |
1062 | 1082 |
|
1063 | 1083 |
private JMenuItem createJMenuItem(ActionInfo action, String text) { |
1064 | 1084 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
1065 |
JMenuItem nuevoMenu = null; |
|
1066 | 1085 |
String label = null; |
1067 | 1086 |
|
1068 | 1087 |
if ( text == null ) { |
... | ... | |
1073 | 1092 |
} else { |
1074 | 1093 |
label = text; |
1075 | 1094 |
} |
1076 |
String translatedText = i18nManager.getTranslation(label); |
|
1095 |
JMenuItem nuevoMenu = new JMenuItem(); |
|
1096 |
nuevoMenu.setText(i18nManager.getTranslation(label)); |
|
1097 |
nuevoMenu.setName(action.getName()); |
|
1077 | 1098 |
if ( action.getIconName() != null ) { |
1078 |
ImageIcon image = action.getIcon(); |
|
1079 |
if ( image != null ) { |
|
1080 |
nuevoMenu = new JMenuItem(translatedText, image); |
|
1081 |
} else { |
|
1082 |
nuevoMenu = new JMenuItem(translatedText); |
|
1083 |
} |
|
1084 |
} else { |
|
1085 |
nuevoMenu = new JMenuItem(translatedText); |
|
1099 |
nuevoMenu.setIcon(action.getIcon()); |
|
1086 | 1100 |
} |
1087 |
nuevoMenu.setText(translatedText); |
|
1088 |
nuevoMenu.setName(action.getName()); |
|
1089 | 1101 |
KeyStroke key = action.getKeyStroke(); |
1090 | 1102 |
if ( key != null ) { |
1091 | 1103 |
nuevoMenu.setAccelerator(key); |
Also available in: Unified diff