Package org.drools.workbench.models.guided.dtable.shared.model

Examples of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52


     * @return
     */
    public DTCellValue52 convertToModelCell( BaseColumn column,
                                             CellValue<?> cell ) {
        DataType.DataTypes dt = utilities.getDataType( column );
        DTCellValue52 dtCell = null;

        switch ( dt ) {
            case BOOLEAN:
                dtCell = new DTCellValue52( (Boolean) cell.getValue() );
                break;
            case DATE:
                dtCell = new DTCellValue52( (Date) cell.getValue() );
                break;
            case NUMERIC:
                dtCell = new DTCellValue52( (BigDecimal) cell.getValue() );
                break;
            case NUMERIC_BIGDECIMAL:
                dtCell = new DTCellValue52( (BigDecimal) cell.getValue() );
                break;
            case NUMERIC_BIGINTEGER:
                dtCell = new DTCellValue52( (BigInteger) cell.getValue() );
                break;
            case NUMERIC_BYTE:
                dtCell = new DTCellValue52( (Byte) cell.getValue() );
                break;
            case NUMERIC_DOUBLE:
                dtCell = new DTCellValue52( (Double) cell.getValue() );
                break;
            case NUMERIC_FLOAT:
                dtCell = new DTCellValue52( (Float) cell.getValue() );
                break;
            case NUMERIC_INTEGER:
                dtCell = new DTCellValue52( (Integer) cell.getValue() );
                break;
            case NUMERIC_LONG:
                dtCell = new DTCellValue52( (Long) cell.getValue() );
                break;
            case NUMERIC_SHORT:
                dtCell = new DTCellValue52( (Short) cell.getValue() );
                break;
            default:
                dtCell = new DTCellValue52( (String) cell.getValue() );
        }
        dtCell.setOtherwise( cell.isOtherwise() );
        return dtCell;
    }
View Full Code Here


     * @param c
     * @return
     */
    public DTCellValue52 makeNewValue( DTColumnConfig52 c ) {
        DataType.DataTypes type = utils.getTypeSafeType( c );
        return new DTCellValue52( type,
                                  allowEmptyValues );
    }
View Full Code Here

     */
    public DTCellValue52 makeNewValue( Pattern52 p,
                                       ConditionCol52 c ) {
        DataType.DataTypes type = utils.getTypeSafeType( p,
                                                         c );
        return new DTCellValue52( type,
                                  allowEmptyValues );
    }
View Full Code Here

     */
    public DTCellValue52 makeNewValue( Pattern52 p,
                                       ActionSetFieldCol52 c ) {
        DataType.DataTypes type = utils.getTypeSafeType( p,
                                                         c );
        return new DTCellValue52( type,
                                  allowEmptyValues );
    }
View Full Code Here

        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 );
        addColumnData( dtable,
                       column );
View Full Code Here

        String value = content;
        if ( value.startsWith( "(" ) && value.endsWith( ")" ) ) {
            value = value.substring( 1,
                                     value.lastIndexOf( ")" ) - 1 );
        }
        final DTCellValue52 dcv = new DTCellValue52();
        try {
            dcv.setNumericValue( Integer.valueOf( value ) );
        } catch ( NumberFormatException nfe ) {
            final String message = "Priority is not an integer literal, in cell " + RuleSheetParserUtil.rc2name( row,
                                                                                                                 column );
            this.conversionResult.addMessage( message,
                                              ConversionMessageType.WARNING );
View Full Code Here

    private List<DTCellValue52> values = new ArrayList<DTCellValue52>();

    public void populateDecisionTable( final GuidedDecisionTable52 dtable ) {
        for ( int iRow = 0; iRow < this.values.size(); iRow++ ) {
            dtable.getData().add( new ArrayList<DTCellValue52>() );
            final DTCellValue52 dcv = this.values.get( iRow );
            dcv.setNumericValue( Integer.valueOf( iRow + 1 ) );
            dtable.getData().get( iRow ).add( 0,
                                              dcv );
        }
    }
View Full Code Here

    }

    public void addCellValue( final int row,
                              final int col,
                              final String value ) {
        this.values.add( new DTCellValue52() );
    }
