use of org.adempiere.webui.component.NumberBox in project adempiere by adempiere.
the class InfoOrderPanel method initComponents.
public void initComponents() {
lblDocumentNo = new Label(Util.cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo")));
lblDescription = new Label(Msg.translate(Env.getCtx(), "Description"));
lblDateOrdered = new Label(Msg.translate(Env.getCtx(), "DateOrdered"));
lblOrderRef = new Label(Msg.translate(Env.getCtx(), "POReference"));
lblGrandTotal = new Label(Msg.translate(Env.getCtx(), "GrandTotal"));
fDocumentNo = new Textbox();
fDocumentNo.addEventListener(Events.ON_CHANGE, this);
fDocumentNo.setAttribute("zk_component_ID", "Lookup_Criteria_DocumentNo");
fDescription = new Textbox();
fDescription.addEventListener(Events.ON_CHANGE, this);
fDescription.setAttribute("zk_component_ID", "Lookup_Criteria_Description");
fPOReference = new Textbox();
fPOReference.addEventListener(Events.ON_CHANGE, this);
fPOReference.setAttribute("zk_component_ID", "Lookup_Criteria_POReference");
// Format the dates and number boxes
fDateFrom = new Datebox();
fDateFrom.setWidth("97px");
fDateFrom.setAttribute("zk_component_ID", "Lookup_Criteria_DateFrom");
fDateFrom.addEventListener(Events.ON_CHANGE, this);
//
fDateTo = new Datebox();
fDateTo.setWidth("97px");
fDateTo.setAttribute("zk_component_ID", "Lookup_Criteria_DateTo");
fDateTo.addEventListener(Events.ON_CHANGE, this);
//
SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.Date, AEnv.getLanguage(Env.getCtx()));
fDateFrom.setFormat(dateFormat.toPattern());
fDateTo.setFormat(dateFormat.toPattern());
//
fAmtFrom = new NumberBox(false);
fAmtFrom.getDecimalbox().setWidth("90px");
fAmtFrom.setAttribute("zk_component_ID", "Lookup_Criteria_AmtFrom");
fAmtFrom.addEventListener(Events.ON_CHANGE, this);
//
fAmtTo = new NumberBox(false);
fAmtTo.getDecimalbox().setWidth("90px");
fAmtTo.setAttribute("zk_component_ID", "Lookup_Criteria_AmtTo");
fAmtTo.addEventListener(Events.ON_CHANGE, this);
//
DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount, AEnv.getLanguage(Env.getCtx()));
fAmtFrom.getDecimalbox().setFormat(format.toPattern());
fAmtFrom.getDecimalbox().setStyle("text-align:right; " + fAmtFrom.getDecimalbox().getStyle());
fAmtTo.getDecimalbox().setFormat(format.toPattern());
fAmtTo.getDecimalbox().setStyle("text-align:right; " + fAmtTo.getDecimalbox().getStyle());
//
fIsSOTrx = new Checkbox();
fIsSOTrx.setLabel(Msg.translate(Env.getCtx(), "IsSOTrx"));
fIsSOTrx.setName("IsSOTrx");
fIsSOTrx.setAttribute("zk_component_ID", "Lookup_Criteria_IsSoTrx");
fIsSOTrx.setAttribute("IsDynamic", "True");
fIsSOTrx.addActionListener(this);
fIsDelivered = new Checkbox();
fIsDelivered.setLabel(Msg.translate(Env.getCtx(), "IsDelivered"));
fIsDelivered.setName("IsDelivered");
fIsDelivered.setAttribute("zk_component_ID", "Lookup_Criteria_IsDelivered");
fIsDelivered.addActionListener(this);
fBPartner_ID = new WSearchEditor(MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, MColumn.getColumn_ID(MOrder.Table_Name, MOrder.COLUMNNAME_C_BPartner_ID), DisplayType.Search), Msg.translate(Env.getCtx(), "C_BPartner_ID"), "", false, false, true);
fBPartner_ID.getComponent().setAttribute("zk_component_ID", "Lookup_Criteria_C_BPartner_ID");
fBPartner_ID.addValueChangeListener(this);
}
use of org.adempiere.webui.component.NumberBox in project adempiere by adempiere.
the class WPAttributeDialog method cmd_newEdit.
// cmd_select
/**
* Instance New/Edit
*/
private void cmd_newEdit() {
boolean rw = cbNewEdit.isChecked();
log.config("R/W=" + rw + " " + m_masi);
//
fieldLotString.setReadonly(!(rw && m_masi.getM_Lot_ID() == 0));
if (fieldLot != null)
fieldLot.setEnabled(rw);
bLot.setEnabled(rw);
fieldSerNo.setReadonly(!rw);
bSerNo.setEnabled(rw);
fieldGuaranteeDate.setReadonly(!rw);
//
for (int i = 0; i < m_editors.size(); i++) {
HtmlBasedComponent editor = m_editors.get(i);
if (editor instanceof InputElement)
((InputElement) editor).setReadonly(!rw);
else if (editor instanceof Listbox)
((Listbox) editor).setEnabled(rw);
else if (editor instanceof NumberBox)
((NumberBox) editor).setEnabled(rw);
}
}
use of org.adempiere.webui.component.NumberBox in project adempiere by adempiere.
the class InfoPAttributePanel method createQuery.
// actionPerformed
/**
* Create Query
* <code>
* Available synonyms:
* M_Product p
* M_ProductPrice pr
* M_AttributeSet pa
* </code>
* @return query
*/
private String createQuery() {
/** Base Query
SELECT *
FROM M_Product p
INNER JOIN M_ProductPrice pr ON (p.M_Product_ID=pr.M_Product_ID)
LEFT OUTER JOIN M_AttributeSet pa ON (p.M_AttributeSet_ID=pa.M_AttributeSet_ID)
WHERE
**/
/*** Instance Attributes */
StringBuffer sb = new StringBuffer();
// Serial No
String s = serNoField.getComponent().getText();
if (s != null && s.length() > 0) {
sb.append(" AND asi.SerNo");
if (s.indexOf('%') == -1 && s.indexOf('_') == 1)
sb.append("=");
else
sb.append(" LIKE ");
sb.append(DB.TO_STRING(s));
}
// Lot Number
s = lotField.getComponent().getText();
if (s != null && s.length() > 0) {
sb.append(" AND asi.Lot");
if (s.indexOf('%') == -1 && s.indexOf('_') == 1)
sb.append("=");
else
sb.append(" LIKE ");
sb.append(DB.TO_STRING(s));
}
// Lot ID
ListItem li = lotSelection.getSelectedItem();
if (li != null && li.getValue() != null) {
KeyNamePair pp = (KeyNamePair) li.getValue();
if (pp != null && pp.getKey() != -1) {
int ID = pp.getKey();
sb.append(" AND asi.M_Lot_ID=").append(ID);
}
}
// Guarantee Date
Timestamp ts = (Timestamp) guaranteeDateField.getValue();
if (ts != null) {
sb.append(" AND TRUNC(asi.GuaranteeDate, 'DD')");
// < = >
int index = guaranteeDateSelection.getSelectedIndex();
if (index == 0)
sb.append("<");
else if (index == 1)
sb.append("=");
else
sb.append(">");
sb.append(DB.TO_DATE(ts, true));
}
// Instance Editors
for (int i = 0; i < m_instanceEditors.size(); i++) {
StringBuffer iAttr = new StringBuffer();
Component c = (Component) m_instanceEditors.get(i);
Component cTo = (Component) m_instanceEditorsTo.get(i);
int M_Attribute_ID = Integer.parseInt(c.getId());
if (c instanceof Listbox) {
Listbox field = (Listbox) c;
li = field.getSelectedItem();
if (li != null && li.getValue() != null) {
KeyNamePair pp = (KeyNamePair) li.getValue();
if (pp != null && pp.getKey() != -1) {
iAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND M_AttributeValue_ID=").append(pp.getKey());
}
}
} else if (c instanceof NumberBox) {
NumberBox field = (NumberBox) c;
BigDecimal value = (BigDecimal) field.getValue();
NumberBox fieldTo = (NumberBox) cTo;
BigDecimal valueTo = (BigDecimal) fieldTo.getValue();
if (value != null || valueTo != null) {
iAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND ValueNumber");
if (value != null && valueTo == null)
iAttr.append("=").append(value);
else if (value == null && valueTo != null)
iAttr.append("<=").append(valueTo);
else if (value != null && valueTo != null)
iAttr.append(" BETWEEN ").append(value).append(" AND ").append(valueTo);
}
} else {
Textbox field = (Textbox) c;
String value = field.getText();
if (value != null && value.length() > 0) {
iAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND Value");
if (value.indexOf('%') == -1 && value.indexOf('_') == -1)
iAttr.append("=");
else
iAttr.append(" LIKE ");
iAttr.append(DB.TO_STRING(value));
}
}
// Add to where
if (iAttr.length() > 0)
sb.append(" AND asi.M_AttributeSetInstance_ID IN " + "(SELECT M_AttributeSetInstance_ID FROM M_AttributeInstance " + "WHERE ").append(iAttr).append(")");
}
// finish Instance Attributes
if (sb.length() > 0) {
sb.insert(0, " AND EXISTS (SELECT * FROM M_Storage s" + " INNER JOIN M_AttributeSetInstance asi ON (s.M_AttributeSetInstance_ID=asi.M_AttributeSetInstance_ID) " + "WHERE s.M_Product_ID=p.M_Product_ID");
sb.append(")");
}
// Product Attributes
for (int i = 0; i < m_productEditors.size(); i++) {
StringBuffer pAttr = new StringBuffer();
Component c = (Component) m_productEditors.get(i);
Component cTo = (Component) m_productEditorsTo.get(i);
int M_Attribute_ID = Integer.parseInt(c.getId());
if (c instanceof Listbox) {
Listbox field = (Listbox) c;
li = field.getSelectedItem();
if (li != null && li.getValue() != null) {
KeyNamePair pp = (KeyNamePair) li.getValue();
if (pp != null && pp.getKey() != -1) {
pAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND M_AttributeValue_ID=").append(pp.getKey());
}
}
} else if (c instanceof NumberBox) {
NumberBox field = (NumberBox) c;
BigDecimal value = (BigDecimal) field.getValue();
NumberBox fieldTo = (NumberBox) cTo;
BigDecimal valueTo = (BigDecimal) fieldTo.getValue();
if (value != null || valueTo != null) {
pAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND ValueNumber");
if (value != null && valueTo == null)
pAttr.append("=").append(value);
else if (value == null && valueTo != null)
pAttr.append("<=").append(valueTo);
else if (value != null && valueTo != null)
pAttr.append(" BETWEEN ").append(value).append(" AND ").append(valueTo);
}
} else {
Textbox field = (Textbox) c;
String value = field.getText();
if (value != null && value.length() > 0) {
pAttr.append("M_Attribute_ID=").append(M_Attribute_ID).append(" AND Value");
if (value.indexOf('%') == -1 && value.indexOf('_') == -1)
pAttr.append("=");
else
pAttr.append(" LIKE ");
pAttr.append(DB.TO_STRING(value));
}
}
// Add to Where
if (pAttr.length() > 0)
sb.append(" AND p.M_AttributeSetInstance_ID IN " + "(SELECT M_AttributeSetInstance_ID " + "FROM M_AttributeInstance WHERE ").append(pAttr).append(")");
}
//
m_query = null;
if (sb.length() > 0)
m_query = sb.toString();
log.config(m_query);
return m_query;
}
use of org.adempiere.webui.component.NumberBox in project adempiere by adempiere.
the class InfoPAttributePanel method setDisplay.
/**
* Set the display text
*/
private void setDisplay() {
StringBuffer display = new StringBuffer();
if (serNoField != null && serNoField.getValue().toString().length() > 0)
display.append(serNoField.getValue().toString() + "-");
if (lotField != null && lotField.getValue().toString().length() > 0)
display.append(lotField.getValue().toString() + "-");
if (lotSelection != null && lotSelection.getSelectedItem().getValue().toString().length() > 0)
display.append(lotSelection.getSelectedItem().getValue().toString() + "-");
if (guaranteeDateField != null && guaranteeDateField.getValue() != null)
display.append(guaranteeDateSelection.getSelectedItem().getValue().toString() + guaranteeDateField.getValue().toString() + "-");
for (int i = 0; i < m_productEditors.size(); i++) {
Component c = (Component) m_productEditors.get(i);
Component cTo = (Component) m_productEditorsTo.get(i);
if (c instanceof Listbox) {
Listbox field = (Listbox) c;
display.append(field.getSelectedItem().getValue().toString() + "-");
} else if (c instanceof NumberBox) {
NumberBox field = (NumberBox) c;
if (field.getValue() != null)
display.append(field.getValue().toString() + "-");
NumberBox fieldTo = (NumberBox) cTo;
if (fieldTo.getValue() != null)
display.append(fieldTo.getValue().toString() + "-");
} else {
Textbox field = (Textbox) c;
display.append(field.getValue() + "-");
}
}
for (int i = 0; i < m_instanceEditors.size(); i++) {
Component c = (Component) m_instanceEditors.get(i);
Component cTo = (Component) m_instanceEditorsTo.get(i);
if (c instanceof Listbox) {
Listbox field = (Listbox) c;
display.append(field.getSelectedItem().getValue().toString() + "-");
} else if (c instanceof NumberBox) {
NumberBox field = (NumberBox) c;
if (field.getValue() != null)
display.append(field.getValue().toString() + "-");
NumberBox fieldTo = (NumberBox) cTo;
if (fieldTo.getValue() != null)
display.append(fieldTo.getValue().toString() + "-");
} else {
Textbox field = (Textbox) c;
display.append(field.getValue() + "-");
}
}
// TODO - there is a more elegant way to do this.
while (display.toString().contains("--") && display.length() > 1) {
display.delete(display.indexOf("--"), display.indexOf("--") + 1);
}
while (display.toString().startsWith("-") && display.length() > 1) {
display.delete(0, 1);
}
while (display.toString().endsWith("-") && display.length() > 1) {
display.delete(display.length() - 1, display.length());
}
m_display = display.toString();
}
use of org.adempiere.webui.component.NumberBox in project adempiere by adempiere.
the class WBrowserListItemRenderer method getCellComponent.
/**
* Generate the cell for the given <code>field</code>.
*
* @param table The table into which the cell will be placed.
* @param field The data field for which the cell is to be created.
* @param rowIndex The row in which the cell is to be placed.
* @param columnIndex The column in which the cell is to be placed.
* @return The list cell component.
*/
private Listcell getCellComponent(WBrowserTable table, Object field, int rowIndex, int columnIndex) {
ListCell listcell = new ListCell();
if (table == null)
return listcell;
BrowserRow browserRows = table.getData();
// BR [ 257 ]
MBrowseField browseField = browserRows.getBrowserField(browserRows.getTableIndex(columnIndex));
if (browseField == null)
return listcell;
//
GridField gridField = table.getGridFieldAt(rowIndex, columnIndex);
boolean isColumnVisible = true;
if (!m_tableColumns.isEmpty())
isColumnVisible = isColumnVisible(getColumn(columnIndex));
// are assigned to Table Columns
if (isColumnVisible && gridField != null) {
// Set Read Only
boolean isCellEditable = table.isCellEditable(rowIndex, columnIndex);
//
if (DisplayType.YesNo == browseField.getAD_Reference_ID()) {
// BR [ 347 ]
boolean selected = false;
if (field != null) {
selected = Boolean.valueOf(field.toString());
}
listcell.setValue(selected);
if (columnIndex == 0)
table.setCheckmark(false);
Checkbox checkbox = new Checkbox();
checkbox.setChecked(selected);
if (isCellEditable) {
checkbox.setEnabled(true);
checkbox.addEventListener(Events.ON_CHECK, this);
} else {
checkbox.setEnabled(false);
}
listcell.appendChild(checkbox);
ZkCssHelper.appendStyle(listcell, "text-align:center");
} else if ((DisplayType.isNumeric(browseField.getAD_Reference_ID())) && !browseField.isKey()) {
DecimalFormat format = field instanceof BigDecimal ? DisplayType.getNumberFormat(DisplayType.Amount, AEnv.getLanguage(Env.getCtx())) : DisplayType.getNumberFormat(DisplayType.Integer, AEnv.getLanguage(Env.getCtx()));
// set cell value to allow sorting
listcell.setValue((field == null ? "0" : field.toString()));
if (isCellEditable) {
NumberBox numberbox = new NumberBox(false);
numberbox.setFormat(format);
numberbox.setValue(field);
numberbox.setWidth("100px");
numberbox.setStyle("text-align:right; " + listcell.getStyle());
numberbox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(numberbox);
numberbox.setEnabled(true);
} else {
listcell.setLabel(format.format(((Number) (field == null ? Env.ZERO : field)).doubleValue()));
ZkCssHelper.appendStyle(listcell, "text-align:right");
}
} else if (DisplayType.Date == browseField.getAD_Reference_ID() || DisplayType.DateTime == browseField.getAD_Reference_ID()) {
if (field != null) {
SimpleDateFormat dateFormat = DisplayType.getDateFormat(browseField.getAD_Reference_ID(), AEnv.getLanguage(Env.getCtx()));
// BR [ 270 ]
listcell.setValue(dateFormat.format(field));
if (isCellEditable) {
Datebox datebox = new Datebox();
datebox.setFormat(dateFormat.toPattern());
//
datebox.setValue((Date) field);
datebox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(datebox);
} else {
listcell.setLabel(dateFormat.format(field));
}
}
} else // Add support to other String
if (browseField.getAD_Reference_ID() == DisplayType.String || browseField.getAD_Reference_ID() == DisplayType.PrinterName || browseField.getAD_Reference_ID() == DisplayType.Text || browseField.getAD_Reference_ID() == DisplayType.TextLong) {
listcell.setValue((field == null ? "" : field.toString()));
if (isCellEditable) {
Textbox textbox = new Textbox();
textbox.setValue((field == null ? "" : field.toString()));
textbox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(textbox);
} else {
listcell.setLabel((field == null ? "" : field.toString()));
}
} else if (field instanceof org.adempiere.webui.component.Combobox) {
listcell.setValue(field);
if (isCellEditable) {
Combobox combobox = (Combobox) field;
combobox.addEventListener(Events.ON_CHANGE, this);
listcell.appendChild(combobox);
} else {
Combobox combobox = (Combobox) field;
if (combobox != null && combobox.getItemCount() > 0) {
if (combobox.getSelectedIndex() >= 0)
listcell.setLabel((String) combobox.getItemAtIndex(combobox.getSelectedIndex()).getLabel());
else
listcell.setLabel("");
}
}
} else if (field instanceof org.adempiere.webui.component.Button) {
listcell.setValue(field);
if (isCellEditable) {
Button button = (Button) field;
button.addEventListener(Events.ON_CLICK, this);
listcell.appendChild(button);
} else {
Button button = (Button) field;
if (button != null) {
listcell.setLabel("");
}
}
} else // if ID column make it invisible
if (field instanceof IDColumn && browseField.isKey()) {
IDColumn id = (IDColumn) field;
if (id != null && id.getRecord_ID() != null) {
listcell.setValue(id.getRecord_ID());
if (!table.isCheckmark()) {
table.setCheckmark(true);
table.removeEventListener(Events.ON_SELECT, this);
table.addEventListener(Events.ON_SELECT, this);
}
}
} else if ((DisplayType.isLookup(browseField.getAD_Reference_ID()) || DisplayType.ID == browseField.getAD_Reference_ID()) && !browseField.isKey()) {
if (isCellEditable) {
WEditor editor = WebEditorFactory.getEditor(gridField, true);
editor.addValueChangeListener(this);
editor.dynamicDisplay();
editor.setReadWrite(true);
editor.fillHorizontal();
gridField.addPropertyChangeListener(editor);
listcell.appendChild(editor.getComponent());
} else {
Component component;
if (gridField.getDisplayType() == DisplayType.YesNo) {
component = createReadonlyCheckbox(field);
} else {
String text = getDisplayText(field, gridField);
Label label = new Label();
setLabelText(text, label);
component = label;
}
listcell.appendChild(component);
}
} else {
listcell.setLabel((field == null ? null : field.toString()));
listcell.setValue((field == null ? null : field.toString()));
}
} else {
listcell.setLabel("");
listcell.setValue("");
}
listcell.setAttribute("zk_component_ID", "ListItem_Cell_" + rowIndex + "_" + columnIndex);
return listcell;
}
Aggregations