Package org.drools.guvnor.client.common

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


    public void showPatternPopup(Widget w,
                                 final String factType,
                                 final FieldConstraint con) {

        String title = (con == null) ? constants.ModifyConstraintsFor0( factType ) : constants.AddSubFieldConstraint();
        final FormStylePopup popup = new FormStylePopup( images.newexWiz(),
                                                         title );

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

        box.setSelectedIndex( 0 );

        box.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent event) {
                String fieldName = box.getItemText( box.getSelectedIndex() );
                if ( "...".equals( fieldName ) ) {
                    return;
                }
                String qualifiedName = factType + "." + fieldName;
                String fieldType = completions.getFieldType( qualifiedName );
                pattern.addConstraint( new SingleFieldConstraint( fieldName,
                                                                  fieldType,
                                                                  con ) );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
        popup.addAttribute( constants.AddARestrictionOnAField(),
                            box );

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

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

        InfoPopup infoComp = new InfoPopup( constants.MultipleFieldConstraints(),
                                            constants.MultipleConstraintsTip1() );

        HorizontalPanel horiz = new HorizontalPanel();

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

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

            Button ebBtn = new Button( constants.ExpressionEditor() );

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

            doBindingEditor( popup );
        }

        popup.show();
    }
View Full Code Here


            return clickme;
        }
    }

    protected void showTypeChoice(Widget w) {
        final FormStylePopup form = new FormStylePopup( images.newexWiz(),
                                                        constants.FieldValue() );
        Button lit = new Button( constants.LiteralValue() );
        lit.addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                value.nature = FieldNature.TYPE_LITERAL;
                value.value = "";
                makeDirty();
                executeOnChageCommand();
                refresh();
                form.hide();
            }
        } );

        form.addAttribute( constants.LiteralValue() + ":",
                           widgets( lit,
                                    new InfoPopup( constants.Literal(),
                                                   constants.ALiteralValueMeansTheValueAsTypedInIeItsNotACalculation() ) ) );

        if ( model.isTemplate() ) {
            Button templateButton = new Button( constants.TemplateKey() );
            templateButton.addClickHandler( new ClickHandler() {
                public void onClick(ClickEvent event) {
                    value.nature = FieldNature.TYPE_TEMPLATE;
                    value.value = "";
                    makeDirty();
                    refresh();
                    form.hide();
                }
            } );
            form.addAttribute( constants.TemplateKey() + ":",
                               widgets( templateButton,
                                        new InfoPopup( constants.Literal(),
                                                       constants.ALiteralValueMeansTheValueAsTypedInIeItsNotACalculation() ) ) );
        }

        form.addRow( new HTML( "<hr/>" ) );
        form.addRow( new SmallLabel( constants.AdvancedSection() ) );

        Button formula = new Button( constants.Formula() );
        formula.addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                value.nature = FieldNature.TYPE_FORMULA;
                value.value = "=";
                makeDirty();
                refresh();
                form.hide();
            }
        } );

        // If there is a bound Facts or Fields that are of the same type as the current variable type, then show a button
        List<String> bindings = getApplicableBindings();
        if ( bindings.size() > 0 ) {
            Button variable = new Button( constants.BoundVariable() );
            form.addAttribute( constants.BoundVariable() + ":",
                               variable );
            variable.addClickHandler( new ClickHandler() {

                public void onClick(ClickEvent event) {
                    value.nature = FieldNature.TYPE_VARIABLE;
                    value.value = "=";
                    makeDirty();
                    refresh();
                    form.hide();
                }
            } );
        }

        form.addAttribute( constants.Formula() + ":",
                           widgets( formula,
                                    new InfoPopup( constants.Formula(),
                                                   constants.FormulaTip() ) ) );

        form.show();
    }
