use of org.adempiere.webui.event.DrillEvent 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.adempiere.webui.event.DrillEvent in project adempiere by adempiere.
the class DrillCommand method service.
public boolean service(AuRequest request, boolean everError) {
if (!DrillEvent.ON_DRILL_ACROSS.equals(request.getCommand()) && !DrillEvent.ON_DRILL_DOWN.equals(request.getCommand()))
return false;
final Map<?, ?> map = request.getData();
JSONArray data = (JSONArray) map.get("data");
final Component comp = request.getComponent();
if (comp == null)
throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this);
if (data == null || data.size() < 2)
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] { Objects.toString(data), this });
String columnName = (String) data.get(0);
String tableName = MQuery.getZoomTableName(columnName);
String code = (String) data.get(1);
//
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code);
Events.postEvent(new DrillEvent(request.getCommand(), comp, query));
return true;
}
Aggregations