use of org.eclipse.scout.rt.client.ui.action.IAction in project scout.rt by eclipse.
the class TreeContextMenu method calculateEnableState.
/**
* @param ownerSelection
*/
protected void calculateEnableState(Collection<? extends ITreeNode> ownerSelection) {
boolean enabled = true;
for (ITreeNode node : ownerSelection) {
if (!node.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.IAction in project scout.rt by eclipse.
the class AbstractMenu method afterChildMenusAdd.
protected void afterChildMenusAdd(Collection<? extends IMenu> newChildMenus) {
if (CollectionUtility.hasElements(newChildMenus)) {
final Object ownerValue = m_ownerValue;
IActionVisitor visitor = new IActionVisitor() {
@Override
public int visit(IAction action) {
if (action instanceof IMenu) {
IMenu menu = (IMenu) action;
try {
if (ObjectUtility.notEquals(menu.getOwnerValue(), ownerValue)) {
menu.handleOwnerValueChanged(ownerValue);
}
} catch (RuntimeException e) {
LOG.error("error during handle owner value changed.", e);
}
}
return CONTINUE;
}
};
for (IMenu m : newChildMenus) {
m.acceptVisitor(visitor);
}
}
}
use of org.eclipse.scout.rt.client.ui.action.IAction in project scout.rt by eclipse.
the class JsonAction method initJsonProperties.
@Override
protected void initJsonProperties(ACTION model) {
super.initJsonProperties(model);
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_TEXT, model) {
@Override
protected String modelValue() {
return getModel().getText();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_ICON_ID, model) {
@Override
protected String modelValue() {
return getModel().getIconId();
}
@Override
public Object prepareValueForToJson(Object value) {
return BinaryResourceUrlUtility.createIconUrl((String) value);
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_TOOLTIP_TEXT, model) {
@Override
protected String modelValue() {
return getModel().getTooltipText();
}
});
putJsonProperty(new JsonProperty<ACTION>("toggleAction", model) {
@Override
protected Boolean modelValue() {
return getModel().isToggleAction();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_SELECTED, model) {
@Override
protected Boolean modelValue() {
return getModel().isSelected();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isEnabled();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_VISIBLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isVisible();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_KEY_STROKE, model) {
@Override
protected String modelValue() {
return getModel().getKeyStroke();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_KEYSTROKE_FIRE_POLICY, model) {
@Override
protected Integer modelValue() {
return getModel().getKeyStrokeFirePolicy();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_HORIZONTAL_ALIGNMENT, model) {
@Override
protected Integer modelValue() {
return (int) getModel().getHorizontalAlignment();
}
});
putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_CSS_CLASS, model) {
@Override
protected String modelValue() {
return getModel().getCssClass();
}
});
putJsonProperty(new JsonAdapterProperty<ACTION>(IActionNode.PROP_CHILD_ACTIONS, model, getUiSession()) {
@Override
protected JsonAdapterPropertyConfig createConfig() {
return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<IAction>()).build();
}
@Override
protected Object modelValue() {
if (getModel() instanceof IActionNode) {
return ((IActionNode) getModel()).getChildActions();
}
return null;
}
});
}
Aggregations