public void dispose() { log.config("(" + m_mTab.toString() + ")"); // clear info stopEditor(false); if (m_mTab.needSave(true, false)) { m_mTab.dataIgnore(); } vIncludedGC = null; // Listeners m_mTab.getTableModel().removeDataStatusListener(this); m_mTab.getTableModel().removeVetoableChangeListener(this); vTable.getSelectionModel().removeListSelectionListener(this); m_mTab.removePropertyChangeListener(vTable); // editors Component[] comp = vPanel.getComponents(); for (int i = 0; i < comp.length; i++) { if (comp[i] instanceof VEditor) { VEditor vEditor = (VEditor) comp[i]; vEditor.removeVetoableChangeListener(this); String columnName = comp[i].getName(); MField mField = m_mTab.getField(columnName); if (mField != null) { mField.removePropertyChangeListener(vEditor); } vEditor.dispose(); } } vTable.removeAll(); vTable.setModel(new DefaultTableModel()); // remove reference vTable = null; vPanel.removeAll(); vPanel = null; splitPane.removeAll(); splitPane = null; m_mTab = null; m_tree = null; this.removeAll(); } // dispose
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 }
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(); }
public WTableDirEditor(MField mField) { super(new Combobox(), mField); lookup = mField.getLookup(); init(); }
/** Descripción de Método */ private void cmd_find() { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); String title = null; String tableName = null; // Get Find Tab Info String sql = "SELECT t.AD_Tab_ID " // ,w.Name, t.Name, w.IsDefault, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID) + "FROM AD_Tab t" + " INNER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)" + " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID) " + "WHERE t.AD_Table_ID=? " + "ORDER BY w.IsDefault DESC, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)"; int AD_Tab_ID = DB.getSQLValue(null, sql, AD_Table_ID); // sql = "SELECT Name, TableName FROM AD_Tab_v WHERE AD_Tab_ID=?"; if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab")) { sql = "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?" + " AND AD_Language='" + Env.getAD_Language(Env.getCtx()) + "'"; } try { PreparedStatement pstmt = DB.prepareStatement(sql); pstmt.setInt(1, AD_Tab_ID); ResultSet rs = pstmt.executeQuery(); // if (rs.next()) { title = rs.getString(1); tableName = rs.getString(2); } // rs.close(); pstmt.close(); } catch (SQLException e) { log.log(Level.SEVERE, "MTabVO.create(1)", e); } MField[] findFields = null; if (tableName != null) { findFields = MField.createFields(m_ctx, m_WindowNo, 0, AD_Tab_ID); } if (findFields == null) { // No Tab for Table exists bFind.setEnabled(false); } else { Find find = new Find(this, m_WindowNo, title, AD_Table_ID, tableName, "", findFields, 1); m_reportEngine.setQuery(find.getQuery()); revalidate(); } cmd_drill(); // setCursor } // cmd_find
/** * 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