Search in sources :

Example 66 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class ActionColumnSynchronizer method isWorkItemFragmentBeforeInsertFactCol.

protected boolean isWorkItemFragmentBeforeInsertFactCol(final List<? extends MetaData> metaData) {
    final List<ActionCol52> columnsToMove = metaData.stream().map(c -> (MoveColumnToMetaData) c).map(MoveColumnToMetaData::getColumn).map(c -> (ActionCol52) c).collect(Collectors.toList());
    final List<String> bindingsUsedByWID = new ArrayList<>();
    bindingsUsedByWID.addAll(columnsToMove.stream().filter(c -> c instanceof ActionWorkItemInsertFactCol52).map(c -> (ActionWorkItemInsertFactCol52) c).map(ActionWorkItemInsertFactCol52::getBoundName).collect(Collectors.toList()));
    final AtomicBoolean result = new AtomicBoolean(true);
    final int tgtIndex = ((MoveColumnToMetaData) metaData.get(0)).getTargetColumnIndex();
    final List<BaseColumn> modelColumns = model.getExpandedColumns();
    // Cannot move "Insert and Set field" created by the WID to after other "Insert and Set field"
    for (String binding : bindingsUsedByWID) {
        model.getActionCols().stream().filter(c -> !columnsToMove.contains(c)).filter(c -> c instanceof ActionInsertFactCol52).filter(c -> !(c instanceof ActionWorkItemInsertFactCol52)).map(c -> (ActionInsertFactCol52) c).filter(c -> c.getBoundName().equals(binding)).map(modelColumns::indexOf).filter(i -> tgtIndex >= i).findFirst().ifPresent(i -> result.set(false));
    }
    return result.get();
}
Also used : IntStream(java.util.stream.IntStream) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) ColumnMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.ColumnMetaData) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) OptionalInt(java.util.OptionalInt) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Dependent(javax.enterprise.context.Dependent) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) Collections(java.util.Collections) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 67 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class ActionColumnSynchronizer method doMoveActionFragment.

protected void doMoveActionFragment(final List<MoveColumnToMetaData> metaData) throws VetoException {
    final MoveColumnToMetaData md = metaData.get(0);
    final BaseColumn firstColumnInFragment = md.getColumn();
    final BaseColumn lastColumnInFragment = metaData.get(metaData.size() - 1).getColumn();
    final int srcColumnFirstIndex = model.getExpandedColumns().indexOf(firstColumnInFragment);
    final int srcColumnLastIndex = model.getExpandedColumns().indexOf(lastColumnInFragment);
    final List<ActionCol52> srcModelFragmentColumns = IntStream.rangeClosed(srcColumnFirstIndex, srcColumnLastIndex).mapToObj(i -> model.getExpandedColumns().get(i)).map(column -> (ActionCol52) column).collect(Collectors.toList());
    final int srcModelFragmentColumnsCount = srcModelFragmentColumns.size();
    if (srcModelFragmentColumnsCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    if (srcModelFragmentColumnsCount != metaData.size()) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final int tgtActionIndex = findTargetActionIndex(md);
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelFragmentColumns.get(0)), allModelColumns.indexOf(srcModelFragmentColumns.get(0)) + srcModelFragmentColumnsCount - 1);
    // Moving left
    if (tgtColumnIndex < srcColumnFirstIndex) {
        final AtomicInteger offset = new AtomicInteger(0);
        srcModelFragmentColumns.forEach(column -> {
            model.getActionCols().remove(column);
            model.getActionCols().add(tgtActionIndex + offset.getAndIncrement(), column);
        });
    }
    // Moving right
    if (tgtColumnIndex > srcColumnFirstIndex) {
        srcModelFragmentColumns.forEach(column -> {
            model.getActionCols().remove(column);
            model.getActionCols().add(tgtActionIndex, column);
        });
    }
}
Also used : IntStream(java.util.stream.IntStream) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) ColumnMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.ColumnMetaData) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) OptionalInt(java.util.OptionalInt) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Dependent(javax.enterprise.context.Dependent) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) Collections(java.util.Collections) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 68 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn 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 69 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn 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)

Example 70 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class BaseActionWorkItemConverterTest method checkConvertColumn.

@Test
public void checkConvertColumn() {
    final BaseColumn column = getColumn();
    final GridColumn<?> uiColumn = converter.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn.isResizable());
    assertTrue(uiColumn.isVisible());
    assertEquals(WIDTH, uiColumn.getWidth(), 0.0);
    assertEquals(2, uiColumn.getHeaderMetaData().size());
    final GridColumn.HeaderMetaData row0 = uiColumn.getHeaderMetaData().get(0);
    assertEquals(WID_NAME, row0.getTitle());
    assertEquals(ActionCol52.class.getName(), row0.getColumnGroup());
    final GridColumn.HeaderMetaData row1 = uiColumn.getHeaderMetaData().get(1);
    assertEquals(HEADER, row1.getTitle());
    assertEquals(getExpectedColumnGroup(), row1.getColumnGroup());
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Test(org.junit.Test)

Aggregations

BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)126 Test (org.junit.Test)72 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)57 ArrayList (java.util.ArrayList)55 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)44 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)34 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)33 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)29 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)26 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)25 List (java.util.List)23 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)23 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)23 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)21 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)21 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)20 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)20 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)20 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)19 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)19