Package org.drools.guvnor.client.common

Examples of org.drools.guvnor.client.common.DirtyableFlexTable


                          new HTML( "    " ) );
        layout.getFlexCellFormatter().setColSpan( 0,
                                                  0,
                                                  2 );

        DirtyableFlexTable inner = new DirtyableFlexTable();
        int col = 0;

        for ( int i = 0; i < model.fieldValues.length; i++ ) {
            ActionFieldValue val = model.fieldValues[i];

            inner.setWidget( i,
                             0 + col,
                             fieldSelector( val ) );
            inner.setWidget( i,
                             1 + col,
                             valueEditor( val ) );
            final int idx = i;
            Image remove = new ImageButton( DroolsGuvnorImages.INSTANCE.deleteItemSmall() );
            remove.addClickHandler( new ClickHandler() {
                public void onClick(ClickEvent event) {
                    if ( Window.confirm( Constants.INSTANCE.RemoveThisItem() ) ) {
                        model.removeField( idx );
                        setModified( true );
                        getModeller().refreshWidget();

                        //Signal possible change in Template variables
                        TemplateVariablesChangedEvent tvce = new TemplateVariablesChangedEvent( getModeller().getModel() );
                        getEventBus().fireEventFromSource( tvce,
                                                           getModeller().getModel() );
                    }
                }
            } );
            if ( !this.readOnly ) {
                inner.setWidget( i,
                                 2 + col,
                                 remove );
            }

        }
