use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WPAttributeDialog method onEvent.
// dispose
public void onEvent(Event e) throws Exception {
// Select Instance
if (e.getTarget() == bSelect) {
if (cmd_select())
dispose();
} else // New/Edit
if (e.getTarget() == cbNewEdit) {
cmd_newEdit();
} else // Select Lot from existing
if (e.getTarget() == fieldLot) {
ListItem pp = fieldLot.getSelectedItem();
if (pp != null && (Integer) pp.getValue() != -1) {
fieldLotString.setText(pp.getLabel());
fieldLotString.setReadonly(true);
m_masi.setM_Lot_ID((Integer) pp.getValue());
} else {
fieldLotString.setReadonly(false);
m_masi.setM_Lot_ID(0);
}
} else // Create New Lot
if (e.getTarget() == bLot) {
KeyNamePair pp = m_masi.createLot(m_M_Product_ID);
if (pp != null) {
ListItem item = new ListItem(pp.getName(), pp.getKey());
fieldLot.appendChild(item);
fieldLot.setSelectedItem(item);
fieldLotString.setText(m_masi.getLot());
fieldLotString.setReadonly(true);
}
} else // Create New SerNo
if (e.getTarget() == bSerNo) {
fieldSerNo.setText(m_masi.getSerNo(true));
} else // OK
if (e.getTarget().getId().equals("Ok")) {
if (saveSelection())
dispose();
} else // Cancel
if (e.getTarget().getId().equals("Cancel")) {
// in the product window.
if (m_productWindow || !m_productASI) {
m_changed = m_M_AttributeSetInstance_ID != 0;
m_M_AttributeSetInstance_ID = 0;
m_M_Locator_ID = 0;
}
dispose();
} else // Zoom M_Lot
if (e.getTarget() == mZoom) {
cmd_zoom();
} else
log.log(Level.SEVERE, "not found - " + e);
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WPAttributeDialog method cmd_zoom.
// cmd_newEdit
/**
* Zoom M_Lot
*/
private void cmd_zoom() {
int M_Lot_ID = 0;
ListItem pp = fieldLot.getSelectedItem();
if (pp != null)
M_Lot_ID = (Integer) pp.getValue();
MQuery zoomQuery = new MQuery("M_Lot");
zoomQuery.addRestriction("M_Lot_ID", MQuery.EQUAL, M_Lot_ID);
log.info(zoomQuery.toString());
//
// Lot
int AD_Window_ID = MWindow.getWindow_ID("Lot");
AEnv.zoom(AD_Window_ID, zoomQuery);
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WAssignmentDialog method onEvent.
// getResources
public void onEvent(Event e) throws Exception {
if (m_setting)
return;
// Update Assignment
ListItem listItem = fResource.getSelectedItem();
KeyNamePair resource = listItem != null ? new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel()) : null;
if (resource != null) {
int S_Resource_ID = resource.getKey();
m_mAssignment.setS_Resource_ID(S_Resource_ID);
}
Calendar date = new GregorianCalendar();
getDateAndTimeFrom(date);
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
if (assignDateFrom != null)
m_mAssignment.setAssignDateFrom(assignDateFrom);
if (fQty.getValue() != null) {
BigDecimal qty = fQty.getValue();
m_mAssignment.setQty(qty);
}
m_mAssignment.setName((String) fName.getValue());
m_mAssignment.setDescription((String) fDescription.getValue());
// Resource - Look up UOM
if (e.getTarget() == fResource) {
Object o = m_lookup.get(resource);
if (o == null)
lUOM.setValue(" ? ");
else
lUOM.setValue(o.toString());
} else // Zoom - InfoResource
if (e.getTarget().getId().equals("Zoom")) {
InfoSchedule is = new InfoSchedule(m_mAssignment, true);
if (is.getMResourceAssignment() != null) {
m_mAssignment = is.getMResourceAssignment();
// setDisplay();
detach();
}
is = null;
} else // cancel - return
if (e.getTarget().getId().equals("Cancel")) {
m_cancel = true;
detach();
} else // delete - delete and return
if (e.getTarget().getId().equals("Delete")) {
if (m_mAssignment.delete(true)) {
m_mAssignment = null;
detach();
} else
FDialog.error(0, this, "ResourceAssignmentNotDeleted");
} else // OK - Save
if (e.getTarget().getId().equals("Ok")) {
if (cmd_save())
detach();
}
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WAssignmentDialog method setDisplay.
// jbInit
/**
* Initialize component & values from m_mAssignment
*/
private void setDisplay() {
m_setting = true;
// Set Resource
int S_Resource_ID = m_mAssignment.getS_Resource_ID();
for (Listitem item : fResource.getItems()) {
if ((Integer) item.getValue() == S_Resource_ID) {
fResource.setSelectedItem(item);
break;
}
}
ListItem listItem = fResource.getSelectedItem();
KeyNamePair check = new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel());
if (check == null || check.getKey() != S_Resource_ID) {
if (// new record select first
m_mAssignment.getS_ResourceAssignment_ID() == 0)
// initiates UOM display
fResource.setSelectedItem(fResource.getSelectedItem());
else
log.log(Level.SEVERE, "Resource not found ID=" + S_Resource_ID);
}
// Set Date, Qty
fDateFrom.setValue(m_mAssignment.getAssignDateFrom());
fTimeFrom.setValue(m_mAssignment.getAssignDateFrom());
fQty.setValue(m_mAssignment.getQty());
// Name, Description
fName.setValue(m_mAssignment.getName());
fDescription.setValue(m_mAssignment.getDescription());
// Set Editor to R/O if confirmed
boolean readWrite = true;
if (m_mAssignment.isConfirmed())
readWrite = false;
confirmPanel.getButton("Cancel").setVisible(readWrite);
fResource.setEnabled(readWrite);
fDateFrom.setReadonly(!readWrite);
fQty.setEnabled(readWrite);
m_setting = false;
}
use of org.adempiere.webui.component.ListItem in project adempiere by adempiere.
the class WAssignmentDialog method cmd_save.
// getMResourceAssignment
/**
* Check availability and insert record
* @return true if saved/updated
*/
private boolean cmd_save() {
log.config("");
// Set AssignDateTo
Calendar date = new GregorianCalendar();
getDateAndTimeFrom(date);
Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
BigDecimal qty = fQty.getValue();
ListItem listItem = fResource.getSelectedItem();
KeyNamePair resource = listItem != null ? new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel()) : null;
KeyNamePair uom = (KeyNamePair) m_lookup.get(resource);
int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty);
Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes);
m_mAssignment.setAssignDateTo(assignDateTo);
// m_mAssignment.dump();
return m_mAssignment.save();
}
Aggregations