use of org.compiere.model.MRecordAccess in project adempiere by adempiere.
the class WRecordAccessDialog method cmd_save.
/**
* Save Command
* @return true if saved
*/
private boolean cmd_save() {
ListItem pp = roleField.getSelectedItem();
if (pp == null)
return false;
int AD_Role_ID = ((Integer) pp.getValue()).intValue();
//
boolean isActive = cbActive.isSelected();
boolean isExclude = cbExclude.isSelected();
boolean isReadOnly = cbReadOnly.isSelected();
boolean isDependentEntities = cbDependent.isSelected();
//
if (m_currentData == null) {
m_currentData = new MRecordAccess(Env.getCtx(), AD_Role_ID, m_AD_Table_ID, m_Record_ID, null);
m_recordAccesss.add(m_currentData);
m_currentRow = m_recordAccesss.size() - 1;
}
m_currentData.setIsActive(isActive);
m_currentData.setIsExclude(isExclude);
m_currentData.setIsReadOnly(isReadOnly);
m_currentData.setIsDependentEntities(isDependentEntities);
boolean success = m_currentData.save();
//
log.fine("Success=" + success);
return success;
}
use of org.compiere.model.MRecordAccess in project adempiere by adempiere.
the class WRecordAccessDialog method dynInit.
/**
* Dynamic Init
*/
private void dynInit() {
// Load Roles
String sql = MRole.getDefault().addAccessSQL("SELECT AD_Role_ID, Name FROM AD_Role ORDER BY 2", "AD_Role", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
roleField = new Listbox(DB.getKeyNamePairs(sql, false));
roleField.setMold("select");
// Load Record Access for all roles
sql = "SELECT * FROM AD_Record_Access " + "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Client_ID=?";
PreparedStatement pstmt = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Table_ID);
pstmt.setInt(2, m_Record_ID);
pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx()));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) m_recordAccesss.add(new MRecordAccess(Env.getCtx(), rs, null));
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
}
try {
if (pstmt != null)
pstmt.close();
pstmt = null;
} catch (Exception e) {
pstmt = null;
}
log.fine("#" + m_recordAccesss.size());
setLine(0, false);
}
use of org.compiere.model.MRecordAccess in project adempiere by adempiere.
the class RecordAccessDialog method setLine.
// jbInit
/**
* Set Line
* @param rowDelta delta to current row
* @param newRecord new
*/
private void setLine(int rowDelta, boolean newRecord) {
log.fine("delta=" + rowDelta + ", new=" + newRecord + " - currentRow=" + m_currentRow + ", size=" + m_recordAccesss.size());
int maxIndex = 0;
// nothing defined
if (m_recordAccesss.size() == 0) {
m_currentRow = 0;
maxIndex = 0;
newRecord = true;
setLine(null);
} else if (newRecord) {
m_currentRow = m_recordAccesss.size();
maxIndex = m_currentRow;
setLine(null);
} else {
m_currentRow += rowDelta;
maxIndex = m_recordAccesss.size() - 1;
if (m_currentRow < 0)
m_currentRow = 0;
else if (m_currentRow > maxIndex)
m_currentRow = maxIndex;
//
MRecordAccess ra = (MRecordAccess) m_recordAccesss.get(m_currentRow);
setLine(ra);
}
// Label
StringBuffer txt = new StringBuffer();
if (newRecord)
txt.append("+");
txt.append(m_currentRow + 1).append("/").append(maxIndex + 1);
rowNoLabel.setText(txt.toString());
// set up/down
bUp.setEnabled(m_currentRow > 0);
bDown.setEnabled(m_currentRow < maxIndex);
}
use of org.compiere.model.MRecordAccess in project adempiere by adempiere.
the class RecordAccessDialog method cmd_save.
// actionPerformed
/**
* Save Command
* @return true if saved
*/
private boolean cmd_save() {
KeyNamePair pp = (KeyNamePair) roleField.getSelectedItem();
roleField.setBackground(pp == null);
if (pp == null)
return false;
int AD_Role_ID = pp.getKey();
//
boolean isActive = cbActive.isSelected();
boolean isExclude = cbExclude.isSelected();
boolean isReadOnly = cbReadOnly.isSelected();
boolean isDependentEntities = cbDependent.isSelected();
//
if (m_currentData == null) {
m_currentData = new MRecordAccess(Env.getCtx(), AD_Role_ID, m_AD_Table_ID, m_Record_ID, null);
m_recordAccesss.add(m_currentData);
m_currentRow = m_recordAccesss.size() - 1;
}
m_currentData.setIsActive(isActive);
m_currentData.setIsExclude(isExclude);
m_currentData.setIsReadOnly(isReadOnly);
m_currentData.setIsDependentEntities(isDependentEntities);
boolean success = m_currentData.save();
//
log.fine("Success=" + success);
return success;
}
use of org.compiere.model.MRecordAccess in project adempiere by adempiere.
the class RecordAccessDialog method dynInit.
/**
* Dynamic Init
*/
private void dynInit() {
// Load Roles
String sql = MRole.getDefault().addAccessSQL("SELECT AD_Role_ID, Name FROM AD_Role ORDER BY 2", "AD_Role", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
roleField = new CComboBox(DB.getKeyNamePairs(sql, false));
// Load Record Access for all roles
sql = "SELECT * FROM AD_Record_Access " + "WHERE AD_Table_ID=? AND Record_ID=? AND AD_Client_ID=?";
PreparedStatement pstmt = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_AD_Table_ID);
pstmt.setInt(2, m_Record_ID);
pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx()));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) m_recordAccesss.add(new MRecordAccess(Env.getCtx(), rs, null));
rs.close();
pstmt.close();
pstmt = null;
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
}
try {
if (pstmt != null)
pstmt.close();
pstmt = null;
} catch (Exception e) {
pstmt = null;
}
log.fine("#" + m_recordAccesss.size());
setLine(0, false);
}
Aggregations