use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel in project drools-wb by kiegroup.
the class BaseSynchronizerTest method setup.
@Before
public void setup() {
// Setup model related classes
model = new GuidedDecisionTable52();
uiModel = new GuidedDecisionTableUiModel(modelSynchronizer);
incrementalDataModelServiceCaller = new CallerMock<>(incrementalDataModelService);
final BRLRuleModel rm = new BRLRuleModel(model);
final CellUtilities cellUtilities = new CellUtilities();
final ColumnUtilities columnUtilities = new ColumnUtilities(model, oracle);
final DependentEnumsUtilities enumsUtilities = new DependentEnumsUtilities(model, oracle);
final GridWidgetCellFactory gridWidgetCellFactory = new GridWidgetCellFactoryImpl();
// Setup mocks
final GuidedDecisionTableModellerView.Presenter modellerPresenter = mock(GuidedDecisionTableModellerView.Presenter.class);
final GuidedDecisionTableModellerView modellerView = mock(GuidedDecisionTableModellerView.class);
final GridLayer gridLayer = mock(GridLayer.class);
final AbsolutePanel domElementContainer = mock(AbsolutePanel.class);
final GuidedDecisionTableView.Presenter dtablePresenter = mock(GuidedDecisionTableView.Presenter.class);
final EventBus eventBus = mock(EventBus.class);
when(dtablePresenter.getModellerPresenter()).thenReturn(modellerPresenter);
when(modellerPresenter.getView()).thenReturn(modellerView);
when(modellerView.getGridLayerView()).thenReturn(gridLayer);
when(gridLayer.getDomElementContainer()).thenReturn(domElementContainer);
when(domElementContainer.iterator()).thenReturn(mock(Iterator.class));
// Setup column converters
final List<BaseColumnConverter> converters = getConverters();
gridWidgetColumnFactory.setConverters(converters);
gridWidgetColumnFactory.initialise(model, oracle, columnUtilities, dtablePresenter);
// Setup synchronizers
final List<Synchronizer<? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData>> synchronizers = getSynchronizers();
modelSynchronizer.setSynchronizers(synchronizers);
modelSynchronizer.initialise(model, uiModel, cellUtilities, columnUtilities, enumsUtilities, gridWidgetCellFactory, gridWidgetColumnFactory, view, rm, eventBus, editable);
// Dummy columns for Row number, rule name and Description
uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new RowNumberCol52(), readOnly, view));
uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new RuleNameColumn(), readOnly, view));
uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new DescriptionCol52(), readOnly, view));
ApplicationPreferences.setUp(new HashMap<String, String>() {
{
put(ApplicationPreferences.DATE_FORMAT, "dd-MM-yyyy");
}
});
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel in project drools-wb by kiegroup.
the class GuidedDecisionTableRendererTest method setup.
@Before
public void setup() {
this.uiModel = new GuidedDecisionTableUiModel(synchronizer);
this.uiColumn = new RowNumberColumn();
this.uiModel.appendColumn(uiColumn);
this.uiModel.appendRow(new BaseGridRow());
this.renderer = spy(new GuidedDecisionTableRenderer(uiModel, new GuidedDecisionTable52()));
when(renderingInformation.getVisibleRowOffsets()).thenReturn(Collections.singletonList(20.0));
when(renderingInformation.getAllRowHeights()).thenReturn(Collections.singletonList(20.0));
when(context.getBlockColumns()).thenReturn(Collections.singletonList(uiColumn));
when(renderingInformation.getBodyBlockInformation()).thenReturn(bodyBlockInformation);
when(bodyBlockInformation.getColumns()).thenReturn(Collections.singletonList(uiColumn));
when(renderingInformation.getFloatingBlockInformation()).thenReturn(floatingBlockInformation);
when(floatingBlockInformation.getColumns()).thenReturn(Collections.emptyList());
when(context.getRenderer()).thenReturn(renderer);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method makeUiModel.
// Instantiate UiModel overriding cell selection to inform MenuItems about changes to selected cells.
GuidedDecisionTableUiModel makeUiModel() {
return new GuidedDecisionTableUiModel(synchronizer) {
@Override
public Range selectCell(final int rowIndex, final int columnIndex) {
final Range rows = super.selectCell(rowIndex, columnIndex);
decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
lockManager.acquireLock();
return rows;
}
@Override
public Range selectCells(final int rowIndex, final int columnIndex, final int width, final int height) {
final Range rows = super.selectCells(rowIndex, columnIndex, width, height);
decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
lockManager.acquireLock();
return rows;
}
@Override
public boolean isRowDraggingEnabled() {
return access.isEditable();
}
@Override
public boolean isColumnDraggingEnabled() {
return access.isEditable();
}
@Override
public Range deleteCell(int rowIndex, int columnIndex) {
Range cellRange = super.deleteCell(rowIndex, columnIndex);
decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
return cellRange;
}
@Override
public void deleteColumn(GridColumn<?> column) {
super.deleteColumn(column);
decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
}
@Override
public Range deleteRow(int rowIndex) {
Range rowRange = super.deleteRow(rowIndex);
decisionTableSelectionsChangedEvent.fire(new DecisionTableSelectionsChangedEvent(GuidedDecisionTablePresenter.this));
return rowRange;
}
};
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel in project drools-wb by kiegroup.
the class GuidedDecisionTableViewImplTest method setup.
@Before
public void setup() {
when(renderer.getTheme()).thenReturn(theme);
when(theme.getBodyGridLine()).thenReturn(border);
when(theme.getHeaderText()).thenReturn(caption);
when(theme.getBaseRectangle(any(GuidedDecisionTableTheme.ModelColumnType.class))).thenReturn(rectangle);
GwtMockito.useProviderForType(Group.class, clazz -> container);
this.uiModel = new GuidedDecisionTableUiModel(modelSynchronizer);
this.model = new GuidedDecisionTable52();
this.view = new TestGuidedDecisionTableViewImpl(uiModel, renderer, presenter, model, notificationEvent) {
};
this.allColumns = Arrays.asList(uiRowNumberColumn, uiDescriptionColumn, uiColumn1, uiColumn2);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel in project drools-wb by kiegroup.
the class CellContextMenuTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
model = new GuidedDecisionTable52();
uiModel = new GuidedDecisionTableUiModel(mock(ModelSynchronizer.class));
clipboard = new DefaultClipboard();
when(dtPresenter.getView()).thenReturn(dtPresenterView);
when(dtPresenter.getAccess()).thenReturn(access);
when(dtPresenterView.getModel()).thenReturn(uiModel);
uiModel.appendColumn(new BaseGridColumn<String>(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
uiModel.appendColumn(new BaseGridColumn<String>(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
uiModel.appendColumn(new BaseGridColumn<String>(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
uiModel.appendRow(new BaseGridRow());
menu = spy(new CellContextMenu(view, clipboard));
menu.setup();
}
Aggregations