Beispiel #1
0
  public String getClipboardData() {
    int size = m_mTab.getFieldCount();
    int currentRow = m_mTab.getCurrentRow();

    StringBuffer header = new StringBuffer();
    StringBuffer body = new StringBuffer();
    StringBuffer data = new StringBuffer();

    boolean justCreatedHeader = false;
    MField mField;
    String value;
    for (int row = 0; row < m_mTab.getRowCount(); row++) {
      for (int i = 0; i < size; i++) {
        mField = m_mTab.getField(i);

        if (mField.isDisplayed()) {
          if (!justCreatedHeader) {
            header.append(mField.getHeader()).append("\t");
          }
          fieldEditors.get(mField).setValue(m_mTab.getValue(row, mField.getColumnName()));
          value =
              fieldEditors.get(mField).getValue() != null
                  ? fieldEditors.get(mField).getDisplay()
                  : "";
          body.append(value).append("\t");
        }
      }
      justCreatedHeader = true;
      body.append("\n");
    }

    // Restaurar datos de la fila actual
    for (int i = 0; i < size; i++) {
      mField = m_mTab.getField(i);
      if (mField.isDisplayed()) {
        fieldEditors.get(mField).setValue(m_mTab.getValue(currentRow, mField.getColumnName()));
      }
    }

    data.append(header).append("\n").append(body);
    return data.toString();
  }
Beispiel #2
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