Search in sources :

Example 1 with GuidedDecisionTableUiModel

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");
        }
    });
}
Also used : ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableModellerView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) EventBus(com.google.gwt.event.shared.EventBus) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GridWidgetCellFactoryImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.impl.GridWidgetCellFactoryImpl) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) MetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer.MetaData) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Iterator(java.util.Iterator) BaseColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter) Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) DependentEnumsUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.DependentEnumsUtilities) CellUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.CellUtilities) GridLayer(org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer) GridWidgetCellFactory(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.GridWidgetCellFactory) RuleNameColumn(org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Before(org.junit.Before)

Example 2 with GuidedDecisionTableUiModel

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);
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Before(org.junit.Before)

Example 3 with GuidedDecisionTableUiModel

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;
        }
    };
}
Also used : GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) DecisionTableSelectionsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn)

Example 4 with GuidedDecisionTableUiModel

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);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Before(org.junit.Before)

Example 5 with GuidedDecisionTableUiModel

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();
}
Also used : DefaultClipboard(org.drools.workbench.screens.guided.dtable.client.editor.clipboard.impl.DefaultClipboard) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Before(org.junit.Before)

Aggregations

GuidedDecisionTableUiModel (org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel)8 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)7 Before (org.junit.Before)7 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)5 DefaultClipboard (org.drools.workbench.screens.guided.dtable.client.editor.clipboard.impl.DefaultClipboard)3 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)3 Annotation (java.lang.annotation.Annotation)2 MenuItemFactory (org.uberfire.ext.widgets.common.client.menu.MenuItemFactory)2 BaseGridColumn (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn)2 EventBus (com.google.gwt.event.shared.EventBus)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 Iterator (java.util.Iterator)1 BRLRuleModel (org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)1 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)1 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)1 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)1 GuidedDecisionTableModellerView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView)1 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)1 DecisionTableSelectionsChangedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent)1 GridWidgetCellFactory (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.GridWidgetCellFactory)1