Package org.jboss.as.console.client.widgets.forms

Examples of org.jboss.as.console.client.widgets.forms.Form$FormItemVisitor


        layout.add(dataSourceTable);


        // -----------

        Form<DataSource> form = new Form(DataSource.class);
        form.setNumColumns(2);

        TextItem nameItem = new TextItem("name", "Name");
        CheckBoxItem enabledItem = new CheckBoxItem("enabled", "Is enabled?");
        TextBoxItem jndiItem = new TextBoxItem("jndiName", "JNDI");
        TextBoxItem driverItem = new TextBoxItem("driverClass", "Driver");

        TextBoxItem userItem = new TextBoxItem("username", "Username");
        PasswordBoxItem passwordItem = new PasswordBoxItem("password", "Password");

        form.setFields(nameItem, enabledItem, jndiItem, driverItem, userItem, passwordItem);
        form.bind(dataSourceTable);
        form.setEnabled(false); // currently not editable

        Widget formWidget = form.asWidget();

        layout.add(new ContentGroupLabel("Details"));
        layout.add(formWidget);
        return scroll;
    }
View Full Code Here


    public NewServerGroupWizard(final ServerGroupPresenter presenter, final List<ServerGroupRecord> existing) {
        layout = new VerticalPanel();
        layout.setStyleName("fill-layout-width");
        layout.getElement().setAttribute("cellpadding", "10");

        final Form<ServerGroupRecord> form = new Form(ServerGroupRecord.class);

        TextBoxItem nameField = new TextBoxItem("groupName", "Group Name")
        {
            @Override
            public boolean validate(String value) {
                boolean hasValue = super.validate(value);
                boolean hasWhitespace = value.contains(" ");
                return hasValue && !hasWhitespace;
            }

            @Override
            public String getErrMessage() {
                return "Not empty, no whitespace";
            }
        };

        final ComboBoxItem basedOnSelection = new ComboBoxItem("based-on", "Based On");

        String[] exists = new String[existing.size()];
        int i=0;
        for(ServerGroupRecord rec : existing)
        {
            exists[i] = rec.getGroupName();
            i++;
        }

        basedOnSelection.setDefaultToFirstOption(true);
        basedOnSelection.setValueMap(exists);

        form.setFields(nameField, basedOnSelection);

        Button submit = new DefaultButton("Save");
        submit.getElement().setAttribute("style", "width:50px;height:18px");
        submit.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                // merge base
                ServerGroupRecord newGroup = form.getUpdatedEntity();

                FormValidation validation = form.validate();
                if(validation.hasErrors())
                    return;

                ServerGroupRecord base = null;
                for(ServerGroupRecord rec : existing)
                {
                    if(rec.getGroupName().equals(basedOnSelection.getValue()))
                    {
                        base = rec;
                        break;
                    }
                }

                newGroup.setJvm(base.getJvm());
                newGroup.setSocketBinding(base.getSocketBinding());
                newGroup.setProfileName(base.getProfileName());
                newGroup.setProperties(base.getProperties());

                presenter.createNewGroup(newGroup);

            }
        });


        Label cancel = new Label("Cancel");
        cancel.setStyleName("html-link");
        cancel.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                presenter.closeDialoge();
            }
        });

        HorizontalPanel options = new HorizontalPanel();
        options.getElement().setAttribute("style", "width:100%");

        HTML spacer = new HTML("&nbsp;");
        options.add(spacer);
        //spacer.getElement().getParentElement().setAttribute("width", "100%");

        options.add(submit);
        options.add(spacer);
        options.add(cancel);
        cancel.getElement().getParentElement().setAttribute("style","vertical-align:middle");
        submit.getElement().getParentElement().setAttribute("align", "right");
        submit.getElement().getParentElement().setAttribute("width", "100%");

        // ----------------------------------------

        Widget formWidget = form.asWidget();

        layout.add(new HTML("Create a new server group based on an existing one. " +
                "The new group will inherit the properties of the selected group."));
        layout.add(formWidget);
View Full Code Here

    public NewGroupWizard(final ServerGroupPresenter presenter, final List<ServerGroupRecord> existing) {
        layout = new LayoutPanel();
        layout.setStyleName("fill-layout-width");
        layout.getElement().setAttribute("style", "margin:15px;");

        final Form<ServerGroupRecord> form = new Form(ServerGroupRecord.class);

        TextBoxItem nameField = new TextBoxItem("groupName", "Group Name");

        final ComboBoxItem basedOnSelection = new ComboBoxItem("based-on", "Based On");

        String[] exists = new String[existing.size()];
        int i=0;
        for(ServerGroupRecord rec : existing)
        {
            exists[i] = rec.getGroupName();
            i++;
        }

        basedOnSelection.setValueMap(exists);
        basedOnSelection.setDefaultToFirstOption(true);

        form.setFields(nameField, basedOnSelection);

        Button submit = new DefaultButton("Save");
        submit.getElement().setAttribute("style", "float:right");
        submit.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              // merge base
                ServerGroupRecord newGroup = form.getUpdatedEntity();
                ServerGroupRecord base = null;
                for(ServerGroupRecord rec : existing)
                {
                    if(rec.getGroupName().equals(basedOnSelection.getValue()))
                    {
                        base = rec;
                        break;
                    }
                }

                newGroup.setJvm(base.getJvm());
                newGroup.setSocketBinding(base.getSocketBinding());
                newGroup.setProfileName(base.getProfileName());
                newGroup.setProperties(base.getProperties());

                presenter.onNewGroup(newGroup);

            }
        });

        // ----------------------------------------

        Widget formWidget = form.asWidget();
        layout.add(formWidget);
        layout.add(submit);

        layout.setWidgetTopHeight(formWidget, 0, Style.Unit.PX, 150, Style.Unit.PX);
        layout.setWidgetTopHeight(submit, 160, Style.Unit.PX, 20, Style.Unit.PX);
View Full Code Here

TOP

Related Classes of org.jboss.as.console.client.widgets.forms.Form$FormItemVisitor

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.