Package org.uberfire.client.common

Examples of org.uberfire.client.common.FormStylePopup


        } );
        return clickme;
    }

    protected void showTypeChoice( Widget w ) {
        final FormStylePopup form = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                        Constants.INSTANCE.FieldValue() );
        Button lit = new Button( Constants.INSTANCE.LiteralValue() );
        lit.addClickHandler( new ClickHandler() {

            public void onClick( ClickEvent event ) {
                methodParameter.setNature( FieldNatureType.TYPE_LITERAL );
                methodParameter.setValue( " " );
                makeDirty();
                refresh();
                form.hide();
            }

        } );

        form.addAttribute( Constants.INSTANCE.LiteralValue() + ":",
                           widgets( lit,
                                    new InfoPopup( Constants.INSTANCE.Literal(),
                                                   Constants.INSTANCE.LiteralValTip() ) ) );
        form.addRow( new HTML( "<hr/>" ) );
        form.addRow( new SmallLabel( Constants.INSTANCE.AdvancedSection() ) );

        /*
         * If there is a bound variable that is the same type of the current
         * variable type, then show abutton
         */
        List<String> vars = model.getModel().getLHSBoundFacts();
        List<String> vars2 = model.getModel().getRHSBoundFacts();
        for ( String i : vars2 ) {
            vars.add( i );
        }
        for ( String v : vars ) {
            boolean createButton = false;
            Button variable = new Button( Constants.INSTANCE.BoundVariable() );
            if ( vars2.contains( v ) == false ) {
                FactPattern factPattern = model.getModel().getLHSBoundFact( v );
                if ( factPattern.getFactType().equals( this.parameterType ) ) {
                    createButton = true;
                }
            } else {
                ActionInsertFact factPattern = model.getModel().getRHSBoundFact( v );
                if ( factPattern.getFactType().equals( this.parameterType ) ) {
                    createButton = true;
                }
            }
            if ( createButton == true ) {
                form.addAttribute( Constants.INSTANCE.BoundVariable() + ":",
                                   variable );
                variable.addClickHandler( new ClickHandler() {

                    public void onClick( ClickEvent event ) {
                        methodParameter.setNature( FieldNatureType.TYPE_VARIABLE );
                        methodParameter.setValue( "=" );
                        makeDirty();
                        refresh();
                        form.hide();
                    }

                } );
                break;
            }

        }

        form.show();
    }
View Full Code Here


                                   !this.readOnly );//HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" + model.variable + "]</b>", clk);
    }

    protected void showAddFieldPopup( ClickEvent w ) {
        final PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
        final FormStylePopup popup = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                         Constants.INSTANCE.AddAField() );

        final ListBox box = new ListBox();
        box.addItem( "..." );

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

        box.setSelectedIndex( 0 );

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

            public void onChange( ChangeEvent event ) {
                String fieldName = box.getItemText( box.getSelectedIndex() );

                String fieldType = completions.getFieldType( variableClass,
                                                             fieldName );
                model.addFieldValue( new ActionFieldValue( fieldName,
                                                           "",
                                                           fieldType ) );
                setModified( true );
                getModeller().refreshWidget();
                popup.hide();
            }
        } );

        popup.show();

    }
