Search in sources :

Example 1 with MultiField

use of com.extjs.gxt.ui.client.widget.form.MultiField in project kapua by eclipse.

the class DeviceConfigPanel method getUpdatedConfiguration.

public GwtConfigComponent getUpdatedConfiguration() {
    List<Component> fields = m_actionFieldSet.getItems();
    for (int i = 0; i < fields.size(); i++) {
        if (fields.get(i) instanceof Field<?>) {
            Field<?> field = (Field<?>) fields.get(i);
            String fieldName = field.getItemId();
            GwtConfigParameter param = m_configComponent.getParameter(fieldName);
            if (param == null) {
                System.err.println(field);
            }
            if (!(field instanceof MultiField) || (field instanceof RadioGroup)) {
                // get the updated values for the single field
                String value = getUpdatedFieldConfiguration(param, field);
                param.setValue(value);
            } else {
                // iterate over the subfields and extract each value
                List<String> multiFieldValues = new ArrayList<String>();
                MultiField<?> multiField = (MultiField<?>) field;
                List<Field<?>> childFields = multiField.getAll();
                for (int j = 0; j < childFields.size(); j++) {
                    Field<?> childField = (Field<?>) childFields.get(j);
                    String value = getUpdatedFieldConfiguration(param, childField);
                    if (value != null) {
                        multiFieldValues.add(value);
                    }
                }
                param.setValues(multiFieldValues.toArray(new String[] {}));
            }
        }
    }
    return m_configComponent;
}
Also used : RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) ArrayList(java.util.ArrayList) MultiField(com.extjs.gxt.ui.client.widget.form.MultiField) MultiField(com.extjs.gxt.ui.client.widget.form.MultiField) TextField(com.extjs.gxt.ui.client.widget.form.TextField) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField) Field(com.extjs.gxt.ui.client.widget.form.Field) GwtConfigParameter(org.eclipse.kapua.app.console.shared.model.GwtConfigParameter) GwtConfigComponent(org.eclipse.kapua.app.console.shared.model.GwtConfigComponent) Component(com.extjs.gxt.ui.client.widget.Component)

Example 2 with MultiField

use of com.extjs.gxt.ui.client.widget.form.MultiField in project kura by eclipse.

the class DeviceConfigPanel method getUpdatedConfiguration.

public GwtConfigComponent getUpdatedConfiguration() {
    List<Component> fields = m_actionFieldSet.getItems();
    for (int i = 0; i < fields.size(); i++) {
        if (fields.get(i) instanceof Field<?>) {
            Field<?> field = (Field<?>) fields.get(i);
            String fieldName = field.getItemId();
            GwtConfigParameter param = m_configComponent.getParameter(fieldName);
            if (param == null) {
                System.err.println(field);
            }
            if (!(field instanceof MultiField) || (field instanceof RadioGroup)) {
                // get the updated values for the single field
                String value = getUpdatedFieldConfiguration(param, field);
                param.setValue(value);
            } else {
                // iterate over the subfields and extract each value
                List<String> multiFieldValues = new ArrayList<String>();
                MultiField<?> multiField = (MultiField<?>) field;
                List<Field<?>> childFields = multiField.getAll();
                for (int j = 0; j < childFields.size(); j++) {
                    Field<?> childField = (Field<?>) childFields.get(j);
                    String value = getUpdatedFieldConfiguration(param, childField);
                    if (value != null) {
                        multiFieldValues.add(value);
                    }
                }
                param.setValues(multiFieldValues.toArray(new String[] {}));
            }
        }
    }
    return m_configComponent;
}
Also used : RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) ArrayList(java.util.ArrayList) MultiField(com.extjs.gxt.ui.client.widget.form.MultiField) MultiField(com.extjs.gxt.ui.client.widget.form.MultiField) TextField(com.extjs.gxt.ui.client.widget.form.TextField) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField) Field(com.extjs.gxt.ui.client.widget.form.Field) GwtConfigParameter(org.eclipse.kura.web.shared.model.GwtConfigParameter) Component(com.extjs.gxt.ui.client.widget.Component) GwtConfigComponent(org.eclipse.kura.web.shared.model.GwtConfigComponent)

Example 3 with MultiField

