Package com.smartgwt.client.widgets.form

Examples of com.smartgwt.client.widgets.form.DynamicForm


        });
        return form;
    }

    private DynamicForm createExistingPackageForm() {
        DynamicForm form = new DynamicForm();
        form.setTitleOrientation(TitleOrientation.TOP);
        existingPackageSelector = new SortedSelectItem("existingPackageSelector", "");
        existingPackageSelector.setDefaultToFirstOption(true);
        existingPackageSelector.setWrapTitle(false);
        existingPackageSelector.setRedrawOnChange(true);
        existingPackageSelector.setWidth(300);
        existingPackageSelector.setValueMap(MSG.common_msg_loading());
        existingPackageSelector.setDisabled(true);

        form.setFields(existingPackageSelector);
        return form;
    }
View Full Code Here


        addMember(createDeploymentsTable());
        addMember(detail);
    }

    private DynamicForm createSummaryForm() {
        DynamicForm form = new DynamicForm();
        form.setWidth100();
        form.setColWidths("20%", "40%", "40%");
        form.setNumCols(3);
        form.setAutoHeight();
        form.setWrapItemTitles(false);
        form.setExtraSpace(10);
        form.setIsGroup(true);
        form.setGroupTitle(MSG.common_title_summary());
        form.setPadding(5);

        StaticTextItem bundleName = new StaticTextItem("bundle");
        bundleName.setTitle(MSG.common_title_bundle());
        bundleName.setValue("<a href=\"" + LinkManager.getBundleLink(bundle.getId()) + "\">"
            + StringUtility.escapeHtml(bundle.getName()) + "</a>");

        CanvasItem actionItem = new CanvasItem("actions");
        actionItem.setColSpan(1);
        actionItem.setRowSpan(5);
        actionItem.setShowTitle(false);
        actionItem.setCanvas(getActionLayout());

        StaticTextItem created = new StaticTextItem("created", MSG.view_bundle_dest_created());
        created.setValue(new Date(destination.getCtime()));

        StaticTextItem destinationGroup = new StaticTextItem("group");
        destinationGroup.setTitle(MSG.view_bundle_dest_group());
        destinationGroup.setValue("<a href=\"" + LinkManager.getResourceGroupLink(destination.getGroup()) + "\">"
            + StringUtility.escapeHtml(destination.getGroup().getName()) + "</a>");

        StaticTextItem baseDirName = new StaticTextItem("baseDir", MSG.view_bundle_dest_baseDirName());
        baseDirName.setValue(destination.getDestinationSpecificationName());

        StaticTextItem path = new StaticTextItem("path", MSG.view_bundle_dest_deployDir());
        path.setValue(destination.getDeployDir());

        StaticTextItem description = new StaticTextItem("description", MSG.common_title_description());
        description.setValue(StringUtility.escapeHtml(destination.getDescription()));

        form.setFields(bundleName, actionItem, created, destinationGroup, baseDirName, path, description);
        return form;
    }
View Full Code Here

        }
        if (handler != null) {
            setValueEditedHandler(handler);
        }

        this.innerForm = new DynamicForm();
        this.staticItem = prepareStaticFormItem();
        this.editItem = prepareEditFormItem();
        this.innerForm.setCanFocus(true);
        this.innerForm.setNumCols(1);
View Full Code Here

            Map<String, Integer> bodyDefaults = new HashMap<String, Integer>(2);
            bodyDefaults.put("layoutLeftMargin", 15);
            bodyDefaults.put("membersMargin", 10);
            setBodyDefaults(bodyDefaults);

            final DynamicForm form = new DynamicForm();
            addItem(form);

            tagInputItem = new ComboBoxItem("tag");
            tagInputItem.setShowTitle(false);
            tagInputItem.setHideEmptyPickList(true);
            tagInputItem.setValueField("tag");
            tagInputItem.setDisplayField("tag");
            tagInputItem.setType("comboBox");
            tagInputItem.setTextMatchStyle(TextMatchStyle.SUBSTRING);
            tagInputItem.setTooltip(MSG.view_tags_tooltip_3());
            tagInputItem.addKeyPressHandler(new KeyPressHandler() {
                public void onKeyPress(KeyPressEvent event) {
                    if ((event.getCharacterValue() != null) && (event.getCharacterValue() == KeyCodes.KEY_ENTER)) {
                        //String tag = form.getValueAsString("tag");
                        String tag = tagInputItem.getEnteredValue();
                        if (tag != null) {
                            Tag newTag = new Tag(tag.trim());
                            tags.add(newTag);
                            TagEditorView.this.save();
                            TagInputDialog.this.hide();
                        }
                    }
                }
            });
            form.setFields(tagInputItem);
        }
