Exemplo n.º 1
0
  /**
   * DOC bessaies Comment method "build".
   *
   * @param configGroups
   */
  public void build(ConfigGroup[] configGroups) {
    for (ConfigGroup configGroup : configGroups) {
      ImageResource imageResource = IconConfigProvider.provideIcon(configGroup);
      ContentPanel cPanel = buildConfigBloc(configGroup, imageResource);
      cPanel.setVisible(false);
      FormLayout formLayout1 = new FormLayout();
      formLayout1.setLabelWidth(200);

      FormLayout formLayout2 = new FormLayout();

      final LayoutContainer fieldPart = new LayoutContainer(formLayout1);
      final LayoutContainer messagePart = new LayoutContainer(formLayout2);

      fieldPart.setStyleAttribute("padding-left", "10px");
      fieldPart.setStyleAttribute("padding-top", "10px");
      fieldPart.setStyleAttribute("padding-bottom", "10px");
      messagePart.setStyleAttribute("padding-top", "12px");
      messagePart.setStyleAttribute("padding-bottom", "12px");

      cPanel.add(fieldPart, new ColumnData(0.7));
      cPanel.add(messagePart, new ColumnData(0.25));

      for (Config config : configGroup.configs) {
        Field<?> field = null;
        switch (config.type) {
          case txt:
            field = buildTextField(fieldPart, messagePart, config);
            break;
          case password:
            field = buildPasswordField(fieldPart, messagePart, config);
            break;
          case list:
            field = buildListField(fieldPart, messagePart, config);
            break;
          default:
            break;
        }
        if (null != field) {
          mapKeyField.put(config, field);
        }
      }

      add(cPanel);
    }
  }
Exemplo n.º 2
0
  /**
   * DOC bessaies Comment method "updateGroupStatus".
   *
   * @param configGroup
   */
  private void updateGroupStatus(ConfigGroup configGroup, boolean bling) {
    int nbKo = 0;
    int nbNA = 0;
    int nbInit = 0;

    for (Config config : configGroup.configs) {
      MessageWidget messageWidget = mapKeyStatus.get(config);
      if (null != messageWidget) {
        if (messageWidget.getStatus() == ConfigStatus.ERROR) {
          nbKo++;
        } else if (messageWidget.getStatus() == ConfigStatus.NA) {
          nbNA++;
        } else if (null == messageWidget.getStatus()) {
          nbInit++;
        }
      }
    }

    if (nbNA == configGroup.configs.length) {
      ContentPanel panel = mapConfigGroupPanel.get(configGroup);
      if (null != panel) {
        panel.setVisible(false);
      }
    }

    if (nbInit > 0) {
      updateStatus(configGroup, ConfigStatus.CHECKING, null, bling);
    } else if (isNAGroupStatus(configGroup) && nbNA > 0) {
      updateStatus(configGroup, ConfigStatus.NA, null, bling);
    } else if (nbKo == 0) {
      updateStatus(
          configGroup,
          ConfigStatus.VALID,
          " (" + configGroup.configs.length + " Parameters)",
          bling);
    } else {
      updateStatus(
          configGroup,
          ConfigStatus.ERROR,
          " (" + configGroup.configs.length + " Parameters / " + nbKo + " errors)",
          bling);
    }
  }