use of com.extjs.gxt.ui.client.widget.form.MultiField in project geo-platform by geosdi.

the class UserPropertiesBinding method createFormPanel.

@Override
public FormPanel createFormPanel() {
    FormPanel fp = new FormPanel();
    fp.setHeaderVisible(false);
    fp.setBodyBorder(Boolean.FALSE);
    this.nameField = new GPSecureStringTextField();
    this.nameField.setId(GPSimpleUserKeyValue.NAME.toString());
    this.nameField.setFieldLabel(UserModuleConstants.INSTANCE.nameFieldText());
    this.nameField.setEmptyText(UserModuleConstants.INSTANCE.UserPropertiesBinding_nameFieldEmptyText());
    this.nameField.setToolTip(UserModuleConstants.INSTANCE.UserPropertiesBinding_nameFieldToolTipText());
    this.nameField.setAutoValidate(true);
    this.emailField = new GPSecureStringTextField();
    this.emailField.setId(GPSimpleUserKeyValue.EMAIL.toString());
    this.emailField.setFieldLabel(UserModuleConstants.INSTANCE.emailFieldText());
    this.emailField.setEmptyText(UserModuleConstants.INSTANCE.UserPropertiesBinding_emailFieldEmptyText());
    this.emailField.setToolTip(UserModuleConstants.INSTANCE.UserPropertiesBinding_emailFieldToolTipText());
    this.emailField.setAutoValidate(true);
    this.usernameField = new GPSecureStringTextField();
    this.usernameField.setId(GPSimpleUserKeyValue.USERNAME.toString());
    this.usernameField.setFieldLabel(UserModuleConstants.INSTANCE.usernameFieldText());
    this.usernameField.setEmptyText(UserModuleConstants.INSTANCE.UserPropertiesBinding_usernameFieldEmptyText());
    this.usernameField.setToolTip(UserModuleConstants.INSTANCE.UserPropertiesBinding_usernameFieldToolTipText());
    this.usernameField.setAllowBlank(false);
    this.usernameField.setAutoValidate(true);
    this.usernameField.setMinLength(4);
    this.passwordField = new GPSecureStringTextField();
    this.passwordField.setPassword(true);
    this.passwordField.setFieldLabel(UserModuleConstants.INSTANCE.UserPropertiesBinding_passwordFieldText());
    this.passwordField.setValidator(this.validatorPassword());
    this.passwordRepeatField = new GPSecureStringTextField();
    this.passwordRepeatField.setPassword(true);
    this.passwordRepeatField.setFieldLabel(UserModuleConstants.INSTANCE.UserPropertiesBinding_repeatPasswordFieldText());
    this.passwordRepeatField.setToolTip(UserModuleConstants.INSTANCE.UserPropertiesBinding_repeatPasswordFieldTooltipText());
    this.enabledField = new CheckBox();
    this.enabledField.setId(GPUserManageDetailKeyValue.ENABLED.toString());
    this.enabledField.setToolTip(UserModuleConstants.INSTANCE.UserPropertiesBinding_enableFieldTooltipText());
    this.enabledField.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            Boolean check = (Boolean) be.getValue();
            if (check.booleanValue() != userOriginal.isEnabled()) {
                updateEnabled(true);
            } else {
                updateEnabled(false);
            }
        }
    });
    this.creationDateLabelField = new LabelField();
    MultiField enabledAndCreationFields = new MultiField();
    enabledAndCreationFields.setFieldLabel(UserModuleConstants.INSTANCE.enabledFieldLabelText());
    enabledAndCreationFields.add(enabledField);
    enabledAndCreationFields.add(new LabelField("<span class='spacer'>&nbsp;</span>"));
    enabledAndCreationFields.add(creationDateLabelField);
    this.temporaryField = new CheckBox();
    this.temporaryField.setId(GPUserManageDetailKeyValue.TEMPORARY.toString());
    this.temporaryField.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            Boolean temporary = (Boolean) be.getValue();
            if (temporary.booleanValue() != userOriginal.isTemporary()) {
                updateTemporary(true);
            } else {
                updateTemporary(false);
            }
        }
    });
    this.expiredLabelField = new LabelField();
    MultiField tempAndExpiredFields = new MultiField();
    tempAndExpiredFields.setFieldLabel(UserModuleConstants.INSTANCE.temporaryFieldLabelText());
    tempAndExpiredFields.add(temporaryField);
    tempAndExpiredFields.add(new LabelField("<span class='spacer'>&nbsp;</span>"));
    tempAndExpiredFields.add(expiredLabelField);
    this.userRoleComboBox = new SimpleComboBox<String>() {

        @Override
        protected void onSelect(SimpleComboValue<String> model, int index) {
            super.onSelect(model, index);
            roleComboBinding.updateModel();
        }
    };
    this.userRoleComboBox.setId(GPSimpleUserKeyValue.AUTORITHY.toString());
    this.userRoleComboBox.setFieldLabel(UserModuleConstants.INSTANCE.userRoleLabelText());
    this.userRoleComboBox.setEmptyText(UserModuleConstants.INSTANCE.UserPropertiesBinding_userRoleEmptyText());
    this.userRoleComboBox.setToolTip(UserModuleConstants.INSTANCE.UserPropertiesBinding_userRoleTooltipText());
    this.userRoleComboBox.setEditable(false);
    this.userRoleComboBox.setTypeAhead(true);
    this.userRoleComboBox.setAllowBlank(false);
    this.userRoleComboBox.setMaxHeight(150);
    this.userRoleComboBox.setTriggerAction(TriggerAction.ALL);
    this.trustedLevelComboBox = new SimpleComboBox<GPTrustedLevel>();
    this.trustedLevelComboBox.setId(GPSimpleUserKeyValue.TRUSTED_LEVEL.toString());
    this.trustedLevelComboBox.setFieldLabel(UserModuleConstants.INSTANCE.UserPropertiesBinding_trustedLevelLabelText());
    this.trustedLevelComboBox.setEmptyText(UserModuleConstants.INSTANCE.UserPropertiesBinding_trustedLevelEmptyText());
    this.trustedLevelComboBox.setToolTip(UserModuleConstants.INSTANCE.UserPropertiesBinding_trustedLevelTooltipText());
    this.trustedLevelComboBox.setEditable(false);
    this.trustedLevelComboBox.setTypeAhead(true);
    this.trustedLevelComboBox.setAllowBlank(false);
    this.trustedLevelComboBox.setMaxHeight(200);
    this.trustedLevelComboBox.setTriggerAction(TriggerAction.ALL);
    this.trustedLevelComboBox.add(Arrays.asList(GPTrustedLevel.values()));
    fp.add(this.nameField);
    fp.add(this.emailField);
    fp.add(this.usernameField);
    fp.add(this.passwordField);
    fp.add(this.passwordRepeatField);
    fp.add(enabledAndCreationFields);
    fp.add(tempAndExpiredFields);
    fp.add(this.userRoleComboBox);
    fp.add(this.trustedLevelComboBox);
    fp.setBorders(Boolean.FALSE);
    return fp;
}
Also used : GPSecureStringTextField(org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) MultiField(com.extjs.gxt.ui.client.widget.form.MultiField) GPTrustedLevel(org.geosdi.geoplatform.gui.shared.GPTrustedLevel) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) CheckBox(com.extjs.gxt.ui.client.widget.form.CheckBox) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField)

Aggregations

MultiField (com.extjs.gxt.ui.client.widget.form.MultiField)3 Component (com.extjs.gxt.ui.client.widget.Component)2 Field (com.extjs.gxt.ui.client.widget.form.Field)2 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)2 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)2 TextField (com.extjs.gxt.ui.client.widget.form.TextField)2 ArrayList (java.util.ArrayList)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 CheckBox (com.extjs.gxt.ui.client.widget.form.CheckBox)1 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)1 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)1 GwtConfigComponent (org.eclipse.kapua.app.console.shared.model.GwtConfigComponent)1 GwtConfigParameter (org.eclipse.kapua.app.console.shared.model.GwtConfigParameter)1 GwtConfigComponent (org.eclipse.kura.web.shared.model.GwtConfigComponent)1 GwtConfigParameter (org.eclipse.kura.web.shared.model.GwtConfigParameter)1 GPSecureStringTextField (org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField)1 GPTrustedLevel (org.geosdi.geoplatform.gui.shared.GPTrustedLevel)1