if(options.get(0).equals("create")){
manageOption("create");
return;
}
if(!ids.isEmpty()){
final Warehouse warehouse=manager.find(new Long(ids.get(0)));
nameBox.setText(warehouse.getName());
groupsCombo.setText(warehouse.getGroup().getName());
if(warehouse.getReplacingWarehouse() !=null){
replacingBox.setText(warehouse.getReplacingWarehouse().getName());
}
shareableCheck.setChecked(warehouse.getShareable());
sbox.setText(warehouse.getDescription().getShortDescription());
dbox.setText(warehouse.getDescription().getLongDescription());
cmbox.setText(warehouse.getDescription().getComment());
if(options.get(0).equals("show")){
nameBox.setDisabled(true);
groupsCombo.setDisabled(true);
replacingBox.setDisabled(true);
shareableCheck.setDisabled(true);
sbox.setDisabled(true);
dbox.setDisabled(true);
cmbox.setDisabled(true);
}
if(options.get(0).equals("edit")){
nameBox.setDisabled(true);
List<OrganizationGroup> groups=organizationGroupManager.findAll();
for (OrganizationGroup group : groups) {
Comboitem item=new Comboitem(group.getName());
groupsCombo.appendChild(item);
}
List<Warehouse> replacements=manager.findAll();
for (Warehouse replacement : replacements) {
Comboitem item=new Comboitem(replacement.getName());
replacingBox.appendChild(item);
}
Button okButton=new Button("OK");
okButton.addEventListener("onClick", new EventListener(){
public void onEvent(Event event) throws Exception {
OrganizationGroup comp=organizationGroupManager.findByName(groupsCombo.getText()).get(0);
if(nameBox.getText().equals("")){
Messagebox.show("Name is empty!", "Error", Messagebox.YES , null);
nameBox.focus();
return;
}
warehouse.setGroup(comp);
if(replacingBox.getText().equals(nameBox.getText())){
Messagebox.show("Warehouse cannot replace itself!", "Error", Messagebox.YES , null);
replacingBox.focus();
return;
}
if(!replacingBox.getText().equals("")){
Warehouse replacing=(Warehouse)((List<Warehouse>)manager.findByName(replacingBox.getText())).get(0);
warehouse.setReplacingWarehouse(replacing);
}
warehouse.setShareable(shareableCheck.isChecked());
warehouse.getDescription().setShortDescription(sbox.getText());
warehouse.getDescription().setLongDescription(dbox.getText());