Esempio n. 1
0
  /** Disables the Validation by setting empty constraints. */
  private void doRemoveValidation() {

    setValidationOn(false);

    artNr.setConstraint("");
    aupMenge.setConstraint("");
    aupEinzelwert.setConstraint("");
    aupGesamtwert.setConstraint("");
  }
Esempio n. 2
0
  /** Sets the Validation by setting the accordingly constraints to the fields. */
  private void doSetValidation() {

    setValidationOn(true);

    artNr.setConstraint(new SimpleConstraint("NO EMPTY"));
    aupMenge.setConstraint("NO EMPTY, NO ZERO");
    aupEinzelwert.setConstraint("NO EMPTY, NO ZERO");
    aupGesamtwert.setConstraint("NO EMPTY, NO ZERO");
  }
Esempio n. 3
0
  /**
   * *********************************************************** Create
   * ***********************************************************
   */
  @SuppressWarnings("rawtypes")
  private void onNodeTypeChanged() {
    ListModelList typeModel = (ListModelList) typeBox.getModel();
    Set selections = typeModel.getSelection();
    if (selections.isEmpty()) return;
    String selection = (String) selections.iterator().next();
    logger.info("Node type set to: " + selection);

    Map<String, String> ntd = GeneralUtil.getNodeDescriptionByLabel(ntds, selection);
    String nodeType = ntd.get("type");
    if (nodeType.equals(Constants.NODE_TYPE_USER)) {
      firstNameRow.setVisible(true);
      firstNameBox.setConstraint("no empty");
      lastNameRow.setVisible(true);
      lastNameBox.setConstraint("no empty");
      midNameRow.setVisible(true);
    } else {
      firstNameRow.setVisible(false);
      firstNameBox.setConstraint("");
      lastNameRow.setVisible(false);
      lastNameBox.setConstraint("");
      midNameRow.setVisible(false);
    }
  }
  protected Tabpanel renderTabpanel(final Resource resource) {

    Tabpanel sourcepanel = new Tabpanel();

    Hlayout hlayout = new Hlayout();
    hlayout.setStyle("margin-top:20px");
    final Label label = new Label("Image url:");
    hlayout.appendChild(label);

    final Textbox txtURL = new Textbox();
    txtURL.setValue(resource.getContent());
    txtURL.setWidth("500px");
    txtURL.setConstraint("no empty");
    hlayout.appendChild(txtURL);
    txtURL.addEventListener(
        Events.ON_CHANGE,
        new EventListener() {
          public void onEvent(Event event) throws Exception {
            if (txtURL.isValid()) {
              if (event instanceof InputEvent) {
                String value = ((InputEvent) event).getValue();
                resource.setContent(value);
                FiddleSourceEventQueue.lookup().fireResourceChanged(resource, Type.Modified);
              }
            }
          }
        });
    sourcepanel.appendChild(hlayout);

    {
      sourcepanel.appendChild(new Separator());
    }
    {
      Label lbl =
          new Label(
              "Enter a image url ,and you have to make sure you have the right to use the image.");
      sourcepanel.appendChild(lbl);
    }

    return sourcepanel;
  }
