Search in sources :

Example 86 with BaseColumn

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

the class BRLActionColumnSynchronizer method doMoveBRLFragment.

private void doMoveBRLFragment(final List<MoveColumnToMetaData> metaData) throws VetoException {
    final MoveColumnToMetaData md = metaData.get(0);
    final BRLActionVariableColumn srcModelColumn = (BRLActionVariableColumn) md.getColumn();
    final BRLActionColumn srcModelBRLFragment = model.getBRLColumn(srcModelColumn);
    if (srcModelBRLFragment == null) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BRLActionVariableColumn> srcModelBRLFragmentColumns = srcModelBRLFragment.getChildColumns();
    final int srcModelBRLFragmentColumnsCount = srcModelBRLFragmentColumns.size();
    if (srcModelBRLFragmentColumnsCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    if (srcModelBRLFragmentColumnsCount != 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(srcModelBRLFragmentColumns.get(0)), allModelColumns.indexOf(srcModelBRLFragmentColumns.get(0)) + srcModelBRLFragmentColumnsCount - 1);
    model.getActionCols().remove(srcModelBRLFragment);
    model.getActionCols().add(tgtActionIndex, srcModelBRLFragment);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 87 with BaseColumn

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

the class BaseColumnSynchronizer method findTargetActionIndex.

protected int findTargetActionIndex(final MoveColumnToMetaData md) throws ModelSynchronizer.MoveVetoException {
    int tgtActionIndex = -1;
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final List<ActionCol52> allModelActions = model.getActionCols();
    for (int actionIndex = 0; actionIndex < allModelActions.size(); actionIndex++) {
        final ActionCol52 ac = allModelActions.get(actionIndex);
        final List<ActionCol52> children = getChildren(ac);
        if (children == null || children.isEmpty()) {
            continue;
        }
        final BaseColumn firstChild = children.get(0);
        final BaseColumn lastChild = children.get(children.size() - 1);
        final int firstChildIndex = allModelColumns.indexOf(firstChild);
        final int lastChildIndex = allModelColumns.indexOf(lastChild);
        if (tgtColumnIndex >= firstChildIndex && tgtColumnIndex <= lastChildIndex) {
            tgtActionIndex = actionIndex;
            break;
        }
    }
    if (tgtActionIndex < 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    return tgtActionIndex;
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 88 with BaseColumn

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

the class ColumnHeaderPopOverImpl method showSource.

private void showSource(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter, final int uiColumnIndex) {
    final BaseColumn column = dtPresenter.getModel().getExpandedColumns().get(uiColumnIndex);
    final int screenX = getScreenX(modellerView, dtPresenter, uiColumnIndex);
    final int screenY = getScreenY(modellerView, dtPresenter);
    view.show((Callback<PopOverView.Content> callback) -> columnDefinitionFactory.generateColumnDefinition(dtPresenter, column, (String definition) -> callback.callback(new PopOverView.Content() {

        @Override
        public String getContent() {
            return definition;
        }

        @Override
        public int getX() {
            return screenX;
        }

        @Override
        public int getY() {
            return screenY;
        }
    })));
}
Also used : Callback(org.uberfire.client.callbacks.Callback) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 89 with BaseColumn

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

the class LimitedEntryBRLConditionColumnSynchronizer method moveColumnsTo.

@Override
public void moveColumnsTo(final List<MoveColumnToMetaData> metaData) throws VetoException {
    // Check operation is supported
    if (!handlesMoveColumnsTo(metaData)) {
        return;
    }
    final MoveColumnToMetaData md = metaData.get(0);
    final LimitedEntryBRLConditionColumn modelColumn = (LimitedEntryBRLConditionColumn) md.getColumn();
    final List<CompositeColumn<? extends BaseColumn>> modelConditionColumns = model.getConditions();
    final int modelConditionColumnCount = modelConditionColumns.size();
    if (modelConditionColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final int minColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(0));
    final int maxColumnIndex = allModelColumns.indexOf(modelConditionColumns.get(modelConditionColumnCount - 1));
    final int targetColumnIndex = md.getTargetColumnIndex();
    final int sourceColumnIndex = md.getSourceColumnIndex();
    if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
    modelConditionColumns.remove(modelColumn);
    modelConditionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
Also used : LimitedEntryBRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLConditionColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)

Example 90 with BaseColumn

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

the class ModelSynchronizerImpl method setCellOtherwiseState.

@Override
public void setCellOtherwiseState(final int rowIndex, final int columnIndex) {
    final BaseColumn modelColumn = model.getExpandedColumns().get(columnIndex);
    final DTCellValue52 modelCell = model.getData().get(rowIndex).get(columnIndex);
    modelCell.clearValues();
    modelCell.setOtherwise(true);
    // BaseGridData is sparsely populated; only add values if needed.
    if (modelCell.hasValue()) {
        uiModel.setCellValueInternal(rowIndex, columnIndex, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
    }
    uiModel.indexColumn(columnIndex);
}
Also used : BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

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