Search in sources :

Example 1 with BaseUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn 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 2 with BaseUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn in project drools-wb by kiegroup.

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_ActionSetFieldColumn.

@Test
public void columnResizingListenerSetup_ActionSetFieldColumn() {
    final Pattern52 pattern = mock(Pattern52.class);
    final ActionSetFieldCol52 column = new ActionSetFieldCol52();
    column.setFactField("MyField");
    column.setHeader("MyColumn");
    column.setBoundName("$f");
    when(model.getConditions()).thenReturn(new ArrayList<CompositeColumn<? extends BaseColumn>>() {

        {
            add(pattern);
        }
    });
    when(pattern.getFactType()).thenReturn("MyFact");
    when(pattern.getBoundName()).thenReturn("$f");
    when(pattern.isBound()).thenReturn(true);
    when(oracle.getFieldType("MyFact", "MyField")).thenReturn(DataType.TYPE_STRING);
    final GridColumn<?> uiColumn = factory.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn instanceof BaseUiColumn);
    assertEquals((int) uiColumn.getWidth(), column.getWidth());
    uiColumn.setWidth(200.0);
    assertEquals(200, column.getWidth());
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 3 with BaseUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn in project drools-wb by kiegroup.

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_MetadataColumn.

@Test
public void columnResizingListenerSetup_MetadataColumn() {
    final MetadataCol52 column = new MetadataCol52();
    column.setMetadata("metadata");
    final GridColumn<?> uiColumn = factory.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn instanceof BaseUiColumn);
    assertEquals((int) uiColumn.getWidth(), column.getWidth());
    uiColumn.setWidth(200.0);
    assertEquals(200, column.getWidth());
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) Test(org.junit.Test)

Example 4 with BaseUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn in project drools-wb by kiegroup.

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_ConditionColumn.

@Test
public void columnResizingListenerSetup_ConditionColumn() {
    final Pattern52 pattern = mock(Pattern52.class);
    final ConditionCol52 column = new ConditionCol52();
    column.setFactField("MyField");
    column.setHeader("MyColumn");
    when(model.getPattern(eq(column))).thenReturn(pattern);
    when(pattern.getFactType()).thenReturn("MyFact");
    when(oracle.getFieldType("MyFact", "MyField")).thenReturn(DataType.TYPE_STRING);
    final GridColumn<?> uiColumn = factory.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn instanceof BaseUiColumn);
    assertEquals((int) uiColumn.getWidth(), column.getWidth());
    uiColumn.setWidth(200.0);
    assertEquals(200, column.getWidth());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) Test(org.junit.Test)

Example 5 with BaseUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn in project drools-wb by kiegroup.

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_DescriptionColumn.

@Test
public void columnResizingListenerSetup_DescriptionColumn() {
    final BaseColumn column = new DescriptionCol52();
    final GridColumn<?> uiColumn = factory.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn instanceof BaseUiColumn);
    assertEquals((int) uiColumn.getWidth(), column.getWidth());
    assertEquals(150.0, column.getWidth(), 0.0);
    uiColumn.setWidth(200.0);
    assertEquals(200, column.getWidth());
}
Also used : DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) Test(org.junit.Test)

Aggregations

BaseUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn)8 Test (org.junit.Test)7 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)2 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)1 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)1 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)1 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)1 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)1 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)1 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)1 BaseColumnConverter (org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter)1