use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.
the class AbstractImageField method initConfig.
@Override
protected void initConfig() {
m_uiFacade = BEANS.get(ModelContextProxy.class).newProxy(new P_UIFacade(), ModelContext.copyCurrent());
super.initConfig();
setImageTransform(new AffineTransformSpec());
setAutoFit(getConfiguredAutoFit());
setImageId(getConfiguredImageId());
setPanDelta(getConfiguredPanDelta());
setRotateDelta(getConfiguredRotateDelta());
setZoomDelta(getConfiguredZoomDelta());
setDragType(getConfiguredDragType());
setDropType(getConfiguredDropType());
setDropMaximumSize(getConfiguredDropMaximumSize());
setScrollBarEnabled(getConfiguredScrollBarEnabled());
// menus
List<Class<? extends IMenu>> declaredMenus = getDeclaredMenus();
List<IMenu> contributedMenus = m_contributionHolder.getContributionsByClass(IMenu.class);
OrderedCollection<IMenu> menus = new OrderedCollection<IMenu>();
for (Class<? extends IMenu> menuClazz : declaredMenus) {
menus.addOrdered(ConfigurationUtility.newInnerInstance(this, menuClazz));
}
menus.addAllOrdered(contributedMenus);
injectMenusInternal(menus);
new MoveActionNodesHandler<IMenu>(menus).moveModelObjects();
m_contextMenu = new FormFieldContextMenu<IImageField>(this, menus.getOrderedList());
m_contextMenu.setContainerInternal(this);
}
use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.
the class JsonMenuTest method testInitialVSPropertyChange.
@Test
public void testInitialVSPropertyChange() throws Exception {
Menu menu = new Menu();
menu.setText("foo");
// when adapter has been created we have the complete adapter in the adapter-data section of the JSON response
JsonMenu<IMenu> menuAdapter = m_uiSession.getOrCreateJsonAdapter(menu, null);
JSONObject json = m_uiSession.currentJsonResponse().toJson();
JSONObject adpaterData = JsonTestUtility.getAdapterData(json, menuAdapter.getId());
assertEquals("foo", adpaterData.getString("text"));
// Simulate processRequest, which resets the current JSON response. Otherwise the property change event
// would be ignored because a new adapter exists in the current JSON response.
JsonTestUtility.endRequest(m_uiSession);
// when a property change occurs we assert an event is created for the adapter to update, containing only the changed property
menu.setText("bar");
json = m_uiSession.currentJsonResponse().toJson();
JSONObject event = JsonTestUtility.getPropertyChange(json, 0);
assertEquals("bar", event.getString("text"));
}
use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.
the class MoveActionNodeTest method testMoveRootMenuToSubMenu.
@Test
public void testMoveRootMenuToSubMenu() {
BEANS.get(IExtensionRegistry.class).registerMove(Top1Menu.class, 15d, Top2Menu.class);
TestMenus menus = new TestMenus();
List<IMenu> topLevelMenu = menus.getMenus();
assertMenus(topLevelMenu, Top2Menu.class);
assertMenus(topLevelMenu.get(0).getChildActions(), Sub1Top2Menu.class, Top1Menu.class, Sub2Top2Menu.class);
assertMenus(topLevelMenu.get(0).getChildActions().get(1).getChildActions(), Sub1Top1Menu.class, Sub2Top1Menu.class);
assertMenus(topLevelMenu.get(0).getChildActions().get(1).getChildActions().get(0).getChildActions(), Sub1Sub1Top1Menu.class);
}
use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.
the class MoveActionNodeTest method doTestMoveSubMenuToRoot.
protected void doTestMoveSubMenuToRoot() {
TestMenus menus = new TestMenus();
List<IMenu> topLevelMenu = menus.getMenus();
assertMenus(topLevelMenu, Top1Menu.class, Sub1Top1Menu.class, Top2Menu.class);
assertMenus(topLevelMenu.get(0).getChildActions(), Sub2Top1Menu.class);
assertMenus(topLevelMenu.get(1).getChildActions(), Sub1Sub1Top1Menu.class);
assertMenus(topLevelMenu.get(2).getChildActions(), Sub1Top2Menu.class, Sub2Top2Menu.class);
}
use of org.eclipse.scout.rt.client.ui.action.menu.IMenu in project scout.rt by eclipse.
the class JsonStatusMenuMapping method initJsonProperties.
@Override
protected void initJsonProperties(T model) {
super.initJsonProperties(model);
putJsonProperty(new JsonProperty<T>(IStatusMenuMapping.PROP_CODES, model) {
@Override
protected List<Integer> modelValue() {
return getModel().getCodes();
}
@Override
@SuppressWarnings("unchecked")
public Object prepareValueForToJson(Object value) {
// Do NOT remove the cast! It is required to use the correct constructor.
return new JSONArray((List<Integer>) value);
}
});
putJsonProperty(new JsonProperty<T>(IStatusMenuMapping.PROP_SEVERITIES, model) {
@Override
protected List<Integer> modelValue() {
return getModel().getSeverities();
}
@Override
@SuppressWarnings("unchecked")
public Object prepareValueForToJson(Object value) {
// Do NOT remove the cast! It is required to use the correct constructor.
return new JSONArray((List<Integer>) value);
}
});
putJsonProperty(new JsonProperty<T>(IStatusMenuMapping.PROP_MENU, model) {
@Override
protected IMenu modelValue() {
return getModel().getMenu();
}
@Override
public Object prepareValueForToJson(Object value) {
// The menu is managed by the parent -> don't create a new adapter but use the one from the parent instead
IJsonAdapter adapter = getParent().getAdapter((IMenu) value, new DisplayableActionFilter<>());
if (adapter == null) {
return null;
}
return adapter.getId();
}
});
}
Aggregations