Package org.drools.guvnor.client.common

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


        } else {
            this.readOnly = readOnly;
            this.isFactTypeKnown = true;
        }

        this.layout = new DirtyableFlexTable();
        if ( this.readOnly ) {
            this.layout.addStyleName( "editor-disabled-widget" );
        }
        this.layout.addStyleName( "model-builderInner-Background" );
View Full Code Here


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

        DirtyableFlexTable panel = new DirtyableFlexTable();

        int r = 0;

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

        panel.setWidget( r,
                         0,
                         new HTML( lbl ) );
        ExpressionBuilder expressionBuilder = new ExpressionBuilder( this.getModeller(),
                                                                     this.getEventBus(),
                                                                     this.pattern.getExpression(),
                                                                     this.readOnly );
        expressionBuilder.addOnModifiedCommand( new Command() {
            public void execute() {
                setModified( true );
            }
        } );
        panel.setWidget( r,
                         1,
                         expressionBuilder );

        return panel;
    }
View Full Code Here

     * @param sortedConst
     *            a sorted list of constraints to display.
     */
    private void drawConstraints(List<FieldConstraint> sortedConst,
                                 HasConstraints hasConstraints) {
        final DirtyableFlexTable table = new DirtyableFlexTable();
        layout.setWidget( 1,
                          0,
                          table );
        List<FieldConstraint> parents = new ArrayList<FieldConstraint>();

        for ( int i = 0; i < sortedConst.size(); i++ ) {
            traverseSingleFieldConstraints( sortedConst,
                                            table,
                                            parents,
                                            hasConstraints,
                                            i );

            //now the clear icon
            final int currentRow = i;
            Image clear = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
            clear.setTitle( Constants.INSTANCE.RemoveThisWholeRestriction() );
            clear.addClickHandler( createClickHandlerForClearImageButton( currentRow ) );

            if ( !this.readOnly ) {
                //This used to be 5 and Connectives were not rendered
                table.setWidget( currentRow,
                                 6,
                                 clear );
            }

        }
View Full Code Here

        t.getFlexCellFormatter().setColSpan( 0,
                                             0,
                                             2 );

        FieldConstraint[] nested = constraint.constraints;
        DirtyableFlexTable inner = new DirtyableFlexTable();
        if ( nested != null ) {
            for ( int i = 0; i < nested.length; i++ ) {
                this.renderFieldConstraint( inner,
                                            i,
                                            nested[i],
                                            constraint,
                                            true,
                                            0 );
                //add in remove icon here...
                final int currentRow = i;
                Image clear = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
                clear.setTitle( Constants.INSTANCE.RemoveThisNestedRestriction() );
                clear.addClickHandler( new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        if ( Window.confirm( Constants.INSTANCE.RemoveThisItemFromNestedConstraint() ) ) {
                            setModified( true );
                            constraint.removeConstraint( currentRow );
                            getModeller().refreshWidget();
                        }
                    }
                } );
                if ( !this.readOnly ) {
                    //This used to be 5 and Connectives were not rendered
                    inner.setWidget( i,
                                     6,
                                     clear );
                }
            }
        }