View Full Code Here

    }

    public void addCellValue( final int row,
                              final int column,
                              final String value ) {
        final DTCellValue52 dcv = new DTCellValue52();
        try {
            dcv.setNumericValue( Long.valueOf( value ) );
        } catch ( NumberFormatException nfe ) {
            final String message = "Duration is not an long literal, in cell " + RuleSheetParserUtil.rc2name( row,
                                                                                                              column );
            this.conversionResult.addMessage( message,
                                              ConversionMessageType.WARNING );
View Full Code Here

                || attributeName.equals( RuleAttributeWidget.ACTIVATION_GROUP_ATTR )
                || attributeName.equals( RuleAttributeWidget.TIMER_ATTR )
                || attributeName.equals( RuleAttributeWidget.CALENDARS_ATTR ) ) {
            final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_STRING );
            if ( ac.getDefaultValue() == null ) {
                ac.setDefaultValue( new DTCellValue52( "" ) );
            }
            final DTCellValue52 defaultValue = ac.getDefaultValue();
            tb.setValue( defaultValue.getStringValue() );
            tb.setEnabled( !isReadOnly );
            if ( !isReadOnly ) {
                tb.addValueChangeHandler( new ValueChangeHandler<String>() {

                    public void onValueChange( ValueChangeEvent<String> event ) {
                        DTCellValue52 clonedDefaultValue = defaultValue.cloneDefaultValueCell();
                        defaultValue.setStringValue( tb.getValue() );
                        defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, clonedDefaultValue));
                    }

                } );
            }
            editor = tb;

        } else if ( attributeName.equals( RuleAttributeWidget.SALIENCE_ATTR ) ) {
            final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_NUMERIC_INTEGER );
            if ( ac.getDefaultValue() == null ) {
                ac.setDefaultValue( new DTCellValue52( 0 ) );
            } else {
                assertIntegerDefaultValue( ac.getDefaultValue() );
            }
            final DTCellValue52 defaultValue = ac.getDefaultValue();
            final Integer numericValue = (Integer) defaultValue.getNumericValue();
            tb.setValue( numericValue == null ? "" : numericValue.toString() );
            tb.setEnabled( !isReadOnly );
            if ( !isReadOnly ) {
                tb.addValueChangeHandler( new ValueChangeHandler<String>() {

                    public void onValueChange( ValueChangeEvent<String> event ) {
                        DTCellValue52 clonedDefaultValue = defaultValue.cloneDefaultValueCell();
                        try {
                            defaultValue.setNumericValue( Integer.valueOf( event.getValue() ) );
                        } catch ( NumberFormatException nfe ) {
                            defaultValue.setNumericValue( 0 );
                            tb.setValue( "0" );
                        } finally {
                            defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, clonedDefaultValue));
                        }
                    }

                } );
            }
            editor = tb;

        } else if ( attributeName.equals( RuleAttributeWidget.DURATION_ATTR ) ) {
            final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_NUMERIC_LONG );
            if ( ac.getDefaultValue() == null ) {
                ac.setDefaultValue( new DTCellValue52( 0L ) );
            } else {
                assertLongDefaultValue( ac.getDefaultValue() );
            }
            final DTCellValue52 defaultValue = ac.getDefaultValue();
            final Long numericValue = (Long) defaultValue.getNumericValue();
            tb.setValue( numericValue == null ? "" : numericValue.toString() );
            tb.setEnabled( !isReadOnly );
            if ( !isReadOnly ) {
                tb.addValueChangeHandler( new ValueChangeHandler<String>() {

                    public void onValueChange( ValueChangeEvent<String> event ) {
                        DTCellValue52 clonedDefaultValue = defaultValue.cloneDefaultValueCell();
                        try {
                            defaultValue.setNumericValue( Long.valueOf( event.getValue() ) );
                        } catch ( NumberFormatException nfe ) {
                            defaultValue.setNumericValue( 0L );
                            tb.setValue( "0" );
                        } finally {
                            defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, clonedDefaultValue));
                        }
                    }

                } );
            }
            editor = tb;

        } else if ( attributeName.equals( RuleAttributeWidget.NO_LOOP_ATTR )
                || attributeName.equals( RuleAttributeWidget.LOCK_ON_ACTIVE_ATTR )
                || attributeName.equals( RuleAttributeWidget.AUTO_FOCUS_ATTR )
                || attributeName.equals( RuleAttributeWidget.ENABLED_ATTR )
                || attributeName.equals( GuidedDecisionTable52.NEGATE_RULE_ATTR ) ) {
            final CheckBox cb = new CheckBox();
            if ( ac.getDefaultValue() == null ) {
                ac.setDefaultValue( new DTCellValue52( Boolean.FALSE ) );
            } else {
                assertBooleanDefaultValue( ac.getDefaultValue() );
            }
            final DTCellValue52 defaultValue = ac.getDefaultValue();
            final Boolean booleanValue = defaultValue.getBooleanValue();
            cb.setEnabled( !isReadOnly );
            if ( booleanValue == null ) {
                cb.setValue( false );
                defaultValue.setBooleanValue( Boolean.FALSE );
            } else {
                cb.setValue( booleanValue );
            }

            cb.addClickHandler( new ClickHandler() {
                public void onClick( ClickEvent event ) {
                    DTCellValue52 clonedDefaultValue = defaultValue.cloneDefaultValueCell();
                    defaultValue.setBooleanValue( cb.getValue() );
                    defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, clonedDefaultValue));
                }
            } );
            editor = cb;

        } else if ( attributeName.equals( RuleAttributeWidget.DATE_EFFECTIVE_ATTR )
                || attributeName.equals( RuleAttributeWidget.DATE_EXPIRES_ATTR ) ) {
            if ( ac.getDefaultValue() == null ) {
                ac.setDefaultValue( new DTCellValue52( new Date() ) );
            } else {
                assertDateDefaultValue( ac.getDefaultValue() );
            }
            final DTCellValue52 defaultValue = ac.getDefaultValue();
            if ( isReadOnly ) {
                final TextBox tb = TextBoxFactory.getTextBox( DataType.TYPE_STRING );
                tb.setValue( format.format( defaultValue.getDateValue() ) );
                tb.setEnabled( false );
            } else {
                final PopupDatePicker dp = new PopupDatePicker( false );
                final Date dateValue = defaultValue.getDateValue();
                dp.setValue( dateValue );

                dp.addValueChangeHandler( new ValueChangeHandler<Date>() {

                    public void onValueChange( ValueChangeEvent<Date> event ) {
                        DTCellValue52 clonedDefaultValue = defaultValue.cloneDefaultValueCell();
                        defaultValue.setDateValue( event.getValue() );
                        defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, clonedDefaultValue));
                    }

                } );
                editor = dp;
            }
        } else if ( attributeName.equals( RuleAttributeWidget.DIALECT_ATTR ) ) {
            final ListBox lb = new ListBox();
            lb.addItem( RuleAttributeWidget.DIALECTS[ 0 ] );
            lb.addItem( RuleAttributeWidget.DIALECTS[ 1 ] );
            if ( ac.getDefaultValue() == null ) {
                ac.setDefaultValue( new DTCellValue52( RuleAttributeWidget.DIALECTS[ 1 ] ) );
            }
            final DTCellValue52 defaultValue = ac.getDefaultValue();
            final String stringValue = defaultValue.getStringValue();
            lb.setEnabled( !isReadOnly );
            if ( !isReadOnly ) {
                lb.addChangeHandler( new ChangeHandler() {
                    @Override
                    public void onChange( ChangeEvent event ) {
                        final int selectedIndex = lb.getSelectedIndex();
                        if ( selectedIndex < 0 ) {
                            return;
                        }
                        DTCellValue52 newValue = new DTCellValue52( lb.getValue( selectedIndex ) );
                        ac.setDefaultValue( newValue );
                        defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(newValue, defaultValue));
                    }
                } );
            }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.