use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.
the class GuidedDecisionTableGraphEditorPresenterTest method checkOnDecisionTableSelected.
private void checkOnDecisionTableSelected(final ParameterizedCommand<PlaceRequest> setup, final Command assertion) {
final ObservablePath dtGraphPath = mock(ObservablePath.class);
final PlaceRequest dtGraphPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorGraphContent dtGraphContent = makeDecisionTableGraphContent();
final ObservablePath dtPath = mock(ObservablePath.class);
final PlaceRequest dtPlaceRequest = mock(PlaceRequest.class);
final GuidedDecisionTableEditorContent dtContent = makeDecisionTableContent(0);
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable(dtPath, dtPath, dtPlaceRequest, dtContent);
final GuidedDecisionTableGraphEntry dtGraphEntry = new GuidedDecisionTableGraphEntry(dtPath, dtPath);
dtGraphContent.getModel().getEntries().add(dtGraphEntry);
when(dtPath.toURI()).thenReturn("dtPath");
when(dtGraphPath.toURI()).thenReturn("dtGraphPath");
when(dtGraphPath.getFileName()).thenReturn("filename");
when(dtService.loadContent(eq(dtPath))).thenReturn(dtContent);
when(dtGraphService.loadContent(eq(dtGraphPath))).thenReturn(dtGraphContent);
when(versionRecordManager.getCurrentPath()).thenReturn(dtGraphPath);
when(modeller.addDecisionTable(any(ObservablePath.class), any(PlaceRequest.class), any(GuidedDecisionTableEditorContent.class), any(Boolean.class), any(Double.class), any(Double.class))).thenReturn(dtPresenter);
when(modeller.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
setup.execute(dtGraphPlaceRequest);
presenter.onStartup(dtGraphPath, dtGraphPlaceRequest);
final DecisionTableSelectedEvent event = new DecisionTableSelectedEvent(dtPresenter);
presenter.onDecisionTableSelected(event);
assertion.execute();
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.
the class EditMenuBuilderTest method testOnDecisionTableSelectedEventWithNonOtherwiseColumnSelectedAndItHasEditableColumnsAndItDoesNotHaveEditableColumns.
@Test
public void testOnDecisionTableSelectedEventWithNonOtherwiseColumnSelectedAndItHasEditableColumnsAndItDoesNotHaveEditableColumns() {
when(dtPresenter.hasEditableColumns()).thenReturn(false);
model.getMetadataCols().add(new MetadataCol52());
model.getData().add(makeDTCellValue52());
uiModel.selectCell(0, 2);
builder.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));
assertTrue(builder.miCut.getMenuItem().isEnabled());
assertTrue(builder.miCopy.getMenuItem().isEnabled());
assertFalse(builder.miPaste.getMenuItem().isEnabled());
assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled());
assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled());
assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled());
assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled());
verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null));
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.
the class EditMenuBuilderTest method testOnDecisionTableSelectedEventWithSelectionsWithClipboardPopulated.
@Test
public void testOnDecisionTableSelectedEventWithSelectionsWithClipboardPopulated() {
model.getMetadataCols().add(new MetadataCol52());
model.getData().add(makeDTCellValue52());
uiModel.selectCell(0, 2);
clipboard.setData(makeClipboardHashSetData());
builder.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));
assertTrue(builder.miCut.getMenuItem().isEnabled());
assertTrue(builder.miCopy.getMenuItem().isEnabled());
assertTrue(builder.miPaste.getMenuItem().isEnabled());
assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled());
assertTrue(builder.miDeleteSelectedColumns.getMenuItem().isEnabled());
assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled());
assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled());
verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null));
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.
the class EditMenuBuilderTest method testOnDecisionTableSelectedEventReadOnly.
@Test
public void testOnDecisionTableSelectedEventReadOnly() {
dtPresenter.getAccess().setReadOnly(true);
builder.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));
assertFalse(builder.miCut.getMenuItem().isEnabled());
assertFalse(builder.miCopy.getMenuItem().isEnabled());
assertFalse(builder.miPaste.getMenuItem().isEnabled());
assertFalse(builder.miDeleteSelectedCells.getMenuItem().isEnabled());
assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled());
assertFalse(builder.miDeleteSelectedRows.getMenuItem().isEnabled());
assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled());
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent in project drools-wb by kiegroup.
the class EditMenuBuilderTest method testOnDecisionTableSelectedEventWithNoSelections.
@Test
public void testOnDecisionTableSelectedEventWithNoSelections() {
builder.onDecisionTableSelectedEvent(new DecisionTableSelectedEvent(dtPresenter));
assertFalse(builder.miCut.getMenuItem().isEnabled());
assertFalse(builder.miCopy.getMenuItem().isEnabled());
assertFalse(builder.miPaste.getMenuItem().isEnabled());
assertFalse(builder.miDeleteSelectedCells.getMenuItem().isEnabled());
assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled());
assertFalse(builder.miDeleteSelectedRows.getMenuItem().isEnabled());
assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled());
}
Aggregations