use of org.compiere.model.MQuery in project adempiere by adempiere.
the class AEnv method actionZoom.
/**
*
* @param lookup
* @param value
*/
public static void actionZoom(Lookup lookup, Object value) {
if (lookup == null)
return;
//
MQuery zoomQuery = lookup.getZoomQuery();
// If not already exist or exact value
if (zoomQuery == null || value != null) {
// ColumnName might be changed in MTab.validateQuery
zoomQuery = new MQuery();
String column = lookup.getColumnName();
// Check if it is a Table Reference
if (lookup instanceof MLookup && DisplayType.List == lookup.getDisplayType()) {
int AD_Reference_ID = ((MLookup) lookup).getAD_Reference_Value_ID();
column = "AD_Ref_List_ID";
value = DB.getSQLValue(null, "SELECT AD_Ref_List_ID FROM AD_Ref_List WHERE AD_Reference_ID=? AND Value=?", AD_Reference_ID, value);
}
//strip off table name, fully qualify name doesn't work when zoom into detail tab
if (column.indexOf(".") > 0) {
int p = column.indexOf(".");
String tableName = column.substring(0, p);
column = column.substring(column.indexOf(".") + 1);
zoomQuery.setZoomTableName(tableName);
zoomQuery.setZoomColumnName(column);
} else {
zoomQuery.setZoomColumnName(column);
//remove _ID to get table name
zoomQuery.setZoomTableName(column.substring(0, column.length() - 3));
}
zoomQuery.setZoomValue(value);
zoomQuery.addRestriction(column, MQuery.EQUAL, value);
// guess
zoomQuery.setRecordCount(1);
}
int windowId = lookup.getZoom(zoomQuery);
zoom(windowId, zoomQuery);
}
use of org.compiere.model.MQuery in project adempiere by adempiere.
the class ZkReportViewer method init.
private void init() {
Borderlayout layout = new Borderlayout();
layout.setStyle("position: absolute; height: 99%; width: 99%");
this.appendChild(layout);
this.setStyle("width: 100%; height: 100%; position: absolute");
toolBar.setHeight("26px");
previewType.setMold("select");
previewType.appendItem("PDF", "PDF");
previewType.appendItem("HTML", "HTML");
previewType.appendItem("Excel", "XLS");
toolBar.appendChild(previewType);
previewType.addEventListener(Events.ON_SELECT, this);
toolBar.appendChild(new Separator("vertical"));
//set default type
String type = m_reportEngine.getPrintFormat().isForm() ? MSysConfig.getValue("ZK_REPORT_FORM_OUTPUT_TYPE") : MSysConfig.getValue("ZK_REPORT_TABLE_OUTPUT_TYPE");
if ("PDF".equals(type))
previewType.setSelectedIndex(0);
else if ("HTML".equals(type))
previewType.setSelectedIndex(1);
else if ("XLS".equals(type))
previewType.setSelectedIndex(2);
else
//fallback to PDF
previewType.setSelectedIndex(0);
labelDrill.setValue(Msg.getMsg(Env.getCtx(), "Drill") + ": ");
toolBar.appendChild(labelDrill);
comboDrill.setMold("select");
comboDrill.setTooltiptext(Msg.getMsg(Env.getCtx(), "Drill"));
toolBar.appendChild(comboDrill);
toolBar.appendChild(new Separator("vertical"));
comboReport.setMold("select");
comboReport.setTooltiptext(Msg.translate(Env.getCtx(), "AD_PrintFormat_ID"));
toolBar.appendChild(comboReport);
// FR [ 237 ]
// toolBar.appendChild(new Separator("vertical"));
comboReportView.setMold("select");
comboReportView.setTooltiptext(Msg.translate(Env.getCtx(), "AD_ReportView_ID"));
toolBar.appendChild(comboReportView);
summary.setText(Msg.getMsg(Env.getCtx(), "Summary"));
toolBar.appendChild(summary);
bCustomize.setImage(ServletFns.resolveThemeURL("~./images/Preference24.png"));
bCustomize.setTooltiptext(Msg.getMsg(Env.getCtx(), "PrintCustomize"));
toolBar.appendChild(bCustomize);
bCustomize.addEventListener(Events.ON_CLICK, this);
bFind.setImage(ServletFns.resolveThemeURL("~./images/Find24.png"));
bFind.setTooltiptext(Msg.getMsg(Env.getCtx(), "Find"));
toolBar.appendChild(bFind);
bFind.addEventListener(Events.ON_CLICK, this);
toolBar.appendChild(new Separator("vertical"));
bSendMail.setImage(ServletFns.resolveThemeURL("~./images/SendMail24.png"));
bSendMail.setTooltiptext(Msg.getMsg(Env.getCtx(), "SendMail"));
toolBar.appendChild(bSendMail);
bSendMail.addEventListener(Events.ON_CLICK, this);
bArchive.setImage(ServletFns.resolveThemeURL("~./images/Archive24.png"));
bArchive.setTooltiptext(Msg.getMsg(Env.getCtx(), "Archive"));
toolBar.appendChild(bArchive);
bArchive.addEventListener(Events.ON_CLICK, this);
if (m_isCanExport) {
bExport.setImage(ServletFns.resolveThemeURL("~./images/ExportX24.png"));
bExport.setTooltiptext(Msg.getMsg(Env.getCtx(), "Export"));
toolBar.appendChild(bExport);
bExport.addEventListener(Events.ON_CLICK, this);
}
toolBar.appendChild(new Separator("vertical"));
bRefresh.setImage(ServletFns.resolveThemeURL("~./images/Refresh24.png"));
bRefresh.setTooltiptext(Msg.getMsg(Env.getCtx(), "Refresh"));
toolBar.appendChild(bRefresh);
bRefresh.addEventListener(Events.ON_CLICK, this);
North north = new North();
layout.appendChild(north);
north.appendChild(toolBar);
Center center = new Center();
center.setHflex("true");
center.setVflex("true");
layout.appendChild(center);
iframe = new Iframe();
iframe.setId("reportFrame");
iframe.setHeight("100%");
iframe.setWidth("100%");
iframe.addEventListener(Events.ON_CLICK, this);
iframe.addEventListener(Events.ON_RIGHT_CLICK, this);
center.appendChild(iframe);
try {
renderReport();
} catch (Exception e) {
throw new AdempiereException("Failed to render report", e);
}
iframe.setAutohide(true);
this.setBorder("normal");
this.addEventListener("onZoom", new EventListener() {
public void onEvent(Event event) throws Exception {
if (event instanceof ZoomEvent) {
ZoomEvent ze = (ZoomEvent) event;
if (ze.getData() != null && ze.getData() instanceof MQuery) {
AEnv.zoom((MQuery) ze.getData());
}
}
}
});
this.addEventListener(DrillEvent.ON_DRILL_ACROSS, new EventListener() {
public void onEvent(Event event) throws Exception {
if (event instanceof DrillEvent) {
DrillEvent de = (DrillEvent) event;
if (de.getData() != null && de.getData() instanceof MQuery) {
MQuery query = (MQuery) de.getData();
Listitem item = comboDrill.getSelectedItem();
if (item != null && item.getValue() != null && item.toString().trim().length() > 0) {
query.setTableName(item.getValue().toString());
executeDrill(query, event.getTarget());
}
}
}
}
});
this.addEventListener(DrillEvent.ON_DRILL_DOWN, new EventListener() {
public void onEvent(Event event) throws Exception {
if (event instanceof DrillEvent) {
DrillEvent de = (DrillEvent) event;
if (de.getData() != null && de.getData() instanceof MQuery) {
MQuery query = (MQuery) de.getData();
executeDrill(query, event.getTarget());
}
}
}
});
}
use of org.compiere.model.MQuery in project adempiere by adempiere.
the class WBrowser method cmd_zoom.
/**
* Zoom
*/
private void cmd_zoom() {
showBusyDialog();
MQuery query = getMQuery(detail);
if (query != null)
AEnv.zoom(getAD_Window_ID(), query);
hideBusyDialog();
}
use of org.compiere.model.MQuery in project adempiere by adempiere.
the class GenericZoomProvider method retrieveZoomInfos.
public List<ZoomInfoFactory.ZoomInfo> retrieveZoomInfos(PO po) {
String sql = "SELECT DISTINCT ws.AD_Window_ID, ws.Name, wp.AD_Window_ID, wp.Name, t.TableName, tts.AD_Tab_ID, ttp.AD_Tab_ID " + "FROM AD_Table t ";
boolean baseLanguage = Env.isBaseLanguage(Env.getCtx(), "AD_Window");
if (baseLanguage)
sql += "INNER JOIN AD_Window ws ON (t.AD_Window_ID=ws.AD_Window_ID)" + " LEFT OUTER JOIN AD_Window wp ON (t.PO_Window_ID=wp.AD_Window_ID) ";
else
sql += "INNER JOIN AD_Window_Trl ws ON (t.AD_Window_ID=ws.AD_Window_ID AND ws.AD_Language=?)" + " LEFT OUTER JOIN AD_Window_Trl wp ON (t.PO_Window_ID=wp.AD_Window_ID AND wp.AD_Language=?) ";
// WARNING - HardCoded: first tab must have SeqNo = 10
sql += // first tab so
"JOIN AD_Tab tts ON (tts.AD_Window_ID=ws.AD_Window_ID AND tts.AD_Table_ID=t.AD_Table_ID AND tts.SeqNo=10)" + // first tab po
" LEFT OUTER JOIN AD_Tab ttp ON (ttp.AD_Window_ID=wp.AD_Window_ID AND ttp.AD_Table_ID=t.AD_Table_ID AND ttp.SeqNo=10)" + // No Import
" WHERE t.TableName NOT LIKE 'I%'" + " AND t.AD_Table_ID IN " + "(SELECT AD_Table_ID FROM AD_Column " + // #x
"WHERE ColumnName=? AND IsKey='N' AND IsParent='N') " + "ORDER BY 2";
final PreparedStatement pstmt = DB.prepareStatement(sql, null);
ResultSet rs = null;
try {
int index = 1;
if (!baseLanguage) {
pstmt.setString(index++, Env.getAD_Language(Env.getCtx()));
pstmt.setString(index++, Env.getAD_Language(Env.getCtx()));
}
pstmt.setString(index++, po.get_TableName() + "_ID");
rs = pstmt.executeQuery();
final List<ZoomInfoFactory.ZoomInfo> result = new ArrayList<ZoomInfoFactory.ZoomInfo>();
while (rs.next()) {
int AD_Window_ID = rs.getInt(1);
String Name = rs.getString(2);
int PO_Window_ID = rs.getInt(3);
int AD_Tab_ID = rs.getInt(6);
int PO_Tab_ID = rs.getInt(7);
String targetTableName = rs.getString(5);
final MQuery query = evaluateQuery(targetTableName, AD_Tab_ID, Name, po);
result.add(new ZoomInfoFactory.ZoomInfo(AD_Window_ID, query, Name));
if (PO_Window_ID != 0 && PO_Tab_ID != 0) {
Name = rs.getString(4);
final MQuery querypo = evaluateQuery(targetTableName, PO_Tab_ID, Name, po);
result.add(new ZoomInfoFactory.ZoomInfo(PO_Window_ID, querypo, Name));
}
}
return result;
} catch (SQLException e) {
logger.log(Level.SEVERE, sql, e);
throw new AdempiereException(e);
} finally {
DB.close(rs, pstmt);
}
}
use of org.compiere.model.MQuery in project adempiere by adempiere.
the class StringElement method getDrillDown.
// calculateSize
/**************************************************************************
* Get Drill Down value
* @param relativePoint relative Point
* @param pageNo page number (ignored)
* @return if found query or null
*/
public MQuery getDrillDown(Point relativePoint, int pageNo) {
if (m_ID != null && getBounds().contains(relativePoint)) {
log.fine(toString());
String columnName = MQuery.getZoomColumnName(m_ID.getName());
String tableName = MQuery.getZoomTableName(columnName);
Object code = m_ID.getID();
if (m_ID instanceof KeyNamePair)
code = new Integer(((KeyNamePair) m_ID).getKey());
//
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code);
return query;
}
return null;
}
Aggregations