Search in sources :

Example 21 with Listitem

use of org.zkoss.zul.Listitem in project adempiere by adempiere.

the class ZkReportViewer method fillComboReportView.

//	fillComboReport
/**
	 * 	Fill ComboBox comboReportView (report view options)
	 */
private void fillComboReportView() {
    comboReportView.removeEventListener(Events.ON_SELECT, this);
    comboReportView.getItems().clear();
    Listitem selectValue = null;
    //	fill Report View Options
    String sql = "";
    //	For base language
    if (Env.isBaseLanguage(Env.getCtx(), "AD_ReportView")) {
        sql = MRole.getDefault().addAccessSQL("SELECT AD_ReportView_ID, COALESCE(PrintName, Name) AS Name " + "FROM AD_ReportView " + "WHERE AD_Table_ID = ? " + "AND IsActive='Y' " + "ORDER BY Name", "AD_ReportView", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    } else {
        sql = MRole.getDefault().addAccessSQL("SELECT rv.AD_ReportView_ID, COALESCE(rvt.PrintName, rv.PrintName, rvt.Name, rv.Name) AS Name " + "FROM AD_ReportView rv " + "LEFT JOIN AD_ReportView_Trl rvt ON(rvt.AD_ReportView_ID = rv.AD_ReportView_ID " + "										AND rvt.AD_Language = '" + Env.getAD_Language(Env.getCtx()) + "') " + "WHERE rv.AD_Table_ID = ? " + "AND rv.IsActive='Y' " + "ORDER BY rvt.Name", "rv", MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
    }
    //	Get Table
    int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
    //	Get Default Report View
    int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID();
    //	Get from DB
    KeyNamePair[] pairs = DB.getKeyNamePairs(sql, true, AD_Table_ID);
    //	fill combo
    for (KeyNamePair view : pairs) {
        Listitem li = comboReportView.appendItem(view.getName(), view.getKey());
        if (view.getKey() == AD_ReportView_ID) {
            selectValue = li;
        }
    }
    //	Select Default
    if (selectValue != null) {
        comboReportView.setSelectedItem(selectValue);
    }
    //	Add Listener
    comboReportView.addEventListener(Events.ON_SELECT, this);
}
Also used : Listitem(org.zkoss.zul.Listitem) KeyNamePair(org.compiere.util.KeyNamePair)

Example 22 with Listitem

use of org.zkoss.zul.Listitem in project adempiere by adempiere.

the class ZkReportViewer method renderReport.

private void renderReport() throws Exception {
    AMedia media = null;
    Listitem selected = previewType.getSelectedItem();
    if (selected == null || "PDF".equals(selected.getValue())) {
        String path = System.getProperty("java.io.tmpdir");
        String prefix = makePrefix(m_reportEngine.getName());
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
        }
        File file = File.createTempFile(prefix, ".pdf", new File(path));
        m_reportEngine.createPDF(file);
        media = new AMedia(getTitle(), "pdf", "application/pdf", file, true);
    } else if ("HTML".equals(previewType.getSelectedItem().getValue())) {
        String path = System.getProperty("java.io.tmpdir");
        String prefix = makePrefix(m_reportEngine.getName());
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
        }
        File file = File.createTempFile(prefix, ".html", new File(path));
        m_reportEngine.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", this.getUuid()));
        media = new AMedia(getTitle(), "html", "text/html", file, false);
    } else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
        String path = System.getProperty("java.io.tmpdir");
        String prefix = makePrefix(m_reportEngine.getName());
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE, "Path=" + path + " Prefix=" + prefix);
        }
        File file = File.createTempFile(prefix, ".xls", new File(path));
        m_reportEngine.createXLS(file, AEnv.getLanguage(Env.getCtx()));
        media = new AMedia(getTitle(), "xls", "application/vnd.ms-excel", file, true);
    }
    iframe.setContent(media);
}
Also used : AMedia(org.zkoss.util.media.AMedia) Listitem(org.zkoss.zul.Listitem) File(java.io.File) HTMLExtension(org.adempiere.webui.report.HTMLExtension)

