use of org.zkoss.zul.Listitem in project adempiere by adempiere.
the class ZkReportViewer method fillComboReport.
// dynInit
/**
* Fill ComboBox comboReport (report options)
* @param AD_PrintFormat_ID item to be selected
*/
private void fillComboReport(int AD_PrintFormat_ID) {
comboReport.removeEventListener(Events.ON_SELECT, this);
comboReport.getItems().clear();
Listitem selectValue = null;
// fill Report Options
String sql = MRole.getDefault().addAccessSQL("SELECT AD_PrintFormat_ID, Name, Description " + "FROM AD_PrintFormat " + "WHERE AD_Table_ID=? " + //Added Lines by Armen
"AND IsActive='Y' " + //End of Added Lines
"ORDER BY Name", "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID();
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
Listitem li = comboReport.appendItem(pp.getName(), pp.getKey());
if (rs.getInt(1) == AD_PrintFormat_ID) {
selectValue = li;
comboReport.setSelectedItem(li);
}
}
// Select Default
if (selectValue != null) {
comboReport.setSelectedItem(selectValue);
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(Env.getCtx(), "NewReport")).append(" **");
KeyNamePair pp = new KeyNamePair(-1, sb.toString());
comboReport.appendItem(pp.getName(), pp.getKey());
sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "CopyReport")).append(" **");
pp = new KeyNamePair(-2, sb.toString());
comboReport.addItem(pp);
comboReport.addEventListener(Events.ON_SELECT, this);
// FR [ 237 ]
fillComboReportView();
}
use of org.zkoss.zul.Listitem in project adempiere by adempiere.
the class ZkReportViewer method selectReportView.
// fillComboReport
/**
* Select a Report view from print format
* @param p_AD_ReportView_ID
*/
private void selectReportView(int p_AD_ReportView_ID) {
comboReportView.removeEventListener(Events.ON_SELECT, this);
// Select
Listitem selectValue = null;
for (int i = 0; i < comboReportView.getItemCount(); i++) {
Listitem pp = (Listitem) comboReportView.getItemAtIndex(i);
if ((int) pp.getValue() == p_AD_ReportView_ID) {
selectValue = pp;
break;
}
}
// Select Default
if (selectValue != null) {
comboReportView.setSelectedItem(selectValue);
}
// Add Listener
comboReportView.addEventListener(Events.ON_SELECT, this);
}
use of org.zkoss.zul.Listitem 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.zkoss.zul.Listitem in project adempiere by adempiere.
the class WBrowserListItemRenderer method onEvent.
@Override
public void onEvent(Event event) throws Exception {
int col = -1;
int row = -1;
Object value = null;
TableValueChangeEvent vcEvent = null;
WTableColumn tableColumn;
Component source = event.getTarget();
if (isWithinListCell(source)) {
row = getRowPosition(source);
col = getColumnPosition(source);
tableColumn = m_tableColumns.get(col);
if (source instanceof Checkbox) {
value = Boolean.valueOf(((Checkbox) source).isChecked());
} else if (source instanceof Decimalbox) {
value = ((Decimalbox) source).getValue();
} else if (source instanceof Datebox) {
value = ((Datebox) source).getValue();
} else if (source instanceof Textbox) {
value = ((Textbox) source).getValue();
}
if (value != null) {
vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), row, col, value, value);
fireTableValueChange(vcEvent);
}
} else if (event.getTarget() instanceof WBrowserTable && Events.ON_SELECT.equals(event.getName())) {
WBrowserTable table = (WBrowserTable) event.getTarget();
if (table.isCheckmark()) {
int cnt = table.getRowCount();
if (cnt == 0 || !(table.getValueAt(0, 0) instanceof IDColumn))
return;
//update IDColumn
tableColumn = m_tableColumns.get(0);
for (int i = 0; i < cnt; i++) {
IDColumn idcolumn = (IDColumn) table.getValueAt(i, 0);
if (idcolumn != null) {
Listitem item = table.getItemAtIndex(i);
value = item.isSelected();
Boolean old = idcolumn.isSelected();
if (!old.equals(value)) {
vcEvent = new TableValueChangeEvent(source, tableColumn.getHeaderValue().toString(), i, 0, old, value);
fireTableValueChange(vcEvent);
}
}
}
}
}
return;
}
use of org.zkoss.zul.Listitem in project spatial-portal by AtlasOfLivingAustralia.
the class ActiveLayersLegendEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
MapComposer mapComposer = getMapComposer(event);
if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
// get reference to the label/image the user clicked on
Component target = event.getTarget();
Listitem listItem = (Listitem) target.getParent().getParent();
listItem.setSelected(true);
} else {
LOGGER.debug("MapController reports unsafe to perform action");
}
}
Aggregations