View Full Code Here

            // No or one prop groups, so we just need a single form for the non-grouped props
            // and another one if there is just one group
            List<PropertyDefinition> propertyDefinitions = new ArrayList<PropertyDefinition>(
                configurationDefinition.getNonGroupedProperties());
            if (!propertyDefinitions.isEmpty()) {
                DynamicForm form = buildPropertiesForm(propertyDefinitions, configuration);
                form.validate();
                layout.addMember(form);
            }
            if (groupDefinitions.size() == 1) {
                propertyDefinitions = new ArrayList<PropertyDefinition>(
                    configurationDefinition.getPropertiesInGroup(groupDefinitions.get(0).getName()));
                DynamicForm groupForm = buildPropertiesForm(propertyDefinitions, configuration);
                groupForm.setIsGroup(true);
                groupForm.setGroupTitle(groupDefinitions.get(0).getDisplayName());
                groupForm.validate();
                layout.addMember(groupForm);
            }
        } else {
            // Two or more prop groups, so create a section stack with one section per group.
            final SectionStack sectionStack = new SectionStack();
View Full Code Here

        List<PropertyDefinition> propertyDefinitions = new ArrayList<PropertyDefinition>(
            ((group == null) ? configurationDefinition.getNonGroupedProperties()
                : configurationDefinition.getPropertiesInGroup(group.getName())));

        DynamicForm form = buildPropertiesForm(propertyDefinitions, configuration);

        // If the group contains any invalid properties, expand the section so the user can see the error icons next to
        // the invalid properties.
        if (!form.validate()) {
            section.setExpanded(true);
        }

        section.addItem(form);
        return section;
View Full Code Here

    }

    protected DynamicForm buildPropertiesForm(Collection<PropertyDefinition> propertyDefinitions,
        AbstractPropertyMap propertyMap) {

        DynamicForm form = new DynamicForm();
        if (propertyMap instanceof Configuration) {
            this.topLevelPropertiesValuesManager.addMember(form);
        }
        form.setHiliteRequiredFields(true);
        form.setNumCols(4);
        form.setCellPadding(5);
        form.setColWidths(190, 28, 210);
        form.setStyleName("propertiesForm");

        List<FormItem> fields = new ArrayList<FormItem>();
        addHeaderItems(fields);
        addItemsForPropertiesRecursively(propertyDefinitions, propertyMap, fields);
        form.setFields(fields.toArray(new FormItem[fields.size()]));

        return form;
    }