Example 23 with Listitem

use of org.zkoss.zul.Listitem in project adempiere by adempiere.

the class ZkReportViewer method cmd_report.

/**
	 * 	Report Combo - Start other Report or create new one
	 * 	@param isSummaryChanged for when the check Is Summary is changed
	 */
private void cmd_report(boolean isSummaryChanged) {
    ListItem li = comboReport.getSelectedItem();
    if (li == null || li.getValue() == null)
        return;
    Object pp = li.getValue();
    if (pp == null)
        return;
    //
    MPrintFormat pf = null;
    int AD_PrintFormat_ID = Integer.valueOf(pp.toString());
    //	create new
    if (AD_PrintFormat_ID == -1) {
        int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID();
        if (AD_ReportView_ID != 0) {
            String name = m_reportEngine.getName();
            int index = name.lastIndexOf('_');
            if (index != -1)
                name = name.substring(0, index);
            pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name);
        } else {
            int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
            pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID);
        }
        if (pf != null)
            fillComboReport(pf.get_ID());
        else
            return;
    } else if (AD_PrintFormat_ID == -2) {
        MPrintFormat current = m_reportEngine.getPrintFormat();
        if (current != null) {
            pf = MPrintFormat.copyToClient(m_ctx, current.getAD_PrintFormat_ID(), Env.getAD_Client_ID(m_ctx));
            if (pf != null)
                fillComboReport(pf.get_ID());
            else
                return;
        } else
            return;
    } else
        pf = MPrintFormat.get(Env.getCtx(), AD_PrintFormat_ID, true);
    //	FR [ 238 ]
    if (pf == null)
        return;
    //	
    if (!isSummaryChanged) {
        summary.setSelected(pf.isSummary());
    }
    // Set Summary for report
    m_reportEngine.setSummary(summary.isSelected());
    //	Get Language from previous - thanks Gunther Hoppe 
    if (m_reportEngine.getPrintFormat() != null) {
        //	needs to be re-set - otherwise viewer will be blank
        pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage());
        pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage());
    }
    //	FR [ 237 ]
    Listitem reportView = (Listitem) comboReportView.getSelectedItem();
    if (reportView != null) {
        m_reportEngine.setAD_ReportView_ID((int) reportView.getValue());
    }
    m_reportEngine.setPrintFormat(pf);
    //	
    try {
        renderReport();
    } catch (Exception e) {
        throw new AdempiereException("Failed to render report", e);
    }
    revalidate();
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) AdempiereException(org.adempiere.exceptions.AdempiereException) Listitem(org.zkoss.zul.Listitem) ListItem(org.adempiere.webui.component.ListItem) SQLException(java.sql.SQLException) AdempiereException(org.adempiere.exceptions.AdempiereException)

Example 24 with Listitem

use of org.zkoss.zul.Listitem in project adempiere by adempiere.

the class WDocActionPanel method dynInit.

/**
	 *	Dynamic Init - determine valid DocActions based on DocStatus for the different documents.
	 */
