Ejemplo n.º 1
0
 /**
  * Instantiates a new prompt top dialog.
  *
  * @param builder the builder
  */
 protected PromptTopDialog(final Builder builder) {
   super(builder);
   promptLabel = new Label();
   promptLabel.addStyleName("kune-Margin-Medium-b");
   if (builder.promptLines > 1) {
     textField = new TextArea();
     textField.setHeight(20 * builder.promptLines);
   } else {
     textField = new TextField<String>();
   }
   if (TextUtils.notEmpty(builder.textFieldStyle)) {
     textField.addStyleName(builder.textFieldStyle);
   }
   textField.setRegex(builder.regex);
   textField.getMessages().setRegexText(builder.regexText);
   textField.getMessages().setMinLengthText(builder.minLengthText);
   textField.getMessages().setMaxLengthText(builder.maxLengthText);
   textField.setTabIndex(1);
   textField.setId(builder.textboxId);
   if (TextUtils.notEmpty(builder.emptyText)) {
     textField.setEmptyText(builder.emptyText);
   }
   if (builder.textFieldWidth != 0) {
     textField.setWidth(builder.textFieldWidth);
   }
   if (builder.minLength != 0) {
     textField.setMinLength(builder.minLength);
   }
   if (builder.maxLength != 0) {
     textField.setMaxLength(builder.maxLength);
   }
   if (builder.promptWidth != 0) {
     textField.setWidth(builder.promptWidth);
   }
   textField.setAllowBlank(builder.allowBlank);
   textField.addListener(
       Events.OnKeyPress,
       new Listener<FieldEvent>() {
         @Override
         public void handleEvent(final FieldEvent fe) {
           if (fe.getEvent().getKeyCode() == 13) {
             builder.onEnter.onEnter();
           }
         }
       });
   if (TextUtils.notEmpty(builder.promptText)) {
     promptLabel.setText(builder.promptText);
   }
   super.getInnerPanel().add(promptLabel);
   super.getInnerPanel().add(textField);
 }
Ejemplo n.º 2
0
  @Override
  protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);

    tfTitle.setFieldLabel("Title");
    tfTitle.setAllowBlank(false);
    tfTitle.getMessages().setBlankText("Title is required");

    taDescription.setFieldLabel("Description");
    taDescription.setAllowBlank(false);
    taDescription.getMessages().setBlankText("Description is required");

    tfLink.setFieldLabel("Link");
    tfLink.setAllowBlank(false);
    tfLink.setRegex("^http\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(/\\S*)?$");
    tfLink.getMessages().setBlankText("Link is required");
    tfLink
        .getMessages()
        .setRegexText("The link field must be a URL e.g. http://www.example.com/rss.xml");

    add(tfTitle);
    add(taDescription);
    add(tfLink);
  }
Ejemplo n.º 3
0
  private FormPanel setupUserRightForm(String title, int tabIndex) {

    FormPanel formPanel = new FormPanel();
    formPanel.setTitle(title);
    formPanel.setHeaderVisible(false);
    formPanel.setBodyBorder(false);
    formPanel.setWidth(400);
    //	    formPanel.setLabelAlign(LabelAlign.RIGHT); // default is LEFT
    formPanel.setLabelWidth(150);

    // Address fields
    FieldSet addressfieldSet = new FieldSet();
    addressfieldSet.setHeading("Address");
    addressfieldSet.setCollapsible(true);
    addressfieldSet.setBorders(false);
    FormLayout addresslayout = new FormLayout();
    addresslayout.setLabelWidth(150);
    addressfieldSet.setLayout(addresslayout);

    address = new TextField<String>();
    address.setFieldLabel("Address");
    address.setTabIndex(tabIndex++);

    city = new TextField<String>();
    city.setFieldLabel("City");
    city.setAllowBlank(false);
    city.setTabIndex(tabIndex++);

    state = new ComboBox<State>();
    state.setFieldLabel("State");
    state.setEmptyText("Select a state...");
    state.setDisplayField("name");
    state.setWidth(150);
    state.setStore(states);
    state.setTypeAhead(true);
    state.setTriggerAction(TriggerAction.ALL);
    state.setTabIndex(tabIndex++);

    zip = new TextField<String>();
    zip.setFieldLabel("Zip Code");
    zip.setAllowBlank(false);
    zip.setTabIndex(tabIndex++);

    country = new ComboBox<Country>();
    country.setFieldLabel("Country");
    country.setEmptyText("Select a country...");
    country.setDisplayField("name");
    country.setTemplate(InputFormat.getFlagTemplate());
    country.setWidth(100);
    country.setStore(countries);
    country.setTypeAhead(true);
    country.setTriggerAction(TriggerAction.ALL);
    country.setTabIndex(tabIndex++);

    addressfieldSet.add(address);
    addressfieldSet.add(city);
    addressfieldSet.add(state);
    addressfieldSet.add(zip);
    addressfieldSet.add(country);

    FieldSet otherfieldSet = new FieldSet();
    otherfieldSet.setHeading("Other");
    otherfieldSet.setCollapsible(true);
    otherfieldSet.setBorders(false);
    FormLayout otherlayout = new FormLayout();
    otherlayout.setLabelWidth(150);
    otherfieldSet.setLayout(otherlayout);

    phoneNumber = new TextField<String>();
    phoneNumber.setFieldLabel("Phone Number");
    phoneNumber.setToolTip("xxx-xxxx");
    phoneNumber.setTabIndex(tabIndex++);

    email = new TextField<String>();
    email.setFieldLabel("Email");
    email.setAllowBlank(false);
    email.setRegex(InputFormat.EMAIL_FORMATS);
    email.getMessages().setRegexText("Invalid email format");
    //		    email.setAutoValidate(true);
    email.setToolTip("*****@*****.**");
    email.setTabIndex(tabIndex++);

    emailConfirm = new TextField<String>();
    emailConfirm.setFieldLabel("Confirm Email");
    emailConfirm.setRegex(InputFormat.EMAIL_FORMATS);
    emailConfirm.getMessages().setRegexText("Invalid email format");
    //		    email.setAutoValidate(true);
    emailConfirm.setToolTip("*****@*****.**");
    emailConfirm.setTabIndex(tabIndex++);

    webSite = new TextField<String>();
    webSite.setFieldLabel("Website");
    webSite.setTabIndex(tabIndex++);

    otherfieldSet.add(phoneNumber);
    otherfieldSet.add(email);
    otherfieldSet.add(emailConfirm);
    otherfieldSet.add(webSite);

    formPanel.add(addressfieldSet);
    formPanel.add(otherfieldSet);

    return formPanel;
  }