View Full Code Here

            customFormPopUp.show( sfc.getId(),
                                  sfc.getValue() );
            return;
        }

        final FormStylePopup form = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                        Constants.INSTANCE.FieldValue() );

        Button lit = new Button( Constants.INSTANCE.LiteralValue() );
        lit.addClickHandler( new ClickHandler() {
            public void onClick( ClickEvent event ) {
                con.setConstraintValueType( isDropDownDataEnum && dropDownData != null ? SingleFieldConstraint.TYPE_ENUM : SingleFieldConstraint.TYPE_LITERAL );
                doTypeChosen( form );
            }
        } );

        boolean showLiteralSelector = true;
        boolean showFormulaSelector = !OperatorsOracle.operatorRequiresList( con.getOperator() );
        boolean showVariableSelector = !OperatorsOracle.operatorRequiresList( con.getOperator() );
        boolean showExpressionSelector = !OperatorsOracle.operatorRequiresList( con.getOperator() );

        if ( con instanceof SingleFieldConstraint ) {
            SingleFieldConstraint sfc = (SingleFieldConstraint) con;
            String fieldName = sfc.getFieldName();
            if ( fieldName.equals( DataType.TYPE_THIS ) ) {
                showLiteralSelector = CEPOracle.isCEPOperator( sfc.getOperator() );
                showFormulaSelector = showFormulaSelector && showLiteralSelector;
            }
        } else if ( con instanceof ConnectiveConstraint ) {
            ConnectiveConstraint cc = (ConnectiveConstraint) con;
            String fieldName = cc.getFieldName();
            if ( fieldName.equals( DataType.TYPE_THIS ) ) {
                showLiteralSelector = CEPOracle.isCEPOperator( cc.getOperator() );
                showFormulaSelector = showFormulaSelector && showLiteralSelector;
            }
        }

        //Literal value selector
        if ( showLiteralSelector ) {
            form.addAttribute( Constants.INSTANCE.LiteralValue() + ":",
                               widgets( lit,
                                        new InfoPopup( Constants.INSTANCE.LiteralValue(),
                                                       Constants.INSTANCE.LiteralValTip() ) ) );
        }

        //Template key selector
        if ( modeller.isTemplate() ) {
            String templateKeyLabel = Constants.INSTANCE.TemplateKey();
            Button templateKeyButton = new Button( templateKeyLabel );
            templateKeyButton.addClickHandler( new ClickHandler() {

                public void onClick( ClickEvent event ) {
                    con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_TEMPLATE );
                    doTypeChosen( form );
                }
            } );

            form.addAttribute( templateKeyLabel + ":",
                               widgets( templateKeyButton,
                                        new InfoPopup( templateKeyLabel,
                                                       Constants.INSTANCE.LiteralValTip() ) ) );
        }

        //Divider, if we have any advanced options
        if ( showVariableSelector || showFormulaSelector || showExpressionSelector ) {
            form.addRow( new HTML( "<hr/>" ) );
            form.addRow( new SmallLabel( Constants.INSTANCE.AdvancedOptions() ) );
        }

        //Show variables selector, if there are any variables in scope
        if ( showVariableSelector ) {
            List<String> bindingsInScope = this.model.getBoundVariablesInScope( this.constraint );
            if ( bindingsInScope.size() > 0
                    || DataType.TYPE_COLLECTION.equals( this.fieldType ) ) {

                List<String> applicableBindingsInScope = getApplicableBindingsInScope( bindingsInScope );
                if ( applicableBindingsInScope.size() > 0 ) {

                    Button variable = new Button( Constants.INSTANCE.BoundVariable() );
                    variable.addClickHandler( new ClickHandler() {

                        public void onClick( ClickEvent event ) {
                            con.setConstraintValueType( SingleFieldConstraint.TYPE_VARIABLE );
                            doTypeChosen( form );
                        }
                    } );
                    form.addAttribute( Constants.INSTANCE.AVariable(),
                                       widgets( variable,
                                                new InfoPopup( Constants.INSTANCE.ABoundVariable(),
                                                               Constants.INSTANCE.BoundVariableTip() ) ) );
                }
            }
        }

        //Formula selector
        if ( showFormulaSelector ) {
            Button formula = new Button( Constants.INSTANCE.NewFormula() );
            formula.addClickHandler( new ClickHandler() {

                public void onClick( ClickEvent event ) {
                    con.setConstraintValueType( SingleFieldConstraint.TYPE_RET_VALUE );
                    doTypeChosen( form );
                }
            } );

            form.addAttribute( Constants.INSTANCE.AFormula() + ":",
                               widgets( formula,
                                        new InfoPopup( Constants.INSTANCE.AFormula(),
                                                       Constants.INSTANCE.FormulaExpressionTip() ) ) );
        }

        //Expression selector
        if ( showExpressionSelector ) {
            Button expression = new Button( Constants.INSTANCE.ExpressionEditor() );
            expression.addClickHandler( new ClickHandler() {

                public void onClick( ClickEvent event ) {
                    con.setConstraintValueType( SingleFieldConstraint.TYPE_EXPR_BUILDER_VALUE );
                    doTypeChosen( form );
                }
            } );

            form.addAttribute( Constants.INSTANCE.ExpressionEditor() + ":",
                               widgets( expression,
                                        new InfoPopup( Constants.INSTANCE.ExpressionEditor(),
                                                       Constants.INSTANCE.ExpressionEditor() ) ) );
        }

        form.show();
    }
