Exemplo n.º 1
0
  public static void updateComponents(
      Component[] comp,
      Map<String, MField> fields,
      boolean checkContextForAccess,
      boolean checkContextForDisplayed) {

    for (int i = 0; i < comp.length; i++) {
      String columnName = comp[i].getName();

      if (columnName != null) {
        MField mField = fields.get(columnName);

        if (mField != null) {
          if (mField.isDisplayed(checkContextForDisplayed)) // check context
          {
            if (!comp[i].isVisible()) {
              comp[i].setVisible(true); // visibility
            }

            if (comp[i] instanceof VEditor) {
              VEditor ve = (VEditor) comp[i];
              boolean rw = mField.isEditable(checkContextForAccess); // r/w - check Context

              ve.setReadWrite(rw);

              // Log.trace(7, "GridController.dynamicDisplay RW=" + rw, mField);

              boolean manMissing = false;

              // least expensive operations first        //  missing mandatory

              if (rw && (mField.getValue() == null) && mField.isMandatory(true)) { // check context
                manMissing = true;
              }

              ve.setBackground(manMissing || mField.isError());
            }
          } else if (comp[i].isVisible()) {
            comp[i].setVisible(false);
          }
        }
      }
    } // all components
  }
Exemplo n.º 2
0
  /**
   * Descripción de Método
   *
   * @param col
   */
  public void dynamicDisplay(int col) {

    // log.config( "GridController.dynamicDisplay (" + m_mTab.toString() + ") SingleRow=" +
    // isSingleRow() + ", OnlyMultiRow=" + m_onlyMultiRow);
    // Don't update if multi-row

    if (!isSingleRow() || m_onlyMultiRow) {
      return;
    }

    if (!m_mTab.isOpen()) {
      return;
    }

    // Selective

    if (col != 0) {
      MField changedField = m_mTab.getField(col);
      String columnName = changedField.getColumnName();
      ArrayList dependants = m_mTab.getDependantList(columnName);

      log.config(
          "(" + m_mTab.toString() + ") " + columnName + " - Dependents=" + dependants.size());

      // No Dependents and no Callout - Set just Background

      if ((dependants.size() == 0) && (changedField.getCallout().length() > 0)) {
        Component[] comp = vPanel.getComponents();

        for (int i = 0; i < comp.length; i++) {
          if (columnName.equals(comp[i].getName()) && (comp[i] instanceof VEditor)) {
            VEditor ve = (VEditor) comp[i];
            boolean manMissing = false;
            boolean noValue =
                (changedField.getValue() == null)
                    || (changedField.getValue().toString().length() == 0);

            if (noValue
                && changedField.isEditable(true)
                && changedField.isMandatory(true)) { // check context
              manMissing = true;
            }

            ve.setBackground(manMissing || changedField.isError());

            break;
          }
        }

        return;
      }
    } // selective

    // complete single row re-display

    log.config("(" + m_mTab.toString() + ")");

    // All Components in vPanel (Single Row)

    updateComponents(vPanel.getComponents(), m_mTab.getMapFields(), true, true);

    log.config("(" + m_mTab.toString() + ") - fini - " + ((col == 0) ? "complete" : "seletive"));
  } // dynamicDisplay