Ejemplo n.º 4
0
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FitLayout());
    setId("network-dhcp-nat");
    FormData formData = new FormData();
    formData.setWidth(250);

    m_formPanel = new FormPanel();
    m_formPanel.setFrame(false);
    m_formPanel.setBodyBorder(false);
    m_formPanel.setHeaderVisible(false);
    m_formPanel.setLayout(new FlowLayout());
    m_formPanel.setStyleAttribute("min-width", "775px");
    m_formPanel.setStyleAttribute("padding-left", "30px");

    FieldSet fieldSet = new FieldSet();
    FormLayout layoutAccount = new FormLayout();
    layoutAccount.setLabelWidth(Constants.LABEL_WIDTH_FORM);
    fieldSet.setLayout(layoutAccount);
    fieldSet.setBorders(false);

    //
    // Tool Tip Box
    //
    toolTipField.setText(defaultToolTip);
    fieldSet.add(toolTipField);

    //
    // Router Mode
    //
    m_modeCombo = new SimpleComboBox<String>();
    m_modeCombo.setName("comboMode");
    m_modeCombo.setFieldLabel(MSGS.netRouterMode());
    m_modeCombo.setEditable(false);
    m_modeCombo.setTypeAhead(true);
    m_modeCombo.setTriggerAction(TriggerAction.ALL);
    for (GwtNetRouterMode mode : GwtNetRouterMode.values()) {
      m_modeCombo.add(MessageUtils.get(mode.name()));
    }
    m_modeCombo.setSimpleValue(MessageUtils.get(GwtNetRouterMode.netRouterDchpNat.name()));
    m_modeCombo.setValidator(
        new Validator() {
          public String validate(Field<?> field, String value) {
            if (m_tcpIpConfigTab.isDhcp()
                && !value.equals(MessageUtils.get(GwtNetRouterMode.netRouterOff.toString()))) {
              return MSGS.netRouterConfiguredForDhcpError();
            }

            return null;
          }
        });
    m_modeCombo.addSelectionChangedListener(
        new SelectionChangedListener<SimpleComboValue<String>>() {
          @Override
          public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
            refreshForm();
          }
        });
    m_modeCombo.addListener(Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipMode()));
    m_modeCombo.addStyleName("kura-combobox");
    m_modeCombo.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_modeCombo, formData);

    //
    // DHCP Beginning Address
    //
    m_dhcpBeginAddressField = new TextField<String>();
    m_dhcpBeginAddressField.setAllowBlank(true);
    m_dhcpBeginAddressField.setName("dhcpBeginAddress");
    m_dhcpBeginAddressField.setFieldLabel(MSGS.netRouterDhcpBeginningAddress());
    m_dhcpBeginAddressField.setRegex(IPV4_REGEX);
    m_dhcpBeginAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpBeginAddressField.addPlugin(m_dirtyPlugin);
    m_dhcpBeginAddressField.setStyleAttribute("margin-top", Constants.LABEL_MARGIN_TOP_SEPARATOR);
    m_dhcpBeginAddressField.addStyleName("kura-textfield");
    m_dhcpBeginAddressField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpBeginAddr()));
    fieldSet.add(m_dhcpBeginAddressField, formData);

    //
    // DHCP Ending Address
    //
    m_dhcpEndAddressField = new TextField<String>();
    m_dhcpEndAddressField.setAllowBlank(true);
    m_dhcpEndAddressField.setName("dhcpEndAddress");
    m_dhcpEndAddressField.setFieldLabel(MSGS.netRouterDhcpEndingAddress());
    m_dhcpEndAddressField.setRegex(IPV4_REGEX);
    m_dhcpEndAddressField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpEndAddressField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpEndAddr()));
    m_dhcpEndAddressField.addStyleName("kura-textfield");
    ;
    m_dhcpEndAddressField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpEndAddressField, formData);

    //
    // DHCP Subnet Mask
    //
    m_dhcpSubnetMaskField = new TextField<String>();
    m_dhcpSubnetMaskField.setAllowBlank(true);
    m_dhcpSubnetMaskField.setName("dhcpSubnetMask");
    m_dhcpSubnetMaskField.setFieldLabel(MSGS.netRouterDhcpSubnetMask());
    m_dhcpSubnetMaskField.setRegex(IPV4_REGEX);
    m_dhcpSubnetMaskField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpSubnet()));
    m_dhcpSubnetMaskField.getMessages().setRegexText(MSGS.netIPv4InvalidAddress());
    m_dhcpSubnetMaskField.addStyleName("kura-textfield");
    m_dhcpSubnetMaskField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpSubnetMaskField, formData);

    //
    // DHCP Default Lease
    //
    m_dhcpLeaseDefaultField = new NumberField();
    m_dhcpLeaseDefaultField.setPropertyEditorType(Integer.class);
    m_dhcpLeaseDefaultField.setAllowDecimals(false);
    m_dhcpLeaseDefaultField.setAllowNegative(false);
    m_dhcpLeaseDefaultField.setMaxValue(Integer.MAX_VALUE);
    m_dhcpLeaseDefaultField.setAllowBlank(true);
    m_dhcpLeaseDefaultField.setName("dhcpDefaultLease");
    m_dhcpLeaseDefaultField.setFieldLabel(MSGS.netRouterDhcpDefaultLease());
    m_dhcpLeaseDefaultField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpDefaultLeaseTime()));
    m_dhcpLeaseDefaultField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpLeaseDefaultField, formData);

    //
    // DHCP Max Lease
    //
    m_dhcpLeaseMaxField = new NumberField();
    m_dhcpLeaseMaxField.setPropertyEditorType(Integer.class);
    m_dhcpLeaseMaxField.setAllowDecimals(false);
    m_dhcpLeaseMaxField.setAllowNegative(false);
    m_dhcpLeaseMaxField.setMaxValue(Integer.MAX_VALUE);
    m_dhcpLeaseMaxField.setAllowBlank(true);
    m_dhcpLeaseMaxField.setName("dhcpMaxLease");
    m_dhcpLeaseMaxField.setFieldLabel(MSGS.netRouterDhcpMaxLease());
    m_dhcpLeaseMaxField.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipDhcpMaxLeaseTime()));
    m_dhcpLeaseMaxField.addPlugin(m_dirtyPlugin);
    fieldSet.add(m_dhcpLeaseMaxField, formData);

    //
    // Pass DNS
    //
    m_passDnsRadioTrue = new Radio();
    m_passDnsRadioTrue.setBoxLabel(MSGS.trueLabel());
    m_passDnsRadioTrue.setItemId("true");

    m_passDnsRadioFalse = new Radio();
    m_passDnsRadioFalse.setBoxLabel(MSGS.falseLabel());
    m_passDnsRadioFalse.setItemId("false");

    m_passDnsRadioGroup = new RadioGroup();
    m_passDnsRadioGroup.setName("dhcpPassDns");
    m_passDnsRadioGroup.setFieldLabel(MSGS.netRouterPassDns());
    m_passDnsRadioGroup.add(m_passDnsRadioTrue);
    m_passDnsRadioGroup.add(m_passDnsRadioFalse);
    m_passDnsRadioGroup.addPlugin(m_dirtyPlugin);
    m_passDnsRadioGroup.addListener(
        Events.OnMouseOver, new MouseOverListener(MSGS.netRouterToolTipPassDns()));
    fieldSet.add(m_passDnsRadioGroup, formData);

    m_formPanel.add(fieldSet);
    add(m_formPanel);
    setScrollMode(Scroll.AUTO);
    m_initialized = true;
  }