View Full Code Here

        HTMLFlow description = new HTMLFlow(propertyDefinitionMap.getDescription());
        layout.addMember(description);

        final PropertyDefinitionMap propertyDefinitionMapFinal = propertyDefinitionMap;
        DynamicForm valuesCanvas = buildPropertiesForm(propertyDefinitionMapFinal.getOrderedPropertyDefinitions(),
            propertyMap);
        layout.addMember(valuesCanvas);

        if (isDynamic && !isReadOnly(propertyDefinitionMap, propertyMap)) {
            // Map is not read-only - add footer with New and Delete buttons to allow user to add or remove members.
            EnhancedToolStrip buttonBar = new EnhancedToolStrip();
            buttonBar.setPadding(5);
            buttonBar.setMembersMargin(15);

            final IButton newButton = new EnhancedIButton(MSG.common_button_new(), ButtonColor.BLUE);
            newButton.setIcon(Window.getImgURL("[SKIN]/actions/add.png"));
            newButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                public void onClick(ClickEvent clickEvent) {
                    SC.askforValue(MSG.view_configEdit_enterPropName(), new ValueCallback() {
                        public void execute(String propertyName) {
                            if (propertyMap.get(propertyName) != null) {
                                CoreGUI.getMessageCenter().notify(
                                    new Message(MSG.view_configEdit_error_3(propertyName), Message.Severity.Error,
                                        EnumSet.of(Message.Option.Transient)));
                            } else {
                                PropertySimple memberPropertySimple = new PropertySimple(propertyName, null);
                                addPropertyToDynamicMap(memberPropertySimple, propertyMap);
                                firePropertyChangedEvent(propertyMap, propertyDefinitionMapFinal, true);

                                reload();

                                CoreGUI.getMessageCenter().notify(
                                    new Message(MSG.view_configEdit_msg_1(propertyName), EnumSet
                                        .of(Message.Option.Transient)));
                            }
                        }
                    });
                }
            });
            buttonBar.addMember(newButton);

            HLayout spacer = new HLayout();
            spacer.setWidth(12);
            buttonBar.addMember(spacer);

            EnhancedHLayout deleteControlsLayout = new EnhancedHLayout();
            deleteControlsLayout.setMargin(3);
            deleteControlsLayout.setMembersMargin(3);
            deleteControlsLayout.setWidth100();
            DynamicForm deleteForm = new DynamicForm();
            deleteForm.setWidth100();

            final SelectItem selectItem = new SortedSelectItem();
            selectItem.setMultiple(true);
            selectItem.setMultipleAppearance(MultipleAppearance.GRID);
            selectItem.setTitle(MSG.common_button_delete());
            selectItem.setValueMap(propertyDefinitionMap.getMap().keySet()
                .toArray(new String[propertyDefinitionMap.getMap().size()]));

            final EnhancedIButton okButton = new EnhancedIButton(MSG.common_button_ok(), ButtonColor.BLUE);
            okButton.setDisabled(true);
            okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                public void onClick(ClickEvent clickEvent) {
                    SC.confirm(MSG.view_configEdit_confirm_1(), new BooleanCallback() {
                        @Override
                        public void execute(Boolean confirmed) {
                            if (confirmed) {
                                Object value = selectItem.getValue();
                                if (value != null) {
                                    String stringValue = value.toString();
                                    String[] memberPropertyNames = stringValue.split(",");
                                    for (final String memberPropertyName : memberPropertyNames) {
                                        PropertySimple memberPropertySimple = propertyMap.getSimple(memberPropertyName);
                                        removePropertyFromDynamicMap(memberPropertySimple);
                                        firePropertyChangedEvent(propertyMap, propertyDefinitionMapFinal, true);
                                    }
                                }

                                reload();
                                CoreGUI.getMessageCenter().notify(
                                    new Message(MSG.view_configEdit_msg_2(), EnumSet.of(Message.Option.Transient)));
                            }
                        }
                    });
                }
            });

            selectItem.addChangedHandler(new ChangedHandler() {
                @Override
                public void onChanged(ChangedEvent changedEvent) {
                    Object value = changedEvent.getValue();
                    if (value != null) {
                        String stringValue = value.toString();
                        String[] memberPropertyNames = stringValue.split(",");
                        okButton.setDisabled(memberPropertyNames.length == 0);
                    }
                }
            });

            deleteForm.setFields(selectItem);
            deleteControlsLayout.addMember(deleteForm);
            deleteControlsLayout.addMember(okButton);

            buttonBar.addMember(deleteControlsLayout);
            layout.addMember(buttonBar);
