use of org.compiere.grid.ed.VLine in project adempiere by adempiere.
the class InfoPAttribute method addAttributes.
// dynInit
/**
* Add Attributes
* @return rows
*/
private int addAttributes() {
int row = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
String whereAttributeSet;
if (p_M_AttributeSet_ID > 0)
whereAttributeSet = "AND M_Attribute_ID IN (SELECT M_Attribute_ID FROM M_AttributeUse WHERE M_AttributeSet_ID=" + p_M_AttributeSet_ID + ")";
else
whereAttributeSet = "";
String sql = MRole.getDefault().addAccessSQL("SELECT M_Attribute_ID, Name, Description, AttributeValueType, IsInstanceAttribute " + "FROM M_Attribute " + "WHERE IsActive='Y' " + whereAttributeSet + " ORDER BY IsInstanceAttribute, Name", "M_Attribute", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
boolean instanceLine = false;
boolean productLine = false;
try {
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next()) {
int attribute_ID = rs.getInt(1);
String name = rs.getString(2);
String description = rs.getString(3);
String attributeValueType = rs.getString(4);
boolean isInstanceAttribute = "Y".equals(rs.getString(5));
// Add label for product attributes if there are any
if (!productLine && !isInstanceAttribute) {
CPanel group = new CPanel();
group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsProductAttribute")));
group.add(Box.createVerticalStrut(VLine.SPACE));
centerPanel.add(group, new ALayoutConstraint(row++, 0));
productLine = true;
}
// Add label for Instances attributes
if (!instanceLine && isInstanceAttribute) {
CPanel group = new CPanel();
group.add(Box.createVerticalStrut(VLine.SPACE));
group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsInstanceAttribute")));
group.add(Box.createVerticalStrut(VLine.SPACE));
centerPanel.add(group, new ALayoutConstraint(row++, 0));
instanceLine = true;
}
//
CLabel label = new CLabel(name);
if (description != null && description.length() > 0)
label.setToolTipText(description);
centerPanel.add(label, new ALayoutConstraint(row++, 0));
Component field = null;
if (MAttribute.ATTRIBUTEVALUETYPE_List.equals(attributeValueType))
field = new VComboBox(getAttributeList(attribute_ID));
else if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType))
field = new VNumber(name, false, false, true, DisplayType.Number, name);
else
field = new VString(name, false, false, true, 10, 40, null, null);
label.setLabelFor(field);
centerPanel.add(field, null);
//
field.setName(String.valueOf(attribute_ID));
if (isInstanceAttribute)
m_instanceEditors.add(field);
else
m_productEditors.add(field);
// To (numbers)
Component fieldTo = null;
if (MAttribute.ATTRIBUTEVALUETYPE_Number.equals(attributeValueType)) {
fieldTo = new VNumber(name, false, false, true, DisplayType.Number, name);
centerPanel.add(new CLabel("-"), null);
centerPanel.add(fieldTo, null);
}
if (isInstanceAttribute)
m_instanceEditorsTo.add(fieldTo);
else
m_productEditorsTo.add(fieldTo);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
// print instance line if not printed
if (!instanceLine) {
boolean isGuarantee = true;
boolean isSerial = true;
boolean isLot = true;
if (p_M_AttributeSet_ID > 0) {
MAttributeSet as = new MAttributeSet(Env.getCtx(), p_M_AttributeSet_ID, null);
isGuarantee = as.isGuaranteeDate();
isSerial = as.isSerNo();
isLot = as.isLot();
}
if (isGuarantee || isSerial || isLot) {
CPanel group = new CPanel();
group.setBorder(new VLine(Msg.translate(Env.getCtx(), "IsInstanceAttribute")));
group.add(Box.createVerticalStrut(VLine.SPACE));
centerPanel.add(group, new ALayoutConstraint(row++, 0));
instanceLine = true;
}
}
return row;
}
Aggregations