use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy in project geo-platform by geosdi.
the class GPMenuActionBinder method bindMenuCheckAction.
@Override
public void bindMenuCheckAction(MenuCheckAction action, GPCheckMenuItem tool, final Menu menu) {
checkArgument(tool != null, "The Parameter tool must not be null.");
checkArgument(menu != null, "The Parameter menu must not be null.");
final CheckMenuItem item = new CheckMenuItem(tool.getText());
item.setItemId(tool.getId());
menu.add(item);
if (action != null) {
action.setId(tool.getId());
item.addSelectionListener(action);
this.addMenuActionEnableHandler(action, item);
action.addMenuActionChangeCheckHandler(new MenuActionChangeCheckHandler() {
@Override
public void onActionCheckChange(MenuActionChangeCheckEvent event) {
item.setChecked(event.isCheck());
item.fireEvent(Events.Select, new MenuEvent(menu, item));
}
});
action.setChecked(tool.isChecked());
action.setEnabled(tool.isEnabled());
if ((action instanceof TreeMenuCompositeAction) && (this.menuCreator instanceof AbstractTreeMenuStrategy)) {
((TreeMenuCompositeAction) action).addTreeMenuSelectionHandler();
}
}
}
use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy in project geo-platform by geosdi.
the class GPMenuActionBinder method bindMenuBaseAction.
/**
* @param action
* @param tool
* @param menu
*/
@Override
public void bindMenuBaseAction(MenuAction action, GPMenuItem tool, final 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());
item.setItemId(tool.getId());
if (action != null) {
action.setId(tool.getId());
if (action instanceof MenuBaseAction) {
item.setIcon(((MenuBaseAction) action).getImage());
}
item.addSelectionListener(action);
this.addMenuActionEnableHandler(action, item);
action.setEnabled((action.isMustBeEnabled()) ? action.isMustBeEnabled() : tool.isEnabled());
if ((action instanceof TreeMenuCompositeAction) && (this.menuCreator instanceof AbstractTreeMenuStrategy)) {
((TreeMenuCompositeAction) action).addTreeMenuSelectionHandler();
}
}
menu.add(item);
}
use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy 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);
}
});
}
}
use of org.geosdi.geoplatform.gui.impl.tree.menu.strategy.AbstractTreeMenuStrategy in project geo-platform by geosdi.
the class GPMenuActionBinder method addMenuActionEnableHandler.
/**
* @param action
* @param item
*/
@Override
public void addMenuActionEnableHandler(MenuAction action, final MenuItem item) {
checkArgument(action != null, "The Parameter action must not be null.");
checkArgument(item != null, "The Parameter item must not be null.");
action.addActionEnableHandler(new ActionEnableHandler() {
@Override
public void onActionEnabled(ActionEnableEvent event) {
item.setEnabled(event.isEnabled());
if ((menuCreator instanceof AbstractTreeMenuStrategy) && (item.getParentMenu() != null) && (item.getParentMenu().getParentItem() != null) && (item.getParentMenu().getParentItem() instanceof MenuItem) && ((MenuItem) (item.getParentMenu().getParentItem())).getSubMenu() != null) {
Menu menu = item.getParentMenu();
GPMenuActionHandlerManager.fireEventFromSource(new GPTreeMenuGroupEnableEvent(), menu.getId());
}
}
});
}
Aggregations