Search in sources :

Example 1 with VCellEditor

use of org.compiere.grid.ed.VCellEditor in project adempiere by adempiere.

the class GridController method setupVTable.

//	getTitle
/**
	 *	Setup Multi-Row Table (add fields)
	 * 	@param aPanel Panel
	 * 	@param mTab Model Tab
	 * 	@param table JTable
	 * 	@return size
	 */
private int setupVTable(APanel aPanel, GridTab mTab, VTable table) {
    if (!mTab.isDisplayed())
        return 0;
    int size = mTab.getFieldCount();
    TableColumnModel tcm = table.getColumnModel();
    if (size != tcm.getColumnCount())
        throw new IllegalStateException("TableColumn Size <> TableModel");
    for (int i = 0; i < size; i++) {
        GridField mField = mTab.getField(i);
        TableColumn tc = tcm.getColumn(i);
        tc.setMinWidth(30);
        // FR 3051618 - Hide in list view
        if (!mField.isDisplayedGrid()) {
            vTable.setColumnVisibility(tc, false);
        }
        if (mField.getColumnName().equals(tc.getIdentifier().toString())) {
            //don't show included tab field in grid
            if (mField.getIncluded_Tab_ID() > 0) {
                TableCellNone tcn = new TableCellNone(mField.getColumnName());
                tc.setCellRenderer(tcn);
                tc.setCellEditor(tcn);
                tc.setHeaderValue(null);
                tc.setMinWidth(0);
                tc.setMaxWidth(0);
                tc.setPreferredWidth(0);
                table.setColumnVisibility(tc, false);
            } else 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.isDisplayedGrid()) {
                    tc.setCellRenderer(new VCellRenderer(mField));
                    VCellEditor ce = new VCellEditor(mField);
                    tc.setCellEditor(ce);
                    //
                    tc.setHeaderValue(mField.getHeader());
                    tc.setPreferredWidth(Math.max(mField.getDisplayLength(), 30));
                    tc.setHeaderRenderer(new VHeaderRenderer(mField));
                    //  Enable Button actions in grid
                    if (mField.getDisplayType() == DisplayType.Button) {
                        ce.setActionListener(aPanel);
                    }
                } else //  column not displayed
                {
                    TableCellNone tcn = new TableCellNone(mField.getColumnName());
                    tc.setCellRenderer(tcn);
                    tc.setCellEditor(tcn);
                    tc.setHeaderValue(null);
                    tc.setMinWidth(0);
                    tc.setMaxWidth(0);
                    tc.setPreferredWidth(0);
                    table.setColumnVisibility(tc, false);
                }
            }
        } else
            //	found field
            log.log(Level.SEVERE, "TableColumn " + tc.getIdentifier() + " <> MField " + mField.getColumnName() + mField.getHeader());
    }
    //  for all fields
    return size;
}
Also used : TableCellNone(org.compiere.swing.TableCellNone) VCellRenderer(org.compiere.grid.ed.VCellRenderer) VCellEditor(org.compiere.grid.ed.VCellEditor) TableColumnModel(javax.swing.table.TableColumnModel) VRowIDEditor(org.compiere.grid.ed.VRowIDEditor) VHeaderRenderer(org.compiere.grid.ed.VHeaderRenderer) GridField(org.compiere.model.GridField) VRowIDRenderer(org.compiere.grid.ed.VRowIDRenderer) TableColumn(javax.swing.table.TableColumn)

Aggregations

TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1 VCellEditor (org.compiere.grid.ed.VCellEditor)1 VCellRenderer (org.compiere.grid.ed.VCellRenderer)1 VHeaderRenderer (org.compiere.grid.ed.VHeaderRenderer)1 VRowIDEditor (org.compiere.grid.ed.VRowIDEditor)1 VRowIDRenderer (org.compiere.grid.ed.VRowIDRenderer)1 GridField (org.compiere.model.GridField)1 TableCellNone (org.compiere.swing.TableCellNone)1