View Full Code Here

    private Command       loggedInEvent;
    private String        userNameLoggedIn;

    public void show() {
        final FormStylePopup pop = new FormStylePopup( images.login(),
                                                       constants.Login() );

        final TextBox userName = new TextBox();
        pop.addAttribute( constants.UserName(),
                          userName );
        final PasswordTextBox password = new PasswordTextBox();
        pop.addAttribute( constants.Password(),
                          password );

        KeyPressHandler kph = new KeyPressHandler() {
            public void onKeyPress(KeyPressEvent event) {
                if ( KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode() ) {
                    doLogin( userName,
                             password,
                             pop );
                }
            }
        };
        userName.addKeyPressHandler( kph );
        password.addKeyPressHandler( kph );

        Button b = new Button( constants.OK() );
        b.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent event) {
                doLogin( userName,
                         password,
                         pop );
            }
        } );

        pop.addAttribute( "",
                          b );
      
        pop.setAfterShow( new Command() {
            public void execute() {
                Scheduler scheduler = Scheduler.get();
                scheduler.scheduleDeferred( new Command() {
                    public void execute() {
                        userName.setFocus( true );
                    }
                });
            }
        } );

        pop.show();
    }
View Full Code Here

    }
   
    public void bind() {
        Command newUserCommand = new Command() {
            public void execute() {
                final FormStylePopup form = new FormStylePopup( images.snapshot(),
                                                                constants.EnterNewUserName() );
                final TextBox userName = new TextBox();
                form.addAttribute( constants.NewUserName(),
                                   userName );

                Button btnOK = new Button( constants.OK() );
                form.addAttribute( "",
                                   btnOK );
                btnOK.addClickHandler( new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        if ( userName.getText() != null
                             && userName.getText().length() != 0 ) {
                            RepositoryServiceFactory.getService().createUser( userName.getText(),
                                                                              new GenericCallback<java.lang.Void>() {
                                                                                  public void onSuccess(Void a) {
                                                                                      view.refresh();
                                                                                      showEditor( userName.getText() );
                                                                                  }

                                                                                  public void onFailure(Throwable t) {
                                                                                      super.onFailure( t );
                                                                                  }
                                                                              } );
                            form.hide();
                        }
                    }
                } );
                form.show();
            }
        };
        view.setNewUserCommand(newUserCommand);

        Command deleteUserCommand = new Command() {
View Full Code Here

                                                                       } );
    }
   
    private void doPermissionEditor(final String userName, final Map<String, List<String>> perms) {
        final FormStylePopup editor = new FormStylePopup(images.management(),
                constants.EditUser0(userName));
        editor.addRow(new HTML("<i>" + constants.UserAuthenticationTip()
                + "</i>"));
        // now render the actual permissions...
        VerticalPanel vp = new VerticalPanel();
        editor.addAttribute("", doPermsPanel(perms, vp));

        HorizontalPanel hp = new HorizontalPanel();
        Button save = new Button(constants.SaveChanges());
        hp.add(save);
        editor.addAttribute("", hp);
        save.addClickHandler(createClickHandlerForSaveButton(userName, perms,
                editor));

        Button cancel = new Button(constants.Cancel());
        hp.add(cancel);
        cancel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent w) {
                editor.hide();
            }
        });
        editor.show();
    }
