Package org.drools.ide.common.client.modeldriven.brl

Examples of org.drools.ide.common.client.modeldriven.brl.DSLVariableValue


        RuleModel model = new RuleModel();

        model.lhs = new IPattern[2];
        DSLSentence dsl0 = new DSLSentence();
        dsl0.setDefinition( "DSL Sentence 0" );
        dsl0.getValues().add( new DSLVariableValue( "dsl0v0" ) );
        dsl0.getValues().add( new DSLVariableValue( "dsl0v1" ) );
        model.lhs[0] = dsl0;
        DSLSentence dsl1 = new DSLSentence();
        dsl1.setDefinition( "DSL Sentence 1" );
        dsl1.getValues().add( new DSLVariableValue( "dsl1v0" ) );
        dsl1.getValues().add( new DSLVariableValue( "dsl1v1" ) );
        model.lhs[1] = dsl1;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.lhs.length );

        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof DSLSentence );
        DSLSentence dsl0Clone = (DSLSentence) clone.lhs[0];
        assertEquals( dsl0.getDefinition(),
                      dsl0Clone.getDefinition() );

        assertEquals( 2,
                      dsl0Clone.getValues().size() );
        assertNotSame( dsl0.getValues().get( 0 ),
                       dsl0Clone.getValues().get( 0 ) );
        assertNotNull( dsl0Clone.getValues().get( 0 ) );
        assertTrue( dsl0Clone.getValues().get( 0 ) instanceof DSLVariableValue );
        DSLVariableValue dsl0v0Clone = (DSLVariableValue) dsl0Clone.getValues().get( 0 );
        assertEquals( dsl0.getValues().get( 0 ).getValue(),
                      dsl0v0Clone.getValue() );

        assertNotSame( dsl0.getValues().get( 1 ),
                       dsl0Clone.getValues().get( 1 ) );
        assertNotNull( dsl0Clone.getValues().get( 1 ) );
        assertTrue( dsl0Clone.getValues().get( 1 ) instanceof DSLVariableValue );
        DSLVariableValue dsl0v1Clone = (DSLVariableValue) dsl0Clone.getValues().get( 1 );
        assertEquals( dsl0.getValues().get( 1 ).getValue(),
                      dsl0v1Clone.getValue() );

        assertNotSame( model.lhs[1],
                       clone.lhs[1] );
        assertNotNull( clone.lhs[1] );
        assertTrue( clone.lhs[1] instanceof DSLSentence );
        DSLSentence dsl1Clone = (DSLSentence) clone.lhs[1];
        assertEquals( dsl1.getDefinition(),
                      dsl1Clone.getDefinition() );

        assertEquals( 2,
                      dsl1Clone.getValues().size() );
        assertNotSame( dsl1.getValues().get( 0 ),
                       dsl0Clone.getValues().get( 0 ) );
        assertNotNull( dsl1Clone.getValues().get( 0 ) );
        assertTrue( dsl1Clone.getValues().get( 0 ) instanceof DSLVariableValue );
        DSLVariableValue dsl1v0Clone = (DSLVariableValue) dsl1Clone.getValues().get( 0 );
        assertEquals( dsl1.getValues().get( 0 ).getValue(),
                      dsl1v0Clone.getValue() );

        assertNotSame( dsl1.getValues().get( 1 ),
                       dsl1Clone.getValues().get( 1 ) );
        assertNotNull( dsl1Clone.getValues().get( 1 ) );
        assertTrue( dsl1Clone.getValues().get( 1 ) instanceof DSLVariableValue );
        DSLVariableValue dsl1v1Clone = (DSLVariableValue) dsl1Clone.getValues().get( 1 );
        assertEquals( dsl1.getValues().get( 1 ).getValue(),
                      dsl1v1Clone.getValue() );
    }
View Full Code Here


        }
        return clone;
    }

    private DSLVariableValue visitDSLVariableValue(DSLVariableValue value) {
        DSLVariableValue clone = new DSLVariableValue();
        clone.setValue( value.getValue() );
        return clone;
    }
View Full Code Here

        for ( Iterator<ModelWidget> iter = widgets.iterator(); iter.hasNext(); ) {
            ModelWidget wid = (ModelWidget) iter.next();
            if ( wid instanceof FieldEditor ) {
                FieldEditor editor = (FieldEditor) wid;
                sentence.getValues().set( iVariable++,
                                          new DSLVariableValue(editor.getText().trim()) );

            } else if ( wid instanceof DSLDropDown ) {
                DSLDropDown drop = (DSLDropDown) wid;
                sentence.getValues().set( iVariable++,
                                          new DSLVariableValue(drop.getSelectedValue()) );

            } else if ( wid instanceof DSLCheckBox ) {
                DSLCheckBox check = (DSLCheckBox) wid;
                sentence.getValues().set( iVariable++,
                                          new DSLVariableValue(check.getCheckedValue().trim()) );

            } else if ( wid instanceof DSLDateSelector ) {
                DSLDateSelector dateSel = (DSLDateSelector) wid;
                String dateString = dateSel.getDateString();
                sentence.getValues().set( iVariable++,
                                          new DSLVariableValue(dateString) );
            }

        }
    }
View Full Code Here

            int endVariable = getIndexForEndOfVariable( dslDefinition,
                                                        startVariable );
            String currVariable = dslDefinition.substring( startVariable + 1,
                                                           endVariable );

            DSLVariableValue value = dslValues.get( index );
            Widget varWidget = processVariable( currVariable,
                                                value );
            lineWidgets.add( varWidget );
            index++;
View Full Code Here

            //if oldVariableValue was of type DSLComplexVariableValue, then return a
            //copy of it with only the 'value' part modified
            if (oldVariableValue instanceof DSLComplexVariableValue){
                return new DSLComplexVariableValue(((DSLComplexVariableValue)oldVariableValue).getId(),box.getText());
            }
            return new DSLVariableValue(box.getText());
        }
View Full Code Here

                public void valueChanged(String newText,
                                         String newValue) {

                    makeDirty();
                    selectedValue = new DSLVariableValue(newValue);

                    //When the value changes we need to reset the content of *ALL* DSLSentenceWidget drop-downs.
                    //An improvement would be to determine the chain of dependent drop-downs and only update
                    //children of the one whose value changes. However in reality DSLSentences only contain
                    //a couple of drop-downs so it's quicker to simply update them all.
View Full Code Here

        }

        public DSLVariableValue getSelectedValue() {
            int selectedIndex = resultWidget.getSelectedIndex();
            if ( selectedIndex != -1 ) {
                return new DSLVariableValue(resultWidget.getValue( selectedIndex ));
            } else {
                return new DSLVariableValue("");
            }
        }
View Full Code Here

            initWidget( hp );
        }

        public DSLVariableValue getSelectedValue() {
            String value = this.resultWidget.getSelectedIndex() == 0 ? "true" : "false";
            return new DSLVariableValue(value);
        }
View Full Code Here

            hp.add( new HTML( "&nbsp;" ) );
            initWidget( hp );
        }

        public DSLVariableValue getSelectedValue() {
            return new DSLVariableValue(resultWidget.getDateString());
        }
View Full Code Here

            int endVariable = getIndexForEndOfVariable( dslDefinition,
                                                        startVariable );
            String currVariable = dslDefinition.substring( startVariable + 1,
                                                           endVariable );

            DSLVariableValue value = dslValues.get( index );
            Widget varWidget = processVariable( currVariable,
                                                value );
            lineWidgets.add( varWidget );
            index++;
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.brl.DSLVariableValue

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.