use of org.geosdi.geoplatform.gui.configuration.composite.menu.tools.GPTreeMenuGroupItem in project geo-platform by geosdi.
the class GPMenuActionBinder method bindGroupMenuItem.
/**
* @param tool
* @param menu
*/
@Override
public void bindGroupMenuItem(GPGroupMenuItem tool, Menu menu) {
checkArgument(tool != null, "The Parameter tool must not be null.");
checkArgument(menu != null, "The Parameter menu must not be null.");
final MenuItem item = new MenuItem(tool.getText());
menu.add(item);
final Menu subMenu = new Menu();
this.bindTools(subMenu, tool.getTools());
item.setSubMenu(subMenu);
if ((tool instanceof GPTreeMenuGroupItem) && (this.menuCreator instanceof AbstractTreeMenuStrategy)) {
GPMenuActionHandlerManager.addHandlerToSource(TYPE, subMenu.getId(), new GPTreeMenuGroupEnableHander() {
@Override
public void onEnableTreeMenuGroupItem() {
int menuItemsNoEnabled = 0;
for (Component component : subMenu.getItems()) {
if (!component.isEnabled()) {
++menuItemsNoEnabled;
}
}
item.setEnabled((menuItemsNoEnabled == subMenu.getItemCount()) ? FALSE : TRUE);
}
});
}
}
Aggregations