View Full Code Here

    private ClickHandler createClickHandlerForNewPersmissionImageButton(final Map<String, List<String>> perms,
                                                                        final Panel vp) {
        return new ClickHandler() {
            public void onClick(ClickEvent w) {
                final FormStylePopup pop = new FormStylePopup();
                final ListBox permTypeBox = new ListBox();
                permTypeBox.addItem( constants.Loading() );

                HorizontalPanel hp = new HorizontalPanel();
                hp.add( permTypeBox );
                hp.add( new InfoPopup( constants.PermissionDetails(),
                                       constants.PermissionDetailsTip() ) );
                pop.addAttribute( constants.PermissionType(),
                                  hp );

                RepositoryServiceFactory.getService().listAvailablePermissionRoleTypes( new GenericCallback<List<String>>() {
                    public void onSuccess(List<String> items) {
                        permTypeBox.clear();
                        permTypeBox.addItem( constants.pleaseChoose1() );
                        for ( String roleType : items ) {
                            permTypeBox.addItem( roleType );
                        }
                    }
                } );

                permTypeBox.addChangeHandler( createChangeHandlerForPermTypeBox( perms,
                                                                                 vp,
                                                                                 pop,
                                                                                 permTypeBox ) );

                pop.show();
            }

            private ChangeHandler createChangeHandlerForPermTypeBox(final Map<String, List<String>> perms,
                                                                    final Panel vp,
                                                                    final FormStylePopup pop,
                                                                    final ListBox permTypeBox) {
                return new ChangeHandler() {
                    public void onChange(ChangeEvent event) {
                        pop.clear();
                        final String sel = permTypeBox.getItemText( permTypeBox.getSelectedIndex() );
                        if ( sel.equals( "admin" ) ) { // NON-NLS
                            createButtonsAndHandlersForAdmin( perms,
                                                              vp,
                                                              pop );
                        } else if ( sel.startsWith( "analyst" ) ) { // NON-NLS
                            CategoryExplorerWidget cat = createCategoryExplorerWidget( perms,
                                                                                       vp,
                                                                                       pop,
                                                                                       sel );
                            pop.addAttribute( constants.SelectCategoryToProvidePermissionFor(),
                                              cat );
                        } else if ( sel.startsWith( "package" ) ) {
                            createButtonsPanelsAndHandlersForPackage( perms,
                                                                      vp,
                                                                      pop,
                                                                      sel );
                        }
                    }

                    private void createButtonsPanelsAndHandlersForPackage(final Map<String, List<String>> perms,
                                                                          final Panel vp,
                                                                          final FormStylePopup pop,
                                                                          final String sel) {
                        final RulePackageSelector rps = new RulePackageSelector( true );
                        Button ok = new Button( constants.OK() );
                        ok.addClickHandler( new ClickHandler() {
                            public void onClick(ClickEvent w) {
                                String pkName = rps.getSelectedPackage();
                                if ( perms.containsKey( sel ) ) {
                                    perms.get( sel ).add( "package="
                                                          + pkName ); // NON-NLS
                                } else {
                                    List<String> ls = new ArrayList<String>();
                                    ls.add( "package="
                                            + pkName ); // NON-NLS
                                    perms.put( sel,
                                               ls );
                                }

                                doPermsPanel( perms,
                                              vp );
                                pop.hide();

                            }
                        } );

                        HorizontalPanel hp = new HorizontalPanel();
                        hp.add( rps );
                        hp.add( ok );
                        pop.addAttribute( constants.SelectPackageToApplyPermissionTo(),
                                          hp );
                    }

                    private CategoryExplorerWidget createCategoryExplorerWidget(final Map<String, List<String>> perms,
                                                                                final Panel vp,
                                                                                final FormStylePopup pop,
                                                                                final String sel) {
                        CategoryExplorerWidget cat = new CategoryExplorerWidget( new CategorySelectHandler() {
                            public void selected(String selectedPath) {
                                if ( perms.containsKey( sel ) ) {
                                    perms.get( sel ).add( "category="
                                                          + selectedPath ); // NON-NLS
                                } else {
                                    List<String> ls = new ArrayList<String>();
                                    ls.add( "category="
                                            + selectedPath ); // NON-NLS
                                    perms.put( sel,
                                               ls );
                                }
                                doPermsPanel( perms,
                                              vp );
                                pop.hide();
                            }
                        } );
                        return cat;
                    }

                    private void createButtonsAndHandlersForAdmin(final Map<String, List<String>> perms,
                                                                  final Panel vp,
                                                                  final FormStylePopup pop) {
                        Button ok = new Button( constants.OK() );

                        pop.addAttribute( constants.MakeThisUserAdmin(),
                                          ok );
                        ok.addClickHandler( new ClickHandler() {
                            public void onClick(ClickEvent w) {
                                perms.put( "admin",
                                           new ArrayList<String>() ); // NON-NLS

                                doPermsPanel( perms,
                                              vp );
                                pop.hide();
                            }
                        } );
                        Button cancel = new Button( constants.Cancel() );

                        pop.addAttribute( "",
                                          cancel );
                        cancel.addClickHandler( new ClickHandler() {
                            public void onClick(ClickEvent w) {
                                pop.hide();
                            }
                        } );
                    }
                };
            }
View Full Code Here

                                              String dependencyVersion) {
        return dependencyPath + "?version=" + dependencyVersion;
    }

    private void showEditor(final String dependencyPath) {
        final FormStylePopup editor = new FormStylePopup(images.management(),
                "Edit Dependency");
        /*    editor.addRow(new HTML("<i>" + "Choose the version you want to depend on"
                + "</i>"));
        */
        editor.addAttribute("Dependency Path: ",
                new Label(decodeDependencyPath(dependencyPath)[0]));
        final VersionChooser versionChoose = new VersionChooser(clientFactory,
                eventBus,
                decodeDependencyPath(dependencyPath)[1],
                conf.getUuid(),
                decodeDependencyPath(dependencyPath)[0],
                new Command() {
                    public void execute() {
                        table.refresh();
                    }
                });
        editor.addAttribute("Dependency Version: ",
                versionChoose);

        HorizontalPanel hp = new HorizontalPanel();
        Button useSelectedVersionButton = new Button("Use selected version");
        hp.add(useSelectedVersionButton);
        useSelectedVersionButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent w) {
                String selectedVersion = versionChoose.getSelectedVersionName();
                if (selectedVersion == null) {
                    return;
                }
                if (Window.confirm("Are you sure you want to use version: " + selectedVersion + " as dependency?")) {
                    RepositoryServiceFactory.getPackageService().updateDependency(
                            conf.getUuid(),
                            encodeDependencyPath(DependencyWidget
                                    .decodeDependencyPath(dependencyPath)[0],
                                    selectedVersion),
                            new GenericCallback<Void>() {
                                public void onSuccess(Void v) {
                                    editor.hide();
                                    table.refresh();
                                }
                            });
                }
            }
        });
        useSelectedVersionButton.setEnabled(!isHistoricalReadOnly);

        Button cancel = new Button(constants.Cancel());
        hp.add(cancel);
        cancel.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent w) {
                editor.hide();
            }
        });

        editor.addAttribute("",
                hp);
        editor.show();
    }