View Full Code Here

            }
        };

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

        DirtyableFlexTable panel = new DirtyableFlexTable();

        int r = 0;

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

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

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

            RuleModellerWidget patternWidget = null;
            if ( rPattern instanceof FactPattern ) {
                patternWidget = new FactPatternWidget( this.getModeller(),
                                                       this.getEventBus(),
                                                       rPattern,
                                                       true,
                                                       true,
                                                       this.readOnly );

            } else if ( rPattern instanceof FromAccumulateCompositeFactPattern ) {
                patternWidget = new FromAccumulateCompositeFactPatternWidget( this.getModeller(),
                                                                              this.getEventBus(),
                                                                              (FromAccumulateCompositeFactPattern) rPattern,
                                                                              this.readOnly );

            } else if ( rPattern instanceof FromCollectCompositeFactPattern ) {
                patternWidget = new FromCollectCompositeFactPatternWidget( this.getModeller(),
                                                                           this.getEventBus(),
                                                                           (FromCollectCompositeFactPattern) rPattern,
                                                                           this.readOnly );

            } else if ( rPattern instanceof FromEntryPointFactPattern ) {
                patternWidget = new FromEntryPointFactPatternWidget( this.getModeller(),
                                                                     this.getEventBus(),
                                                                     (FromEntryPointFactPattern) rPattern,
                                                                     this.readOnly );

            } else if ( rPattern instanceof FromCompositeFactPattern ) {
                patternWidget = new FromCompositeFactPatternWidget( this.getModeller(),
                                                                    this.getEventBus(),
                                                                    (FromCompositeFactPattern) rPattern,
                                                                    this.readOnly );

            } else if ( rPattern instanceof FreeFormLine ) {
                patternWidget = new FreeFormLineWidget( this.getModeller(),
                                                        this.getEventBus(),
                                                        (FreeFormLine) rPattern,
                                                        this.readOnly );
            } else {
                throw new IllegalArgumentException( "Unsuported pattern " + rPattern + " for right side of FROM COLLECT" );
            }

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

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

                                                  public void onClick(ClickEvent event) {
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( DroolsGuvnorImageResources.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( DroolsGuvnorImageResources.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 = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
            del.setAltText(Constants.INSTANCE.RemoveThisRuleExpectation());
            del.setTitle(Constants.INSTANCE.RemoveThisRuleExpectation());
            del.addClickHandler(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

            layout.add(disclosurePanel);
            dtableContainer.setPixelSize(1000, 200);
            layout.add(dtableContainer);

            for (Characteristic characteristic : scorecardModel.getCharacteristics()) {
                DirtyableFlexTable flexTable = addCharacteristic(characteristic);
                for (Attribute attribute : characteristic.getAttributes()) {
                    addAttribute(flexTable, attribute);
                }
            }
            initWidget(layout);
View Full Code Here

            }
        }
    }

    private DirtyableFlexTable addCharacteristic(final Characteristic characteristic) {
        final DirtyableFlexTable cGrid = new DirtyableFlexTable();
        cGrid.setBorderWidth(0);
        cGrid.setCellPadding(1);
        cGrid.setCellSpacing(1);

        cGrid.setStyleName("rule-ListHeader");

        Button btnAddAttribute = new Button("Add Attribute", new ClickHandler() {
            public void onClick(ClickEvent event) {
                addAttribute(cGrid, null);
            }
        });

        Button btnRemoveCharacteristic = new Button("Remove Characteristic", new ClickHandler() {
            public void onClick(ClickEvent event) {
                removeCharacteristic(cGrid);
            }
        });

        String selectedFact = "";
        if (characteristic != null) {
            selectedFact = characteristic.getFact();
            if (selectedFact.lastIndexOf(".") > -1) {
                selectedFact = selectedFact.substring(selectedFact.lastIndexOf(".")+1);
            }
        }
        final EnumDropDown dropDownFields = new EnumDropDown("",
                new DropDownValueChanged() {
                    public void valueChanged(String newText,
                                             String newValue) {
                        //do nothing
                    }
                }, DropDownData.create(new String[]{}));

        EnumDropDown dropDownFacts = new EnumDropDown(selectedFact,
                new DropDownValueChanged() {
                    public void valueChanged(String newText, String newValue) {
                        String selectedField = "";
                        if (characteristic != null) {
                            selectedField = characteristic.getField();
                            selectedField = selectedField+" : "+characteristic.getDataType();
                        }
                        dropDownFields.setDropDownData(selectedField, DropDownData.create(getEligibleFields(newValue, typesForAttributes)));
                        //dropDownFields.setSelectedIndex(0);
                    }
                }, DropDownData.create(sce.getFactTypes()));

        DropDownData dropDownData = DropDownData.create(getEligibleFields(selectedFact, typesForAttributes));
        dropDownFields.setDropDownData("", dropDownData);

        cGrid.setWidget(0, 0, new Label("Name"));
        final TextBox tbName = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_STRING);
        cGrid.setWidget(0, 1, tbName);
        cGrid.setWidget(0, 2, btnRemoveCharacteristic);
        cGrid.setWidget(0, 3, btnAddAttribute);

        cGrid.setWidget(1, 0, new Label("Fact"));
        cGrid.setWidget(1, 1, new Label("Characteristic"));
        cGrid.setWidget(1, 2, new Label("Baseline Score"));
        cGrid.setWidget(1, 3, new Label("Reason Code"));

        cGrid.setWidget(2, 0, dropDownFacts);
        cGrid.setWidget(2, 1, dropDownFields);

        TextBox tbBaseline = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_NUMERIC_DOUBLE);
        boolean useReasonCodesValue = "true".equalsIgnoreCase(ddUseReasonCode.getValue(ddUseReasonCode.getSelectedIndex()));
        tbBaseline.setEnabled(useReasonCodesValue);
        cGrid.setWidget(2, 2, tbBaseline);

        TextBox tbReasonCode = TextBoxFactory.getTextBox(SuggestionCompletionEngine.TYPE_STRING);
        tbReasonCode.setEnabled(useReasonCodesValue);
        cGrid.setWidget(2, 3, tbReasonCode);

        SimplePanel gapPanel = new SimplePanel();
        gapPanel.add(new HTML("<br/>"));

        VerticalPanel panel = new VerticalPanel();
        panel.add(cGrid);
        panel.add(addAttributeCellTable(cGrid, characteristic));
        panel.setWidth("100%");
        DecoratorPanel decoratorPanel = new DecoratorPanel();
        decoratorPanel.add(panel);
        characteristicsPanel.add(decoratorPanel);
        characteristicsPanel.add(gapPanel);

        characteristicsTables.add(cGrid);

        cGrid.getColumnFormatter().setWidth(0, "150px");
        cGrid.getColumnFormatter().setWidth(1, "250px");
        cGrid.getColumnFormatter().setWidth(2, "150px");
        cGrid.getColumnFormatter().setWidth(3, "150px");

        if (characteristic != null) {
            tbReasonCode.setValue(characteristic.getReasonCode());
            tbBaseline.setValue("" + characteristic.getBaselineScore());
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.