View Full Code Here

    public void showBindFieldPopup( final Widget w,
                                    final FactPattern fp,
                                    final SingleFieldConstraint con,
                                    String[] fields,
                                    final PopupCreator popupCreator ) {
        final FormStylePopup popup = new FormStylePopup();
        popup.setWidth( 500 + "px" );
        final HorizontalPanel vn = new HorizontalPanel();
        final TextBox varName = new BindingTextBox();
        if ( con.getFieldBinding() != null ) {
            varName.setText( con.getFieldBinding() );
        }
        final Button ok = new Button( HumanReadableConstants.INSTANCE.Set() );
        vn.add( varName );
        vn.add( ok );

        ok.addClickHandler( new ClickHandler() {
            public void onClick( ClickEvent event ) {
                String var = varName.getText();
                if ( modeller.isVariableNameUsed( var ) ) {
                    Window.alert( Constants.INSTANCE.TheVariableName0IsAlreadyTaken( var ) );
                    return;
                }
                con.setFieldBinding( var );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
        popup.addAttribute( Constants.INSTANCE.BindTheFieldCalled0ToAVariable( con.getFieldName() ),
                            vn );

        //Show the sub-field selector is there are applicable sub-fields
        if ( hasApplicableFields( fields ) ) {
            Button sub = new Button( Constants.INSTANCE.ShowSubFields() );
            popup.addAttribute( Constants.INSTANCE.ApplyAConstraintToASubFieldOf0( con.getFieldName() ),
                                sub );
            sub.addClickHandler( new ClickHandler() {
                public void onClick( ClickEvent event ) {
                    popup.hide();
                    popupCreator.showPatternPopup( w,
                                                   fp,
                                                   con,
                                                   true );
                }
            } );
        }

        popup.show();
    }
View Full Code Here

    /**
     * This shows a popup for adding fields to a composite
     */
    public void showPatternPopupForComposite( Widget w,
                                              final HasConstraints hasConstraints ) {
        final FormStylePopup popup = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                         Constants.INSTANCE.AddFieldsToThisConstraint() );

        final ListBox box = new ListBox();
        box.addItem( "..." );
        String[] fields = this.completions.getFieldCompletions( this.pattern.getFactType() );
        for ( int i = 0; i < fields.length; i++ ) {
            box.addItem( fields[ i ] );
        }

        box.setSelectedIndex( 0 );

        box.addChangeHandler( new ChangeHandler() {
            public void onChange( ChangeEvent event ) {
                String factType = pattern.getFactType();
                String fieldName = box.getItemText( box.getSelectedIndex() );
                String fieldType = getCompletions().getFieldType( factType,
                                                                  fieldName );
                hasConstraints.addConstraint( new SingleFieldConstraint( factType,
                                                                         fieldName,
                                                                         fieldType,
                                                                         null ) );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
        popup.addAttribute( Constants.INSTANCE.AddARestrictionOnAField(),
                            box );

        final ListBox composites = new ListBox();
        composites.addItem( "..." ); //NON-NLS
        composites.addItem( Constants.INSTANCE.AllOfAnd(),
                            CompositeFieldConstraint.COMPOSITE_TYPE_AND );
        composites.addItem( Constants.INSTANCE.AnyOfOr(),
                            CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        composites.setSelectedIndex( 0 );

        composites.addChangeHandler( new ChangeHandler() {
            public void onChange( ChangeEvent event ) {
                CompositeFieldConstraint comp = new CompositeFieldConstraint();
                comp.setCompositeJunctionType( composites.getValue( composites.getSelectedIndex() ) );
                hasConstraints.addConstraint( comp );
                modeller.refreshWidget();
                popup.hide();
            }
        } );

        InfoPopup infoComp = new InfoPopup( Constants.INSTANCE.MultipleFieldConstraints(),
                                            Constants.INSTANCE.MultipleConstraintsTip() );

        HorizontalPanel horiz = new HorizontalPanel();
        horiz.add( composites );
        horiz.add( infoComp );
        popup.addAttribute( Constants.INSTANCE.MultipleFieldConstraint(),
                            horiz );

        //Include Expression Editor
        popup.addRow( new SmallLabel( "<i>" + Constants.INSTANCE.AdvancedOptionsColon() + "</i>" ) );
        Button ebBtn = new Button( Constants.INSTANCE.ExpressionEditor() );

        ebBtn.addClickHandler( new ClickHandler() {
            public void onClick( ClickEvent event ) {
                SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
                con.setConstraintValueType( SingleFieldConstraint.TYPE_UNDEFINED );
                con.setExpressionLeftSide( new ExpressionFormLine( new ExpressionUnboundFact( pattern ) ) );
                hasConstraints.addConstraint( con );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
        popup.addAttribute( Constants.INSTANCE.ExpressionEditor(),
                            ebBtn );

        popup.show();

    }
View Full Code Here

        final String factType = getFactType( fp,
                                             con );

        String title = ( con == null ) ? Constants.INSTANCE.ModifyConstraintsFor0( fp.getFactType() ) : Constants.INSTANCE.AddSubFieldConstraint();
        final FormStylePopup popup = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                         title );

        final ListBox box = new ListBox();
        box.addItem( "..." );
        String[] fields = this.completions.getFieldCompletions( FieldAccessorsAndMutators.ACCESSOR,
                                                                factType );
        for ( int i = 0; i < fields.length; i++ ) {
            //You can't use "this" in a nested accessor
            if ( !isNested || !fields[ i ].equals( DataType.TYPE_THIS ) ) {
                box.addItem( fields[ i ] );
            }
        }

        box.setSelectedIndex( 0 );

        box.addChangeHandler( new ChangeHandler() {
            public void onChange( ChangeEvent event ) {
                String fieldName = box.getItemText( box.getSelectedIndex() );
                if ( "...".equals( fieldName ) ) {
                    return;
                }
                String fieldType = completions.getFieldType( factType,
                                                             fieldName );
                fp.addConstraint( new SingleFieldConstraint( factType,
                                                             fieldName,
                                                             fieldType,
                                                             con ) );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
        popup.addAttribute( Constants.INSTANCE.AddARestrictionOnAField(),
                            box );

        final ListBox composites = new ListBox();
        composites.addItem( "..." );
        composites.addItem( Constants.INSTANCE.AllOfAnd(),
                            CompositeFieldConstraint.COMPOSITE_TYPE_AND );
        composites.addItem( Constants.INSTANCE.AnyOfOr(),
                            CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        composites.setSelectedIndex( 0 );

        composites.addChangeHandler( new ChangeHandler() {
            public void onChange( ChangeEvent event ) {
                CompositeFieldConstraint comp = new CompositeFieldConstraint();
                comp.setCompositeJunctionType( composites.getValue( composites.getSelectedIndex() ) );
                fp.addConstraint( comp );
                modeller.refreshWidget();
                popup.hide();
            }
        } );

        InfoPopup infoComp = new InfoPopup( Constants.INSTANCE.MultipleFieldConstraints(),
                                            Constants.INSTANCE.MultipleConstraintsTip1() );

        HorizontalPanel horiz = new HorizontalPanel();

        horiz.add( composites );
        horiz.add( infoComp );
        if ( con == null ) {
            popup.addAttribute( Constants.INSTANCE.MultipleFieldConstraint(),
                                horiz );
        }

        if ( con == null ) {
            popup.addRow( new SmallLabel( "<i>" + Constants.INSTANCE.AdvancedOptionsColon() + "</i>" ) ); //NON-NLS
            Button predicate = new Button( Constants.INSTANCE.NewFormula() );
            predicate.addClickHandler( new ClickHandler() {
                public void onClick( ClickEvent event ) {
                    SingleFieldConstraint con = new SingleFieldConstraint();
                    con.setConstraintValueType( SingleFieldConstraint.TYPE_PREDICATE );
                    fp.addConstraint( con );
                    modeller.refreshWidget();
                    popup.hide();
                }
            } );
            popup.addAttribute( Constants.INSTANCE.AddANewFormulaStyleExpression(),
                                predicate );

            Button ebBtn = new Button( Constants.INSTANCE.ExpressionEditor() );

            ebBtn.addClickHandler( new ClickHandler() {
                public void onClick( ClickEvent event ) {
                    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
                    con.setConstraintValueType( SingleFieldConstraint.TYPE_UNDEFINED );
                    fp.addConstraint( con );
                    con.setExpressionLeftSide( new ExpressionFormLine( new ExpressionUnboundFact( pattern ) ) );
                    modeller.refreshWidget();
                    popup.hide();
                }
            } );
            popup.addAttribute( Constants.INSTANCE.ExpressionEditor(),
                                ebBtn );

            doBindingEditor( popup );
        }

        popup.show();
    }
View Full Code Here

        final Button run = new Button(TestScenarioConstants.INSTANCE.RunScenario());
        run.setTitle(TestScenarioConstants.INSTANCE.RunScenarioTip());
        run.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final FormStylePopup pop = new FormStylePopup();
                final TextBox sessionNameTextBox = new TextBox();       
                pop.addAttribute(TestScenarioConstants.INSTANCE.SessionName() + ":", sessionNameTextBox);

                Button ok = new Button("OK");
                ok.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        if(sessionNameTextBox.getText() == null || "".equals(sessionNameTextBox.getText())) {
                            Window.alert(TestScenarioConstants.INSTANCE.PleaseInputSessionName());
                            return;
                        }
                       
                        BusyPopup.showMessage(TestScenarioConstants.INSTANCE.BuildingAndRunningScenario());

                        testScenarioEditorService.call(new RemoteCallback<Void>() {
                            @Override
                            public void callback(Void v) {
                                pop.hide();
                                BusyPopup.close();
                                layout.clear();
                                layout.add(actions);
                                layout.add(results);
                                actions.setVisible(true);
                            }
                        },
                                new HasBusyIndicatorDefaultErrorCallback(TestRunnerWidget.this)
                        ).runScenario(path, scenario, sessionNameTextBox.getText());                       
                    }
                });
                pop.addAttribute( "", ok);
                pop.show();               
             }
        });

        actions.add(run);
        layout.add(actions);
View Full Code Here

        return tb;
    }

    private void showTypeChoice(Widget w,
                                final VerifyField con) {
        final FormStylePopup form = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(),
                TestScenarioConstants.INSTANCE.FieldValue() );

        Button lit = new Button( TestScenarioConstants.INSTANCE.LiteralValue() );
        lit.addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                con.setNature( FieldData.TYPE_LITERAL );
                doTypeChosen( form );
            }

        } );
        form.addAttribute( TestScenarioConstants.INSTANCE.LiteralValue() + ":",
                widgets( lit,
                        new InfoPopup( TestScenarioConstants.INSTANCE.LiteralValue(),
                                TestScenarioConstants.INSTANCE.LiteralValTip() ) ) );

        form.addRow( new HTML( "<hr/>" ) );
        form.addRow( new SmallLabel( TestScenarioConstants.INSTANCE.AdvancedOptions() ) );

        // If we are here, then there must be a bound variable compatible with
        // me

        Button variable = new Button( TestScenarioConstants.INSTANCE.BoundVariable() );
        variable.addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                con.setNature( FieldData.TYPE_VARIABLE );
                doTypeChosen( form );
            }
        } );
        form.addAttribute( TestScenarioConstants.INSTANCE.AVariable(),
                widgets( variable,
                        new InfoPopup( TestScenarioConstants.INSTANCE.ABoundVariable(),
                                TestScenarioConstants.INSTANCE.BoundVariableTip() ) ) );

        form.show();
    }