Esempio n. 5
0
  public ProfileComponent() {
    super();
    final PlayerProfileData player = getPlayerFacade().getCurrentPlayer();

    final Grid profileGrid = new Grid();
    profileGrid.setSclass("profileGrid");

    final Rows profileRows = new Rows();
    profileGrid.appendChild(profileRows);

    final Row idRow = new Row();
    idRow.setSclass("profileRow");
    idRow.appendChild(new Label(Labels.getLabel("profile.id")));
    idRow.appendChild(new Label(player.getId()));
    profileRows.appendChild(idRow);

    final Row nameRow = new Row();
    nameRow.setSclass("profileRow");
    nameRow.appendChild(new Label(Labels.getLabel("profile.name")));
    final Textbox nameBox = new Textbox(player.getName());
    nameBox.setConstraint(
        new SimpleConstraint(SimpleConstraint.NO_EMPTY, Labels.getLabel("register.error.noname")));
    nameRow.appendChild(nameBox);
    profileRows.appendChild(nameRow);

    final Row mailRow = new Row();
    mailRow.setSclass("profileRow");
    mailRow.appendChild(new Label(Labels.getLabel("profile.email")));
    final Textbox mailBox = new Textbox(player.getEMail());
    mailBox.setConstraint("/.+@.+\\.[a-z]+/: " + Labels.getLabel("register.error.noemail"));
    mailRow.appendChild(mailBox);
    profileRows.appendChild(mailRow);

    final Row pwdRow = new Row();
    pwdRow.setSclass("profileRow");
    pwdRow.appendChild(new Label(Labels.getLabel("profile.password")));
    final Textbox pwdBox = new Textbox(player.getPassword());
    // pwdBox.setConstraint(new SimpleConstraint(SimpleConstraint.NO_EMPTY,
    // Labels.getLabel("register.error.nopassword")));
    pwdBox.setType("password");
    pwdRow.appendChild(pwdBox);
    profileRows.appendChild(pwdRow);

    final Row pwd2Row = new Row();
    pwd2Row.setSclass("profileRow");
    pwd2Row.appendChild(new Label(Labels.getLabel("profile.passwordagain")));
    final Textbox pwd2Box = new Textbox(player.getPassword());
    pwd2Box.setConstraint(
        new Constraint() {
          @Override
          public void validate(final Component comp, final Object value)
              throws WrongValueException {
            if (!(pwdBox.getValue().equals(value))) {
              throw new WrongValueException(
                  comp, Labels.getLabel("register.error.unequalpassword"));
            }
          }
        });
    pwd2Box.setType("password");
    pwd2Row.appendChild(pwd2Box);
    profileRows.appendChild(pwd2Row);

    final Row countryRow = new Row();
    countryRow.setSclass("profileRow");
    countryRow.appendChild(new Label(Labels.getLabel("profile.country")));
    final Combobox countryBox = new Combobox();
    countryBox.setConstraint(
        new SimpleConstraint(
            SimpleConstraint.NO_EMPTY, Labels.getLabel("register.error.nocountry")));
    countryBox.setAutodrop(true);
    countryBox.setReadonly(true);
    fillCombo(countryBox, player.getLocale());
    countryRow.appendChild(countryBox);
    profileRows.appendChild(countryRow);

    final Row avCompetitionsRow = new Row();
    avCompetitionsRow.setSclass("competitionsRow");
    avCompetitionsRow.appendChild(new Label(Labels.getLabel("profile.availableCompetitions")));
    final Listbox listbox = new Listbox();
    listbox.setSclass("competitionsListbox");
    avCompetitionsRow.appendChild(listbox);
    listbox.setCheckmark(true);
    listbox.setMultiple(true);

    final List<CompetitionData> comps = getPlayerFacade().getAllCompetitions();
    for (final CompetitionData cmpData : comps) {
      final Listitem listItem = new Listitem(cmpData.getName());
      listItem.setValue(cmpData);
      listItem.setSelected(cmpData.isActive());
      listItem.setDisabled(
          !cmpData.isDeactivatable() || (cmpData.isCurrentCompetition() && comps.size() != 1));
      listbox.appendChild(listItem);
    }

    profileRows.appendChild(avCompetitionsRow);

    final Row buttonRow = new Row();
    buttonRow.setSclass("profileRow");
    final Button button = new Button(Labels.getLabel("profile.submit"));
    button.addEventListener(
        Events.ON_CLICK,
        new EventListener() {
          @Override
          public void onEvent(final Event event) {
            player.setEMail(mailBox.getValue());
            player.setName(nameBox.getValue());

            if (StringUtils.isNotBlank(pwdBox.getValue())
                && pwdBox.getValue().equals(pwd2Box.getValue())) {
              player.setPassword(pwdBox.getValue());
            }
            player.setLocale((Locale) countryBox.getSelectedItem().getValue());

            final List<CompetitionData> cmps = new ArrayList<CompetitionData>();
            for (final Object listItem : listbox.getSelectedItems()) {
              if (listItem instanceof Listitem) {
                final Object value = ((Listitem) listItem).getValue();
                if (value instanceof CompetitionData) {
                  cmps.add((CompetitionData) value);
                }
              }
            }

            getPlayerFacade().setActiveCompetitions(cmps);

            getPlayerFacade().updatePlayer(player);

            try {
              Messagebox.show(Labels.getLabel("profile.update.success"));
              // TODO proper update mechanism
              Executions.sendRedirect("/");
            } catch (final InterruptedException e) {
              LOG.warn("Error while showing messagebox: ", e);
            }
          }
        });
    buttonRow.appendChild(button);
    profileRows.appendChild(buttonRow);

    this.appendChild(profileGrid);

    final Div detailsDiv = new Div();
    detailsDiv.setSclass("rankingUserDetails");

    final Img img = new Img();
    final Div imgCnt = new Div();
    imgCnt.appendChild(img);
    imgCnt.setSclass("rankingUserDetailsImg");
    img.setDynamicProperty("src", player.getPictureUrl());
    detailsDiv.appendChild(imgCnt);

    final Button uploadButton = new Button(Labels.getLabel("profile.upload"));
    uploadButton.setSclass("btngreen profileUserDetailsUpload");
    detailsDiv.appendChild(uploadButton);

    uploadButton.addEventListener(
        Events.ON_CLICK,
        new EventListener() {

          @Override
          public void onEvent(final Event event) throws InterruptedException {
            final Object media = Fileupload.get();
            if (media instanceof Image) {
              final Image image = (Image) media;
              player.setPictureUrl(
                  getPlayerFacade().uploadProfilePicture(image.getByteData(), image.getName()));
              img.setDynamicProperty("src", player.getPictureUrl());
            } else if (media != null) {
              Messagebox.show("Not an image: " + media, "Error", Messagebox.OK, Messagebox.ERROR);
            }
          }
        });
    this.appendChild(detailsDiv);
  }
 @Override
 protected void configurarConstraints() {
   tbNome.setConstraint("no empty");
   tbDescricao.setConstraint("no empty");
 }
Esempio n. 7
0
  /** Sets the Validation by setting the accordingly constraints to the fields. */
  private void doSetValidation() {

    setValidationOn(true);

    rolShortdescription.setConstraint("NO EMPTY");
  }