/** * Convert a Model cell to one that can be used in the UI * * @param cell * @return */ @Override public CellValue<? extends Comparable<?>> convertModelCellValue( BaseColumn column, DTCellValue52 dcv) { // Analysis cells do not use data-type if (column instanceof AnalysisCol52) { return makeNewAnalysisCellValue(); } // Other cells do use data-type DTDataTypes52 dataType = getDataType(column); assertDTCellValue(dataType, dcv); CellValue<? extends Comparable<?>> cell = null; switch (dataType) { case BOOLEAN: cell = makeNewBooleanCellValue(dcv.getBooleanValue()); break; case DATE: cell = makeNewDateCellValue(dcv.getDateValue()); break; case NUMERIC: if (column instanceof RowNumberCol52) { cell = makeNewRowNumberCellValue(dcv.getNumericValue()); } else { cell = makeNewNumericCellValue(dcv.getNumericValue()); if (column instanceof AttributeCol52) { AttributeCol52 at = (AttributeCol52) column; if (at.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) { if (at.isUseRowNumber()) { cell = makeNewRowNumberCellValue(dcv.getNumericValue()); } } } } break; default: cell = makeNewStringCellValue(dcv.getStringValue()); if (column instanceof AttributeCol52) { AttributeCol52 ac = (AttributeCol52) column; if (ac.getAttribute().equals(RuleAttributeWidget.DIALECT_ATTR)) { cell = makeNewDialectCellValue(dcv.getStringValue()); } } } if (dcv.isOtherwise()) { cell.addState(CellState.OTHERWISE); } return cell; }
/** * Create a Cell for the given DTColumnConfig * * @param column The Decision Table model column * @return A Cell */ public DecoratedGridCellValueAdaptor<? extends Comparable<?>> getCell(BaseColumn column) { // This is the cell that will be used to edit values; its type can differ to the "fieldType" // of the underlying model. For example a "Guvnor-enum" requires a drop-down list of potential // values whereas the "fieldType" may be a String. DecoratedGridCellValueAdaptor<? extends Comparable<?>> cell = makeTextCell(); if (column instanceof RowNumberCol52) { cell = makeRowNumberCell(); } else if (column instanceof AttributeCol52) { AttributeCol52 attrCol = (AttributeCol52) column; String attrName = attrCol.getAttribute(); if (attrName.equals(RuleAttributeWidget.SALIENCE_ATTR)) { if (attrCol.isUseRowNumber()) { cell = makeRowNumberCell(); } else { cell = makeNumericIntegerCell(); } } else if (attrName.equals(GuidedDecisionTable52.ENABLED_ATTR)) { cell = makeBooleanCell(); } else if (attrName.equals(GuidedDecisionTable52.NO_LOOP_ATTR)) { cell = makeBooleanCell(); } else if (attrName.equals(GuidedDecisionTable52.DURATION_ATTR)) { cell = makeNumericLongCell(); } else if (attrName.equals(GuidedDecisionTable52.TIMER_ATTR)) { cell = makeTimerCell(); } else if (attrName.equals(GuidedDecisionTable52.CALENDARS_ATTR)) { cell = makeCalendarsCell(); } else if (attrName.equals(GuidedDecisionTable52.AUTO_FOCUS_ATTR)) { cell = makeBooleanCell(); } else if (attrName.equals(GuidedDecisionTable52.LOCK_ON_ACTIVE_ATTR)) { cell = makeBooleanCell(); } else if (attrName.equals(GuidedDecisionTable52.DATE_EFFECTIVE_ATTR)) { cell = makeDateCell(); } else if (attrName.equals(GuidedDecisionTable52.DATE_EXPIRES_ATTR)) { cell = makeDateCell(); } else if (attrName.equals(GuidedDecisionTable52.DIALECT_ATTR)) { cell = makeDialectCell(); } else if (attrName.equals(GuidedDecisionTable52.NEGATE_RULE_ATTR)) { cell = makeBooleanCell(); } } else if (column instanceof LimitedEntryCol) { cell = makeBooleanCell(); } else if (column instanceof BRLConditionVariableColumn) { // Before ConditionCol52 as this is a sub-class cell = derieveCellFromCondition((BRLConditionVariableColumn) column); } else if (column instanceof ConditionCol52) { cell = derieveCellFromCondition((ConditionCol52) column); } else if (column instanceof ActionWorkItemSetFieldCol52) { // Before ActionSetFieldCol52 as this is a sub-class cell = makeBooleanCell(); } else if (column instanceof ActionWorkItemInsertFactCol52) { // Before ActionInsertFactCol52 as this is a sub-class cell = makeBooleanCell(); } else if (column instanceof ActionSetFieldCol52) { cell = derieveCellFromAction((ActionSetFieldCol52) column); } else if (column instanceof ActionInsertFactCol52) { cell = derieveCellFromAction((ActionInsertFactCol52) column); } else if (column instanceof ActionRetractFactCol52) { cell = derieveCellFromAction((ActionRetractFactCol52) column); } else if (column instanceof ActionWorkItemCol52) { cell = makeBooleanCell(); } else if (column instanceof BRLActionVariableColumn) { cell = derieveCellFromAction((BRLActionVariableColumn) column); } else if (column instanceof AnalysisCol52) { cell = makeRowAnalysisCell(); } return cell; }