use of org.adempiere.webui.exception.ApplicationException in project adempiere by adempiere.
the class WBrowserTable method initialiseHeader.
/**
* Create the listbox header by fetching it from the renderer and adding
* it to the Listbox.
*
*/
private void initialiseHeader() {
ListHead head = null;
head = super.getListHead();
//init only once
if (head != null) {
return;
}
head = new ListHead();
// render list head
if (this.getItemRenderer() instanceof WBrowserListItemRenderer) {
((WBrowserListItemRenderer) this.getItemRenderer()).renderListHead(head);
} else {
throw new ApplicationException("Rendering of the ListHead is unsupported for " + this.getItemRenderer().getClass().getSimpleName());
}
//attach the listhead
head.setParent(this);
return;
}
use of org.adempiere.webui.exception.ApplicationException in project adempiere by adempiere.
the class WPOSTable method loadTable.
/**
* Load Table from ResultSet - The ResultSet is not closed.
*
* @param rs ResultSet containing data t enter int the table.
* The contents must conform to the column layout defined in
* {@link #prepareTable(ColumnInfo[], String, String, boolean, String)}
*/
public void loadTable(ResultSet rs) {
int no = 0;
// model row
int row = 0;
// model column
int col = 0;
Object data = null;
// index into result set
int rsColIndex = 0;
// result set columns start with 1
int rsColOffset = 1;
// class of the column
Class columnClass;
if (getLayout() == null) {
throw new UnsupportedOperationException("Layout not defined");
}
clearTable();
try {
while (rs.next()) {
row = getItemCount();
setRowCount(row + 1);
rsColOffset = 1;
no++;
for (col = 0; col < m_layout.length; col++) {
//reset the data value
data = null;
columnClass = m_layout[col].getColClass();
rsColIndex = col + rsColOffset;
if (isColumnClassMismatch(col, columnClass)) {
throw new ApplicationException("Cannot enter a " + columnClass.getName() + " in column " + col + ". " + "An object of type " + m_modelHeaderClass.get(col).getSimpleName() + " was expected.");
}
if (columnClass == IDColumn.class && !m_layout[col].getColSQL().equals("'Row' AS \"Row\"")) {
data = new IDColumn(rs.getInt(rsColIndex));
} else if (columnClass == IDColumn.class && m_layout[col].getColSQL().equals("'Row' AS \"Row\"")) {
data = new IDColumn(no);
} else if (columnClass == Boolean.class) {
data = rs.getString(rsColIndex) == null ? new Boolean(false) : new Boolean(rs.getString(rsColIndex).equals("Y"));
} else if (columnClass == Timestamp.class) {
data = rs.getTimestamp(rsColIndex);
} else if (columnClass == BigDecimal.class) {
data = rs.getBigDecimal(rsColIndex);
} else if (columnClass == Double.class) {
data = new Double(rs.getDouble(rsColIndex));
} else if (columnClass == Integer.class) {
data = new Integer(rs.getInt(rsColIndex));
} else if (columnClass == KeyNamePair.class) {
// TODO factor out this generation
String display = rs.getString(rsColIndex);
int key = rs.getInt(rsColIndex + 1);
data = new KeyNamePair(key, display);
rsColOffset++;
} else if (columnClass == DeleteColumn.class) {
// TODO factor out this generation
data = new DeleteColumn(rs.getInt(rsColIndex));
} else {
// TODO factor out this cleanup
String s = rs.getString(rsColIndex);
if (s != null) {
// problems with NCHAR
data = s.trim();
} else {
data = null;
}
}
// store in underlying model
getModel().setDataAt(data, row, col);
}
}
} catch (SQLException exception) {
logger.log(Level.SEVERE, "", exception);
}
autoSize();
if (getShowTotals())
addTotals(m_layout);
// repaint the table
this.repaint();
logger.config("Row(rs)=" + getRowCount());
return;
}
use of org.adempiere.webui.exception.ApplicationException in project adempiere by adempiere.
the class AbstractADWindowPanel method initPanel.
/**
* @param adWindowId
* @param query
* @return boolean
*/
public boolean initPanel(int adWindowId, MQuery query) {
// This temporary validation code is added to check the reported bug
// [ adempiere-ZK Web Client-2832968 ] User context lost?
// https://sourceforge.net/tracker/?func=detail&atid=955896&aid=2832968&group_id=176962
// it's harmless, if there is no bug then this must never fail
Session currSess = Executions.getCurrent().getDesktop().getSession();
int checkad_user_id = -1;
if (currSess != null && currSess.getAttribute("Check_AD_User_ID") != null)
checkad_user_id = (Integer) currSess.getAttribute("Check_AD_User_ID");
if (checkad_user_id != Env.getAD_User_ID(ctx)) {
String msg = "Timestamp=" + new Date() + ", Bug 2832968 SessionUser=" + checkad_user_id + ", ContextUser=" + Env.getAD_User_ID(ctx) + ". Please report conditions to your system administrator or in sf tracker 2832968";
ApplicationException ex = new ApplicationException(msg);
logger.log(Level.SEVERE, msg, ex);
throw ex;
}
// Set AutoCommit for this Window
if (embeddedTabIndex < 0) {
Env.setAutoCommit(ctx, curWindowNo, Env.isAutoCommit(ctx));
boolean autoNew = Env.isAutoNew(ctx);
Env.setAutoNew(ctx, curWindowNo, autoNew);
GridWindowVO gWindowVO = AEnv.getMWindowVO(curWindowNo, adWindowId, 0);
if (gWindowVO == null) {
throw new ApplicationException(Msg.getMsg(ctx, "AccessTableNoView") + "(No Window Model Info)");
}
gridWindow = new GridWindow(gWindowVO, true);
title = gridWindow.getName();
// Set SO/AutoNew for Window
Env.setContext(ctx, curWindowNo, "IsSOTrx", gridWindow.isSOTrx());
if (!autoNew && gridWindow.isTransaction()) {
Env.setAutoNew(ctx, curWindowNo, true);
}
}
m_onlyCurrentRows = embeddedTabIndex < 0 && gridWindow.isTransaction();
MQuery detailQuery = null;
/**
* Window Tabs
*/
if (embeddedTabIndex < 0) {
if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null && query.getZoomValue() instanceof Integer && (Integer) query.getZoomValue() > 0) {
if (!query.getZoomTableName().equalsIgnoreCase(gridWindow.getTab(0).getTableName())) {
detailQuery = query;
query = new MQuery();
query.addRestriction("1=2");
query.setRecordCount(0);
}
}
int tabSize = gridWindow.getTabCount();
for (int tab = 0; tab < tabSize; tab++) {
initTab(query, tab);
if (tab == 0 && curTab == null && m_findCancelled)
return false;
}
setActiveTab(0);
getToolbar().setCurrentPanel(curTabPanel);
Env.setContext(ctx, curWindowNo, "WindowName", gridWindow.getName());
} else {
initEmbeddedTab(query, embeddedTabIndex);
}
if (curTab != null)
curTab.getTableModel().setChanged(false);
if (embeddedTabIndex < 0) {
curTabIndex = 0;
adTab.setSelectedIndex(0);
toolbar.enableTabNavigation(adTab.getTabCount() > 1);
toolbar.enableFind(true);
adTab.evaluate(null);
if (gridWindow.isTransaction()) {
toolbar.enableHistoryRecords(true);
}
if (detailQuery != null && zoomToDetailTab(detailQuery)) {
return true;
}
} else {
curTabIndex = embeddedTabIndex;
toolbar.enableTabNavigation(false);
toolbar.enableFind(true);
toolbar.enableHistoryRecords(false);
}
updateToolbar();
return true;
}
Aggregations