private void dynInit() {
    //
    Object Processing = gridTab.getValue("Processing");
    String OrderType = Env.getContext(Env.getCtx(), gridTab.getWindowNo(), "OrderType");
    String IsSOTrx = Env.getContext(Env.getCtx(), gridTab.getWindowNo(), "IsSOTrx");
    if (DocStatus == null) {
        //message.setText("*** ERROR ***");
        return;
    }
    logger.fine("DocStatus=" + DocStatus + ", DocAction=" + DocAction + ", OrderType=" + OrderType + ", IsSOTrx=" + IsSOTrx + ", Processing=" + Processing + ", AD_Table_ID=" + gridTab.getAD_Table_ID() + ", Record_ID=" + gridTab.getRecord_ID());
    int index = 0;
    if (lstDocAction.getSelectedItem() != null) {
        String selected = (lstDocAction.getSelectedItem().getValue()).toString();
        for (int i = 0; i < s_value.length && index == 0; i++) {
            if (s_value[i].equals(selected)) {
                index = i;
            }
        }
    }
    String[] options = new String[s_value.length];
    /**
		 * 	Check Existence of Workflow Acrivities
		 */
    String wfStatus = MWFActivity.getActiveInfo(Env.getCtx(), m_AD_Table_ID, gridTab.getRecord_ID());
    if (wfStatus != null) {
        FDialog.error(gridTab.getWindowNo(), this, "WFActiveForRecord", wfStatus);
        return;
    }
    //	Status Change
    if (!checkStatus(gridTab.getTableName(), gridTab.getRecord_ID(), DocStatus)) {
        FDialog.error(gridTab.getWindowNo(), this, "DocumentStatusChanged");
        return;
    }
    /*******************
		 *  General Actions
		 */
    String[] docActionHolder = new String[] { DocAction };
    index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options);
    MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID);
    PO po = table.getPO(gridTab.getRecord_ID(), null);
    if (po instanceof DocOptions)
        index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options, index);
    Integer doctypeId = (Integer) gridTab.getValue("C_DocType_ID");
    if (doctypeId == null || doctypeId.intValue() == 0) {
        doctypeId = (Integer) gridTab.getValue("C_DocTypeTarget_ID");
    }
    logger.fine("get doctype: " + doctypeId);
    if (doctypeId != null) {
        index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx()), doctypeId, options, index);
    }
    DocAction = docActionHolder[0];
    /**
		 *	Fill actionCombo
		 */
    boolean firstadded = true;
    for (int i = 0; i < index; i++) {
        //	Serach for option and add it
        boolean added = false;
        for (int j = 0; j < s_value.length && !added; j++) {
            if (options[i].equals(s_value[j])) {
                Listitem newitem = lstDocAction.appendItem(s_name[j], s_value[j]);
                if (firstadded) {
                    // select by default the first added item - can be changed below
                    lstDocAction.setSelectedItem(newitem);
                    firstadded = false;
                }
                added = true;
            }
        }
    }
    // look if the current DocAction is within the list and assign it as selected if it exists
    List<Listitem> lst = (List<Listitem>) lstDocAction.getItems();
    for (Listitem item : lst) {
        String value = item.getValue().toString();
        if (DocAction.equals(value)) {
            lstDocAction.setSelectedItem(item);
            label.setValue(s_description[getSelectedIndex()]);
        }
    }
    //	setDefault
    if (//	If None, suggest closing
    DocAction.equals("--"))
        DocAction = DocumentEngine.ACTION_Close;
}
Also used : MTable(org.compiere.model.MTable) DocOptions(org.compiere.process.DocOptions) Listitem(org.zkoss.zul.Listitem) ArrayList(java.util.ArrayList) List(java.util.List) PO(org.compiere.model.PO)

Aggregations

Listitem (org.zkoss.zul.Listitem)24 Component (org.zkoss.zk.ui.Component)7 MapComposer (au.org.emii.portal.composer.MapComposer)6 KeyNamePair (org.compiere.util.KeyNamePair)5 MapLayer (au.org.emii.portal.menu.MapLayer)4 SQLException (java.sql.SQLException)3 ValueNamePair (org.compiere.util.ValueNamePair)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 ListItem (org.adempiere.webui.component.ListItem)2 TableValueChangeEvent (org.adempiere.webui.event.TableValueChangeEvent)2 IDColumn (org.compiere.minigrid.IDColumn)2 MAcctSchemaElement (org.compiere.model.MAcctSchemaElement)2 MPrintFormat (org.compiere.print.MPrintFormat)2 AMedia (org.zkoss.util.media.AMedia)2 Decimalbox (org.zkoss.zul.Decimalbox)2 ScatterplotDataDTO (au.org.ala.spatial.dto.ScatterplotDataDTO)1 Query (au.org.ala.spatial.util.Query)1 PortalSession (au.org.emii.portal.session.PortalSession)1