use of org.compiere.minigrid.ROCellEditor in project adempiere by adempiere.
the class VBrowserTable method setColumnClass.
// addColumn
/**
* Set Column Editor & Renderer to Class
*
* @param index column index
* @param gridField
* @param displayType define Type Value IDColumn, Boolean, Double (Quantity), BigDecimal (Amount), Integer, Timestamp, String (default)
* @param readOnly read only flag
* @param header optional header value
*/
public void setColumnClass(int index, GridField gridField, int displayType, boolean readOnly, String header) {
// log.config( "MiniTable.setColumnClass - " + index, c.getName() + ", r/o=" + readOnly);
TableColumn tc = getColumnModel().getColumn(index);
if (tc == null)
return;
// Set R/O
setColumnReadOnly(index, readOnly);
// Header
if (header != null && header.length() > 0)
tc.setHeaderValue(Util.cleanAmp(header));
// ID Column & Selection
if (index == p_keyColumnIndex) {
tc.setCellRenderer(new IDColumnRenderer(m_multiSelection));
if (m_multiSelection) {
tc.setCellEditor(new IDColumnEditor());
setColumnReadOnly(index, false);
} else {
tc.setCellEditor(new ROCellEditor());
}
m_minWidth.add(new Integer(10));
tc.setMaxWidth(20);
tc.setPreferredWidth(20);
tc.setResizable(false);
tc.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
} else {
tc.setCellRenderer(new VCellRenderer(gridField));
tc.setCellEditor(new VBrowserCellEditor(gridField));
m_minWidth.add(new Integer(30));
tc.setHeaderRenderer(new VHeaderRenderer(displayType));
}
}
use of org.compiere.minigrid.ROCellEditor in project adempiere by adempiere.
the class POSTable method setColumnClass.
@Override
public void setColumnClass(int index, @SuppressWarnings("rawtypes") Class c, int displayType, boolean readOnly, String header) {
// logger.config( "MiniTable.setColumnClass - " + index, c.getName() + ", r/o=" + readOnly);
TableColumn tableColumn = getColumnModel().getColumn(index);
if (tableColumn == null)
return;
// Set R/O
setColumnReadOnly(index, readOnly);
// Header
if (header != null && header.length() > 0)
tableColumn.setHeaderValue(Util.cleanAmp(header));
ArrayList<Integer> minWidth = new ArrayList<Integer>();
boolean multiSelection = false;
// ID Column & Selection
if (c == IDColumn.class) {
IDColumnRenderer columnRenderer = new IDColumnRenderer(multiSelection);
tableColumn.setCellRenderer(columnRenderer);
if (multiSelection) {
VHeaderRenderer headerRenderer = new VHeaderRenderer(multiSelection);
tableColumn.setCellEditor(new IDColumnEditor());
tableColumn.setHeaderRenderer(headerRenderer);
// Connect the IDColumn with the header
columnRenderer.addChangeListener(headerRenderer);
setColumnReadOnly(index, false);
} else {
tableColumn.setCellEditor(new ROCellEditor());
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
}
minWidth.add(new Integer(10));
tableColumn.setMaxWidth(20);
tableColumn.setPreferredWidth(20);
tableColumn.setResizable(false);
} else // Boolean
if (DisplayType.YesNo == displayType || c == Boolean.class) {
CheckRenderer checkRenderer = new CheckRenderer();
tableColumn.setCellRenderer(checkRenderer);
if (readOnly) {
tableColumn.setCellEditor(new ROCellEditor());
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.YesNo));
} else {
if (multiSelection) {
VHeaderRenderer headerRenderer = new VHeaderRenderer(multiSelection);
setColumnReadOnly(index, false);
CCheckBox check = new CCheckBox();
check.setMargin(new Insets(0, 0, 0, 0));
check.setHorizontalAlignment(SwingConstants.CENTER);
tableColumn.setCellEditor(new DefaultCellEditor(check));
tableColumn.setHeaderRenderer(headerRenderer);
// Connect the check control with the header
checkRenderer.addChangeListener(headerRenderer);
}
}
minWidth.add(new Integer(30));
} else // Date
if (DisplayType.Date == displayType || DisplayType.DateTime == displayType || c == Timestamp.class) {
if (DisplayType.DateTime == displayType)
tableColumn.setCellRenderer(new VCellRenderer(DisplayType.DateTime));
else
tableColumn.setCellRenderer(new VCellRenderer(DisplayType.Date));
if (readOnly)
tableColumn.setCellEditor(new ROCellEditor());
else if (DisplayType.Date == displayType || DisplayType.DateTime == displayType)
tableColumn.setCellEditor(new MiniCellEditor(c, displayType));
else
tableColumn.setCellEditor(new MiniCellEditor(c));
minWidth.add(new Integer(30));
if (DisplayType.DateTime == displayType)
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.DateTime));
else
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.Date));
} else // Amount
if (DisplayType.Amount == displayType || c == BigDecimal.class) {
tableColumn.setCellRenderer(new VCellRenderer(DisplayType.Amount));
if (readOnly) {
tableColumn.setCellEditor(new ROCellEditor());
minWidth.add(new Integer(70));
} else {
tableColumn.setCellEditor(new MiniCellEditor(c));
minWidth.add(new Integer(80));
}
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
} else // Number
if (DisplayType.Number == displayType || c == Double.class) {
tableColumn.setCellRenderer(new VCellRenderer(DisplayType.Number));
if (readOnly) {
tableColumn.setCellEditor(new ROCellEditor());
minWidth.add(new Integer(70));
} else {
tableColumn.setCellEditor(new MiniCellEditor(c));
minWidth.add(new Integer(80));
}
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
} else // Integer
if (DisplayType.Integer == displayType || c == Integer.class) {
tableColumn.setCellRenderer(new VCellRenderer(DisplayType.Integer));
if (readOnly)
tableColumn.setCellEditor(new ROCellEditor());
else
tableColumn.setCellEditor(new MiniCellEditor(c));
minWidth.add(new Integer(30));
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.Number));
} else // String
{
tableColumn.setCellRenderer(new VCellRenderer(DisplayType.String));
if (readOnly)
tableColumn.setCellEditor(new ROCellEditor());
else
tableColumn.setCellEditor(new MiniCellEditor(String.class));
minWidth.add(new Integer(30));
tableColumn.setHeaderRenderer(new VHeaderRenderer(DisplayType.String));
}
// logger.fine( "Renderer=" + tc.getCellRenderer().toString() + ", Editor=" + tc.getCellEditor().toString());
}
Aggregations