use of org.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class VStocktake method dynParameter.
// jbInit
/**
* Initialize Parameter fields
* @throws Exception if Lookups cannot be initialized
*/
private void dynParameter() throws Exception {
Properties ctx = Env.getCtx();
// Physical Inventory Document
String vcode = "M_Inventory.IsStocktake='Y' ";
MLookup inventoryLookup = MLookupFactory.get(ctx, m_WindowNo, 3563, DisplayType.TableDir, Env.getLanguage(Env.getCtx()), "M_Inventory_ID", 53249, true, vcode);
inventoryField = new VLookup("M_Inventory_ID", false, false, true, inventoryLookup);
// Locator
MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo);
locatorField = new VLocator("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo);
// Product
MLookup productLookup = MLookupFactory.get(ctx, m_WindowNo, 0, 3668, DisplayType.Search);
productField = new VLookup("M_Product_ID", false, false, true, productLookup);
// Aisle(X)
MLookup aislexLookup = MLookupFactory.get(ctx, m_WindowNo, 1399, DisplayType.Table, Env.getLanguage(Env.getCtx()), "X", 53562, false, null);
aislexField = new VLookup("X", false, false, true, aislexLookup);
// lines
lineFField = new VNumber();
lineTField = new VNumber();
//
confirmPanel.addActionListener(this);
statusBar.setStatusLine("");
}
use of org.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class InfoPAttribute 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.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.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
KeyNamePair pp = (KeyNamePair) lotSelection.getSelectedItem();
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.getName());
if (c instanceof VComboBox) {
VComboBox field = (VComboBox) c;
pp = (KeyNamePair) field.getSelectedItem();
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 VNumber) {
VNumber field = (VNumber) c;
BigDecimal value = (BigDecimal) field.getValue();
VNumber fieldTo = (VNumber) 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 {
VString field = (VString) 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.getName());
if (c instanceof VComboBox) {
VComboBox field = (VComboBox) c;
pp = (KeyNamePair) field.getSelectedItem();
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 VNumber) {
VNumber field = (VNumber) c;
BigDecimal value = (BigDecimal) field.getValue();
VNumber fieldTo = (VNumber) 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 {
VString field = (VString) 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.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class InfoPAttribute 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.getDisplay().length() > 0)
display.append(lotSelection.getDisplay() + "-");
if (guaranteeDateField != null && guaranteeDateField.getValue() != null)
display.append(guaranteeDateSelection.getDisplay() + 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 VComboBox) {
VComboBox field = (VComboBox) c;
display.append(field.getDisplay() + "-");
} else if (c instanceof VNumber) {
VNumber field = (VNumber) c;
display.append(field.getDisplay() + "-");
VNumber fieldTo = (VNumber) cTo;
display.append(fieldTo.getDisplay() + "-");
} else {
VString field = (VString) c;
display.append(field.getDisplay() + "-");
}
}
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 VComboBox) {
VComboBox field = (VComboBox) c;
display.append(field.getDisplay() + "-");
} else if (c instanceof VNumber) {
VNumber field = (VNumber) c;
display.append(field.getDisplay() + "-");
VNumber fieldTo = (VNumber) cTo;
display.append(fieldTo.getDisplay() + "-");
} else {
VString field = (VString) c;
display.append(field.getDisplay() + "-");
}
}
// 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.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class VBOMDrop 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, String feature, BigDecimal lineQty) {
log.fine("M_Product_ID=" + M_Product_ID + ",Type=" + bomType + ",Name=" + name + ",feature=" + feature + ",Qty=" + lineQty);
//
boolean selected = true;
if (MPPProductBOMLine.COMPONENTTYPE_Component.equals(bomType)) {
String title = "";
JCheckBox cb = new JCheckBox(title);
cb.setSelected(true);
cb.setEnabled(false);
// cb.addActionListener(this); // will not change
m_selectionList.add(cb);
this.add(cb, new ALayoutConstraint(m_bomLine++, 0));
} else if (MPPProductBOMLine.COMPONENTTYPE_Option.equals(bomType)) {
//String title = Msg.getMsg(Env.getCtx(), "Optional");
JCheckBox cb = new JCheckBox(feature);
cb.setSelected(false);
selected = false;
cb.addActionListener(this);
m_selectionList.add(cb);
this.add(cb, new ALayoutConstraint(m_bomLine++, 0));
} else if (MPPProductBOMLine.COMPONENTTYPE_Variant.equals(bomType)) {
//String title = Msg.getMsg(Env.getCtx(), "Variant") + " " + bomType;
JRadioButton b = new JRadioButton(feature);
String groupName = feature + "_" + String.valueOf(parentM_Product_ID) + "_" + bomType;
ButtonGroup group = (ButtonGroup) m_buttonGroups.get(groupName);
if (group == null) {
log.fine("ButtonGroup=" + groupName);
group = new ButtonGroup();
m_buttonGroups.put(groupName, group);
group.add(b);
// select first one
b.setSelected(true);
} else {
group.add(b);
b.setSelected(false);
selected = false;
}
b.addActionListener(this);
m_selectionList.add(b);
this.add(b, new ALayoutConstraint(m_bomLine++, 0));
}
// Add to List & display
m_productList.add(new Integer(M_Product_ID));
VNumber qty = new VNumber("Qty", true, false, true, DisplayType.Quantity, name);
qty.setValue(lineQty);
qty.setReadWrite(selected);
m_qtyList.add(qty);
CLabel label = new CLabel(name);
label.setLabelFor(qty);
this.add(label);
this.add(qty);
}
use of org.compiere.grid.ed.VNumber in project adempiere by adempiere.
the class VBOMDrop 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);
VNumber qty = (VNumber) m_qtyList.get(i);
qty.setReadWrite(selected);
return;
}
}
log.log(Level.SEVERE, "not found - " + source);
}
Aggregations