Search in sources :

Example 1 with IMenuType

use of org.eclipse.scout.rt.client.ui.action.menu.IMenuType in project scout.rt by eclipse.

the class JsonMenu method initJsonProperties.

@Override
protected void initJsonProperties(MENU model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<MENU>(PROP_SEPARATOR, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isSeparator();
        }
    });
    putJsonProperty(new JsonProperty<MENU>(PROP_OUTLINE_MENU_WRAPPER, model) {

        @Override
        protected Boolean modelValue() {
            return getModel() instanceof OutlineMenuWrapper;
        }
    });
    putJsonProperty(new JsonProperty<MENU>(IMenu.PROP_MENU_TYPES, model) {

        @Override
        protected Set<IMenuType> modelValue() {
            return getModel().getMenuTypes();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            Set<String> menuTypes = new HashSet<>();
            for (IMenuType type : getModel().getMenuTypes()) {
                String prefix = type.getClass().getSimpleName().replace("MenuType", "");
                menuTypes.add(prefix + "." + type.toString());
            }
            return new JSONArray(menuTypes);
        }
    });
    putJsonProperty(new JsonProperty<MENU>(IMenu.PROP_PREVENT_DOUBLE_CLICK, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isPreventDoubleClick();
        }
    });
}
Also used : OutlineMenuWrapper(org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper) HashSet(java.util.HashSet) Set(java.util.Set) IMenuType(org.eclipse.scout.rt.client.ui.action.menu.IMenuType) JSONArray(org.json.JSONArray)

Example 2 with IMenuType

use of org.eclipse.scout.rt.client.ui.action.menu.IMenuType in project scout.rt by eclipse.

the class OutlineMenuWrapper method mapMenuTypes.

protected Set<IMenuType> mapMenuTypes(IMenu menu, IMenuTypeMapper mapper) {
    Set<IMenuType> originalTypes = menu.getMenuTypes();
    Set<IMenuType> mappedTypes = new HashSet<IMenuType>(originalTypes.size());
    for (IMenuType menuType : originalTypes) {
        mappedTypes.add(mapper.map(menuType));
    }
    return mappedTypes;
}
Also used : IMenuType(org.eclipse.scout.rt.client.ui.action.menu.IMenuType) HashSet(java.util.HashSet)

Example 3 with IMenuType

use of org.eclipse.scout.rt.client.ui.action.menu.IMenuType in project scout.rt by eclipse.

the class JsonValueField method attachModel.

@Override
protected void attachModel() {
    super.attachModel();
    if (m_contextMenuListener != null) {
        throw new IllegalStateException();
    }
    m_contextMenuListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (IMenu.PROP_VISIBLE.equals(evt.getPropertyName())) {
                handleModelContextMenuVisibleChanged((Boolean) evt.getNewValue());
            } else if (IContextMenu.PROP_CURRENT_MENU_TYPES.equals(evt.getPropertyName())) {
                @SuppressWarnings("unchecked") Set<? extends IMenuType> newValue = (Set<? extends IMenuType>) evt.getNewValue();
                handleModelContextMenuCurrentMenuTypesChanged(newValue);
            }
        }
    };
    getModel().getContextMenu().addPropertyChangeListener(m_contextMenuListener);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) Set(java.util.Set) IMenuType(org.eclipse.scout.rt.client.ui.action.menu.IMenuType) PropertyChangeListener(java.beans.PropertyChangeListener)

Aggregations

IMenuType (org.eclipse.scout.rt.client.ui.action.menu.IMenuType)3 HashSet (java.util.HashSet)2 Set (java.util.Set)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 OutlineMenuWrapper (org.eclipse.scout.rt.client.ui.desktop.outline.OutlineMenuWrapper)1 JSONArray (org.json.JSONArray)1