@Nonnull public UserActionSupport8 withRoles (final @Nonnull Object ... rolesOrFactories) { return new UserActionSupport8(callback, rolesOrFactories); }
/******************************************************************************************************************* * * Factory method for the PresentationModel of SimpleEntity instances. * * It aggregates a few extra roles into the PresentationModel that are used by the control, such as callbacks * for action associated to the context menu. Also a Displayable role is usually injected to control the rendering * of entities. * ******************************************************************************************************************/ @Nonnull private PresentationModel pmFor (final @Nonnull SimpleEntity entity) { final Selectable selectable = () -> onSelected(entity); final UserAction action1 = new UserActionSupport8(() -> action1(entity), new DefaultDisplayable("Action 1")); final UserAction action2 = new UserActionSupport8(() -> action2(entity), new DefaultDisplayable("Action 2")); final UserAction action3 = new UserActionSupport8(() -> action3(entity), new DefaultDisplayable("Action 3")); return new DefaultPresentationModel(entity, new DefaultDisplayable("Item #" + entity.getName()), selectable, UserActionProvider.of(action1, action2, action3)); }
/******************************************************************************************************************* * * Factory method for the PresentationModel of SimpleDciEntity instances. * ******************************************************************************************************************/ @Nonnull private PresentationModel pmFor (final @Nonnull SimpleDciEntity entity) { // FIXME: column names final Aggregate aggregate = AggregatePresentationModelBuilder.newInstance() .with("C1", new DefaultDisplayable(entity.getName())) .with("C2", new DefaultDisplayable("" + entity.getAttribute1())) .with("C3", new DefaultDisplayable("" + entity.getAttribute2())) .create(); final Selectable selectable = () -> onSelected(entity); final UserAction action1 = new UserActionSupport8(() -> action1(entity), new DefaultDisplayable("Action 1")); final UserAction action2 = new UserActionSupport8(() -> action2(entity), new DefaultDisplayable("Action 2")); final UserAction action3 = new UserActionSupport8(() -> action3(entity), new DefaultDisplayable("Action 3")); // No explicit Displayable here, as the one inside SimpleDciEntity is used. return new DefaultPresentationModel(entity, aggregate, selectable, UserActionProvider.of(action1, action2, action3)); }