Search in sources :

Example 1 with ZoomEvent

use of org.adempiere.webui.event.ZoomEvent 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());
                }
            }
        }
    });
}
Also used : Iframe(org.zkoss.zul.Iframe) Center(org.zkoss.zul.Center) Listitem(org.zkoss.zul.Listitem) MQuery(org.compiere.model.MQuery) Borderlayout(org.zkoss.zul.Borderlayout) SQLException(java.sql.SQLException) AdempiereException(org.adempiere.exceptions.AdempiereException) ZoomEvent(org.adempiere.webui.event.ZoomEvent) AdempiereException(org.adempiere.exceptions.AdempiereException) ZoomEvent(org.adempiere.webui.event.ZoomEvent) Event(org.zkoss.zk.ui.event.Event) DrillEvent(org.adempiere.webui.event.DrillEvent) DrillEvent(org.adempiere.webui.event.DrillEvent) North(org.zkoss.zul.North) EventListener(org.zkoss.zk.ui.event.EventListener) Separator(org.zkoss.zul.Separator)

Example 2 with ZoomEvent

use of org.adempiere.webui.event.ZoomEvent in project adempiere by adempiere.

the class ZoomCommand method service.

public boolean service(AuRequest request, boolean everError) {
    if (!ZoomEvent.EVENT_NAME.equals(request.getCommand()))
        return false;
    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);
    Object code = null;
    if (columnName.endsWith("_ID")) {
        try {
            code = Integer.parseInt((String) data.get(1));
        } catch (Exception e) {
            code = data.get(1);
        }
    } else {
        code = data.get(1);
    }
    //
    MQuery query = new MQuery(tableName);
    query.addRestriction(columnName, MQuery.EQUAL, code);
    query.setRecordCount(1);
    Events.postEvent(new ZoomEvent(comp, query));
    return true;
}
Also used : JSONArray(org.zkoss.json.JSONArray) MQuery(org.compiere.model.MQuery) UiException(org.zkoss.zk.ui.UiException) Component(org.zkoss.zk.ui.Component) UiException(org.zkoss.zk.ui.UiException) ZoomEvent(org.adempiere.webui.event.ZoomEvent)

Aggregations

ZoomEvent (org.adempiere.webui.event.ZoomEvent)2 MQuery (org.compiere.model.MQuery)2 SQLException (java.sql.SQLException)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 DrillEvent (org.adempiere.webui.event.DrillEvent)1 JSONArray (org.zkoss.json.JSONArray)1 Component (org.zkoss.zk.ui.Component)1 UiException (org.zkoss.zk.ui.UiException)1 Event (org.zkoss.zk.ui.event.Event)1 EventListener (org.zkoss.zk.ui.event.EventListener)1 Borderlayout (org.zkoss.zul.Borderlayout)1 Center (org.zkoss.zul.Center)1 Iframe (org.zkoss.zul.Iframe)1 Listitem (org.zkoss.zul.Listitem)1 North (org.zkoss.zul.North)1 Separator (org.zkoss.zul.Separator)1