Package org.drools.guvnor.client.common

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


        pop.show();
    }

    protected void showNewPatternDialog() {
        final FormStylePopup pop = new FormStylePopup();
        pop.setTitle( constants.NewFactSelectTheType() );
        final ListBox types = new ListBox();
        for ( int i = 0; i < sce.getFactTypes().length; i++ ) {
            types.addItem( sce.getFactTypes()[i] );
        }
        pop.addAttribute( constants.FactType(),
                          types );
        final TextBox binding = new TextBox();
        pop.addAttribute( constants.name(),
                          binding );

        Button ok = new Button( constants.OK() );
        ok.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent w) {
                editingCol.setBoundName( binding.getText() );
                editingCol.setFactType( types.getItemText( types
                        .getSelectedIndex() ) );
                editingCol.setFactField( null );
                doPatternLabel();
                doFieldLabel();
                pop.hide();
            }
        } );
        pop.addAttribute( "",
                          ok );

        pop.show();
    }
View Full Code Here


    private void showTypeQuestion(Widget w,
                                  final Types t,
                                  final boolean global,
                                  String headerMessage) {
        final FormStylePopup pop = new FormStylePopup( images.homeIcon(),
                                                       constants.ChooseAFactType() );
        pop.addRow( new HTML( "<small><i>" + headerMessage + " </i></small>" ) ); //NON-NLS
        final ListBox factList = new ListBox();
        factList.addItem( constants.loadingList() );

        RepositoryServiceFactory.getPackageService().listTypesInPackage( this.conf.getUuid(),
                                                                         createGenericCallbackForListTypesInPackage( global,
                                                                                                                     factList ) );

        InfoPopup info = new InfoPopup( constants.TypesInThePackage(),
                                        constants.IfNoTypesTip() );

        pop.addAttribute( constants.ChooseClassType(),
                          createHorizontalPanel( factList,
                                                 info ) );
        final TextBox globalName = new TextBox();
        if ( global ) {
            pop.addAttribute( constants.GlobalName(),
                              globalName );
        }
        final TextBox className = new TextBox();
        InfoPopup infoClass = new InfoPopup( constants.EnteringATypeClassName(),
                                             constants.EnterTypeNameTip() );
        pop.addAttribute( constants.advancedClassName(),
                          createHorizontalPanel( className,
                                                 infoClass ) );

        Button ok = new Button( constants.OK() ) {
            {
                addClickHandler( new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        String type = (!"".equals( className.getText() )) ? className.getText() : factList.getItemText( factList.getSelectedIndex() );
                        if ( !global ) {
                            t.imports.add( new Import( type ) );
                            doImports( t );
                        } else {
                            if ( "".equals( globalName.getText() ) ) {
                                Window.alert( constants.YouMustEnterAGlobalVariableName() );
                                return;
                            }
                            t.globals.add( new Global( type,
                                                       globalName.getText() ) );
                            doGlobals( t );
                        }
                        updateHeader( t );
                        pop.hide();
                    }
                } );
            }
        };

        Button cancel = new Button( constants.Cancel() ) {
            {
                addClickHandler( new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        pop.hide();
                    }
                } );
            }
        };

        HorizontalPanel buttonPanel = new HorizontalPanel();
        buttonPanel.add( ok );
        buttonPanel.add( cancel );
        pop.addAttribute( "",
                          buttonPanel );
        pop.show();
    }
View Full Code Here

        return box;
    }

    private void showChangeFact(ClickEvent w) {
        final FormStylePopup pop = new FormStylePopup();

        final ListBox pats = this.loadBoundFacts();
        pop.addAttribute( constants.ChooseFact(),
                          pats );
        Button ok = new Button( constants.OK() );
        pop.addAttribute( "",
                          ok );

        ok.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent w) {
                String val = pats.getValue( pats.getSelectedIndex() );
                editingCol.setBoundName( val );
                editingCol.setFactField( null );
                doBindingLabel();
                doFieldLabel();
                pop.hide();
            }
        } );

        pop.show();

    }
