Search in sources :

Example 1 with DynamicColumn

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.DynamicColumn in project drools-wb by kiegroup.

the class AbstractDecoratedTemplateDataGridWidget method onSetModel.

public void onSetModel(SetModelEvent<TemplateModel> event) {
    DynamicData data = new DynamicData();
    TemplateModel model = event.getModel();
    List<DynamicColumn<TemplateDataColumn>> columns = new ArrayList<DynamicColumn<TemplateDataColumn>>();
    setupInternalModel(model, columns, data);
    // Raise event setting data and columns for UI components
    SetInternalTemplateDataModelEvent sime = new SetInternalTemplateDataModelEvent(model, data, columns);
    eventBus.fireEvent(sime);
}
Also used : SetInternalTemplateDataModelEvent(org.drools.workbench.screens.guided.template.client.editor.events.SetInternalTemplateDataModelEvent) ArrayList(java.util.ArrayList) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) DynamicColumn(org.kie.workbench.common.widgets.decoratedgrid.client.widget.DynamicColumn) DynamicData(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicData)

Example 2 with DynamicColumn

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.DynamicColumn in project drools-wb by kiegroup.

the class AbstractDecoratedTemplateDataGridWidget method setupInternalModel.

private void setupInternalModel(TemplateModel model, List<DynamicColumn<TemplateDataColumn>> columns, DynamicData data) {
    // Get interpolation variables
    InterpolationVariable[] vars = model.getInterpolationVariablesList();
    if (vars.length == 0) {
        return;
    }
    int colIndex = 0;
    String[][] modelData = model.getTableAsArray();
    // to be enough rows to receive the columns data
    for (int iRow = 0; iRow < modelData.length; iRow++) {
        data.addRow();
    }
    // Add corresponding columns to table
    for (InterpolationVariable var : vars) {
        TemplateDataColumn col = new TemplateDataColumn(var.getVarName(), var.getDataType(), var.getFactType(), var.getFactField());
        DynamicColumn<TemplateDataColumn> column = new DynamicColumn<TemplateDataColumn>(col, cellFactory.getCell(col), colIndex, eventBus);
        columns.add(column);
        data.addColumn(colIndex, makeColumnData(modelData, col, colIndex++), true);
    }
}
Also used : InterpolationVariable(org.drools.workbench.models.datamodel.rule.InterpolationVariable) DynamicColumn(org.kie.workbench.common.widgets.decoratedgrid.client.widget.DynamicColumn)

Aggregations

DynamicColumn (org.kie.workbench.common.widgets.decoratedgrid.client.widget.DynamicColumn)2 ArrayList (java.util.ArrayList)1 InterpolationVariable (org.drools.workbench.models.datamodel.rule.InterpolationVariable)1 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)1 SetInternalTemplateDataModelEvent (org.drools.workbench.screens.guided.template.client.editor.events.SetInternalTemplateDataModelEvent)1 DynamicData (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicData)1