use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class SessionDiagramEditorScreen method openDiagram.
private void openDiagram(Diagram diagram, Command callback) {
final Metadata metadata = diagram.getMetadata();
sessionManager.getSessionFactory(metadata, ClientFullSession.class).newSession(metadata, s -> {
final AbstractClientFullSession session = (AbstractClientFullSession) s;
presenter = sessionPresenterFactory.newPresenterEditor();
screenPanelView.setWidget(presenter.getView());
presenter.withToolbar(true).withPalette(true).displayNotifications(type -> true).open(diagram, session, new ScreenPresenterCallback(callback));
});
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class SessionDiagramEditorScreen method onStartup.
@OnStartup
public void onStartup(final PlaceRequest placeRequest) {
this.placeRequest = placeRequest;
this.menu = makeMenuBar();
final String name = placeRequest.getParameter("name", "");
final boolean isCreate = name == null || name.trim().length() == 0;
final Command callback = () -> {
final Diagram diagram = getDiagram();
if (null != diagram) {
// Update screen title.
updateTitle(diagram.getMetadata().getTitle());
}
};
if (isCreate) {
final String defSetId = placeRequest.getParameter("defSetId", "");
final String shapeSetd = placeRequest.getParameter("shapeSetId", "");
final String title = placeRequest.getParameter("title", "");
// Create a new diagram.
newDiagram(UUID.uuid(), title, defSetId, shapeSetd, callback);
} else {
// Load an existing diagram.
load(name, callback);
}
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class WorkbenchConfigurationMenu method setup.
@PostConstruct
public void setup() {
final Collection<SyncBeanDef<WorkbenchConfigurationHandler>> handlerBeans = iocBeanManager.lookupBeans(WorkbenchConfigurationHandler.class);
if (handlerBeans.size() > 0) {
for (SyncBeanDef<WorkbenchConfigurationHandler> handlerBean : handlerBeans) {
final WorkbenchConfigurationHandler activeHandler = handlerBean.getInstance();
final String description = activeHandler.getDescription();
final MenuItem menuItem = MenuFactory.newSimpleItem(description).respondsWith(new Command() {
@Override
public void execute() {
newResourcePresenter.show(activeHandler);
}
}).endMenu().build().getItems().get(0);
workbenchConfigurationHandler.put(activeHandler, menuItem);
items.add(menuItem);
}
}
Collections.sort(items, new Comparator<MenuItem>() {
@Override
public int compare(final MenuItem o1, final MenuItem o2) {
return o1.getCaption().compareToIgnoreCase(o2.getCaption());
}
});
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ExplorerPresenterTest method testOnStartUpNoInit.
@Test
public void testOnStartUpNoInit() throws Exception {
when(activeOptions.isBusinessViewActive()).thenReturn(true);
PlaceRequest placeRequest = mock(PlaceRequest.class);
when(placeRequest.getParameter(eq("init_path"), anyString())).thenReturn("something");
ArgumentCaptor<Command> argumentCaptor = ArgumentCaptor.forClass(Command.class);
explorer.onStartup(placeRequest);
verify(activeOptions).init(eq(placeRequest), argumentCaptor.capture());
argumentCaptor.getValue().execute();
verify(technicalViewPresenter).setVisible(false);
verify(businessViewPresenter).setVisible(true);
verify(technicalViewPresenter).initialiseViewForActiveContext("something");
verify(businessViewPresenter).initialiseViewForActiveContext("something");
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ExplorerPresenterTest method testOnStartUpNoInitPath.
@Test
public void testOnStartUpNoInitPath() throws Exception {
when(activeOptions.isTechnicalViewActive()).thenReturn(true);
PlaceRequest placeRequest = mock(PlaceRequest.class);
ArgumentCaptor<Command> argumentCaptor = ArgumentCaptor.forClass(Command.class);
explorer.onStartup(placeRequest);
verify(activeOptions).init(eq(placeRequest), argumentCaptor.capture());
argumentCaptor.getValue().execute();
verify(technicalViewPresenter).setVisible(true);
verify(businessViewPresenter).setVisible(false);
verify(technicalViewPresenter).initialiseViewForActiveContext(context);
verify(businessViewPresenter).initialiseViewForActiveContext(context);
}
Aggregations