View Full Code Here

        pop.show();

    }

    private void showFieldChange() {
        final FormStylePopup pop = new FormStylePopup();
        pop.setModal( false );

        final String factType = getFactType();
        String[] fields = this.sce.getFieldCompletions( factType );
        final ListBox box = new ListBox();
        for ( int i = 0; i < fields.length; i++ ) {
            box.addItem( fields[i] );
        }
        pop.addAttribute( constants.Field(),
                          box );
        Button b = new Button( constants.OK() );
        pop.addAttribute( "",
                          b );
        b.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent w) {
                editingCol.setFactField( box.getItemText( box.getSelectedIndex() ) );
                editingCol.setType( sce.getFieldType( factType,
                                                      editingCol.getFactField() ) );
                doFieldLabel();
                pop.hide();
            }
        } );
        pop.show();

    }
View Full Code Here

        this.okCommand = okCommand;
    }

    public void show() {

        final FormStylePopup pop = new FormStylePopup();
        pop.setTitle( constants.Name() );
        HorizontalPanel changeName = new HorizontalPanel();
        final TextBox name = new TextBox();
        name.setText( factModel.getName() );
        changeName.add( name );

        int selectedIndex = 0;
        lstSuperTypes.addItem( constants.DoesNotExtend() );
        for ( FactMetaModel fmm : factModels ) {
            if ( !fmm.getName().equals( factModel.getName() ) ) {
                lstSuperTypes.addItem( fmm.getName() );
                if ( factModel.getSuperType() != null && factModel.getSuperType().equals( fmm.getName() ) ) {
                    selectedIndex = lstSuperTypes.getItemCount() - 1;
                }
            }
        }
        lstSuperTypes.setSelectedIndex( selectedIndex );
        if ( lstSuperTypes.getItemCount() == 1 ) {
            lstSuperTypes.setEnabled( false );
        }

        lstSuperTypes.addChangeHandler( new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                if ( lstSuperTypes.getSelectedIndex() <= 0 ) {
                    factModel.setSuperType( null );
                } else {
                    String oldSuperType = factModel.getSuperType();
                    String newSuperType = lstSuperTypes.getItemText( lstSuperTypes.getSelectedIndex() );
                    factModel.setSuperType( newSuperType );
                    if ( createsCircularDependency( newSuperType ) ) {
                        Window.alert( constants.CreatesCircularDependency( name.getText() ) );
                        factModel.setSuperType( oldSuperType );
                        lstSuperTypes.setSelectedIndex( getSelectedIndex( oldSuperType ) );
                        return;
                    } else {
                        factModel.setSuperType( newSuperType );
                    }
                }

            }

        } );

        Button nameButton = new Button( constants.OK() );

        nameButton.addKeyPressHandler( new NoSpaceKeyPressHandler() );

        nameButton.addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                if ( doesTheNameExist() ) {
                    Window.alert( constants.NameTakenForModel( name.getText() ) );
                    return;
                }

                if ( factModelAlreadyHasAName( name.getText() ) ) {
                    if ( isTheUserSureHeWantsToChangeTheName() ) {
                        setNameAndClose();
                    }
                } else {
                    setNameAndClose();
                }
            }

            private boolean factModelAlreadyHasAName(String name) {
                return factModel.getName() != null && !factModel.getName().equals( name );
            }

            private void setNameAndClose() {
                String oldName = factModel.getName();
                String newName = name.getText();

                modelNameHelper.changeNameInModelNameHelper( oldName,
                                                             newName );
                factModel.setName( newName );

                okCommand.execute();

                pop.hide();
            }

            private boolean isTheUserSureHeWantsToChangeTheName() {
                return Window.confirm( constants.ModelNameChangeWarning() );
            }

            private boolean doesTheNameExist() {
                if ( factModel.getName() == null ) {
                    return false;
                }
                //The name may not have changed
                if ( factModel.getName().equals( name.getText() ) ) {
                    return false;
                }
                return !modelNameHelper.isUniqueName( name.getText() );
            }
        } );

        pop.addAttribute( constants.Name(),
                          changeName );
        pop.addAttribute( constants.TypeExtends(),
                          lstSuperTypes );
        pop.addRow( nameButton );

        pop.show();
    }