View Full Code Here

        final PropertyList propertyList) {
        Log.debug("Building list-of-simples field for " + propertyList + "...");

        EnhancedVLayout vLayout = new EnhancedVLayout();

        final DynamicForm listGrid = new DynamicForm();
        vLayout.addMember(listGrid);

        final SelectItem membersItem = new SelectItem(propertyList.getName());
        membersItem.setShowTitle(false);
        membersItem.setMultiple(true);
        membersItem.setMultipleAppearance(MultipleAppearance.GRID);
        membersItem.setWidth(220);
        membersItem.setHeight(60);
        LinkedHashMap<String, String> memberValueToIndexMap = buildValueMap(propertyList);
        membersItem.setValueMap(memberValueToIndexMap);
        listGrid.setItems(membersItem);

        if (!isReadOnly(propertyDefinitionList, propertyList)) {
            // List is not read-only - add footer with New and Delete buttons to allow user to add or remove members.
            ToolStrip footer = new ToolStrip();
            footer.setPadding(5);
            footer.setWidth100();
            footer.setMembersMargin(15);
            vLayout.addMember(footer);

            final IButton deleteButton = new EnhancedIButton(MSG.common_button_delete());
            deleteButton.setIcon(Window.getImgURL(ImageManager.getRemoveIcon()));
            deleteButton.setTooltip(MSG.view_configEdit_tooltip_1());
            deleteButton.setDisabled(true);
            deleteButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                public void onClick(ClickEvent clickEvent) {
                    final String[] selectedValues = membersItem.getValues();
                    final String noun = (selectedValues.length == 1) ? MSG.common_label_item() : MSG
                        .common_label_items();
                    String message = MSG.view_configEdit_confirm_3(Integer.toString(selectedValues.length), noun);
                    if (propertyList.getList().size() <= propertyDefinitionList.getMin()) {
                        SC.say("You cannot delete this entry because the minimum size bounds has been met: "
                            + propertyDefinitionList.getMin());
                    } else {
                        SC.ask(message, new BooleanCallback() {
                            public void execute(Boolean confirmed) {
                                if (confirmed) {
                                    for (int i = selectedValues.length - 1; i >= 0; i--) {
                                        String selectedValue = selectedValues[i];
                                        int index = Integer.valueOf(selectedValue);
                                        propertyList.getList().remove(index);

                                        // Rebuild the select item options.
                                        LinkedHashMap<String, String> memberValueToIndexMap = buildValueMap(propertyList);
                                        membersItem.setValueMap(memberValueToIndexMap);

                                        deleteButton.disable();

                                        firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
                                        CoreGUI.getMessageCenter().notify(
                                            new Message(MSG.view_configEdit_msg_3(
                                                Integer.toString(selectedValues.length), noun), EnumSet
                                                .of(Message.Option.Transient)));
                                    }
                                }
                            }
                        });
                    }
                }
            });
            footer.addMember(deleteButton);

            membersItem.addChangedHandler(new ChangedHandler() {
                @Override
                public void onChanged(ChangedEvent changedEvent) {
                    String[] selectedValues = membersItem.getValues();
                    int count = selectedValues.length;
                    deleteButton.setDisabled(count < 1);
                }
            });

            final IButton newButton = new EnhancedIButton(MSG.common_button_new());
            newButton.setIcon(Window.getImgURL(ImageManager.getAddIcon()));
            newButton.setTooltip(MSG.view_configEdit_tooltip_2());
            newButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                public void onClick(ClickEvent clickEvent) {

                    if (propertyList.getList().size() >= propertyDefinitionList.getMax()) {
                        SC.say(MSG.view_configEdit_maxBoundsExceeded(String.valueOf(propertyDefinitionList.getMax())));
                    } else {
                        final Window popup = createPopup(MSG.view_configEdit_addItem(), 400, 150);

                        VLayout vLayout = new VLayout();
                        vLayout.setMargin(10);

                        HTMLFlow description = new HTMLFlow(propertyDefinitionList.getDescription());
                        vLayout.addMember(description);

                        final DynamicForm form = new DynamicForm();

                        PropertyDefinitionSimple memberPropertyDefinitionSimple = (PropertyDefinitionSimple) propertyDefinitionList
                            .getMemberDefinition();
                        final String propertyName = memberPropertyDefinitionSimple.getName();
                        final PropertySimple newMemberPropertySimple = new PropertySimple(propertyName, null);

                        FormItem simpleField = buildSimpleField(memberPropertyDefinitionSimple, newMemberPropertySimple);
                        simpleField.setTitle(memberPropertyDefinitionSimple.getDisplayName());
                        simpleField.setShowTitle(true);
                        simpleField.setAlign(Alignment.CENTER);
                        simpleField.setDisabled(false);
                        simpleField.setRequired(true);
                        simpleField.setEndRow(true);

                        SpacerItem spacer = new SpacerItem();
                        spacer.setHeight(9);

                        form.setItems(simpleField, spacer);
                        vLayout.addMember(form);

                        final IButton okButton = new EnhancedIButton(MSG.common_button_ok(), ButtonColor.BLUE);
                        okButton.disable();
                        okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                            public void onClick(ClickEvent clickEvent) {
                                propertyList.add(newMemberPropertySimple);

                                // Rebuild the select item options.
                                LinkedHashMap<String, String> memberValueToIndexMap = buildValueMap(propertyList);
                                membersItem.setValueMap(memberValueToIndexMap);

                                firePropertyChangedEvent(propertyList, propertyDefinitionList, true);
                                CoreGUI.getMessageCenter().notify(
                                    new Message(MSG.view_configEdit_msg_4(), EnumSet.of(Message.Option.Transient)));

                                popup.destroy();
                            }
                        });

                        form.addItemChangedHandler(new ItemChangedHandler() {
                            public void onItemChanged(ItemChangedEvent itemChangedEvent) {
                                Object newValue = itemChangedEvent.getNewValue();
                                newMemberPropertySimple.setValue(newValue);

                                // Only enable the OK button, allowing the user to add the property to the map, if the
                                // property is valid.
                                boolean isValid = form.validate();
                                okButton.setDisabled(!isValid);
                            }
                        });

                        final IButton cancelButton = new EnhancedIButton(MSG.common_button_cancel());
