Exemplo n.º 1
0
 /** Dynamic Display. */
 public void dynamicDisplay() {
   for (int i = 0; i < m_wEditors.size(); i++) {
     WEditor editor = m_wEditors.get(i);
     GridField mField = editor.getGridField();
     if (mField.isDisplayed(true)) {
       if (!editor.isVisible()) {
         editor.setVisible(true);
         if (mField.getVO().isRange) {
           // m_separators.get(i).setVisible(true);
           m_wEditors2.get(i).setVisible(true);
         }
       }
       boolean rw = mField.isEditablePara(true); // r/w - check if
       // field is Editable
       editor.setReadWrite(rw);
       editor.dynamicDisplay();
       if (mField.getVO().isRange) {
         WEditor editorRange = m_wEditors2.get(i);
         if (editorRange != null) {
           editorRange.setReadWrite(rw);
           editorRange.dynamicDisplay();
         }
       }
     } else if (editor.isVisible()) {
       editor.setVisible(false);
       if (mField.getVO().isRange) {
         // m_separators.get(i).setVisible(false);
         m_wEditors2.get(i).setVisible(false);
       }
     }
   }
 }
Exemplo n.º 2
0
  public void addField(MBrowseField field, Row row, String name, String title) {
    GridFieldVO voBase =
        GridFieldVO.createStdField(field.getCtx(), p_WindowNo, 0, 0, 0, false, false, false);

    String uniqueName = field.getAD_View_Column().getColumnSQL();

    voBase.isProcess = true;
    voBase.IsDisplayed = true;
    voBase.IsReadOnly = false;
    voBase.IsUpdateable = true;
    voBase.WindowNo = p_WindowNo;

    voBase.AD_Column_ID = field.getAD_View_Column().getAD_Column_ID();
    voBase.AD_Table_ID = field.getAD_View_Column().getAD_Column().getAD_Table_ID();
    voBase.ColumnName = field.getAD_View_Column().getAD_Column().getColumnName();
    voBase.displayType = field.getAD_Reference_ID();
    voBase.AD_Reference_Value_ID = field.getAD_Reference_Value_ID();
    voBase.IsMandatory = field.isMandatory();
    voBase.IsAlwaysUpdateable = false;
    voBase.IsKey = field.isKey();

    voBase.DefaultValue = field.getDefaultValue();
    voBase.DefaultValue2 = field.getDefaultValue2();
    voBase.InfoFactoryClass = field.getInfoFactoryClass();
    voBase.FieldLength = field.getFieldLength();
    voBase.ReadOnlyLogic = field.getReadOnlyLogic();
    voBase.DisplayLogic = field.getDisplayLogic();
    voBase.VFormat = field.getVFormat();
    voBase.ValueMin = field.getValueMin();
    voBase.ValueMax = field.getValueMax();
    voBase.ValidationCode = field.getAD_Val_Rule().getCode();

    voBase.isRange = field.isRange();
    voBase.Description = field.getDescription();
    voBase.Help = uniqueName;
    voBase.Header = title;

    GridField gField = new GridField(GridFieldVO.createParameter(voBase));
    GridField gField2 = null;

    WEditor editor = WebEditorFactory.getEditor(gField, false);
    editor.setReadWrite(true);
    editor.addValueChangeListener(this);
    editor.dynamicDisplay();
    gField.addPropertyChangeListener(editor);

    Object defaultObject = null;
    Object defaultObject2 = null;

    //  Set Default
    if (field.getAD_View_Column().getAD_Column_ID() > 0) {
      defaultObject = gField.getDefault();
      if (defaultObject != null && field.getDefaultValue() != null) {
        gField.setValue(defaultObject, true);
        editor.setValue(defaultObject);
      }
    }

    gField.lookupLoadComplete();
    m_mFields.add(gField);
    m_wEditors.add(editor);

    if (DisplayType.YesNo != field.getAD_Reference_ID()) {
      Div div = new Div();
      div.setAlign("right");
      org.adempiere.webui.component.Label label = editor.getLabel();
      label.setValue(title);
      div.appendChild(label);
      if (label.getDecorator() != null) div.appendChild(label.getDecorator());
      row.appendChild(div);
    }
    row.appendChild(editor.getComponent());
    setParameter(name, editor);

    if (field.isRange()) {
      title = Msg.getMsg(Env.getCtx(), "To");
      name = name + "_To";
      voBase.Header = title;
      voBase.DefaultValue = field.getDefaultValue2();
      gField2 = new GridField(GridFieldVO.createParameter(voBase));
      gField2.lookupLoadComplete();

      WEditor editor2 = WebEditorFactory.getEditor(gField2, false);
      editor2.setReadWrite(true);
      editor2.addValueChangeListener(this);
      editor2.dynamicDisplay();
      //  Set Default
      if (field.getAD_View_Column().getAD_Column_ID() > 0) {
        defaultObject2 = gField2.getDefault();
        if (defaultObject2 != null && field.getDefaultValue2() != null) {
          gField2.setValue(defaultObject2, true);
          editor2.setValue(defaultObject2);
        }
      }
      m_mFields2.add(gField2);
      m_wEditors2.add(editor2);

      Div div = new Div();
      div.setAlign("right");
      org.adempiere.webui.component.Label label = editor2.getLabel();
      label.setValue(title);
      div.appendChild(label);
      if (label.getDecorator() != null) div.appendChild(label.getDecorator());
      row.appendChild(div);

      row.appendChild(editor2.getComponent());
      setParameter(name, editor2);
    } else {
      m_mFields2.add(null);
      m_wEditors2.add(null);
    }

    if (gField != null) processNewValue(defaultObject, gField.getVO().Help);
    if (gField2 != null) processNewValue(defaultObject2, gField2.getVO().Help);
  }