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(); }
/** * 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
/** * 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
/** * 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