use of org.compiere.model.GridField in project adempiere by adempiere.
the class BrowserRow method setCurrentRow.
// processCallOut
/**
* Set Current Row for Callout
* @param p_CurrentRow
*/
public void setCurrentRow(int p_CurrentRow) {
m_CurrentRow = p_CurrentRow;
log.fine("Row=" + m_CurrentRow);
if (m_CurrentRow < 0)
return;
// Update Field Values
int size = getColumnCount();
for (int i = 0; i < size; i++) {
GridField mField = getValue(m_CurrentRow, i);
if (mField != null) {
mField.updateContext();
}
}
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class ADServiceImpl method fillDataRow.
private void fillDataRow(DataRow dr, WWindowStatus ws, boolean handleLookups, boolean onlyUpdated) throws XFireFault {
authenticate(webServiceName, "fillDataRow");
int noFields = ws.curTab.getFieldCount();
//m_cs.dateFormat = new SimpleDateFormat( m_cs.datePattern );
//m_cs.dateTimeFormat = new SimpleDateFormat( m_cs.datePattern );
String column = "";
boolean isEditable = false;
if (onlyUpdated) {
java.util.Date clientUpdated = new java.util.Date();
java.util.Date updated = (java.util.Date) ws.curTab.getValue("Updated");
if (!updated.after(clientUpdated)) {
DataField df = dr.addNewField();
df.setColumn(recordIDfield);
df.setDisp(false);
df.setVal(Integer.toString(ws.curTab.getRecord_ID()));
return;
}
}
for (int colNo = 0; colNo < noFields; colNo++) {
GridField field = ws.curTab.getField(colNo);
column = field.getColumnName();
if (!field.isDisplayed(true)) {
DataField df = dr.addNewField();
df.setColumn(column);
df.setDisp(false);
df.setVal("");
//System.out.println(" *** not displayed: "+field.getColumnName()+" | "+field.getDisplayLogic());
continue;
}
if (field.getDisplayType() == DisplayType.Button)
continue;
DataField df = dr.addNewField();
isEditable = field.isEditable(true);
df.setEdit(isEditable);
// Get Data - turn to string
Object data = ws.curTab.getValue(column);
String info = null;
//
if (data == null && !DisplayType.isLookup(field.getDisplayType()))
info = "";
else {
int dt = field.getDisplayType();
switch(dt) {
case DisplayType.Date:
info = m_cs.dateFormat.format(data);
//System.out.println( "Date: "+info );
break;
case DisplayType.DateTime:
// TODO
//m_cs.dateTimeFormat.format(data);
info = m_cs.dateFormat.format(data);
//System.out.println( "DateTime: "+info );
break;
case DisplayType.Amount:
info = m_cs.amountFormat.format(data);
break;
case DisplayType.Number:
case DisplayType.CostPrice:
info = m_cs.numberFormat.format(data);
break;
case DisplayType.Quantity:
info = m_cs.quantityFormat.format(data);
break;
case DisplayType.Integer:
info = m_cs.integerFormat.format(data);
break;
case DisplayType.YesNo:
info = data.toString();
if ("Y".equals(info))
info = "true";
if ("N".equals(info))
info = "false";
//info = Msg.getMsg(ws.ctx, data.toString());
break;
case DisplayType.Location:
info = data.toString();
if (handleLookups) {
String x = DB.getSQLValueString(null, "select l.address1||', '||l.postal||', '||l.city from c_location l where c_location_id=?", Integer.parseInt(info));
df.setLval(x);
System.out.println(" location = " + x);
}
break;
default:
if (DisplayType.isLookup(dt)) {
Lookup lookup = field.getLookup();
//ArrayList<String> deps = field.getDependentOn();
String lookupValue = null;
if (field.getValue() != null) {
lookupValue = lookup.getDisplay(field.getValue());
}
//lookup.refresh();
if (data != null) {
info = lookup.getDisplay(data);
if (info == null) {
lookup.refresh();
info = lookup.getDisplay(data);
}
}
df.setLval(lookupValue);
if (handleLookups && /*&& isEditable*/
lookup != null && //deps.size()>0)
(field.getVO().ValidationCode != null && field.getVO().ValidationCode.length() > 0)) {
if (data != null)
info = lookup.getDisplay(data);
LookupValues lvs = df.addNewLookup();
ADLookup.fillLookupValues(lvs, lookup, field);
}
if (data != null)
info = data.toString();
} else {
info = data.toString();
//System.out.println(">>>>>>>> UNKNOWN > "+field.getColumnName() +" = "+info);
}
}
}
//System.out.println(" "+column+" = "+info);
if ("M_Product_ID".equals(field.getColumnName()))
System.out.println("--- " + info);
df.setDisp(true);
df.setVal(info);
df.setColumn(field.getColumnName());
if (field.isError()) {
df.setError(true);
df.setErrorVal(field.getErrorValue());
}
}
DataField df = dr.addNewField();
df.setColumn(recordIDfield);
df.setVal(Integer.toString(ws.curTab.getRecord_ID()));
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class ADServiceImpl method fillField.
private void fillField(Field f, GridFieldVO fo) {
////(griddieldvo) adempiere specific
f.setADColumnID(fo.AD_Column_ID);
f.setADProcessID(fo.AD_Process_ID);
f.setADReferenceValueID(fo.AD_Reference_Value_ID);
f.setADWindowID(fo.AD_Window_ID);
f.setCallout(fo.Callout);
f.setColumnName(fo.ColumnName);
f.setDefaultValue(fo.DefaultValue);
f.setDefaultValue2(fo.DefaultValue2);
f.setDescription(fo.Description);
f.setDisplayLength(fo.DisplayLength);
f.setDisplayLogic(fo.DisplayLogic);
f.setDisplayType(fo.displayType);
f.setFieldGroup(fo.FieldGroup);
f.setFieldLength(fo.FieldLength);
f.setHeader(fo.Header);
f.setHelp(fo.Help);
f.setIsAlwaysUpdateable(fo.IsAlwaysUpdateable);
f.setIsDisplayed(fo.IsDisplayed);
f.setIsEncryptedColumn(fo.IsEncryptedColumn);
f.setIsEncryptedField(fo.IsEncryptedField);
f.setIsFieldOnly(fo.IsFieldOnly);
f.setIsHeading(fo.IsHeading);
f.setIsKey(fo.IsKey);
f.setIsMandatory(fo.IsMandatory);
f.setIsParent(fo.IsParent);
f.setIsProcess(fo.isProcess);
f.setIsRange(fo.IsRange);
f.setIsReadOnly(fo.IsReadOnly);
f.setIsSameLine(fo.IsSameLine);
f.setIsSelectionColumn(fo.IsSelectionColumn);
f.setIsUpdateable(fo.IsUpdateable);
if (DisplayType.isLookup(fo.displayType)) {
GridField ff = new GridField(fo);
ArrayList<String> deps = ff.getDependentOn();
Lookup lookup = ff.getLookup();
LookupInfo li = f.addNewLookupInfo();
if (fo.lookupInfo != null) {
li.setZoomWindow(fo.lookupInfo.ZoomWindow);
li.setZoomWindow(fo.lookupInfo.ZoomWindow);
}
//if (deps.size()==0)
if (lookup != null && (fo.ValidationCode == null || (fo.ValidationCode != null && fo.ValidationCode.length() == 0))) {
LookupValues lvs = f.addNewLookup();
//System.out.println( "lookup "+fo.ColumnName+" "+lookup.getSize() );
//if(lookup.size() == 0) - nie robic tego
// System.out.println("lookup refresh ["+fo.ColumnName+"]= "+lookup.refresh());
/*if(lookup.getSize() > 0)*/
// the last was false, 2007-05-11
ArrayList ar = lookup.getData(ff.isMandatory(false), true, !ff.isReadOnly(), true);
if (ar != null && ar.size() > 0) {
Object[] list = ar.toArray();
for (int i = 0; i < list.length; i++) {
boolean isNumber = list[0] instanceof KeyNamePair;
LookupValue lv = lvs.addNewLv();
if (isNumber) {
KeyNamePair p = (KeyNamePair) list[i];
lv.setKey(Integer.toString(p.getKey()));
lv.setVal(p.getName());
//System.out.println( "LV " + p.getKey() + " - "+ p.getName() );
} else {
ValueNamePair p = (ValueNamePair) list[i];
lv.setKey(p.getValue());
lv.setVal(p.getName());
//System.out.println( "LV " + p.getValue() + " - "+ p.getName());
}
}
}
}
}
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class WOrderReceiptIssue method fillPicks.
// init
/**
* Fill Picks
* Column_ID from C_Order
* This is only run as part of the windows initialization process
* @throws Exception if Lookups cannot be initialized
*/
private void fillPicks() throws Exception {
Properties ctx = Env.getCtx();
// Base Language
Language language = Language.getLoginLanguage();
MLookup orderLookup = MLookupFactory.get(ctx, m_WindowNo, MColumn.getColumn_ID(MPPOrder.Table_Name, MPPOrder.COLUMNNAME_PP_Order_ID), DisplayType.Search, language, "PP_Order_ID", 0, false, "PP_Order.DocStatus = '" + MPPOrder.DOCACTION_Complete + "'");
orderField = new WSearchEditor(MPPOrder.COLUMNNAME_PP_Order_ID, false, false, true, orderLookup);
orderField.addValueChangeListener(this);
MLookup resourceLookup = MLookupFactory.get(ctx, m_WindowNo, 0, MColumn.getColumn_ID(MPPOrder.Table_Name, MPPOrder.COLUMNNAME_S_Resource_ID), DisplayType.TableDir);
resourceField = new WSearchEditor(MPPOrder.COLUMNNAME_S_Resource_ID, false, false, false, resourceLookup);
MLookup warehouseLookup = MLookupFactory.get(ctx, m_WindowNo, 0, MColumn.getColumn_ID(MPPOrder.Table_Name, MPPOrder.COLUMNNAME_M_Warehouse_ID), DisplayType.TableDir);
warehouseField = new WSearchEditor(MPPOrder.COLUMNNAME_M_Warehouse_ID, false, false, false, warehouseLookup);
MLookup productLookup = MLookupFactory.get(ctx, m_WindowNo, 0, MColumn.getColumn_ID(MPPOrder.Table_Name, MPPOrder.COLUMNNAME_M_Product_ID), DisplayType.TableDir);
productField = new WSearchEditor(MPPOrder.COLUMNNAME_M_Product_ID, false, false, false, productLookup);
MLookup uomLookup = MLookupFactory.get(ctx, m_WindowNo, 0, MColumn.getColumn_ID(MPPOrder.Table_Name, MPPOrder.COLUMNNAME_C_UOM_ID), DisplayType.TableDir);
uomField = new WSearchEditor(MPPOrder.COLUMNNAME_C_UOM_ID, false, false, false, uomLookup);
MLookup uomOrderLookup = MLookupFactory.get(ctx, m_WindowNo, 0, MColumn.getColumn_ID(MPPOrder.Table_Name, MPPOrder.COLUMNNAME_C_UOM_ID), DisplayType.TableDir);
uomorderField = new WSearchEditor(MPPOrder.COLUMNNAME_C_UOM_ID, false, false, false, uomOrderLookup);
MLocatorLookup locatorL = new MLocatorLookup(ctx, m_WindowNo);
locatorField = new WLocatorEditor(MLocator.COLUMNNAME_M_Locator_ID, true, false, true, locatorL, m_WindowNo);
// Tab, Window
int m_Window = MWindow.getWindow_ID("Manufacturing Order");
GridFieldVO vo = GridFieldVO.createStdField(ctx, m_WindowNo, 0, m_Window, MTab.getTab_ID(m_Window, "Manufacturing Order"), false, false, false);
vo.AD_Column_ID = MColumn.getColumn_ID(MPPOrder.Table_Name, MPPOrder.COLUMNNAME_M_AttributeSetInstance_ID);
vo.ColumnName = MPPOrder.COLUMNNAME_M_AttributeSetInstance_ID;
vo.displayType = DisplayType.PAttribute;
GridField field = new GridField(vo);
// M_AttributeSetInstance_ID
attribute = new WPAttributeEditor(field.getGridTab(), field);
attribute.setReadWrite(true);
attribute.setValue(0);
// 4Layers - Further init
scrapQtyField.setValue(Env.ZERO);
rejectQty.setValue(Env.ZERO);
// 4Layers - end
pickcombo.appendItem(Msg.parseTranslation(Env.getCtx(), "@IsBackflush@"), 1);
pickcombo.appendItem(Msg.parseTranslation(Env.getCtx(), "@OnlyIssue@"), 2);
pickcombo.appendItem(Msg.parseTranslation(Env.getCtx(), "@OnlyReceiptProduct@"), 3);
pickcombo.addEventListener(Events.ON_CHANGE, this);
Process.addActionListener(this);
toDeliverQty.addValueChangeListener(this);
scrapQtyField.addValueChangeListener(this);
}
use of org.compiere.model.GridField in project adempiere by adempiere.
the class GridTabListItemRenderer method render.
/**
* @param listitem
* @param data
* @see ListitemRenderer#render(Listitem, Object)
*/
public void render(Listitem listitem, Object data, int arg2) throws Exception {
//don't render if not visible
for (Component c = listitem.getParent(); c != null; c = c.getParent()) {
if (!c.isVisible())
return;
}
Object[] values = (Object[]) data;
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
for (int i = 0; i < columnCount; i++) {
if (!(gridField[i].isDisplayed() && gridField[i].isDisplayedGrid())) {
continue;
}
if (editors.get(gridField[i]) == null)
editors.put(gridField[i], WebEditorFactory.getEditor(gridField[i], true));
int rowIndex = listitem.getIndex();
if (paging != null && paging.getPageSize() > 0) {
rowIndex = (paging.getActivePage() * paging.getPageSize()) + rowIndex;
}
Listcell cell = null;
if (rowIndex == gridTab.getCurrentRow() && gridField[i].isEditable(true)) {
cell = getEditorCell(gridField[i], values[i], i);
cell.setParent(listitem);
} else {
if (gridField[i].getDisplayType() == DisplayType.YesNo) {
cell = new Listcell("", null);
cell.setParent(listitem);
cell.setStyle("text-align:center");
createReadonlyCheckbox(values[i], cell);
} else {
String text = getDisplayText(values[i], i);
String display = text;
if (text != null && text.length() > MAX_TEXT_LENGTH)
display = text.substring(0, MAX_TEXT_LENGTH - 3) + "...";
cell = new Listcell(display, null);
cell.setParent(listitem);
if (text != null && text.length() > MAX_TEXT_LENGTH)
cell.setTooltiptext(text);
if (DisplayType.isNumeric(gridField[i].getDisplayType())) {
cell.setStyle("text-align:right");
} else if (gridField[i].getDisplayType() == DisplayType.Image) {
cell.setStyle("text-align:center");
}
}
}
CellListener listener = new CellListener((Listbox) listitem.getParent());
cell.addEventListener(Events.ON_DOUBLE_CLICK, listener);
}
}
Aggregations