View Full Code Here

        this.okCommand = okCommand;
    }

    public void show() {

        final FormStylePopup pop = new FormStylePopup();

        VerticalPanel vp = new VerticalPanel();

        Grid g = new Grid( 2,
                           3 );

        txtName.addKeyPressHandler( new NoSpaceKeyPressHandler() );
        txtKey.addKeyPressHandler( new NoSpaceKeyPressHandler() );
        g.setWidget( 0,
                     0,
                     new HTML( "<b>Name</b>" ) );
        g.setWidget( 1,
                     0,
                     txtName );

        g.setWidget( 0,
                     1,
                     new HTML( "<b>Key</b>" ) );
        g.setWidget( 1,
                     1,
                     txtKey );

        g.setWidget( 0,
                     2,
                     new HTML( "<b>Value</b>" ) );
        g.setWidget( 1,
                     2,
                     txtValue );

        setControlValues( annotation );

        Button btnOK = new Button( constants.OK() );

        btnOK.addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                if ( doesTheNameExist() ) {
                    Window.alert( constants.NameTakenForModel( txtName.getText() ) );
                    return;
                }

                if ( annotationAlreadyHasAName() && annotationNameHasChanged() ) {
                    if ( isTheUserSureHeWantsToChangeTheName() ) {
                        setNameAndClose();
                    }
                } else {
                    setNameAndClose();
                }
            }

            private boolean annotationAlreadyHasAName() {
                return annotation.name != null && annotation.name.length() > 0;
            }

            private boolean annotationNameHasChanged() {
                String oldName = annotation.name;
                String newName = txtName.getText();
                return !newName.equals( oldName );
            }

            private void setNameAndClose() {
                String name = txtName.getText();
                String key = txtKey.getText();
                if ( key == null || key.length() == 0 ) {
                    //This is the default annotation key constructed by AnnotationDescr when none is provided
                    //e.g. @smurf( Pupa ) -> @smurf( value = Pupa ). We explicitly set it to keep the user
                    //experience consistent between what they enter and what is parsed.
                    key = "value";
                }
                String value = txtValue.getText();

                annotation.name = name;
                annotation.getValues().clear();
                annotation.getValues().put( key,
                                            value );

                okCommand.execute();

                pop.hide();
            }

            private boolean isTheUserSureHeWantsToChangeTheName() {
                return Window.confirm( constants.ModelNameChangeWarning() );
            }

            private boolean doesTheNameExist() {
                for ( AnnotationMetaModel a : annotations ) {
                    if ( a != annotation ) {
                        if ( a.name.equals( txtName.getText() ) ) {
                            return true;
                        }
                    }
                }
                return false;
            }
        } );

        vp.add( g );
        vp.add( btnOK );
        pop.addRow( vp );

        pop.show();
    }
View Full Code Here

        return s == null
               || s.equals( "" );
    }

    private void showFieldChange() {
        final FormStylePopup pop = new FormStylePopup();
        pop.setModal( false );
        String[] fields = this.sce.getFieldCompletions(
                                                        FieldAccessorsAndMutators.MUTATOR,
                                                        this.editingCol.getFactType() );
        final ListBox box = new ListBox();
        for ( int i = 0; i < fields.length; i++ ) {
            box.addItem( fields[i] );
        }
        pop.addAttribute( constants.Field(),
                          box );
        Button b = new Button( constants.OK() );
        pop.addAttribute( "",
                          b );
        b.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent w) {
                editingCol.setFactField( box.getItemText( box.getSelectedIndex() ) );
                editingCol.setType( sce.getFieldType( editingCol.getFactType(),
                                                      editingCol.getFactField() ) );
                doFieldLabel();
                pop.hide();
            }
        } );
        pop.show();

    }
