use of org.compiere.model.GridWindow in project adempiere by adempiere.
the class Base method test.
/**
* Base Test
*/
public static void test() {
//$NON-NLS-1$
System.out.println("** Before Init **");
getMemoryUsed();
Properties ctx = Login.initTest(false);
// Log.printProperties(System.getProperties(), "System", false);
//
// cleanup Init
System.gc();
//
System.out.println("** Before Creation **");
long start = getMemoryUsed();
// *******************************************************************
// Table=100, Shipper=142, Window=102, Reference=101
int AD_Window_ID = 102;
long startTime = System.currentTimeMillis();
GridWindowVO vo = GridWindowVO.create(Env.getCtx(), 1, AD_Window_ID);
GridWindow w = new GridWindow(vo);
long endDef = System.currentTimeMillis();
System.out.println("Load Definition Time in ms = " + String.valueOf(endDef - startTime));
if (// optional step
1 == 2) {
w.loadCompete();
long endDefComplete = System.currentTimeMillis();
System.out.println("Load Definition Complete Time in ms = " + String.valueOf(endDefComplete - startTime));
}
w.query();
long endData = System.currentTimeMillis();
System.out.println("Load Data Time in ms = " + String.valueOf(endData - startTime));
w.loadCompete();
long endDataComplete = System.currentTimeMillis();
System.out.println("Load Data Complete Time in ms = " + String.valueOf(endDataComplete - startTime));
w.getTab(0).navigate(0);
// *******************************************************************
// sleep();
System.out.println("** Before Dispose **");
getMemoryUsed();
w.dispose();
// sleep();
//
System.out.println("** Before GC **");
getMemoryUsed();
w = null;
System.gc();
System.out.println("** After GC **");
getMemoryUsed();
System.gc();
System.out.println("** Final **");
long complete = System.currentTimeMillis();
System.out.println("Complete Time in ms = " + String.valueOf(complete - startTime));
long end = getMemoryUsed();
System.out.println("Memory increase in kB = End-Start=" + String.valueOf((end - start) / 1024));
listThreads();
//
System.out.println("API Test");
System.out.println("64.72=" + MConversionRate.convert(ctx, new BigDecimal(100.0), 116, 100, 0, 0));
System.out.println("0.647169=" + MConversionRate.getRate(116, 100, null, 0, 0, 0));
System.out.println("12.5=" + MUOMConversion.convert(101, 102, new BigDecimal(100.0), true));
}
use of org.compiere.model.GridWindow 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;
}
use of org.compiere.model.GridWindow in project adempiere by adempiere.
the class Stocktake method refresh.
// dynInit
/**************************************************************************
* Refresh - Create Query and refresh grid
*/
public void refresh(Object inventory, Object locator, Object product, Object aislex, Object lineFrom, Object lineTo, IStatusBar statusBar, Boolean isSecondCount) {
m_mTab.dataSave(true);
/**
* Create Where Clause
*/
MQuery query = m_staticQuery.deepCopy();
// Physical Inventory
if (inventory == null || inventory.toString().length() == 0)
return;
query.addRestriction("M_Inventory_ID", MQuery.EQUAL, inventory);
// Locator
if (locator != null && locator.toString().length() > 0)
query.addRestriction("M_Locator_ID", MQuery.EQUAL, locator);
// Product
if (product != null && product.toString().length() > 0)
query.addRestriction("M_Product_ID", MQuery.EQUAL, product);
// aislex
if (aislex != null && aislex.toString().length() > 0)
query.addRestriction("M_Locator_ID IN (SELECT M_Locator_ID FROM M_Locator WHERE X='" + aislex.toString() + "')");
// DateFrom
if (lineFrom != null)
query.addRestriction("Line", MQuery.GREATER_EQUAL, lineFrom);
// DateTO
if (lineTo != null)
query.addRestriction("Line", MQuery.LESS_EQUAL, lineTo);
if (isSecondCount) {
// Hardcoded Window: Physical Inventory
int AD_Window_ID = 168;
GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
if (wVO == null)
return;
GridWindow m_mWindow2 = new GridWindow(wVO);
//second count tab
GridTab m_mTab2 = m_mWindow2.getTab(3);
String sql = m_mTab2.getWhereClause();
query.addRestriction(sql);
}
log.info("VTrxMaterial.refresh query=" + query.toString());
/**
* Refresh/Requery
*/
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "StartSearch"), false);
//
m_mTab.setQuery(query);
m_mTab.query(false);
//
int no = m_mTab.getRowCount();
statusBar.setStatusLine(" ", false);
statusBar.setStatusDB(Integer.toString(no));
}
Aggregations