Package org.drools.workbench.models.commons.shared.oracle

Examples of org.drools.workbench.models.commons.shared.oracle.PackageDataModelOracle


    /**
     * Pops up the fact selector.
     */
    protected void showRightPatternSelector( final Widget w ) {
        final ListBox box = new ListBox();
        PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
        String[] facts = completions.getFactTypes();

        box.addItem( Constants.INSTANCE.Choose() );
        for ( int i = 0; i < facts.length; i++ ) {
            box.addItem( facts[ i ] );
        }
View Full Code Here


    /**
     * Pops up the fact selector.
     */
    protected void showFactTypeSelector( final Widget w ) {
        PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
        final ListBox box = new ListBox();
        String[] facts = completions.getFactTypes();

        box.addItem( Constants.INSTANCE.Choose() );

        for ( int i = 0; i < facts.length; i++ ) {
            box.addItem( facts[ i ] );
View Full Code Here

        this.model = set;
        this.layout = new DirtyableFlexTable();

        layout.setStyleName( "model-builderInner-Background" ); // NON-NLS

        PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
        if ( completions.isGlobalVariable( set.getVariable() ) ) {

            List<MethodInfo> infos = completions.getMethodInfosForGlobalVariable( set.getVariable() );
            if ( infos != null ) {
                this.fieldCompletionTexts = new String[ infos.size() ];
                this.fieldCompletionValues = new String[ infos.size() ];
                int i = 0;
                for ( MethodInfo info : infos ) {
                    this.fieldCompletionTexts[ i ] = info.getName();
                    this.fieldCompletionValues[ i ] = info.getNameWithParameters();
                    i++;
                }

                this.variableClass = completions.getGlobalVariable( set.getVariable() );

            } else {
                this.fieldCompletionTexts = new String[ 0 ];
                this.fieldCompletionValues = new String[ 0 ];
                readOnly = true;
            }

        } else {

            FactPattern pattern = mod.getModel().getLHSBoundFact( set.getVariable() );
            if ( pattern != null ) {
                List<String> methodList = completions.getMethodNames( pattern.getFactType() );
                fieldCompletionTexts = new String[ methodList.size() ];
                fieldCompletionValues = new String[ methodList.size() ];
                int i = 0;
                for ( String methodName : methodList ) {
                    fieldCompletionTexts[ i ] = methodName;
                    fieldCompletionValues[ i ] = methodName;
                    i++;
                }
                this.variableClass = pattern.getFactType();
                this.isBoundFact = true;

            } else {
                /*
                 * if the call method is applied on a bound variable created in
                 * the rhs
                 */
                ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact( set.getVariable() );
                if ( patternRhs != null ) {
                    List<String> methodList = completions.getMethodNames( patternRhs.getFactType() );
                    fieldCompletionTexts = new String[ methodList.size() ];
                    fieldCompletionValues = new String[ methodList.size() ];
                    int i = 0;
                    for ( String methodName : methodList ) {
                        fieldCompletionTexts[ i ] = methodName;
                        fieldCompletionValues[ i ] = methodName;
                        i++;
                    }
                    this.variableClass = patternRhs.getFactType();
                    this.isBoundFact = true;
                } else {
                    readOnly = true;
                }
            }
        }

        this.isFactTypeKnown = completions.isFactTypeRecognized( this.variableClass );
        if ( readOnly == null ) {
            this.readOnly = !this.isFactTypeKnown;
        } else {
            this.readOnly = readOnly;
        }
View Full Code Here

        return horiz;
    }

    protected void showAddFieldPopup( Widget w ) {

        final PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();

        final FormStylePopup popup = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                         Constants.INSTANCE.ChooseAMethodToInvoke() );
        final ListBox box = new ListBox();
        box.addItem( "..." );

        for ( int i = 0; i < fieldCompletionTexts.length; i++ ) {
            box.addItem( fieldCompletionTexts[ i ],
                         fieldCompletionValues[ i ] );
        }

        box.setSelectedIndex( 0 );

        popup.addAttribute( Constants.INSTANCE.ChooseAMethodToInvoke(),
                            box );
        box.addChangeHandler( new ChangeHandler() {

            public void onChange( ChangeEvent event ) {
                model.setState( ActionCallMethod.TYPE_DEFINED );

                String methodName = box.getItemText( box.getSelectedIndex() );
                String methodNameWithParams = box.getValue( box.getSelectedIndex() );

                model.setMethodName( methodName );
                List<String> fieldList = new ArrayList<String>();

                fieldList.addAll( completions.getMethodParams( variableClass,
                                                               methodNameWithParams ) );

                int i = 0;
                for ( String fieldParameter : fieldList ) {
                    model.addFieldValue( new ActionFieldFunction( methodName,
View Full Code Here

    }

    private Widget valueEditor( final ActionFieldFunction val ) {

        PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();

        String type = "";
        if ( completions.isGlobalVariable( this.model.getVariable() ) ) {
            type = completions.getGlobalVariable( this.model.getVariable() );
        } else {
            type = this.getModeller().getModel().getLHSBindingType( this.model.getVariable() );
            if ( type == null ) {
                type = this.getModeller().getModel().getRHSBoundFact( this.model.getVariable() ).getFactType();
            }
        }

        DropDownData enums = completions.getEnums( type,
                                                   val.getField(),
                                                   FieldNatureUtil.toMap( this.model.getFieldValues() ) );

        return new MethodParameterValueEditor( val,
                                               enums,
View Full Code Here

    @Override
    public DrlModelContent loadContent( final Path path ) {
        try {
            final String drl = load( path );
            final PackageDataModelOracle oracle = dataModelService.getDataModel( path );

            return new DrlModelContent( drl,
                                        oracle );

        } catch ( Exception e ) {
View Full Code Here

    @Override
    public GuidedEditorContent loadContent( final Path path ) {
        try {
            final RuleModel model = load( path );
            final PackageDataModelOracle oracle = dataModelService.getDataModel( path );
            return new GuidedEditorContent( oracle,
                                            model );

        } catch ( Exception e ) {
            throw ExceptionUtilities.handleException( e );
View Full Code Here

        assertTrue( xml.indexOf( "Accident" ) > -1 );
        assertTrue( xml.indexOf( "no-loop" ) > -1 );
        assertTrue( xml.indexOf( "org.kie" ) == -1 );
        assertTrue( xml.indexOf( "addToGlobal" ) > -1 );

        PackageDataModelOracle dmo = mock(PackageDataModelOracle.class);
        RuleModel rm_ = BRXMLPersistence.getInstance().unmarshal( xml, dmo );
        assertEquals( 2,
                      rm_.rhs.length );

    }
View Full Code Here

    public void testRoundTrip() {
        final RuleModel m = getComplexModel();

        final String xml = BRXMLPersistence.getInstance().marshal( m );

        PackageDataModelOracle dmo = mock(PackageDataModelOracle.class);
        final RuleModel m2 = BRXMLPersistence.getInstance().unmarshal( xml, dmo );
        assertNotNull( m2 );
        assertEquals( m.name,
                      m2.name );
        assertEquals( m.lhs.length,
View Full Code Here

        m.addRhsItem( ass );

        String xml = BRXMLPersistence.getInstance().marshal( m );
        //System.err.println(xml);

        PackageDataModelOracle dmo = mock(PackageDataModelOracle.class);
        RuleModel m2 = BRXMLPersistence.getInstance().unmarshal( xml, dmo );
        assertNotNull( m2 );
        assertEquals( "with composite",
                      m2.name );
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.commons.shared.oracle.PackageDataModelOracle

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.