/* saves updates to the values of the currently selected resource */ public boolean saveResourceChanges(String id) { NonHumanResource cloned = _sb.getSelectedNonHumanResource(); if (cloned == null) { _msgPanel.error("Could not retrieve changes from session"); return false; } NonHumanResource resource = _orgDataSet.getNonHumanResource(id); if (resource == null) { _msgPanel.error("Invalid resource id: " + id); return false; } // check that any name change is valid String name = (String) txtName.getText(); if ((!name.equals(resource.getName())) && _orgDataSet.isKnownNonHumanResourceName(name)) { addDuplicationError("Resource"); return false; } storeSimpleFieldValues(cloned); resource.merge(cloned); // update resource with clone's values cloned.clearCategory(); // remove cloned from its category _orgDataSet.updateNonHumanResource(resource); updateSelectedResource(resource); return true; }
private void storeSimpleFieldValues(NonHumanResource resource) { String name = (String) txtName.getText(); if ((name != null) && (name.length() > 0)) resource.setName(name); String desc = (String) txtDesc.getText(); if (desc != null) resource.setDescription(desc); String notes = (String) txtNotes.getText(); if (notes != null) resource.setNotes(notes); }
/* saves a newly added resource or category to the org database */ public boolean addNewItem(nonHumanMgt.SelType sType) { String newName = (String) txtName.getText(); if ((newName == null) || (newName.length() == 0)) { _msgPanel.error("Please enter a name for the new Item."); return false; } switch (sType) { case resource: return addResource(newName); case category: return addCategory(newName); } return false; }
/* adds a new subcategory - triggered by categories tab only */ public String btnConfirmAddSubCat_action() { String name = (String) txtSubCat.getText(); if ((name != null) && (name.length() > 0)) { NonHumanCategory category = getCurrentlySelectedCategory(); if (category != null) { if (category.addSubCategory(name)) { // won't add if duplicate _orgDataSet.updateNonHumanCategory(category); _sb.setSubCatAddMode(false); txtSubCat.setText(null); } else _msgPanel.error("Subcategory already exists: " + name); } } else _msgPanel.error("Please enter a subcategory to add."); return null; }
/* saves updates to the values of the currently selected category */ public boolean saveCategoryChanges(String id) { NonHumanCategory category = _orgDataSet.getNonHumanCategory(id); if (category == null) { _msgPanel.error("Invalid category id: " + id); return false; } // check that any name change is valid String name = (String) txtName.getText(); if ((!name.equals(category.getName())) && _orgDataSet.isKnownNonHumanCategoryName(name)) { addDuplicationError("Category"); return false; } storeSimpleFieldValues(category); _orgDataSet.updateNonHumanCategory(category); return true; }
private void storeSimpleFieldValues(NonHumanCategory category) { String name = (String) txtName.getText(); if (name.length() > 0) category.setName(name); category.setDescription((String) txtDesc.getText()); category.setNotes((String) txtNotes.getText()); }