use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.
the class FormFieldContextMenu method handleOwnerEnabledChanged.
protected void handleOwnerEnabledChanged() {
T container = getContainer();
if (container == null) {
return;
}
final boolean enabled = container.isEnabledIncludingParents();
acceptVisitor(new IActionVisitor() {
@Override
public int visit(IAction action) {
if (action instanceof IMenu) {
IMenu menu = (IMenu) action;
if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
menu.setEnabledInheritAccessibility(enabled);
}
}
return CONTINUE;
}
});
}
use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.
the class AbstractContextMenu method calculateLocalVisibility.
protected void calculateLocalVisibility() {
final IActionFilter activeFilter = ActionUtility.createMenuFilterMenuTypes(getCurrentMenuTypes(), true);
if (activeFilter != null) {
final BooleanHolder visibleHolder = new BooleanHolder(false);
acceptVisitor(new IActionVisitor() {
@Override
public int visit(IAction action) {
if (action instanceof IMenu) {
IMenu menu = (IMenu) action;
if (menu.hasChildActions() || menu.isSeparator() || menu instanceof IContextMenu) {
return CONTINUE;
} else if (activeFilter.accept(menu)) {
visibleHolder.setValue(true);
return CANCEL;
}
}
return CONTINUE;
}
});
setVisible(visibleHolder.getValue());
}
}
use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.
the class MenuUtility method getMenuByClass.
/**
* @return the sub-menu of the given context menu owner that implements the given type. If no implementation is found,
* <code>null</code> is returned. Note: This method uses instance-of checks, hence the menu replacement
* mapping is not required.
* @throws IllegalStateException
* when more than one menu implements the given type
* @throws IllegalArgumentException
* when no context menu owner is provided.
*/
public static <T extends IMenu> T getMenuByClass(IContextMenuOwner contextMenuOwner, final Class<T> menuType) {
if (contextMenuOwner == null) {
throw new IllegalArgumentException("Argument 'contextMenuOwner' must not be null");
}
IContextMenu contextMenu = contextMenuOwner.getContextMenu();
if (contextMenu == null || menuType == null) {
return null;
}
final List<T> collectedMenus = new ArrayList<T>();
contextMenu.acceptVisitor(new IActionVisitor() {
@Override
public int visit(IAction action) {
if (menuType.isInstance(action)) {
T menu = menuType.cast(action);
collectedMenus.add(menu);
}
return CONTINUE;
}
});
if (collectedMenus.isEmpty()) {
return null;
}
if (collectedMenus.size() == 1) {
return collectedMenus.get(0);
}
throw new IllegalStateException("Ambiguous menu type " + menuType.getName() + "! More than one implementation was found: " + CollectionUtility.format(collectedMenus));
}
use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.
the class TableContextMenu method calculateEnableState.
/**
* @param ownerValue
*/
protected void calculateEnableState(List<? extends ITableRow> ownerValue) {
boolean enabled = getContainer().isEnabled();
if (enabled) {
for (ITableRow row : ownerValue) {
if (!row.isEnabled()) {
enabled = false;
break;
}
}
}
final boolean inheritedEnability = enabled;
acceptVisitor(new IActionVisitor() {
@Override
public int visit(IAction action) {
if (action instanceof IMenu) {
IMenu menu = (IMenu) action;
if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
menu.setEnabledInheritAccessibility(inheritedEnability);
}
}
return CONTINUE;
}
});
}
use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.
the class TableContextMenu method handleOwnerEnabledChanged.
protected void handleOwnerEnabledChanged() {
ITable container = getContainer();
if (container != null) {
final boolean enabled = container.isEnabled();
acceptVisitor(new IActionVisitor() {
@Override
public int visit(IAction action) {
if (action instanceof IMenu) {
IMenu menu = (IMenu) action;
if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
menu.setEnabled(enabled);
}
}
return CONTINUE;
}
});
}
}
Aggregations