View Full Code Here

            vpConstraintConf.add(editor);
        }
    }

    private void showNewConstrainPop() {
        final FormStylePopup pop = new FormStylePopup(images.config(),
                constants.AddNewConstraint());
        final Button addbutton = new Button(constants.OK());
        final ListBox consDefsCombo = new ListBox(false);

        consDefsCombo.setVisibleItemCount(5);

        addbutton.setTitle(constants.AddNewConstraint());

        List<String> names = new ArrayList<String>(ConstraintsContainer.getAllConfigurations().keySet());
        Collections.sort(names);
        for (String name : names) {
            consDefsCombo.addItem(name);
        }

        addbutton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                String name = consDefsCombo.getItemText(consDefsCombo.getSelectedIndex());
                ConstraintConfiguration config = ConstraintsContainer.getEmptyConfiguration(name);
                if (config != null) {

                    String factName = factsCombo.getItemText( factsCombo.getSelectedIndex() );
                    String fieldName = fieldsCombo.getItemText( fieldsCombo.getSelectedIndex() );
                    config.setFactType( factName );
                    config.setFieldName( fieldName );
                    if ( ((WorkingSetConfigData) workingSet.getContent()).constraints == null ) {
                        ((WorkingSetConfigData) workingSet.getContent()).constraints = new ArrayList<ConstraintConfiguration>();
                    }
                    ((WorkingSetConfigData) workingSet.getContent()).constraints.add( config );
                    constraintsCombo.addItem( config.getConstraintName(),
                                              addContrainsMap( config ) );
                    workingSetEditor.getConstraintsConstrainer().addConstraint( config );

                }
                pop.hide();
            }
        });

        pop.addAttribute(constants.WillExtendTheFollowingRuleCalled(),
                consDefsCombo);
        pop.addAttribute("",
                addbutton);

        pop.show();
    }
View Full Code Here

                    public void onClick( ClickEvent event ) {
                        int height = (int) (Window.getClientHeight() * 0.7);
                        int width = (int) (Window.getClientWidth() * 0.7);

                        final FormStylePopup popUp = new FormStylePopup( null,
                                constants.TemplateData(),
                                width );
                        popUp.setHeight( height + "px" );

                        //Initialise table to edit data
                        table = new TemplateDataTableWidget( sce );
                        table.setPixelSize( width,
                                height );
                        table.setModel( model );
                        popUp.addAttribute( "",
                                table );

                        Button btnSaveAndClose = new Button( constants.SaveAndClose(),
                                new ClickHandler() {
                                    public void onClick( ClickEvent event ) {
                                        table.scrapeData( model );
                                        popUp.hide();
                                    }
                                } );

                        Button btnAddRow = new Button( constants.AddRow(),
                                new ClickHandler() {

                                    public void onClick( ClickEvent event ) {
                                        table.appendRow();
                                    }

                                } );

                        HorizontalPanel pnlClose = new HorizontalPanel();
                        pnlClose.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_RIGHT );
                        pnlClose.add( btnSaveAndClose );
                        pnlClose.add( btnAddRow );
                        popUp.addAttribute( "",
                                pnlClose );

                        popUp.show();
                    }
                } ) );
        tPanel.add( ruleModeller );
        initWidget( tPanel );
    }
View Full Code Here

    }

    @Override
    protected void showFactTypeSelector(final Widget w) {

        final FormStylePopup popup = new FormStylePopup();
        popup.setTitle(constants.NewFactPattern());

        final ListBox box = new ListBox();

        box.addItem(constants.Choose());

        for (Map.Entry<String, String> entry : this.getExtraLeftSidePatternFactTypes().entrySet()) {
            box.addItem(entry.getKey(), entry.getValue());
        }
       
        //TODO: Add Facts that extedns Collection
//        box.addItem("...");
//        box.addItem("TODO: Add Facts that extedns Collection");

        box.setSelectedIndex(0);
        box.addChangeHandler(new ChangeHandler() {
            public void onChange(ChangeEvent event) {
                pattern.setFactPattern(new FactPattern(box.getValue(box
                        .getSelectedIndex())));
                setModified(true);
                getModeller().refreshWidget();
                popup.hide();
            }
        });


        popup.addAttribute(constants.chooseFactType(),
                box);

        popup.show();
    }
View Full Code Here

TOP

Related Classes of org.drools.guvnor.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.