Package org.drools.guvnor.client.common

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


    }
   
    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) {
                        return 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();
                            }
                        } );
                    }

                    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

                                                                 public void onSuccess(Asset asset) {
                                                                     asset.setReadonly( true );
                                                                     Image image = new Image(images.snapshot());
                                                                     image.setAltText(ConstantsCore.INSTANCE.Snapshot());
                                                                     final FormStylePopup pop = new FormStylePopup(image,
                                                                                                                    constants.VersionNumber0Of1(
                                                                                                                                   asset.getVersionNumber(),
                                                                                                                                   asset.getName() ),
                                                                             800);

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

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

    public void bind() {
        Command newUserCommand = new Command() {
            public void execute() {
                Image image = new Image(ImagesCore.INSTANCE.snapshot());
                image.setAltText(ConstantsCore.INSTANCE.Snapshot());
                final FormStylePopup form = new FormStylePopup(image,
                                                                ConstantsCore.INSTANCE.EnterNewUserName() );
                final TextBox userName = new TextBox();
                form.addAttribute( ConstantsCore.INSTANCE.NewUserName(),
                                   userName );

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

                    public void onClick(ClickEvent event) {
                        if ( userName.getText() != null
                             && userName.getText().length() != 0 ) {
                            repositoryService.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) {
        Image image = new Image(ImagesCore.INSTANCE.management());
        image.setAltText(ConstantsCore.INSTANCE.Management());
        final FormStylePopup editor = new FormStylePopup(image,
                ConstantsCore.INSTANCE.EditUser0(userName));
        editor.addRow(new HTML("<i>" + ConstantsCore.INSTANCE.UserAuthenticationTip()
                + "</i>"));
        // now render the actual permissions...
        VerticalPanel vp = new VerticalPanel();
        editor.addAttribute("", doPermsPanel(perms, vp));

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

        Button cancel = new Button(ConstantsCore.INSTANCE.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( ConstantsCore.INSTANCE.Loading() );

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

                repositoryService.listAvailablePermissionRoleTypes( new GenericCallback<List<String>>() {
                    public void onSuccess(List<String> items) {
                        permTypeBox.clear();
                        permTypeBox.addItem( ConstantsCore.INSTANCE.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( ConstantsCore.INSTANCE.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( ConstantsCore.INSTANCE.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( ConstantsCore.INSTANCE.SelectPackageToApplyPermissionTo(),
                                          hp );
                    }

                    private CategoryExplorerWidget createCategoryExplorerWidget(final Map<String, List<String>> perms,
                                                                                final Panel vp,
                                                                                final FormStylePopup pop,
                                                                                final String sel) {
                        return 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();
                            }
                        } );
                    }

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

                        pop.addAttribute( ConstantsCore.INSTANCE.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( ConstantsCore.INSTANCE.Cancel() );

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

    /**
     * Show a list of possibilities for the value type.
     */
    private void showTypeChoice(Widget w,
            final ISingleFieldConstraint con) {
        final FormStylePopup form = new FormStylePopup("images/newex_wiz.gif",
                constants.FieldValue());

        Button lit = new Button(constants.LiteralValue());
        lit.addClickListener(new ClickListener() {

            public void onClick(Widget w) {
                con.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
                doTypeChosen(form);
            }
        });
        form.addAttribute(constants.LiteralValue() + ":",
                widgets(lit,
                new InfoPopup(constants.LiteralValue(),
                constants.LiteralValTip())));

    if (modeller.isTemplate()) {
          String templateKeyLabel = constants.TemplateKey();
          Button templateKeyButton = new Button(templateKeyLabel);
          templateKeyButton.addClickListener(new ClickListener() {
              public void onClick(Widget arg0) {
                  con.constraintValueType = ISingleFieldConstraint.TYPE_TEMPLATE;
                  doTypeChosen(form);
              }
          });
 
          form.addAttribute(templateKeyLabel + ":",
                  widgets(templateKeyButton,
                  new InfoPopup(templateKeyLabel,
                  constants.LiteralValTip())));
        }
       
        form.addRow(new HTML("<hr/>"));
        form.addRow(new SmallLabel(constants.AdvancedOptions()));

        //only want to show variables if we have some !
        if (this.model.getBoundVariablesInScope(this.constraint).size() > 0 || SuggestionCompletionEngine.TYPE_COLLECTION.equals(this.fieldType)) {
            List vars = this.model.getBoundFacts();
            boolean foundABouncVariableThatMatches = false;
            for (int i = 0; i < vars.size(); i++) {
                String var = (String) vars.get(i);
                FactPattern f = model.getBoundFact(var);
                String fieldConstraint = model.getFieldConstraint(var);

                if ((f != null && f.factType.equals(this.fieldType)) || this.fieldType.equals(fieldConstraint)) {
                    foundABouncVariableThatMatches = true;
                    break;
                } else {
                    // for collection, present the list of possible bound variable
                    String factCollectionType = sce.getParametricFieldType(pattern.factType,
                            this.fieldName);
                    if ((f != null && factCollectionType != null && f.factType.equals(factCollectionType)) || (factCollectionType != null && factCollectionType.equals(fieldConstraint))) {
                        foundABouncVariableThatMatches = true;
                        break;
                    }
                }
            }
            if (foundABouncVariableThatMatches == true) {
                Button variable = new Button(constants.BoundVariable());
                variable.addClickListener(new ClickListener() {

                    public void onClick(Widget w) {
                        con.constraintValueType = SingleFieldConstraint.TYPE_VARIABLE;
                        doTypeChosen(form);
                    }
                });
                form.addAttribute(constants.AVariable(),
                        widgets(variable,
                        new InfoPopup(constants.ABoundVariable(),
                        constants.BoundVariableTip())));
            }
        }

        Button formula = new Button(constants.NewFormula());
        formula.addClickListener(new ClickListener() {

            public void onClick(Widget w) {
                con.constraintValueType = SingleFieldConstraint.TYPE_RET_VALUE;
                doTypeChosen(form);
            }
        });

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

        Button expression = new Button(constants.ExpressionEditor());
        expression.addClickListener(new ClickListener() {

            public void onClick(Widget w) {
                con.constraintValueType = SingleFieldConstraint.TYPE_EXPR_BUILDER;
                doTypeChosen(form);
            }
        });

        form.addAttribute(constants.ExpressionEditor() + ":",
                widgets(expression,
                new InfoPopup(constants.ExpressionEditor(),
                constants.ExpressionEditor())));


        form.show();
    }
View Full Code Here

        pop.show();
    }

    private void doRename() {
        final FormStylePopup pop = new FormStylePopup(DroolsGuvnorImages.INSTANCE.Wizard(),
                Constants.INSTANCE.RenameThePackage() );
        pop.addRow( new HTML( Constants.INSTANCE.RenamePackageTip() ) );
        final TextBox name = new TextBox();
        pop.addAttribute( Constants.INSTANCE.NewPackageNameIs(),
                name );
        Button ok = new Button( Constants.INSTANCE.OK() );
        pop.addAttribute( "",
                ok );

        ok.addClickHandler( new ClickHandler() {
            public void onClick(ClickEvent event) {
                moduleService.renameModule( packageConfigData.getUuid(),
                        name.getText(),
                        new GenericCallback<String>() {
                            public void onSuccess(String data) {
                                completedRenaming( data );
                                pop.hide();
                            }
                        } );
            }
        } );

        pop.show();
    }
View Full Code Here

    /**
     * Will show a copy dialog for copying the whole package.
     */
    private void doCopy() {
        final FormStylePopup pop = new FormStylePopup(DroolsGuvnorImages.INSTANCE.Wizard(),
                Constants.INSTANCE.CopyThePackage() );
        pop.addRow( new HTML( Constants.INSTANCE.CopyThePackageTip() ) );
        final TextBox name = new TextBox();
        pop.addAttribute( Constants.INSTANCE.NewPackageNameIs(),
                name );
        Button ok = new Button( Constants.INSTANCE.OK() );
        pop.addAttribute( "",
                ok );

        ok.addClickHandler( new ClickHandler() {

            public void onClick(ClickEvent event) {
                if ( !ModuleNameValidator.validatePackageName( name.getText() ) ) {
                    Window.alert( Constants.INSTANCE.NotAValidPackageName() );
                    return;
                }
                LoadingPopup.showMessage( Constants.INSTANCE.PleaseWaitDotDotDot() );
                moduleService.copyModule( packageConfigData.getName(),
                        name.getText(),
                        new GenericCallback<String>() {
                            public void onSuccess(String uuid) {
                                completedCopying( uuid );
                                pop.hide();
                            }
                        } );
            }
        } );

        pop.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.