Search in sources :

Example 1 with BaseColumnConverter

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter in project drools-wb by kiegroup.

the class BaseSynchronizerTest method getConverters.

protected List<BaseColumnConverter> getConverters() {
    final List<BaseColumnConverter> converters = new ArrayList<BaseColumnConverter>();
    converters.add(new ActionInsertFactColumnConverter());
    converters.add(new ActionRetractFactColumnConverter());
    converters.add(new ActionSetFieldColumnConverter());
    converters.add(new ActionWorkItemExecuteColumnConverter());
    converters.add(new ActionWorkItemInsertFactColumnConverter());
    converters.add(new ActionWorkItemSetFieldColumnConverter());
    converters.add(new AttributeColumnConverter());
    converters.add(new BRLActionVariableColumnConverter());
    converters.add(new BRLConditionVariableColumnConverter());
    converters.add(new ConditionColumnConverter());
    converters.add(new DescriptionColumnConverter());
    converters.add(new LimitedEntryColumnConverter());
    converters.add(new MetaDataColumnConverter());
    converters.add(new RuleNameColumnConverter());
    converters.add(new RowNumberColumnConverter());
    return converters;
}
Also used : ActionWorkItemInsertFactColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionWorkItemInsertFactColumnConverter) ArrayList(java.util.ArrayList) ActionRetractFactColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionRetractFactColumnConverter) RuleNameColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.RuleNameColumnConverter) ActionInsertFactColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionInsertFactColumnConverter) ActionSetFieldColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionSetFieldColumnConverter) LimitedEntryColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.LimitedEntryColumnConverter) RowNumberColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.RowNumberColumnConverter) MetaDataColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.MetaDataColumnConverter) ActionWorkItemExecuteColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionWorkItemExecuteColumnConverter) AttributeColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.AttributeColumnConverter) ConditionColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ConditionColumnConverter) DescriptionColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.DescriptionColumnConverter) ActionWorkItemSetFieldColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionWorkItemSetFieldColumnConverter) BRLActionVariableColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.BRLActionVariableColumnConverter) BaseColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter) BRLConditionVariableColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.BRLConditionVariableColumnConverter)

Example 2 with BaseColumnConverter

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter 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 3 with BaseColumnConverter

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter in project drools-wb by kiegroup.

the class GridWidgetColumnFactoryImpl method convertColumn.

@Override
public GridColumn<?> convertColumn(final BaseColumn column, final GuidedDecisionTablePresenter.Access access, final GuidedDecisionTableView gridWidget) {
    for (BaseColumnConverter converter : converters) {
        if (converter.handles(column)) {
            final GridColumn<?> uiColumn = converter.convertColumn(column, access, gridWidget);
            if (uiColumn instanceof BaseUiColumn) {
                ((BaseUiColumn) uiColumn).setColumnResizeListener((double width) -> column.setWidth(((int) width)));
            }
            // Copy back UI Column width into Model as BaseColumn does not have a width set by default
            column.setWidth((int) uiColumn.getWidth());
            return uiColumn;
        }
    }
    throw new IllegalArgumentException("Column '" + column.getHeader() + "' was not converted.");
}
Also used : BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) BaseColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter)

Example 4 with BaseColumnConverter

use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter in project drools-wb by kiegroup.

the class BaseConverterTest method setup.

@Before
public void setup() {
    this.model = getModel();
    this.oracle = getOracle();
    this.presenter = getPresenter();
    this.columnUtilities = new ColumnUtilities(model, oracle);
    for (BaseColumnConverter bcc : getConverters()) {
        bcc.initialise(model, oracle, columnUtilities, presenter);
    }
}
Also used : ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) BaseColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter) Before(org.junit.Before)

Aggregations

BaseColumnConverter (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter)4 ColumnUtilities (org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities)2 Before (org.junit.Before)2 EventBus (com.google.gwt.event.shared.EventBus)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 ArrayList (java.util.ArrayList)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 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)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 BaseUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn)1 GuidedDecisionTableUiModel (org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel)1 GridWidgetCellFactory (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.GridWidgetCellFactory)1 GridWidgetCellFactoryImpl (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.impl.GridWidgetCellFactoryImpl)1 ActionInsertFactColumnConverter (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionInsertFactColumnConverter)1 ActionRetractFactColumnConverter (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.impl.ActionRetractFactColumnConverter)1