Search in sources :

Example 1 with GwtUserStatus

use of org.eclipse.kapua.app.console.shared.model.GwtUser.GwtUserStatus in project kapua by eclipse.

the class UserForm method onRender.

protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    FormData formData = new FormData("0");
    // Create separate tabs
    m_tabsPanel = new TabPanel();
    m_tabsPanel.setPlain(true);
    m_tabsPanel.setBorders(false);
    m_tabsPanel.setBodyBorder(false);
    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setBorders(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setLayout(new FitLayout());
    m_formPanel.setPadding(0);
    m_formPanel.add(m_tabsPanel);
    // 
    // User info tab
    // 
    FieldSet infoFieldSet = new FieldSet();
    infoFieldSet.setHeading(MSGS.userFormInfo());
    infoFieldSet.setBorders(true);
    infoFieldSet.setStyleAttribute("margin", "0px 10px 0px 10px");
    FormLayout layout = new FormLayout();
    layout.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    infoFieldSet.setLayout(layout);
    username = new TextField<String>();
    username.setAllowBlank(false);
    username.setName("userName");
    username.setFieldLabel("* " + MSGS.userFormName());
    username.setValidator(new TextFieldValidator(username, FieldType.NAME));
    infoFieldSet.add(username, formData);
    password = new TextField<String>();
    password.setAllowBlank(false);
    password.setName("password");
    password.setFieldLabel("* " + MSGS.userFormPassword());
    password.setValidator(new PasswordFieldValidator(password));
    password.setPassword(true);
    infoFieldSet.add(password, formData);
    confirmPassword = new TextField<String>();
    confirmPassword.setAllowBlank(false);
    confirmPassword.setName("confirmPassword");
    confirmPassword.setFieldLabel("* " + MSGS.userFormConfirmPassword());
    confirmPassword.setValidator(new ConfirmPasswordFieldValidator(confirmPassword, password));
    confirmPassword.setPassword(true);
    infoFieldSet.add(confirmPassword, formData);
    LabelField tooltip = new LabelField();
    tooltip.setValue(MSGS.userFormPasswordTooltip());
    tooltip.setStyleAttribute("margin-top", "-5px");
    tooltip.setStyleAttribute("color", "gray");
    tooltip.setStyleAttribute("font-size", "10px");
    infoFieldSet.add(tooltip, formData);
    displayName = new TextField<String>();
    displayName.setName("displayName");
    displayName.setFieldLabel(MSGS.userFormDisplayName());
    infoFieldSet.add(displayName, formData);
    email = new TextField<String>();
    email.setName("userEmail");
    email.setFieldLabel(MSGS.userFormEmail());
    email.setValidator(new TextFieldValidator(email, FieldType.EMAIL));
    infoFieldSet.add(email, formData);
    phoneNumber = new TextField<String>();
    phoneNumber.setName("phoneNumber");
    phoneNumber.setFieldLabel(MSGS.userFormPhoneNumber());
    infoFieldSet.add(phoneNumber, formData);
    optlock = new NumberField();
    optlock.setName("optlock");
    optlock.setEditable(false);
    optlock.setVisible(false);
    infoFieldSet.add(optlock, formData);
    // status field set
    FormLayout userLayout = new FormLayout();
    userLayout.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    statusFieldSet = new FieldSet();
    statusFieldSet.setBorders(true);
    statusFieldSet.setStyleAttribute("margin", "5px 10px 0px 10px");
    statusFieldSet.setHeading(MSGS.userFormStatus());
    statusFieldSet.setLayout(userLayout);
    statusCombo = new SimpleComboBox<String>();
    statusCombo.setName("comboStatus");
    statusCombo.setFieldLabel(MSGS.userFormStatus());
    statusCombo.setLabelSeparator(":");
    statusCombo.setEditable(false);
    statusCombo.setTypeAhead(true);
    statusCombo.setTriggerAction(TriggerAction.ALL);
    // show account status combo box
    for (GwtUserStatus status : GwtUserStatus.values()) {
        statusCombo.add(MessageUtils.get(status.name()));
    }
    statusCombo.setSimpleValue(MessageUtils.get(GwtUserStatus.ENABLED.name()));
    statusFieldSet.add(statusCombo, formData);
    m_tabUserInfo = new TabItem(MSGS.userFormInformation());
    m_tabUserInfo.setBorders(false);
    m_tabUserInfo.setStyleAttribute("background-color", "#E8E8E8");
    m_tabUserInfo.setScrollMode(Scroll.AUTOY);
    m_tabUserInfo.add(infoFieldSet);
    m_tabUserInfo.add(statusFieldSet);
    m_tabsPanel.add(m_tabUserInfo);
    // button bar
    m_status = new Status();
    m_status.setBusy(MSGS.waitMsg());
    m_status.hide();
    m_status.setAutoWidth(true);
    submitButton = new Button(MSGS.submitButton(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            if (!m_formPanel.isValid()) {
                return;
            }
            // Hold the dialog until the action comes back
            m_status.show();
            m_formPanel.getButtonBar().disable();
            submitAccount();
        }
    });
    Button cancelButton = new Button(MSGS.cancelButton(), new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            hide();
        }
    });
    m_formPanel.getButtonBar().add(m_status);
    m_formPanel.getButtonBar().add(new FillToolItem());
    m_formPanel.setButtonAlign(HorizontalAlignment.CENTER);
    m_formPanel.addButton(submitButton);
    m_formPanel.addButton(cancelButton);
    loadUser();
    add(m_formPanel);
    setEditability();
}
Also used : FormData(com.extjs.gxt.ui.client.widget.layout.FormData) TabPanel(com.extjs.gxt.ui.client.widget.TabPanel) FormLayout(com.extjs.gxt.ui.client.widget.layout.FormLayout) GwtUserStatus(org.eclipse.kapua.app.console.shared.model.GwtUser.GwtUserStatus) Status(com.extjs.gxt.ui.client.widget.Status) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField) TabItem(com.extjs.gxt.ui.client.widget.TabItem) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) FormPanel(com.extjs.gxt.ui.client.widget.form.FormPanel) Button(com.extjs.gxt.ui.client.widget.button.Button) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) ConfirmPasswordFieldValidator(org.eclipse.kapua.app.console.client.util.ConfirmPasswordFieldValidator) TextFieldValidator(org.eclipse.kapua.app.console.client.util.TextFieldValidator) GwtUserStatus(org.eclipse.kapua.app.console.shared.model.GwtUser.GwtUserStatus) ConfirmPasswordFieldValidator(org.eclipse.kapua.app.console.client.util.ConfirmPasswordFieldValidator) PasswordFieldValidator(org.eclipse.kapua.app.console.client.util.PasswordFieldValidator) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) FillToolItem(com.extjs.gxt.ui.client.widget.toolbar.FillToolItem) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout) SelectionListener(com.extjs.gxt.ui.client.event.SelectionListener)

