示例#1
0
  /**
   * Descripción de Método
   *
   * @param aPanel
   * @param mTab
   * @param table
   * @return
   */
  private int setupVTable(APanel aPanel, MTab mTab, VTable table) {
    if (!mTab.isDisplayed()) {
      return 0;
    }

    int size = mTab.getFieldCount();

    for (int i = 0; i < size; i++) {
      TableColumn tc = getTableColumn(table, i);
      MField mField = mTab.getField(i);

      //

      if (mField.getColumnName().equals(tc.getIdentifier().toString())) {
        if (mField.getDisplayType() == DisplayType.RowID) {
          tc.setCellRenderer(new VRowIDRenderer(false));
          tc.setCellEditor(new VRowIDEditor(false));
          tc.setHeaderValue("");
          tc.setMaxWidth(2);
        } else {

          // need to set CellEditor explicitly as default editor based on class causes problem
          // (YesNo-> Boolean)
          if (mField.isDisplayed() && mField.isDisplayedInGrid()) {
            tc.setCellRenderer(new VCellRenderer(mField));

            VCellEditor ce = new VCellEditor(mField, this);

            tc.setCellEditor(ce);

            //

            tc.setHeaderValue(mField.getHeader());
            // tc.setPreferredWidth( Math.min( mField.getDisplayLength(),30 )); original, Modificado
            // por ConSerTi
            tc.setPreferredWidth(mField.getDisplayLength());
            tc.setMinWidth(1);

            tc.setHeaderRenderer(new VHeaderRenderer(mField.getDisplayType()));

            // Enable Button actions in grid

            if (mField.getDisplayType() == DisplayType.Button) {
              VEditor button = ce.getEditor();

              if ((button != null) && (aPanel != null)) {
                ((JButton) button).addActionListener(aPanel);
              }
            }
          } else // column not displayed
          {
            tc.setHeaderValue(null);
            tc.setMinWidth(0);
            tc.setMaxWidth(0);
            tc.setPreferredWidth(0);
          }
        }

        // System.out.println ("TableColumnID " + tc.getIdentifier ()
        // + "  Renderer=" + tc.getCellRenderer ()
        // + mField.getHeader ());
        // Modificado Por ConSerTi, para permitir campos de longuitud menor de 30
        tc.setMinWidth(10);
      } // found field
      else {
        log.log(
            Level.SEVERE,
            "TableColumn "
                + tc.getIdentifier()
                + " <> MField "
                + mField.getColumnName()
                + mField.getHeader());
      }
    } // for all fields

    table.createSortRenderers();

    return size;
  } // setupVTable
示例#2
0
  /**
   * Descripción de Método
   *
   * @param mTab
   * @param onlyMultiRow
   * @param WindowNo
   * @param aPanel
   * @param mWindow
   * @return
   */
  public boolean initGrid(
      MTab mTab, boolean onlyMultiRow, int WindowNo, APanel aPanel, MWindow mWindow) {
    log.config("(" + mTab.toString() + ")");
    m_mTab = mTab;
    m_WindowNo = WindowNo;
    m_onlyMultiRow = onlyMultiRow;
    fieldEditors = new HashMap<MField, VEditor>();

    // Set up Multi Row Table

    vTable.setModel(m_mTab.getTableModel());

    // Update Table Info -------------------------------------------------

    int size = setupVTable(aPanel, m_mTab, vTable);

    // Set Color on Tab Level
    // this.setBackgroundColor (mTab.getColor());

    // Single Row  -------------------------------------------------------

    if (!m_onlyMultiRow) {
      for (int i = 0; i < size; i++) {
        MField mField = m_mTab.getField(i);

        if (mField.isDisplayed()) {
          VEditor vEditor = VEditorFactory.getEditor(m_mTab, mField, false);

          if (vEditor == null) {
            log.severe("Editor not created for " + mField.getColumnName());

            continue;
          }

          // MField => VEditor - New Field value to be updated to editor

          mField.addPropertyChangeListener(vEditor);

          // VEditor => this - New Editor value to be updated here (MTable)

          vEditor.addVetoableChangeListener(this);

          // Add to VPanel

          vPanel.addField(VEditorFactory.getLabel(mField), vEditor, mField);

          // APanel Listen to buttons

          if ((mField.getDisplayType() == DisplayType.Button) && (aPanel != null)) {
            ((JButton) vEditor).addActionListener(aPanel);
          }

          fieldEditors.put(mField, vEditor);
        }
      } // for all fields

      // No Included Grid Controller

      srPane.setResizeWeight(1); // top part gets all
      srPane.setDividerSize(0);
      srPane.setDividerLocation(9999);

      // Use SR to size MR

      mrPane.setPreferredSize(vPanel.getPreferredSize());
    } // Single-Row

    // Tree Graphics Layout

    int AD_Tree_ID = 0;

    if (m_mTab.isTreeTab()) {
      AD_Tree_ID =
          MTree.getAD_Tree_ID(Env.getAD_Client_ID(Env.getCtx()), m_mTab.getKeyColumnName());
    }

    if (m_mTab.isTreeTab() && (AD_Tree_ID != 0)) {
      m_tree = new VTreePanel(m_WindowNo, false, true);

      if (m_mTab.getTabNo() == 0) { // initialize other tabs later
        m_tree.initTree(AD_Tree_ID);
      }

      m_tree.addPropertyChangeListener(VTreePanel.NODE_SELECTION, this);
      graphPanel.add(m_tree, BorderLayout.CENTER);
      splitPane.setDividerLocation(250);

      // splitPane.resetToPreferredSizes();

    } else // No Graphics - hide
    {
      graphPanel.setPreferredSize(new Dimension(0, 0));
      splitPane.setDividerSize(0);
      splitPane.setDividerLocation(0);
    }

    // Receive DataStatusChanged info from MTab

    m_mTab.addDataStatusListener(this);

    // Receive vetoableChange info from MTable when saving

    m_mTab.getTableModel().addVetoableChangeListener(this);

    // Selection Listener -> valueChanged

    vTable.getSelectionModel().addListSelectionListener(this);

    // Navigation (RowChanged)

    m_mTab.addPropertyChangeListener(vTable);

    // Update UI
    vTable.autoSize(true); // Original
    // Modificado por ConSerTi.
    // vTable.autoSize( false );//Modificada
    setTabLevel(m_mTab.getTabLevel());

    // Set initial presentation

    if (onlyMultiRow || !m_mTab.isSingleRow()) {
      switchMultiRow();
    } else {
      switchSingleRow();
    }

    // log.config( "GridController.dynInit (" + mTab.toString() + ") - fini");

    return true;
  } // initGrid