View Full Code Here

        final EnhancedVLayout layout = new EnhancedVLayout();
        layout.setHeight100();
        layout.setMargin(8);

        final DynamicForm childForm = buildPropertiesForm(memberDefinitions, workingMap);
        childForm.setHeight100();
        layout.addMember(childForm);

        ToolStrip buttonBar = new ToolStrip();
        buttonBar.setPadding(5);
        buttonBar.setWidth100();
        buttonBar.setMembersMargin(15);
        buttonBar.setAlign(Alignment.CENTER);

        final IButton okButton = new EnhancedIButton(MSG.common_button_ok(), ButtonColor.BLUE);
        if (!mapReadOnly) {
            okButton.disable();
        }
        okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                if (!mapReadOnly) {
                    if (!childForm.validate()) {
                        okButton.disable();
                        return;
                    }
                    if (newRow) {
                        propertyList.add(workingMap);
                        int index = propertyList.getList().size() - 1;
                        PropertyMapListGridRecord record = new PropertyMapListGridRecord(workingMap, index,
                            memberDefinitions);
                        summaryTable.addData(record);
                    } else {
                        mergePropertyMap(workingMap, memberMap, memberDefinitions);
                        existingRecord.refresh();
                        summaryTable.updateData(existingRecord);
                    }
                    boolean listGridRecordCountValid = isListGridRecordCountValid(summaryTable.getRecords(),
                        propertyDefinitionList.getMin(), propertyDefinitionList.getMax());
                    if (errorPanel.isVisible() && listGridRecordCountValid) {
                        errorPanel.setVisible(false);
                    }
                    firePropertyChangedEvent(propertyList, propertyDefinitionList, listGridRecordCountValid);
                    summaryTable.redraw();
                }

                //reset the custom blur event handling - we're destroying the new form here
                blurUnsetItem = null;
                blurValueItem = null;

                layout.destroy();
                popup.destroy();
            }
        });

        // Only enable the OK button if all properties are valid.
        childForm.addItemChangedHandler(new ItemChangedHandler() {
            public void onItemChanged(ItemChangedEvent itemChangedEvent) {
                // TODO (ips, 03/14/11): Ideally, we would validate the form here, but it's preventing boolean prop
                //                       radio buttons from being selectable, most likely due to a SmartGWT bug.
                //okButton.setDisabled(!childForm.validate());
                okButton.setDisabled(false);
View Full Code Here

TOP

Related Classes of com.smartgwt.client.widgets.form.DynamicForm

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.