Search in sources :

Example 56 with Command

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));
    });
}
Also used : OnLostFocus(org.uberfire.lifecycle.OnLostFocus) ValidationUtils(org.kie.workbench.common.stunner.core.validation.impl.ValidationUtils) UUID(org.kie.workbench.common.stunner.core.util.UUID) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) PathFactory(org.uberfire.backend.vfs.PathFactory) Observes(javax.enterprise.event.Observes) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) IsWidget(com.google.gwt.user.client.ui.IsWidget) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) WorkbenchScreen(org.uberfire.client.annotations.WorkbenchScreen) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) Collection(java.util.Collection) Violation(org.kie.workbench.common.stunner.core.validation.Violation) Menus(org.uberfire.workbench.model.menu.Menus) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Logger(java.util.logging.Logger) ClientFactoryService(org.kie.workbench.common.stunner.core.client.service.ClientFactoryService) PlaceRequest(org.uberfire.mvp.PlaceRequest) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) WorkbenchMenu(org.uberfire.client.annotations.WorkbenchMenu) LogConfiguration(com.google.gwt.logging.client.LogConfiguration) EditorToolbar(org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar) OnOpen(org.uberfire.lifecycle.OnOpen) MenuDevCommandsBuilder(org.kie.workbench.common.stunner.client.widgets.menu.dev.MenuDevCommandsBuilder) PostConstruct(javax.annotation.PostConstruct) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) DiagramEditor(org.kie.workbench.common.stunner.core.client.annotation.DiagramEditor) OnFocus(org.uberfire.lifecycle.OnFocus) ScreenPanelView(org.kie.workbench.common.stunner.client.widgets.views.session.ScreenPanelView) ScreenErrorView(org.kie.workbench.common.stunner.client.widgets.views.session.ScreenErrorView) Level(java.util.logging.Level) Inject(javax.inject.Inject) MenuFactory(org.uberfire.workbench.model.menu.MenuFactory) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) WorkbenchPartTitle(org.uberfire.client.annotations.WorkbenchPartTitle) SessionPresenterFactory(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenterFactory) WorkbenchContextId(org.uberfire.client.annotations.WorkbenchContextId) AbstractClientReadOnlySession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientReadOnlySession) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) OnStartup(org.uberfire.lifecycle.OnStartup) Command(org.uberfire.mvp.Command) FINE(java.util.logging.Level.FINE) Event(javax.enterprise.event.Event) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Dependent(javax.enterprise.context.Dependent) WorkbenchPartView(org.uberfire.client.annotations.WorkbenchPartView) OnClose(org.uberfire.lifecycle.OnClose) BusyPopup(org.uberfire.ext.widgets.common.client.common.BusyPopup) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession)

Example 57 with Command

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);
    }
}
Also used : ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) Command(org.uberfire.mvp.Command) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) OnStartup(org.uberfire.lifecycle.OnStartup)

Example 58 with Command

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());
        }
    });
}
Also used : Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) SyncBeanDef(org.jboss.errai.ioc.client.container.SyncBeanDef) PostConstruct(javax.annotation.PostConstruct)

Example 59 with Command

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");
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 60 with Command

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);
}
Also used : PlaceRequest(org.uberfire.mvp.PlaceRequest) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Aggregations

Command (org.uberfire.mvp.Command)117 Test (org.junit.Test)66 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)15 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)11 Group (com.ait.lienzo.client.core.shape.Group)9 YesNoCancelPopup (org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)9 Before (org.junit.Before)8 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)7 Path (org.uberfire.backend.vfs.Path)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 PlaceRequest (org.uberfire.mvp.PlaceRequest)5 MenuItem (org.uberfire.workbench.model.menu.MenuItem)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)4 Inject (javax.inject.Inject)4 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 DeleteHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand)4 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)4 SetHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand)4