use of org.compiere.model.GridWindowVO in project adempiere by adempiere.
the class WZoom method createPage.
// doPost
/**
* Create Attachment Page
* @param ctx context
* @param AD_Attachment_ID id for existing attachment
* @param AD_Table_ID table for new attachment
* @param Record_ID record for new attachment
* @param error optional error message
* @return MobileDoc
*/
public static MobileDoc createPage(Properties ctx, HttpServletRequest request, int AD_Record_ID, int AD_Table_ID) {
//MobileDoc doc = MobileDoc.createPopup (Msg.translate(ctx, "AD_Attachment_ID"));
MobileDoc doc = null;
String TableName = null;
int AD_Window_ID = 0;
int PO_Window_ID = 0;
String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
TableName = rs.getString(1);
AD_Window_ID = rs.getInt(2);
PO_Window_ID = rs.getInt(3);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
if (TableName == null || AD_Window_ID == 0) {
doc = MobileDoc.createPopup("No Context");
//doc.addPopupClose(ctx);
return doc;
}
// PO Zoom ?
boolean isSOTrx = true;
if (PO_Window_ID != 0) {
String whereClause = TableName + "_ID=" + AD_Record_ID;
isSOTrx = DB.isSOTrx(TableName, whereClause);
if (!isSOTrx)
AD_Window_ID = PO_Window_ID;
}
/**
* New Window data
*/
WWindowStatus ws = WWindowStatus.get(request);
HttpSession sess = request.getSession();
MobileSessionCtx wsc = MobileSessionCtx.get(request);
if (ws != null) {
int WindowNo = ws.mWindow.getWindowNo();
log.fine("Disposing - WindowNo=" + WindowNo + ", ID=" + ws.mWindow.getAD_Window_ID());
ws.mWindow.dispose();
Env.clearWinContext(wsc.ctx, WindowNo);
}
GridWindowVO mWindowVO = GridWindowVO.create(ctx, s_WindowNo++, AD_Window_ID, 0);
if (mWindowVO == null) {
String msg = Msg.translate(ctx, "AD_Window_ID") + " " + Msg.getMsg(ctx, "NotFound") + ", ID=" + AD_Window_ID + "/" + 0;
doc = MobileDoc.createPopup(msg);
//doc.addPopupClose(ctx);
return doc;
}
// Create New Window
ws = new WWindowStatus(mWindowVO);
sess.setAttribute(WWindowStatus.NAME, ws);
// Query
ws.mWindow.initTab(ws.curTab.getTabNo());
ws.curTab.setQuery(MQuery.getEqualQuery(TableName + "_ID", AD_Record_ID));
ws.curTab.query(false);
return doc;
}
use of org.compiere.model.GridWindowVO in project adempiere by adempiere.
the class WZoom method createPage.
// doPost
/**
* Create Attachment Page
* @param ctx context
* @param AD_Attachment_ID id for existing attachment
* @param AD_Table_ID table for new attachment
* @param Record_ID record for new attachment
* @param error optional error message
* @return WebDoc
*/
public static WebDoc createPage(Properties ctx, HttpServletRequest request, int AD_Record_ID, int AD_Table_ID) {
//WebDoc doc = WebDoc.createPopup (Msg.translate(ctx, "AD_Attachment_ID"));
WebDoc doc = null;
String TableName = null;
int AD_Window_ID = 0;
int PO_Window_ID = 0;
String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
TableName = rs.getString(1);
AD_Window_ID = rs.getInt(2);
PO_Window_ID = rs.getInt(3);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
if (TableName == null || AD_Window_ID == 0) {
doc = WebDoc.createPopup("No Context");
doc.addPopupClose(ctx);
return doc;
}
// PO Zoom ?
boolean isSOTrx = true;
if (PO_Window_ID != 0) {
String whereClause = TableName + "_ID=" + AD_Record_ID;
isSOTrx = DB.isSOTrx(TableName, whereClause);
if (!isSOTrx)
AD_Window_ID = PO_Window_ID;
}
/**
* New Window data
*/
WWindowStatus ws = WWindowStatus.get(request);
HttpSession sess = request.getSession();
WebSessionCtx wsc = WebSessionCtx.get(request);
if (ws != null) {
int WindowNo = ws.mWindow.getWindowNo();
log.fine("Disposing - WindowNo=" + WindowNo + ", ID=" + ws.mWindow.getAD_Window_ID());
ws.mWindow.dispose();
Env.clearWinContext(wsc.ctx, WindowNo);
}
GridWindowVO mWindowVO = GridWindowVO.create(ctx, s_WindowNo++, AD_Window_ID, 0);
if (mWindowVO == null) {
String msg = Msg.translate(ctx, "AD_Window_ID") + " " + Msg.getMsg(ctx, "NotFound") + ", ID=" + AD_Window_ID + "/" + 0;
doc = WebDoc.createPopup(msg);
doc.addPopupClose(ctx);
return doc;
}
// Create New Window
ws = new WWindowStatus(mWindowVO);
sess.setAttribute(WWindowStatus.NAME, ws);
// Query
ws.mWindow.initTab(ws.curTab.getTabNo());
ws.curTab.setQuery(MQuery.getEqualQuery(TableName + "_ID", AD_Record_ID));
ws.curTab.query(false);
return doc;
}
use of org.compiere.model.GridWindowVO in project adempiere by adempiere.
the class TrxMaterial method dynInit.
/**
* Dynamic Layout (Grid).
* Based on AD_Window: Material Transactions
*/
public void dynInit(IStatusBar statusBar) {
m_staticQuery = new MQuery();
m_staticQuery.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
// Hardcoded
int AD_Window_ID = 223;
GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
if (wVO == null)
return;
m_mWindow = new GridWindow(wVO);
m_mTab = m_mWindow.getTab(0);
m_mWindow.initTab(0);
//
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
m_mTab.query(false);
statusBar.setStatusLine(" ", false);
statusBar.setStatusDB(" ");
}
use of org.compiere.model.GridWindowVO in project adempiere by adempiere.
the class Stocktake method dynInit.
/**
* Dynamic Layout (Grid).
* Based on AD_Window: Stocktake (Indirect Use)
*/
public void dynInit(IStatusBar statusBar) {
m_staticQuery = new MQuery();
m_staticQuery.addRestriction("AD_Client_ID", MQuery.EQUAL, Env.getAD_Client_ID(Env.getCtx()));
// Hardcoded Window: Stocktake (Indirect Use)
int AD_Window_ID = 53278;
GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
if (wVO == null)
return;
m_mWindow = new GridWindow(wVO);
m_mTab = m_mWindow.getTab(0);
m_mWindow.initTab(0);
Env.setAutoCommit(Env.getCtx(), wVO.WindowNo, Env.isAutoCommit(Env.getCtx()));
//
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
m_mTab.query(false);
statusBar.setStatusLine(" ", false);
statusBar.setStatusDB(" ");
}
use of org.compiere.model.GridWindowVO in project adempiere by adempiere.
the class VAccountDialog method initAccount.
// jbInit
/**
* Dyanmic Init.
* When a row is selected, the editor values are set
* (editors do not change grid)
* @return true if initialized
*/
private boolean initAccount() {
m_AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID");
// Get AcctSchema Info
if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
s_AcctSchema = new MAcctSchema(Env.getCtx(), m_C_AcctSchema_ID, null);
log.config(s_AcctSchema.toString() + ", #" + s_AcctSchema.getAcctSchemaElements().length);
Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", m_C_AcctSchema_ID);
// Model
// Maintain Account Combinations
int AD_Window_ID = 153;
GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
if (wVO == null)
return false;
m_mWindow = new GridWindow(wVO);
m_mTab = m_mWindow.getTab(0);
// Make sure is the tab is loaded - teo_sarca [ 1659124 ]
if (!m_mTab.isLoadComplete())
m_mWindow.initTab(0);
// ParameterPanel restrictions
m_mTab.getField("Alias").setDisplayLength(15);
m_mTab.getField("Combination").setDisplayLength(15);
// Grid restrictions
m_mTab.getField("AD_Client_ID").setDisplayed(false);
m_mTab.getField("C_AcctSchema_ID").setDisplayed(false);
m_mTab.getField("IsActive").setDisplayed(false);
m_mTab.getField("IsFullyQualified").setDisplayed(false);
// don't show fields not being displayed in this environment
for (int i = 0; i < m_mTab.getFieldCount(); i++) {
GridField field = m_mTab.getField(i);
if (// check context
!field.isDisplayed(true))
field.setDisplayed(false);
}
// GridController
m_gridController = new GridController();
m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null);
m_gridController.setPreferredSize(new Dimension(300, 100));
panel.add(m_gridController, BorderLayout.CENTER);
// Prepare Parameter
m_gbc.anchor = GridBagConstraints.NORTHWEST;
// line
m_gbc.gridy = 0;
m_gbc.gridx = 0;
m_gbc.gridwidth = 1;
m_gbc.insets = m_fieldInsets;
m_gbc.fill = GridBagConstraints.HORIZONTAL;
m_gbc.weightx = 0;
m_gbc.weighty = 0;
int TabNo = 0;
// Alias
if (s_AcctSchema.isHasAlias()) {
GridField alias = m_mTab.getField("Alias");
f_Alias = VEditorFactory.getEditor(m_mTab, alias, false);
addLine(alias, f_Alias, false);
}
// Alias
// Combination
GridField combination = m_mTab.getField("Combination");
f_Combination = VEditorFactory.getEditor(m_mTab, combination, false);
addLine(combination, f_Combination, false);
m_newRow = true;
/**
* Create Fields in Element Order
*/
MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
for (int i = 0; i < elements.length; i++) {
MAcctSchemaElement ase = elements[i];
String type = ase.getElementType();
boolean isMandatory = ase.isMandatory();
//
if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
GridField field = m_mTab.getField("AD_Org_ID");
f_AD_Org_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_AD_Org_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
GridField field = m_mTab.getField("Account_ID");
f_Account_ID = VEditorFactory.getEditor(m_mTab, field, false);
// ((VLookup)f_Account_ID).setWidth(400);
addLine(field, f_Account_ID, isMandatory);
f_Account_ID.addVetoableChangeListener(this);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
GridField field = m_mTab.getField("C_SubAcct_ID");
f_SubAcct_ID = VEditorFactory.getEditor(m_mTab, field, false);
// ((VLookup)f_SubAcct_ID).setWidth(400);
addLine(field, f_SubAcct_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
GridField field = m_mTab.getField("M_Product_ID");
f_M_Product_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_M_Product_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
GridField field = m_mTab.getField("C_BPartner_ID");
f_C_BPartner_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_BPartner_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
GridField field = m_mTab.getField("C_Campaign_ID");
f_C_Campaign_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_Campaign_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
GridField field = m_mTab.getField("C_LocFrom_ID");
f_C_LocFrom_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_LocFrom_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
GridField field = m_mTab.getField("C_LocTo_ID");
f_C_LocTo_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_LocTo_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
GridField field = m_mTab.getField("C_Project_ID");
f_C_Project_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_Project_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
GridField field = m_mTab.getField("C_SalesRegion_ID");
f_C_SalesRegion_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_SalesRegion_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
GridField field = m_mTab.getField("AD_OrgTrx_ID");
f_AD_OrgTrx_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_AD_OrgTrx_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
GridField field = m_mTab.getField("C_Activity_ID");
f_C_Activity_ID = VEditorFactory.getEditor(m_mTab, field, false);
addLine(field, f_C_Activity_ID, isMandatory);
} else // User1
if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
GridField field = m_mTab.getField("User1_ID");
f_User1_ID = VEditorFactory.getEditor(m_mTab, field, false);
GridFieldVO newFieldVO = f_User1_ID.getField().getVO();
newFieldVO.Header = f_User1_ID.getName();
field = new GridField(newFieldVO);
addLine(field, f_User1_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
GridField field = m_mTab.getField("User2_ID");
f_User2_ID = VEditorFactory.getEditor(m_mTab, field, false);
GridFieldVO newFieldVO = f_User2_ID.getField().getVO();
newFieldVO.Header = f_User2_ID.getName();
field = new GridField(newFieldVO);
addLine(field, f_User2_ID, isMandatory);
} else // User3
if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList3)) {
GridField field = m_mTab.getField("User3_ID");
f_User3_ID = VEditorFactory.getEditor(m_mTab, field, false);
GridFieldVO newFieldVO = f_User3_ID.getField().getVO();
newFieldVO.Header = f_User3_ID.getName();
field = new GridField(newFieldVO);
addLine(field, f_User3_ID, isMandatory);
} else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList4)) {
GridField field = m_mTab.getField("User4_ID");
f_User4_ID = VEditorFactory.getEditor(m_mTab, field, false);
GridFieldVO newFieldVO = f_User4_ID.getField().getVO();
newFieldVO.Header = f_User4_ID.getName();
field = new GridField(newFieldVO);
addLine(field, f_User4_ID, isMandatory);
}
}
// Create Fields in Element Order
// Add description
m_newRow = true;
m_gbc.gridy = m_line++;
m_gbc.gridx = 0;
m_gbc.gridwidth = 4;
// top,left,bottom,right
m_gbc.insets = new Insets(5, 15, 2, 0);
m_gbc.fill = GridBagConstraints.HORIZONTAL;
f_Description.setFont(f_Description.getFont().deriveFont(Font.ITALIC));
parameterPanel.add(f_Description, m_gbc);
// Finish
m_query = new MQuery();
m_query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
m_query.addRestriction("IsFullyQualified", MQuery.EQUAL, "Y");
if (m_mAccount.C_ValidCombination_ID == 0)
m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
else {
MQuery query = new MQuery();
query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
query.addRestriction("C_ValidCombination_ID", MQuery.EQUAL, m_mAccount.C_ValidCombination_ID);
m_mTab.setQuery(query);
}
m_mTab.query(false);
m_gridController.getTable().addMouseListener(new VAccountDialog_mouseAdapter(this));
m_gridController.addDataStatusListener(this);
statusBar.setStatusLine(s_AcctSchema.toString());
statusBar.setStatusDB("?");
// Initial value
if (m_mAccount.C_ValidCombination_ID != 0)
m_mTab.navigate(0);
log.config("fini");
return true;
}
Aggregations