Search in sources :

Example 91 with BaseColumn

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

the class ActionColumnSynchronizer method isWorkItemFragment.

protected boolean isWorkItemFragment(final List<? extends MetaData> metaData) {
    if (!metaData.stream().allMatch((c) -> (c instanceof MoveColumnToMetaData))) {
        return false;
    }
    if (!metaData.stream().map(c -> (MoveColumnToMetaData) c).allMatch(this::isWorkItemActionColumn)) {
        return false;
    }
    final BaseColumn firstColumnInFragment = ((MoveColumnToMetaData) metaData.get(0)).getColumn();
    final BaseColumn lastColumnInFragment = ((MoveColumnToMetaData) metaData.get(metaData.size() - 1)).getColumn();
    final int firstColumnIndex = model.getExpandedColumns().indexOf(firstColumnInFragment);
    final int lastColumnIndex = model.getExpandedColumns().indexOf(lastColumnInFragment);
    return lastColumnIndex - firstColumnIndex == metaData.size() - 1;
}
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) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 92 with BaseColumn

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

the class ActionInsertFactColumnSynchronizer method isActionInsertFactFragment.

private boolean isActionInsertFactFragment(final List<? extends MetaData> metaData) {
    if (!metaData.stream().allMatch((c) -> (c instanceof MoveColumnToMetaData))) {
        return false;
    }
    if (!metaData.stream().map(c -> (MoveColumnToMetaData) c).allMatch(c -> c.getColumn() instanceof ActionInsertFactCol52)) {
        return false;
    }
    final int lastMetaDataIndex = metaData.size() - 1;
    final BaseColumn firstColumnInFragment = ((MoveColumnToMetaData) metaData.get(0)).getColumn();
    final BaseColumn lastColumnInFragment = ((MoveColumnToMetaData) metaData.get(lastMetaDataIndex)).getColumn();
    final int firstColumnIndex = model.getExpandedColumns().indexOf(firstColumnInFragment);
    final int lastColumnIndex = model.getExpandedColumns().indexOf(lastColumnInFragment);
    return lastColumnIndex - firstColumnIndex == lastMetaDataIndex;
}
Also used : ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol) 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) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) Dependent(javax.enterprise.context.Dependent) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) Collections(java.util.Collections) BaseColumnFieldDiffImpl(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiffImpl) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 93 with BaseColumn

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

Example 94 with BaseColumn

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

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_RowNumberColumn.

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

Example 95 with BaseColumn

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

the class DTCellValueWidgetFactory method makeListBoxForColumn.

private ListBox makeListBoxForColumn(final DropDownData dd, final Pattern52 basePattern, final BaseColumn baseCondition, final DTCellValue52 dcv, final boolean isMultipleSelect) {
    final ListBox lb = makeListBox(dd, isMultipleSelect, dcv);
    // Wire up update handler
    lb.setEnabled(!isReadOnly);
    if (!isReadOnly) {
        lb.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                String value = null;
                if (lb.isMultipleSelect()) {
                    for (int i = 0; i < lb.getItemCount(); i++) {
                        if (lb.isItemSelected(i)) {
                            if (value == null) {
                                value = lb.getValue(i);
                            } else {
                                value = value + "," + lb.getValue(i);
                            }
                        }
                    }
                } else {
                    int index = lb.getSelectedIndex();
                    if (index > -1) {
                        // Set base column value
                        value = lb.getValue(index);
                    }
                }
                dcv.setStringValue(value);
                // Update any dependent enumerations
                final LimitedEntryDropDownManager.Context context = new LimitedEntryDropDownManager.Context(basePattern, baseCondition);
                Set<Integer> dependentColumnIndexes = dropDownManager.getDependentColumnIndexes(context);
                for (Integer iCol : dependentColumnIndexes) {
                    BaseColumn column = model.getExpandedColumns().get(iCol);
                    if (column instanceof LimitedEntryCol) {
                        ((LimitedEntryCol) column).setValue(null);
                    } else if (column instanceof DTColumnConfig52) {
                        ((DTColumnConfig52) column).setDefaultValue(null);
                    }
                }
            }
        });
    }
    return lb;
}
Also used : BigInteger(java.math.BigInteger) Set(java.util.Set) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) LimitedEntryDropDownManager(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.LimitedEntryDropDownManager) ListBox(org.gwtbootstrap3.client.ui.ListBox) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol)

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