Search in sources :

Example 1 with ColumnDefinitionBuilder

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

the class ColumnHeaderPopOverImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.model = new GuidedDecisionTable52();
    this.model.getExpandedColumns().get(0).setHeader("#");
    this.model.getExpandedColumns().get(1).setHeader("description");
    this.uiColumn1 = new RowNumberColumn();
    this.uiColumn2 = new BaseGridColumn<>(new BaseHeaderMetaData("description"), columnRenderer, 100.0);
    this.uiModel = new BaseGridData() {

        {
            setHeaderRowCount(2);
        }
    };
    uiModel.appendColumn(uiColumn1);
    uiModel.appendColumn(uiColumn2);
    serviceCaller = new CallerMock<>(service);
    when(service.toSource(any(Path.class), any(GuidedDecisionTable52.class))).thenReturn("source");
    final Instance<ColumnDefinitionBuilder> buildersInstance = makeBuildersInstance();
    final ColumnDefinitionFactory columnDefinitionFactory = new ColumnDefinitionFactory(buildersInstance);
    when(renderer.getHeaderHeight()).thenReturn(64.0);
    when(renderer.getHeaderRowHeight()).thenReturn(32.0);
    when(dtPresenter.getView()).thenReturn(gridWidget);
    when(dtPresenter.getModel()).thenReturn(model);
    when(dtPresenter.getDataModelOracle()).thenReturn(dmo);
    when(modellerView.getGridLayerView()).thenReturn(gridLayer);
    when(gridLayer.getDomElementContainer()).thenReturn(domElementContainer);
    when(gridLayer.getVisibleBounds()).thenReturn(bounds);
    when(gridLayer.getViewport()).thenReturn(viewport);
    when(gridWidget.getModel()).thenReturn(uiModel);
    when(gridWidget.getViewport()).thenReturn(viewport);
    when(gridWidget.getRenderer()).thenReturn(renderer);
    when(gridWidget.getRendererHelper()).thenReturn(rendererHelper);
    when(gridWidget.getWidth()).thenReturn(150.0);
    when(gridWidget.getHeight()).thenReturn(64.0);
    when(gridWidget.getX()).thenReturn(50.0);
    when(gridWidget.getY()).thenReturn(50.0);
    when(domElementContainer.getAbsoluteLeft()).thenReturn(200);
    when(viewport.getTransform()).thenReturn(transform);
    when(rendererHelper.getColumnOffset(uiColumn1)).thenReturn(0.0);
    when(rendererHelper.getColumnOffset(uiColumn2)).thenReturn(uiColumn1.getWidth());
    final BaseGridRendererHelper.RenderingInformation ri = new BaseGridRendererHelper.RenderingInformation(bounds, uiModel.getColumns(), new BaseGridRendererHelper.RenderingBlockInformation(new ArrayList<GridColumn<?>>() {

        {
            add(uiColumn2);
        }
    }, 0.0, 0.0, 0.0, 100.0), new BaseGridRendererHelper.RenderingBlockInformation(new ArrayList<GridColumn<?>>() {

        {
            add(uiColumn1);
        }
    }, 25.0, 0.0, 0.0, 50.0), 0, 0, Collections.<Double>emptyList(), false, false, 0, 2, 0);
    when(rendererHelper.getRenderingInformation()).thenReturn(ri);
    final ColumnHeaderPopOver wrapped = new ColumnHeaderPopOverImpl(view, columnDefinitionFactory);
    this.popOver = spy(wrapped);
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) Path(org.uberfire.backend.vfs.Path) ColumnDefinitionBuilder(org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ColumnDefinitionBuilder) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ArrayList(java.util.ArrayList) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ColumnDefinitionFactory(org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ColumnDefinitionFactory) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper) Before(org.junit.Before)

Example 2 with ColumnDefinitionBuilder

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

the class ColumnHeaderPopOverImplTest method makeBuildersInstance.

private Instance<ColumnDefinitionBuilder> makeBuildersInstance() {
    final List<ColumnDefinitionBuilder> builders = new ArrayList<>();
    builders.add(new ConditionCol52DefinitionBuilder(serviceCaller));
    builders.add(new ColumnDefinitionBuilder() {

        @Override
        public Class getSupportedColumnType() {
            return RowNumberCol52.class;
        }

        @Override
        public void generateDefinition(final GuidedDecisionTableView.Presenter dtPresenter, final BaseColumn column, final Callback<String> afterGenerationCallback) {
            afterGenerationCallback.callback(column.getHeader());
        }
    });
    builders.add(new ColumnDefinitionBuilder() {

        @Override
        public Class getSupportedColumnType() {
            return DescriptionCol52.class;
        }

        @Override
        public void generateDefinition(final GuidedDecisionTableView.Presenter dtPresenter, final BaseColumn column, final Callback<String> afterGenerationCallback) {
            afterGenerationCallback.callback(column.getHeader());
        }
    });
    return new MockInstanceImpl<>(builders);
}
Also used : ColumnDefinitionBuilder(org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ColumnDefinitionBuilder) ArrayList(java.util.ArrayList) ConditionCol52DefinitionBuilder(org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ConditionCol52DefinitionBuilder) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)

Aggregations

ArrayList (java.util.ArrayList)2 ColumnDefinitionBuilder (org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ColumnDefinitionBuilder)2 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)1 ColumnDefinitionFactory (org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ColumnDefinitionFactory)1 ConditionCol52DefinitionBuilder (org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ConditionCol52DefinitionBuilder)1 Before (org.junit.Before)1 Path (org.uberfire.backend.vfs.Path)1 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)1 BaseHeaderMetaData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData)1 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)1 BaseGridRendererHelper (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)1