View Full Code Here

        this.parent = parent;
    }

    @Override
    public void onClick(ClickEvent event) {
        final FormStylePopup pop = new FormStylePopup();
        pop.setTitle(TestScenarioConstants.INSTANCE.ChooseDotDotDot());

        pop.addAttribute(TestScenarioConstants.INSTANCE.ChooseAFieldToAdd(), createAddNewField(pop));

        pop.show();
    }
View Full Code Here

        return horiz;
    }

    protected void showAddFieldPopup(Widget w) {
        final FormStylePopup popup = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(),
                                                         TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke() );
        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( TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke(),
                            box );
        box.addChangeHandler( new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                mCall.setState( ActionCallMethod.TYPE_DEFINED );
                ListBox sourceW = (ListBox) event.getSource();
                String methodName = sourceW.getItemText( sourceW.getSelectedIndex() );
                String methodNameWithParams = sourceW.getValue( sourceW.getSelectedIndex() );

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

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

                // String fieldType = completions.getFieldType( variableClass,
                // fieldName );
                int i = 0;
                for ( String fieldParameter : fieldList ) {
                    mCall.addFieldValue( new CallFieldValue( methodName,
                                                             String.valueOf( i ),
                                                             fieldParameter ) );
                    i++;
                }

                parent.renderEditor();
                popup.hide();

            }
        } );

        popup.setPopupPosition( w.getAbsoluteLeft(),
                                w.getAbsoluteTop() );
        popup.show();

    }
View Full Code Here

TOP

Related Classes of org.uberfire.client.common.FormStylePopup

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.