View Full Code Here

    private void doViewDiagram() {
        LoadingPopup.showMessage( constants.CalculatingSource() );

        try {
            FormStylePopup pop = new FormStylePopup( images.viewSource(),
                    constants.ViewingDiagram(),
                    new Integer( 800 ) );

            pop.addRow( new ScrollPanel( ruleFlowViewer ) );
            pop.addRow( parameterPanel );

            pop.show();
        } catch (Exception e) {
            ErrorPopup.showMessage( constants.CouldNotCreateTheRuleflowDiagramItIsPossibleThatTheRuleflowFileIsInvalid() );
        }

        LoadingPopup.close();
View Full Code Here

        RepositoryServiceFactory.getAssetService().loadRuleAsset( versionUUID,
                                                             new GenericCallback<Asset>() {

                                                                 public void onSuccess(Asset asset) {
                                                                     asset.setReadonly( true );
                                                                     final FormStylePopup pop = new FormStylePopup( images.snapshot(),
                                                                                                                    constants.VersionNumber0Of1(
                                                                                                                                   asset.getVersionNumber(),
                                                                                                                                   asset.getName() ),
                                                                                                                    new Integer( 800 ) );

                                                                     RuleViewerWrapper viewer = new RuleViewerWrapper(
                                                                             clientFactory,
                                                                             eventBus,
                                                                             asset,
                                                                             true
                                                                                                                                                          );
                                                                     viewer.setWidth( "100%" );
                                                                     viewer.setHeight( "100%" );

                                                                     pop.addRow( viewer );
                                                                     pop.show();
                                                                 }
                                                             } );
    }
View Full Code Here

                break;
            case 6 :
                // TODO: Not a manager -Rikkola-
                Frame aboutInfoFrame = new Frame( "../AboutInfo.html" ); // NON-NLS

                FormStylePopup aboutPop = new FormStylePopup();
                aboutPop.setWidth( 600 + "px" );
                aboutPop.setTitle( constants.About() );
                String hhurl = GWT.getModuleBaseURL()
                               + "webdav";
                aboutPop.addAttribute( constants.WebDAVURL()
                                               + ":",
                                       new SmallLabel( "<b>"
                                                       + hhurl
                                                       + "</b>" ) );
                aboutPop.addAttribute( constants.Version()
                                               + ":",
                                       aboutInfoFrame );
                aboutPop.show();

                //When the popup is closed signal closure of place
                aboutPop.addCloseHandler( new CloseHandler<PopupPanel>() {

                    public void onClose(CloseEvent<PopupPanel> event) {
                        ManagerPlace place = new ManagerPlace( id );
                        eventBus.fireEvent( new ClosePlaceEvent( place ) );
                    }
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.