Search in sources :

Example 1 with GuidedDecisionTablePresenter

use of org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenter method init.

@PostConstruct
public void init() {
    super.init();
    // Selecting a Decision Table in the document selector fires a selection event
    registeredDocumentsMenuBuilder.setActivateDocumentCommand((document) -> {
        final GuidedDecisionTablePresenter dtPresenter = ((GuidedDecisionTablePresenter) document);
        decisionTableSelectedEvent.fire(new DecisionTableSelectedEvent(dtPresenter));
    });
    // Removing a Decision Table from the document selector is equivalent to closing the editor
    registeredDocumentsMenuBuilder.setRemoveDocumentCommand((document) -> {
        final GuidedDecisionTablePresenter dtPresenter = ((GuidedDecisionTablePresenter) document);
        if (mayClose(dtPresenter)) {
            removeDocument(dtPresenter);
        }
    });
    registeredDocumentsMenuBuilder.setNewDocumentCommand(this::onNewDocument);
}
Also used : GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) DecisionTableSelectedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent) PostConstruct(javax.annotation.PostConstruct)

Example 2 with GuidedDecisionTablePresenter

use of org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkInitRemoveDocumentFromRegisteredDocumentMenu.

@Test
public void checkInitRemoveDocumentFromRegisteredDocumentMenu() {
    verify(registeredDocumentsMenuBuilder, times(1)).setRemoveDocumentCommand(removeDocumentCommandCaptor.capture());
    final GuidedDecisionTablePresenter dtPresenter = mock(GuidedDecisionTablePresenter.class);
    doReturn(true).when(presenter).mayClose(eq(dtPresenter));
    doNothing().when(presenter).removeDocument(any(GuidedDecisionTablePresenter.class));
    final ParameterizedCommand<KieDocument> removeDocumentCommand = removeDocumentCommandCaptor.getValue();
    assertNotNull(removeDocumentCommand);
    removeDocumentCommand.execute(dtPresenter);
    verify(presenter, times(1)).mayClose(eq(dtPresenter));
    verify(presenter, times(1)).removeDocument(eq(dtPresenter));
}
Also used : KieDocument(org.kie.workbench.common.widgets.metadata.client.KieDocument) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) Test(org.junit.Test)

Example 3 with GuidedDecisionTablePresenter

use of org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter in project drools-wb by kiegroup.

the class GuidedDecisionTableGraphEditorPresenterTest method checkInitActivateDocumentFromRegisteredDocumentMenu.

@Test
public void checkInitActivateDocumentFromRegisteredDocumentMenu() {
    verify(registeredDocumentsMenuBuilder, times(1)).setActivateDocumentCommand(activateDocumentCommandCaptor.capture());
    final GuidedDecisionTablePresenter dtPresenter = mock(GuidedDecisionTablePresenter.class);
    final ParameterizedCommand<KieDocument> activeDocumentCommand = activateDocumentCommandCaptor.getValue();
    assertNotNull(activeDocumentCommand);
    activeDocumentCommand.execute(dtPresenter);
    verify(decisionTableSelectedEvent, times(1)).fire(dtSelectedEventCaptor.capture());
    assertNotNull(dtSelectedEventCaptor.getValue());
    assertEquals(dtPresenter, dtSelectedEventCaptor.getValue().getPresenter().get());
}
Also used : KieDocument(org.kie.workbench.common.widgets.metadata.client.KieDocument) GuidedDecisionTablePresenter(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter) Test(org.junit.Test)

Aggregations

GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)3 Test (org.junit.Test)2 KieDocument (org.kie.workbench.common.widgets.metadata.client.KieDocument)2 PostConstruct (javax.annotation.PostConstruct)1 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)1