Aggregations

ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 SelectionListener (com.extjs.gxt.ui.client.event.SelectionListener)1 Status (com.extjs.gxt.ui.client.widget.Status)1 TabItem (com.extjs.gxt.ui.client.widget.TabItem)1 TabPanel (com.extjs.gxt.ui.client.widget.TabPanel)1 Button (com.extjs.gxt.ui.client.widget.button.Button)1 FieldSet (com.extjs.gxt.ui.client.widget.form.FieldSet)1 FormPanel (com.extjs.gxt.ui.client.widget.form.FormPanel)1 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)1 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 FormData (com.extjs.gxt.ui.client.widget.layout.FormData)1 FormLayout (com.extjs.gxt.ui.client.widget.layout.FormLayout)1 FillToolItem (com.extjs.gxt.ui.client.widget.toolbar.FillToolItem)1 ConfirmPasswordFieldValidator (org.eclipse.kapua.app.console.client.util.ConfirmPasswordFieldValidator)1 PasswordFieldValidator (org.eclipse.kapua.app.console.client.util.PasswordFieldValidator)1 TextFieldValidator (org.eclipse.kapua.app.console.client.util.TextFieldValidator)1 GwtUserStatus (org.eclipse.kapua.app.console.shared.model.GwtUser.GwtUserStatus)1