use of org.eclipse.scout.rt.client.ui.action.IAction 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.IAction 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.IAction 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.IAction in project scout.rt by eclipse.
the class JsonTable method initJsonProperties.
@Override
protected void initJsonProperties(T model) {
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isEnabled();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTI_SELECT, model) {
@Override
protected Boolean modelValue() {
return getModel().isMultiSelect();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTI_CHECK, model) {
@Override
protected Boolean modelValue() {
return getModel().isMultiCheck();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTILINE_TEXT, model) {
@Override
protected Boolean modelValue() {
return getModel().isMultilineText();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CHECKABLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isCheckable();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_ROW_ICON_VISIBLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isRowIconVisible();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_HEADER_VISIBLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isHeaderVisible();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_HEADER_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isHeaderEnabled();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_KEYBOARD_NAVIGATION, model) {
@Override
protected Boolean modelValue() {
return getModel().hasKeyboardNavigation();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_AUTO_RESIZE_COLUMNS, model) {
@Override
protected Boolean modelValue() {
return getModel().isAutoResizeColumns();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_SCROLL_TO_SELECTION, model) {
@Override
protected Boolean modelValue() {
return getModel().isScrollToSelection();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_TABLE_STATUS_VISIBLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isTableStatusVisible();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_TABLE_STATUS, model) {
@Override
protected IStatus modelValue() {
return getModel().getTableStatus();
}
@Override
public Object prepareValueForToJson(Object value) {
return JsonStatus.toJson((IStatus) value);
}
});
putJsonProperty(new JsonAdapterProperty<ITable>(ITable.PROP_TABLE_CONTROLS, model, getUiSession()) {
@Override
protected JsonAdapterPropertyConfig createConfig() {
return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<ITableControl>()).build();
}
@Override
protected List<ITableControl> modelValue() {
return getModel().getTableControls();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_DROP_TYPE, model) {
@Override
protected Integer modelValue() {
return getModel().getDropType();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_DROP_MAXIMUM_SIZE, model) {
@Override
protected Long modelValue() {
return getModel().getDropMaximumSize();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_SORT_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isSortEnabled();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_UI_SORT_POSSIBLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isUiSortPossible();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_LOADING, model) {
@Override
protected Boolean modelValue() {
return getModel().isLoading();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_GROUPING_STYLE, model) {
@Override
protected GroupingStyle modelValue() {
return getModel().getGroupingStyle();
}
@Override
public Object prepareValueForToJson(Object value) {
return ((GroupingStyle) value).name().toLowerCase();
}
});
putJsonProperty(new JsonAdapterProperty<ITable>(ITable.PROP_KEY_STROKES, model, getUiSession()) {
@Override
protected JsonAdapterPropertyConfig createConfig() {
return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<IAction>()).build();
}
@Override
protected List<IKeyStroke> modelValue() {
return getModel().getKeyStrokes();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CSS_CLASS, model) {
@Override
protected String modelValue() {
return getModel().getCssClass();
}
});
putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CONTEXT_COLUMN, model) {
@Override
protected Object modelValue() {
return getModel().getContextColumn();
}
@Override
public Object prepareValueForToJson(Object value) {
if (value == null) {
return null;
}
return m_jsonColumns.get(value).getId();
}
});
}
use of org.eclipse.scout.rt.client.ui.action.IAction in project scout.rt by eclipse.
the class JsonTree method initJsonProperties.
@Override
protected void initJsonProperties(TREE model) {
super.initJsonProperties(model);
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_TITLE, model) {
@Override
protected String modelValue() {
return getModel().getTitle();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.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<TREE>(ITree.PROP_CSS_CLASS, model) {
@Override
protected String modelValue() {
return getModel().getCssClass();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_CHECKABLE, model) {
@Override
protected Boolean modelValue() {
return getModel().isCheckable();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_MULTI_CHECK, model) {
@Override
protected Boolean modelValue() {
return getModel().isMultiCheck();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isEnabled();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_LAZY_EXPANDING_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isLazyExpandingEnabled();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_AUTO_CHECK_CHILDREN, model) {
@Override
protected Boolean modelValue() {
return getModel().isAutoCheckChildNodes();
}
});
putJsonProperty(new JsonProperty<ITree>(ITree.PROP_SCROLL_TO_SELECTION, model) {
@Override
protected Boolean modelValue() {
return getModel().isScrollToSelection();
}
});
putJsonProperty(new JsonProperty<ITree>(ITree.PROP_DROP_TYPE, model) {
@Override
protected Integer modelValue() {
return getModel().getDropType();
}
});
putJsonProperty(new JsonProperty<ITree>(ITree.PROP_DROP_MAXIMUM_SIZE, model) {
@Override
protected Long modelValue() {
return getModel().getDropMaximumSize();
}
});
putJsonProperty(new JsonAdapterProperty<ITree>(ITree.PROP_KEY_STROKES, model, getUiSession()) {
@Override
protected JsonAdapterPropertyConfig createConfig() {
return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<IAction>()).build();
}
@Override
protected List<IKeyStroke> modelValue() {
return getModel().getKeyStrokes();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_DISPLAY_STYLE, model) {
@Override
protected String modelValue() {
return getModel().getDisplayStyle();
}
});
putJsonProperty(new JsonProperty<TREE>(ITree.PROP_TOGGLE_BREADCRUMB_STYLE_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isToggleBreadcrumbStyleEnabled();
}
});
}
Aggregations