Search in sources :

Example 26 with AttributeCol52

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

the class GuidedDecisionTableSalienceBuilder method populateDecisionTable.

@Override
public void populateDecisionTable(final GuidedDecisionTable52 dtable, final int maxRowCount) {
    final AttributeCol52 column = new AttributeCol52();
    column.setAttribute(GuidedDecisionTable52.SALIENCE_ATTR);
    // If sequential set column to use reverse row number
    if (isSequential) {
        column.setUseRowNumber(true);
        column.setReverseOrder(true);
        final int maxRow = this.values.size();
        for (int iRow = 0; iRow < maxRow; iRow++) {
            final DTCellValue52 dcv = this.values.get(iRow);
            dcv.setNumericValue(Integer.valueOf(maxRow - iRow));
        }
    }
    dtable.getAttributeCols().add(column);
    if (this.values.size() < maxRowCount) {
        for (int iRow = this.values.size(); iRow < maxRowCount; iRow++) {
            final DTCellValue52 dcv = new DTCellValue52(0);
            this.values.add(dcv);
        }
    }
    addColumnData(dtable, column);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 27 with AttributeCol52

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

the class AttributeColumnConfigRow method init.

public void init(final AttributeCol52 attributeColumn, final GuidedDecisionTableModellerView.Presenter presenter) {
    view.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    view.addColumnLabel(attributeColumn);
    final AttributeCol52 originalColumn = attributeColumn;
    if (attributeColumn.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) {
        useRowNumberCheckBox = view.addUseRowNumberCheckBox(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> {
            final AttributeCol52 editedColumn = originalColumn.cloneColumn();
            editedColumn.setUseRowNumber(useRowNumberCheckBox.getValue());
            reverseOrderCheckBox.setEnabled(useRowNumberCheckBox.getValue());
            try {
                final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
                if (dtPresenter.isPresent()) {
                    dtPresenter.get().updateColumn(originalColumn, editedColumn);
                }
            } catch (VetoException veto) {
                presenter.getView().showGenericVetoMessage();
            }
        });
        view.add(new Span("("));
        reverseOrderCheckBox = view.addReverseOrderCheckBox(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> {
            final AttributeCol52 editedColumn = originalColumn.cloneColumn();
            editedColumn.setReverseOrder(reverseOrderCheckBox.getValue());
            try {
                final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
                if (dtPresenter.isPresent()) {
                    dtPresenter.get().updateColumn(originalColumn, editedColumn);
                }
            } catch (VetoException veto) {
                presenter.getView().showGenericVetoMessage();
            }
        });
        view.add(new Span(")"));
    }
    view.addDefaultValue(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> {
        final AttributeCol52 editedColumn = originalColumn.cloneColumn();
        editedColumn.setDefaultValue(event.getEditedDefaultValue());
        try {
            final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
            if (dtPresenter.isPresent()) {
                dtPresenter.get().updateColumn(originalColumn, editedColumn);
            }
        } catch (VetoException veto) {
            presenter.getView().showGenericVetoMessage();
        }
    });
    hideColumnCheckBox = view.addHideColumnCheckBox(attributeColumn, (event) -> {
        final AttributeCol52 editedColumn = originalColumn.cloneColumn();
        editedColumn.setHideColumn(hideColumnCheckBox.getValue());
        try {
            final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
            if (dtPresenter.isPresent()) {
                dtPresenter.get().updateColumn(originalColumn, editedColumn);
            }
        } catch (VetoException veto) {
            presenter.getView().showGenericVetoMessage();
        }
    });
    addRemoveAttributeButton(attributeColumn, presenter);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) Inject(javax.inject.Inject) Span(org.gwtbootstrap3.client.ui.html.Span) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) Widget(com.google.gwt.user.client.ui.Widget) Dependent(javax.enterprise.context.Dependent) HasVerticalAlignment(com.google.gwt.user.client.ui.HasVerticalAlignment) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) GuidedDecisionTableModellerView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Optional(java.util.Optional) RuleAttributeWidget(org.drools.workbench.screens.guided.rule.client.editor.RuleAttributeWidget) CheckBox(org.gwtbootstrap3.client.ui.CheckBox) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) Optional(java.util.Optional) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) Span(org.gwtbootstrap3.client.ui.html.Span)

Example 28 with AttributeCol52

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

the class AttributeColumnConverter method convertColumn.

@Override
public GridColumn<?> convertColumn(final BaseColumn column, final GuidedDecisionTablePresenter.Access access, final GuidedDecisionTableView gridWidget) {
    final AttributeCol52 attributeColumn = (AttributeCol52) column;
    final String attributeName = attributeColumn.getAttribute();
    if (attributeName.equals(RuleAttributeWidget.SALIENCE_ATTR)) {
        return newSalienceColumn(makeSalienceHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH + 30), true, !column.isHideColumn(), access, attributeColumn.isUseRowNumber(), gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.ENABLED_ATTR)) {
        return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.NO_LOOP_ATTR)) {
        return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.DURATION_ATTR)) {
        return newLongColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.TIMER_ATTR)) {
        return newStringColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.CALENDARS_ATTR)) {
        return newStringColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.AUTO_FOCUS_ATTR)) {
        return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.LOCK_ON_ACTIVE_ATTR)) {
        return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.DATE_EFFECTIVE_ATTR)) {
        return newDateColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.DATE_EXPIRES_ATTR)) {
        return newDateColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.DIALECT_ATTR)) {
        return newDialectColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    } else if (attributeName.equals(GuidedDecisionTable52.NEGATE_RULE_ATTR)) {
        return newBooleanColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
    }
    return newStringColumn(makeHeaderMetaData(column), Math.max(column.getWidth(), DEFAULT_COLUMN_WIDTH), true, !column.isHideColumn(), access, gridWidget);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)

Example 29 with AttributeCol52

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

the class AttributeColumnSynchronizer 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 AttributeCol52 modelColumn = (AttributeCol52) md.getColumn();
    final List<AttributeCol52> modelAttributeColumns = model.getAttributeCols();
    final int modelAttributeColumnCount = modelAttributeColumns.size();
    if (modelAttributeColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final int minColumnIndex = allModelColumns.indexOf(modelAttributeColumns.get(0));
    final int maxColumnIndex = allModelColumns.indexOf(modelAttributeColumns.get(modelAttributeColumnCount - 1));
    final int targetColumnIndex = md.getTargetColumnIndex();
    final int sourceColumnIndex = md.getSourceColumnIndex();
    if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
    modelAttributeColumns.remove(modelColumn);
    modelAttributeColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 30 with AttributeCol52

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

the class AttributeColumnSynchronizer method append.

@Override
public void append(final ColumnMetaData metaData) throws VetoException {
    // Check operation is supported
    if (!handlesAppend(metaData)) {
        return;
    }
    final AttributeCol52 column = (AttributeCol52) metaData.getColumn();
    model.getAttributeCols().add(column);
    synchroniseAppendColumn(column);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)

Aggregations

AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)86 Test (org.junit.Test)55 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)30 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)20 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)14 ArrayList (java.util.ArrayList)12 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)10 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)10 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)9 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)8 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)8 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)7 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)6 DataListener (org.drools.template.parser.DataListener)6 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)6 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)5 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)5