View Full Code Here


                                ActionSetField set,
                                Boolean readOnly) {
        super( mod,
               eventBus );
        this.model = set;
        this.layout = new DirtyableFlexTable();

        layout.setStyleName( "model-builderInner-Background" );

        SuggestionCompletionEngine completions = this.getModeller().getSuggestionCompletions();
View Full Code Here

        this.configuration = configuration;
        doLayout();
    }

    protected void doLayout() {
        layout = new DirtyableFlexTable();

        initWidget();

        layout.setStyleName( "model-builder-Background" );
        initWidget( layout );
View Full Code Here

        if ( this.layout.getWidgetCount() == 2 ) {
            this.layout.remove( 1 );
        }

        DirtyableFlexTable editorLayout = scenarioWidgetComponentCreator.createDirtyableFlexTable();
        this.layout.add( editorLayout );
        ScenarioHelper scenarioHelper = new ScenarioHelper();

        List<Fixture> fixtures = scenarioHelper.lumpyMap( getScenario().getFixtures() );
        List<ExecutionTrace> listExecutionTrace = scenarioHelper.getExecutionTraceFor( fixtures );

        int layoutRow = 1;
        int executionTraceLine = 0;
        ExecutionTrace previousExecutionTrace = null;
        for ( final Fixture fixture : fixtures ) {
            if ( fixture instanceof ExecutionTrace ) {
                ExecutionTrace currentExecutionTrace = (ExecutionTrace) fixture;
                createWidgetForEditorLayout( editorLayout,
                                             layoutRow,
                                             0,
                                             scenarioWidgetComponentCreator.createExpectPanel( currentExecutionTrace ) );

                executionTraceLine++;
                if ( executionTraceLine >= listExecutionTrace.size() ) {
                    executionTraceLine = listExecutionTrace.size() - 1;
                }
                createWidgetForEditorLayout( editorLayout,
                                             layoutRow,
                                             1,
                                             scenarioWidgetComponentCreator.createExecutionWidget( currentExecutionTrace ) );
                editorLayout.setHorizontalAlignmentForFlexCellFormatter( layoutRow,
                                                                         2,
                                                                         HasHorizontalAlignment.ALIGN_LEFT );

                previousExecutionTrace = currentExecutionTrace;
View Full Code Here

                                     Scenario scenario,
                                     SuggestionCompletionEngine suggestionCompletionEngine,
                                     final ScenarioParentWidget parent,
                                     ExecutionTrace executionTrace) {

        widget = new DirtyableFlexTable();

        widget.setStyleName(DroolsGuvnorResources.INSTANCE.droolsGuvnorCss().greyBorderWithRoundCorners());
        new FactDataWidgetFactory(
                scenario,
                suggestionCompletionEngine,
View Full Code Here

        super( modeller,
               eventBus );
        this.completions = modeller.getSuggestionCompletions();
        this.pattern = pattern;

        this.layout = new DirtyableFlexTable();
        this.layout.setStyleName( "model-builderInner-Background" );

        if ( readOnly != null ) {
            this.readOnly = readOnly;
            this.isFactTypeKnown = true;
View Full Code Here

        this.scenario = scenario;
        this.mCall = mCall;
        this.executionTrace = executionTrace;
        this.suggestionCompletionEngine = parent.suggestionCompletionEngine;

        this.layout = new DirtyableFlexTable();

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

        if ( suggestionCompletionEngine.isGlobalVariable( mCall.getVariable() ) ) {
View Full Code Here

    private void doLayout() {
        layout.clear();
        layout.setWidget( 0,
                          0,
                          getSetterLabel() );
        DirtyableFlexTable inner = new DirtyableFlexTable();
        for ( int i = 0; i < mCall.getCallFieldValues().length; i++ ) {
            CallFieldValue val = mCall.getCallFieldValues()[i];

            inner.setWidget( i,
                             0,
                             fieldSelector( val ) );
            inner.setWidget( i,
                             1,
                             valueEditor( val ) );

        }
        layout.setWidget( 0,
View Full Code Here

                         data );
    }

    private FlexTable render(final FixtureList rfl,
                             final Scenario sc) {
        FlexTable data = new DirtyableFlexTable();

        for ( int i = 0; i < rfl.size(); i++ ) {
            final VerifyRuleFired v = (VerifyRuleFired) rfl.get( i );

            if ( showResults && v.getSuccessResult() != null ) {
                if ( !v.getSuccessResult().booleanValue() ) {
                    data.setWidget( i,
                                    0,
                                    new Image( DroolsGuvnorImages.INSTANCE.warning() ) );
                    data.setWidget( i,
                                    4,
                                    new HTML( Constants.INSTANCE.ActualResult(v.getActualResult().toString()) ) );

                    data.getCellFormatter().addStyleName( i,
                                                          4,
                                                          "testErrorValue" ); //NON-NLS

                } else {
                    data.setWidget( i,
                                    0,
                                    new Image( DroolsGuvnorImages.INSTANCE.testPassed() ) );
                }

            }
            data.setWidget( i,
                            1,
                            new SmallLabel( v.getRuleName() + ":" ) );
            data.getFlexCellFormatter().setAlignment( i,
                                                      1,
                                                      HasHorizontalAlignment.ALIGN_RIGHT,
                                                      HasVerticalAlignment.ALIGN_MIDDLE );

            final ListBox b = new ListBox();
            b.addItem( Constants.INSTANCE.firedAtLeastOnce(),
                       "y" );
            b.addItem( Constants.INSTANCE.didNotFire(),
                       "n" );
            b.addItem( Constants.INSTANCE.firedThisManyTimes(),
                       "e" );
            final TextBox num = new TextBox();
            num.setVisibleLength( 5 );

            if ( v.getExpectedFire() != null ) {
                b.setSelectedIndex( (v.getExpectedFire().booleanValue()) ? 0 : 1 );
                num.setVisible( false );
            } else {
                b.setSelectedIndex( 2 );
                String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
                num.setText( xc );
            }

            b.addChangeHandler( new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    String s = b.getValue( b.getSelectedIndex() );
                    if ( s.equals( "y" ) || s.equals( "n" ) ) {
                        num.setVisible( false );
                        v.setExpectedFire( (s.equals( "y" )) ? Boolean.TRUE : Boolean.FALSE );
                        v.setExpectedCount( null );
                    } else {
                        num.setVisible( true );
                        v.setExpectedFire( null );
                        num.setText( "1" );
                        v.setExpectedCount( new Integer( 1 ) );
                    }
                }
            } );

            b.addItem( Constants.INSTANCE.ChooseDotDotDot() );

            num.addChangeHandler( new ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    v.setExpectedCount( new Integer( num.getText() ) );
                }
            } );

            HorizontalPanel h = new HorizontalPanel();
            h.add( b );
            h.add( num );
            data.setWidget( i,
                            2,
                            h );

            Image del = new ImageButton( DroolsGuvnorImages.INSTANCE.deleteItemSmall(),
                                         Constants.INSTANCE.RemoveThisRuleExpectation(),
                                         new ClickHandler() {
                                             public void onClick(ClickEvent w) {
                                                 if ( Window.confirm( Constants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation() ) ) {
                                                     rfl.remove( v );
                                                     sc.removeFixture( v );
                                                     outer.setWidget( 1,
                                                                      0,
                                                                      render( rfl,
                                                                              sc ) );
                                                 }
                                             }
                                         } );

            data.setWidget( i,
                            3,
                            del );

            //we only want numbers here...
            num.addKeyPressHandler( new KeyPressHandler() {
View Full Code Here

            }
        };

        String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName( "from accumulate" ) + "</div>";

        DirtyableFlexTable panel = new DirtyableFlexTable();

        int r = 0;

        if ( pattern.getFactPattern() == null ) {
            panel.setWidget( r++,
                             0,
                             new ClickableLabel( "<br> <font color='red'>" + Constants.INSTANCE.clickToAddPattern() + "</font>",
                                                 leftPatternclick,
                                                 !this.readOnly ) );
        }

        panel.setWidget( r++,
                         0,
                         new HTML( lbl ) );

        if ( this.getFromAccumulatePattern().getSourcePattern() == null ) {
            panel.setWidget( r++,
                             0,
                             new ClickableLabel( "<br> <font color='red'>" + Constants.INSTANCE.clickToAddPattern() + "</font>",
                                                 sourcePatternClick,
                                                 !this.readOnly ) );
        } else {
            IPattern rPattern = this.getFromAccumulatePattern()
                    .getSourcePattern();

            RuleModellerWidget sourcePatternWidget;
            if ( rPattern instanceof FactPattern ) {
                sourcePatternWidget = new FactPatternWidget(
                                                             this.getModeller(),
                                                             getEventBus(),
                                                             rPattern,
                                                             true,
                                                             true,
                                                             this.readOnly );
            } else if ( rPattern instanceof FromAccumulateCompositeFactPattern ) {
                sourcePatternWidget = new FromAccumulateCompositeFactPatternWidget( this.getModeller(),
                                                                                    this.getEventBus(),
                                                                                    (FromAccumulateCompositeFactPattern) rPattern,
                                                                                    this.readOnly );
            } else if ( rPattern instanceof FromCollectCompositeFactPattern ) {
                sourcePatternWidget = new FromCollectCompositeFactPatternWidget( this.getModeller(),
                                                                                 this.getEventBus(),
                                                                                 (FromCollectCompositeFactPattern) rPattern,
                                                                                 this.readOnly );
            } else if ( rPattern instanceof FromCompositeFactPattern ) {
                sourcePatternWidget = new FromCompositeFactPatternWidget(
                                                                          this.getModeller(),
                                                                          this.getEventBus(),
                                                                          (FromCompositeFactPattern) rPattern,
                                                                          this.readOnly );
            } else {
                throw new IllegalArgumentException( "Unsupported pattern "
                                                    + rPattern + " for right side of FROM ACCUMULATE" );
            }

            sourcePatternWidget.addOnModifiedCommand( new Command() {
                public void execute() {
                    setModified( true );
                }
            } );

            panel.setWidget(
                             r++,
                             0,
                             addRemoveButton( sourcePatternWidget,
                                              new ClickHandler() {

                                                  public void onClick(ClickEvent event) {
                                                      if ( Window.confirm( Constants.INSTANCE
                                                              .RemoveThisBlockOfData() ) ) {
                                                          setModified( true );
                                                          getFromAccumulatePattern()
                                                                  .setSourcePattern( null );
                                                          getModeller().refreshWidget();
                                                      }

                                                  }
                                              } ) );
        }

        //REVISIT: Nested TabLayoutPanel does not work, its content is truncated.
        //TabLayoutPanel tPanel = new TabLayoutPanel(2, Unit.EM);
        TabPanel tPanel = new TabPanel();

        DirtyableFlexTable codeTable = new DirtyableFlexTable();
        int codeTableRow = 0;
        int codeTableCol = 0;

        codeTable.setWidget( codeTableRow,
                             codeTableCol++,
                             new HTML( "<div class='form-field'>Init:</div>" ) );

        final TextBox initField = new TextBox();
        initField.setTitle( "init code" );
        initField.setText( getFromAccumulatePattern().getInitCode() );
        initField.setEnabled( !this.readOnly );
        codeTable.setWidget( codeTableRow++,
                             codeTableCol--,
                             initField );

        codeTable.setWidget( codeTableRow,
                             codeTableCol++,
                             new HTML( "<div class='form-field'>Action:</div>" ) );
        final TextBox actionField = new TextBox();
        actionField.setTitle( "action code" );
        actionField.setText( getFromAccumulatePattern().getActionCode() );
        actionField.setEnabled( !this.readOnly );
        codeTable.setWidget( codeTableRow++,
                             codeTableCol--,
                             actionField );

        codeTable.setWidget( codeTableRow,
                             codeTableCol++,
                             new HTML( "<div class='form-field'>Reverse:</div>" ) );
        final TextBox reverseField = new TextBox();
        reverseField.setTitle( "reverse code." );
        reverseField.setText( getFromAccumulatePattern().getReverseCode() );
        reverseField.setEnabled( !this.readOnly );
        codeTable.setWidget( codeTableRow++,
                             codeTableCol--,
                             reverseField );

        codeTable.setWidget( codeTableRow,
                             codeTableCol++,
                             new HTML( "<div class='form-field'>Result:</div>" ) );
        final TextBox resultField = new TextBox();
        resultField.setTitle( "result code" );
        resultField.setText( getFromAccumulatePattern().getResultCode() );
        resultField.setEnabled( !this.readOnly );
        codeTable.setWidget( codeTableRow++,
                             codeTableCol--,
                             resultField );

        //panel.setWidget(r++, 0, codeTable);
        ScrollPanel codePanel = new ScrollPanel();
        codePanel.add( codeTable );

        tPanel.add( codePanel,
                    "Custom Code" );

        DirtyableFlexTable functionTable = new DirtyableFlexTable();

        functionTable.setWidget( 0,
                                 0,
                                 new HTML( "<div class='form-field'>Function:</div>" ) );
        final TextBox functionField = new TextBox();
        functionField.setTitle( "function code" );
        functionField.setText( getFromAccumulatePattern().getFunction() );
        functionField.setEnabled( !this.readOnly );
        functionTable.setWidget( 0,
                                 1,
                                 functionField );

        //        panel.setWidget(r++, 0, functionTable);
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.common.DirtyableFlexTable

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.