Esempio n. 1
0
    @Override
    public ComponentContainer constructBody() {
      MHorizontalLayout layout = new MHorizontalLayout().withMargin(true);

      nameField =
          ShortcutExtension.installShortcutAction(
              new TextField(),
              new ShortcutListener("OpportunitySearchRequest", ShortcutAction.KeyCode.ENTER, null) {
                @Override
                public void handleAction(Object o, Object o1) {
                  callSearchAction();
                }
              });
      nameField.setInputPrompt("Query by opportunity name");
      nameField.setWidth(UIConstants.DEFAULT_CONTROL_WIDTH);
      layout.with(nameField).withAlign(nameField, Alignment.MIDDLE_CENTER);

      this.myItemCheckbox =
          new CheckBox(AppContext.getMessage(GenericI18Enum.SEARCH_MYITEMS_CHECKBOX));
      layout.with(myItemCheckbox).withAlign(myItemCheckbox, Alignment.MIDDLE_CENTER);

      Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
      searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
      searchBtn.setIcon(FontAwesome.SEARCH);

      searchBtn.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
              OpportunityBasicSearchLayout.this.callSearchAction();
            }
          });
      layout.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_LEFT);

      Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR));
      cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
      cancelBtn.addClickListener(
          new Button.ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
              OpportunityBasicSearchLayout.this.nameField.setValue("");
            }
          });
      layout.with(cancelBtn).withAlign(cancelBtn, Alignment.MIDDLE_CENTER);

      Button advancedSearchBtn =
          new Button(
              AppContext.getMessage(GenericI18Enum.BUTTON_ADVANCED_SEARCH),
              new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                  OpportunitySearchPanel.this.moveToAdvancedSearchLayout();
                }
              });
      advancedSearchBtn.setStyleName(UIConstants.BUTTON_LINK);
      layout.with(advancedSearchBtn).withAlign(advancedSearchBtn, Alignment.MIDDLE_CENTER);
      return layout;
    }
    @Override
    protected Field<?> onCreateField(Object propertyId) {
      if (propertyId.equals("roleid")) {
        return new AdminRoleSelectionField();
      } else if (propertyId.equals("email")) {
        final TextField tf = new TextField();
        tf.setNullRepresentation("");
        tf.setRequired(true);
        tf.setRequiredError("This field must be not null");
        return tf;
      }

      return null;
    }
    @Override
    protected Field<?> onCreateField(final Object propertyId) {
      if (propertyId.equals("roleid")) {
        return new AdminRoleSelectionField();
      } else if (propertyId.equals("firstname")
          || propertyId.equals("lastname")
          || propertyId.equals("email")) {
        final TextField tf = new TextField();
        tf.setNullRepresentation("");
        tf.setRequired(true);
        tf.setRequiredError("This field must be not null");
        return tf;
      } else if (propertyId.equals("dateofbirth")) {
        return new DateComboboxSelectionField();
      } else if (propertyId.equals("timezone")) {
        TimeZoneSelectionField cboTimezone = new TimeZoneSelectionField(false);
        if (UserAddViewImpl.this.user.getTimezone() != null) {
          cboTimezone.setTimeZone(
              TimezoneMapper.getTimezoneExt(UserAddViewImpl.this.user.getTimezone()));
        } else {
          if (AppContext.getSession().getTimezone() != null) {
            cboTimezone.setTimeZone(
                TimezoneMapper.getTimezoneExt(AppContext.getSession().getTimezone()));
          }
        }
        return cboTimezone;
      } else if (propertyId.equals("country")) {
        final CountryComboBox cboCountry = new CountryComboBox();
        cboCountry.addValueChangeListener(
            new Property.ValueChangeListener() {
              private static final long serialVersionUID = 1L;

              @Override
              public void valueChange(final Property.ValueChangeEvent event) {
                UserAddViewImpl.this.user.setCountry((String) cboCountry.getValue());
              }
            });
        return cboCountry;
      }
      return null;
    }