use of org.zkoss.zul.Listitem in project adempiere by adempiere.
the class WAcctViewer method actionQuery.
// sortAddItem
/**
* Query
*/
private void actionQuery() {
// Parameter Info
StringBuffer para = new StringBuffer();
// Reset Selection Data
m_data.C_AcctSchema_ID = 0;
m_data.AD_Org_ID = 0;
// Save Selection Choices
Listitem listitem = selAcctSchema.getSelectedItem();
KeyNamePair kp = null;
if (listitem != null)
kp = (KeyNamePair) listitem.getValue();
if (kp != null)
m_data.C_AcctSchema_ID = kp.getKey();
para.append("C_AcctSchema_ID=").append(m_data.C_AcctSchema_ID);
listitem = selPostingType.getSelectedItem();
ValueNamePair vp = null;
if (listitem != null)
vp = (ValueNamePair) listitem.getValue();
else
return;
m_data.PostingType = vp.getValue();
para.append(", PostingType=").append(m_data.PostingType);
// Document
m_data.documentQuery = selDocument.isChecked();
para.append(", DocumentQuery=").append(m_data.documentQuery);
if (selDocument.isChecked()) {
if (m_data.AD_Table_ID == 0 || m_data.Record_ID == 0)
return;
para.append(", AD_Table_ID=").append(m_data.AD_Table_ID).append(", Record_ID=").append(m_data.Record_ID);
} else {
m_data.DateFrom = selDateFrom.getValue() != null ? new Timestamp(selDateFrom.getValue().getTime()) : null;
para.append(", DateFrom=").append(m_data.DateFrom);
m_data.DateTo = selDateTo.getValue() != null ? new Timestamp(selDateTo.getValue().getTime()) : null;
para.append(", DateTo=").append(m_data.DateTo);
listitem = selOrg.getSelectedItem();
if (listitem != null)
kp = (KeyNamePair) listitem.getValue();
else
kp = null;
if (kp != null)
m_data.AD_Org_ID = kp.getKey();
para.append(", AD_Org_ID=").append(m_data.AD_Org_ID);
//
Iterator<String> it = m_data.whereInfo.values().iterator();
while (it.hasNext()) para.append(", ").append(it.next());
}
// Save Display Choices
m_data.displayQty = displayQty.isChecked();
para.append(" - Display Qty=").append(m_data.displayQty);
m_data.displaySourceAmt = displaySourceAmt.isChecked();
para.append(", Source=").append(m_data.displaySourceAmt);
m_data.displayDocumentInfo = displayDocumentInfo.isChecked();
para.append(", Doc=").append(m_data.displayDocumentInfo);
listitem = sortBy1.getSelectedItem();
vp = null;
if (listitem != null) {
vp = (ValueNamePair) listitem.getValue();
if (vp.getName() != null && vp.getName().trim().length() > 0) {
//vp.getName();
m_data.sortBy1 = vp.getValue();
m_data.group1 = group1.isChecked();
para.append(" - Sorting: ").append(m_data.sortBy1).append("/").append(m_data.group1);
}
}
listitem = sortBy2.getSelectedItem();
vp = null;
if (listitem != null) {
vp = (ValueNamePair) listitem.getValue();
if (vp.getName() != null && vp.getName().trim().length() > 0) {
//vp.getName();
m_data.sortBy2 = vp.getValue();
m_data.group2 = group2.isChecked();
para.append(", ").append(m_data.sortBy2).append("/").append(m_data.group2);
}
}
listitem = sortBy3.getSelectedItem();
vp = null;
if (listitem != null) {
vp = (ValueNamePair) listitem.getValue();
if (vp.getName() != null && vp.getName().trim().length() > 0) {
//vp.getName();
m_data.sortBy3 = vp.getValue();
m_data.group3 = group3.isChecked();
para.append(", ").append(m_data.sortBy3).append("/").append(m_data.group3);
}
}
listitem = sortBy4.getSelectedItem();
vp = null;
if (listitem != null) {
vp = (ValueNamePair) listitem.getValue();
if (vp.getName() != null && vp.getName().trim().length() > 0) {
//vp.getName();
m_data.sortBy4 = vp.getValue();
m_data.group4 = group4.isChecked();
para.append(", ").append(m_data.sortBy4).append("/").append(m_data.group4);
}
}
bQuery.setEnabled(false);
statusLine.setValue(" " + Msg.getMsg(Env.getCtx(), "Processing"));
log.config(para.toString());
// Switch to Result pane
tabbedPane.setSelectedIndex(1);
// Set TableModel with Query
RModel rmodel = m_data.query();
m_queryData = rmodel.getRows();
List<ArrayList<Object>> list = null;
paging.setPageSize(PAGE_SIZE);
if (m_queryData.size() > PAGE_SIZE) {
list = m_queryData.subList(0, PAGE_SIZE);
paging.setTotalSize(m_queryData.size());
pagingPanel.setVisible(true);
} else {
list = m_queryData;
paging.setTotalSize(m_queryData.size());
pagingPanel.setVisible(false);
}
paging.setActivePage(0);
ListModelTable listmodeltable = new ListModelTable(list);
if (table.getListhead() == null) {
Listhead listhead = new Listhead();
listhead.setSizable(true);
for (int i = 0; i < rmodel.getColumnCount(); i++) {
// Replace user columns with the user selected names
String displayColumnName = rmodel.getColumnName(i);
;
String columnName;
RColumn col = rmodel.getColumn(i);
columnName = col.getColumnName();
MAcctSchema as = MAcctSchema.get(Env.getCtx(), m_data.C_AcctSchema_ID);
if (columnName.equals("User1_ID")) {
MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList1);
if (ase != null)
displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
} else if (columnName.equals("User2_ID")) {
MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList2);
if (ase != null)
displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
} else if (columnName.equals("User3_ID")) {
MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList3);
if (ase != null)
displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
} else if (columnName.equals("User4_ID")) {
MAcctSchemaElement ase = as.getAcctSchemaElement(MAcctSchemaElement.ELEMENTTYPE_UserList4);
if (ase != null)
displayColumnName = Msg.translate(Env.getCtx(), ase.getName());
}
Listheader listheader = new Listheader(displayColumnName);
listheader.setTooltiptext(rmodel.getColumnName(i));
listhead.appendChild(listheader);
}
table.appendChild(listhead);
} else // Elaine 2008/07/28
{
Listhead listhead = table.getListhead();
// remove existing column header
listhead.getChildren().clear();
// add in new column header
for (int i = 0; i < rmodel.getColumnCount(); i++) {
Listheader listheader = new Listheader(rmodel.getColumnName(i));
listhead.appendChild(listheader);
}
}
//
table.getItems().clear();
table.setItemRenderer(new WListItemRenderer());
table.setModel(listmodeltable);
resultPanel.invalidate();
bQuery.setEnabled(true);
statusLine.setValue(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions"));
}
use of org.zkoss.zul.Listitem in project adempiere by adempiere.
the class WListItemRenderer method onEvent.
/* (non-Javadoc)
* @see org.zkoss.zk.ui.event.EventListener#onEvent(org.zkoss.zk.ui.event.Event)
*/
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 WListbox && Events.ON_SELECT.equals(event.getName())) {
WListbox table = (WListbox) 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 adempiere by adempiere.
the class Listbox method setValue.
/**
* Set selected item for the list box based on the value of list item
* set selected to none if no item found matching the value given or
* value is null
* @param value Value of ListItem to set as selected
*/
public void setValue(Object value) {
setSelectedItem(null);
if (value == null) {
return;
}
List<Listitem> items = getItems();
for (Listitem item : items) {
if (value.getClass() != item.getValue().getClass()) {
// if the classes of value and item are different convert both to String
String stringValue = value.toString();
String stringItem = item.getValue().toString();
if (stringValue.equals(stringItem)) {
setSelectedItem(item);
break;
}
} else {
if (value.equals(item.getValue())) {
setSelectedItem(item);
break;
}
}
}
}
use of org.zkoss.zul.Listitem in project adempiere by adempiere.
the class Listbox method toString.
@Override
public String toString() {
StringBuffer items = new StringBuffer("[");
for (Listitem item : getItems()) {
if (items.length() > 1)
items.append(", ");
items.append(item.toString());
}
items.append("]");
return items.toString();
}
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
*/
private void cmd_report() {
Listitem pp = (Listitem) comboReport.getSelectedItem();
if (pp != null && (int) pp.getValue() >= 0) {
// Set Default Report View
MPrintFormat pf = MPrintFormat.get(Env.getCtx(), (int) pp.getValue(), true);
selectReportView(pf.getAD_ReportView_ID());
}
// Call Report
cmd_report(false);
}
Aggregations