Revision 39115 branches/v2_0_0_prep/frameworks/_fwAndami/src/org/gvsig/andami/ui/mdiFrame/MDIFrame.java
MDIFrame.java | ||
---|---|---|
556 | 556 |
for (int i = 0; i < parentItem.getMenuComponentCount(); i++) { |
557 | 557 |
|
558 | 558 |
String item_name = parentItem.getMenuComponent(i).getName(); |
559 |
if ((item_name != null) // not a JToolBar.Separator |
|
560 |
&& (item_name.compareTo((String) nombres.get(0)) == 0)) { |
|
559 |
if (((item_name != null) && (item_name.compareTo((String) nombres.get(0)) == 0)) |
|
560 |
|| |
|
561 |
/* |
|
562 |
* We also accept "leaf menus" with no name |
|
563 |
* (Project manager, View-1, View-2, etc) |
|
564 |
*/ |
|
565 |
lastMenuItemWithoutName(parentItem.getMenuComponent(i), nombres)) |
|
566 |
{ |
|
561 | 567 |
|
562 | 568 |
nombres.remove(0); |
563 | 569 |
if (nombres.isEmpty()) { |
... | ... | |
615 | 621 |
} |
616 | 622 |
|
617 | 623 |
/** |
624 |
* @param menuComponent |
|
625 |
* @param nombres |
|
626 |
* @return |
|
627 |
*/ |
|
628 |
private boolean lastMenuItemWithoutName(Component mc, ArrayList names) { |
|
629 |
|
|
630 |
/* |
|
631 |
* names must have 1 string |
|
632 |
*/ |
|
633 |
if (names == null || names.size() != 1) { |
|
634 |
return false; |
|
635 |
} |
|
636 |
if (!(mc instanceof JMenuItem)) { |
|
637 |
return false; |
|
638 |
} |
|
639 |
JMenuItem jmi = (JMenuItem) mc; |
|
640 |
if (jmi.getName() != null) { |
|
641 |
/* |
|
642 |
* Name must be null, so this is a menu leaf |
|
643 |
*/ |
|
644 |
return false; |
|
645 |
} |
|
646 |
if (jmi.getText() == null) { |
|
647 |
return false; |
|
648 |
} |
|
649 |
return jmi.getText().compareTo((String) names.get(0)) == 0; |
|
650 |
} |
|
651 |
|
|
652 |
/** |
|
618 | 653 |
* Crea la estructura de menus recursivamente. Por ejemplo, si se le pasa |
619 | 654 |
* en el par�metro nombres el array {"Search", "References", "Workspace"} |
620 | 655 |
* crear� un men� Search, un submen� del anterior que se llamar� |
... | ... | |
1565 | 1600 |
nuevoMenu.removeActionListener(actionInfo); |
1566 | 1601 |
} |
1567 | 1602 |
nuevoMenu.addActionListener(listener); |
1603 |
} else { |
|
1604 |
/* |
|
1605 |
* We also add action listener for menu with |
|
1606 |
* no name but with text: |
|
1607 |
* |
|
1608 |
* Window/Project manager |
|
1609 |
* Window/View - 1 |
|
1610 |
* Window/View - 2 |
|
1611 |
* etc |
|
1612 |
*/ |
|
1613 |
if( listener != null && menu.getText() != null && menu.getText().trim().length()>0) { |
|
1614 |
nuevoMenu.addActionListener(listener); |
|
1615 |
} |
|
1616 |
|
|
1568 | 1617 |
} |
1569 | 1618 |
menuPadre.add(nuevoMenu); |
1570 | 1619 |
|
Also available in: Unified diff