use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class VGenPanel method tableChanged.
// stateChanged
/**
* Table Model Listener
* @param e event
*/
public void tableChanged(TableModelEvent e) {
int rowsSelected = 0;
int rows = miniTable.getRowCount();
for (int i = 0; i < rows; i++) {
// ID in column 0
IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
if (id != null && id.isSelected())
rowsSelected++;
}
statusBar.setStatusDB(" " + rowsSelected + " ");
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class VBrowserTable method loadTable.
@Override
public int loadTable(ResultSet rs) {
long start = System.currentTimeMillis();
// Row
int row = 0;
int no = 0;
// Delete Row
setRowCount(row);
try {
log.fine("Start load - " + (System.currentTimeMillis() - start) + "ms");
while (rs.next()) {
no++;
setRowCount(row + 1);
// columns start with 1
int colOffset = 1;
int column = 0;
for (MBrowseField field : getFields()) {
Object value = null;
if (field.isKey() && DisplayType.isID(field.getAD_Reference_ID()) && !field.getAD_View_Column().getColumnSQL().equals("'Row' AS \"Row\""))
value = new IDColumn(rs.getInt(column + colOffset));
else if (field.isKey() && DisplayType.isNumeric(field.getAD_Reference_ID()) && field.getAD_View_Column().getColumnSQL().equals("'Row' AS \"Row\""))
value = new IDColumn(no);
else if (DisplayType.isID(field.getAD_Reference_ID()) || field.getAD_Reference_ID() == DisplayType.Integer) {
Integer id = rs.getInt(column + colOffset);
value = id != 0 ? id : null;
} else if (DisplayType.isNumeric(field.getAD_Reference_ID()))
value = rs.getBigDecimal(column + colOffset);
else if (DisplayType.isDate(field.getAD_Reference_ID()))
value = rs.getTimestamp(column + colOffset);
else if (DisplayType.YesNo == field.getAD_Reference_ID()) {
value = rs.getString(column + colOffset);
if (value != null)
value = value.equals("Y");
} else
value = rs.getObject(column + colOffset);
GridField gridField = MBrowseField.createGridFieldVO(field, browser.getWindowNo());
gridField.setValue(value, true);
// Set Value
setValueAnyColumn(row, column, gridField);
column++;
}
// Increment Row
row++;
}
log.fine("End load - " + (System.currentTimeMillis() - start) + "ms");
} catch (SQLException e) {
log.log(Level.SEVERE, "", e);
}
//no = detail.getRowCount();
log.fine("#" + no + " - " + (System.currentTimeMillis() - start) + "ms");
if (isShowTotals())
addTotals();
//
autoSize();
//
return no;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class VInOutInvoiceGen method saveSelection.
// tableChanged
/**
* Save Selection & return selecion Query or ""
* @return where clause like C_Order_ID IN (...)
*/
private void saveSelection() {
log.info("");
// ID selection may be pending
miniTable.editingStopped(new ChangeEvent(this));
// Array of Integers
ArrayList<Integer> results = new ArrayList<Integer>();
selection = null;
// Get selected entries
int rows = miniTable.getRowCount();
for (int i = 0; i < rows; i++) {
// ID in column 0
IDColumn id = (IDColumn) miniTable.getValueAt(i, 0);
// log.fine( "Row=" + i + " - " + id);
if (id != null && id.isSelected())
results.add(id.getRecord_ID());
}
if (results.size() == 0)
return;
log.config("Selected #" + results.size());
selection = results;
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class Browser method saveResultSelection.
/**
* FR [ 245 ]
* save result values
* @param browserTable
*/
protected void saveResultSelection(IBrowserTable browserTable) {
if (m_keyColumnIndex == -1) {
return;
}
// Verify if is Multi-Selection
if (p_multiSelection) {
int rows = browserTable.getRowCount();
BrowserRow browserRows = browserTable.getData();
m_values = new LinkedHashMap<Integer, LinkedHashMap<String, Object>>();
// BR [ 257 ]
List<MBrowseField> fields = m_Browse.getFields();
for (int row = 0; row < rows; row++) {
//Find the IDColumn Key
GridField selectedGridField = (GridField) browserRows.getValue(row, m_keyColumnIndex);
// Get Value
Object data = selectedGridField.getValue();
//
if (data instanceof IDColumn) {
IDColumn dataColumn = (IDColumn) data;
if (dataColumn.isSelected()) {
LinkedHashMap<String, Object> values = new LinkedHashMap<String, Object>();
for (MBrowseField field : fields) {
if (!field.isReadOnly() || field.isIdentifier() || field.isKey()) {
GridField gridField = (GridField) browserRows.getValueOfColumn(row, field.getAD_View_Column().getColumnName());
if (gridField != null) {
Object value = gridField.getValue();
// Parse value to standard values
if (value instanceof IDColumn) {
IDColumn id = (IDColumn) value;
value = id.getRecord_ID();
} else if (value instanceof Double) {
value = BigDecimal.valueOf((Double) value);
} else if (value instanceof Date) {
value = new Timestamp(((Date) value).getTime());
}
// Set
values.put(field.getAD_View_Column().getColumnName(), value);
}
}
}
//
if (values.size() > 0)
m_values.put(dataColumn.getRecord_ID(), values);
}
}
}
}
}
use of org.compiere.minigrid.IDColumn in project adempiere by adempiere.
the class WFActivity method loadActivities.
/**
* Load Activities
* @return int
*/
public int loadActivities() {
resetDisplay(null);
while (selTableModel.getRowCount() > 0) selTableModel.removeRow(0);
long start = System.currentTimeMillis();
ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
String sql = "SELECT * FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + // Owner of Activity
" a.AD_User_ID=?" + // Invoker (if no invoker = all)
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #2
" AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #3
" AND r.AD_User_ID=?)" + // Responsible Role
" OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + // #4
" WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?)" + //
") ORDER BY a.Priority DESC, Created";
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
sql = role.addAccessSQL(sql, "a", true, false);
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_User_ID);
pstmt.setInt(3, AD_User_ID);
pstmt.setInt(4, AD_User_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null);
Object[] rowData = new Object[4];
rowData[0] = new IDColumn(activity.get_ID());
rowData[1] = activity.getPriority();
rowData[2] = activity.getNodeName();
rowData[3] = activity.getSummary();
selTableModel.addRow(rowData);
if (list.size() > MAX_ACTIVITIES_IN_LIST) {
log.warning("More than " + MAX_ACTIVITIES_IN_LIST + " Activities - ignored");
break;
}
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
selTable.autoSize(false);
log.fine("#" + selTable.getModel().getRowCount() + "(" + (System.currentTimeMillis() - start) + "ms)");
return selTable.getModel().getRowCount();
}
Aggregations