use of org.zkoss.zul.Decimalbox 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.Decimalbox in project adempiere by adempiere.
the class WBOMDrop method cmd_selection.
// actionPerformed
/**
* Enable/disable qty based on selection
* @param source JCheckBox or JRadioButton
*/
private void cmd_selection(Object source) {
for (int i = 0; i < m_selectionList.size(); i++) {
if (source == m_selectionList.get(i)) {
boolean selected = isSelectionSelected(source);
Decimalbox qty = m_qtyList.get(i);
qty.setReadonly(!selected);
return;
}
}
log.log(Level.SEVERE, "not found - " + source);
}
use of org.zkoss.zul.Decimalbox in project adempiere by adempiere.
the class WBOMDrop method addDisplay.
// addBOMLine
/**
* Add Line to Display
* @param parentM_Product_ID parent product
* @param M_Product_ID product
* @param bomType bom type
* @param name name
* @param lineQty qty
*/
private void addDisplay(int parentM_Product_ID, int M_Product_ID, String bomType, String name, BigDecimal lineQty) {
log.fine("M_Product_ID=" + M_Product_ID + ",Type=" + bomType + ",Name=" + name + ",Qty=" + lineQty);
boolean selected = true;
Hbox boxQty = new Hbox();
boxQty.setWidth("100%");
boxQty.setWidths("10%, 40%, 50%");
if (MProductBOM.BOMTYPE_StandardPart.equals(bomType)) {
String title = "";
Checkbox cb = new Checkbox();
cb.setLabel(title);
cb.setChecked(true);
cb.setEnabled(false);
m_selectionList.add(cb);
boxQty.appendChild(cb);
} else if (MProductBOM.BOMTYPE_OptionalPart.equals(bomType)) {
String title = Msg.getMsg(Env.getCtx(), "Optional");
Checkbox cb = new Checkbox();
cb.setLabel(title);
cb.setChecked(false);
selected = false;
cb.addEventListener(Events.ON_CHECK, this);
m_selectionList.add(cb);
boxQty.appendChild(cb);
} else // Alternative
{
String title = Msg.getMsg(Env.getCtx(), "Alternative") + " " + bomType;
Radio b = new Radio();
b.setLabel(title);
String groupName = String.valueOf(parentM_Product_ID) + "_" + bomType;
Radiogroup group = m_buttonGroups.get(groupName);
if (group == null) {
log.fine("ButtonGroup=" + groupName);
group = new Radiogroup();
m_buttonGroups.put(groupName, group);
group.appendChild(b);
// select first one
b.setSelected(true);
} else {
group.appendChild(b);
b.setSelected(false);
selected = false;
}
b.addEventListener(Events.ON_CLICK, this);
m_selectionList.add(b);
boxQty.appendChild(b);
}
// Add to List & display
m_productList.add(new Integer(M_Product_ID));
Decimalbox qty = new Decimalbox();
qty.setValue(lineQty);
qty.setReadonly(!selected);
m_qtyList.add(qty);
Label label = new Label(name);
HtmlBasedComponent c = (HtmlBasedComponent) label.rightAlign();
c.setStyle(c.getStyle() + ";margin-right: 5px");
boxQty.appendChild(c);
boxQty.appendChild(qty);
grpSelectProd.appendChild(boxQty);
}
use of org.zkoss.zul.Decimalbox 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.Decimalbox in project adempiere by adempiere.
the class NumberBox method init.
private void init() {
Table grid = new Table();
appendChild(grid);
grid.setStyle("border: none; padding: 0px; margin: 0px;");
grid.setDynamicProperty("border", "0");
grid.setDynamicProperty("cellpadding", "0");
grid.setDynamicProperty("cellspacing", "0");
Tr tr = new Tr();
grid.appendChild(tr);
tr.setStyle("border: none; padding: 0px; margin: 0px; white-space:nowrap; ");
Td td = new Td();
tr.appendChild(td);
td.setStyle("border: none; padding: 0px; margin: 0px;");
decimalBox = new Decimalbox();
if (integral)
decimalBox.setScale(0);
// FR 547
decimalBox.setStyle("display: inline; text-align: right; padding-right: 2px");
td.appendChild(decimalBox);
Td btnColumn = new Td();
tr.appendChild(btnColumn);
btnColumn.setStyle("border: none; padding: 0px; margin: 0px;");
btnColumn.setSclass("editor-button");
btn = new Button();
btn.setImage("/images/Calculator10.png");
btn.setTabindex(-1);
LayoutUtils.addSclass("editor-button", btn);
btnColumn.appendChild(btn);
popup = getCalculatorPopup();
LayoutUtils.addSclass("editor-button", btn);
btn.setPopup(popup);
btn.setStyle("text-align: center;");
appendChild(popup);
String style = AEnv.isFirefox2() ? "display: inline" : "display: inline-block";
style = style + ";white-space:nowrap";
this.setStyle(style);
}
Aggregations