/* 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 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); }
protected void disableInputFields(boolean disable) { txtName.setDisabled(disable); txtDesc.setDisabled(disable); txtNotes.setDisabled(disable); cbbMembers.setDisabled(disable); cbbCategory.setDisabled(disable); cbbSubCategory.setDisabled(disable); btnAddSubCat.setDisabled(disable); btnRemoveSubCat.setDisabled(disable || subCatUnremovable()); }
/* 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; }
/* enable or disable fields depending on whether we are in browse/edit or add mode */ public void setAddMode(boolean adding, String selectedTab) { lbxItems.setDisabled(adding); if (selectedTab.equals("tabCategories")) { lbxSubCatItems.setDisabled(adding); btnAddSubCat.setDisabled(adding); btnRemoveSubCat.setDisabled(adding); disableInputFields(!adding); disableSubCatButtons(adding); _sb.setCategoryMembers(null); } if (adding) clearTextFields(); txtName.setText(""); lblMembers.setText("Members (0)"); }
/* 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; }
public String button1_action() { try { // 待做事项:处理按钮单击操作。返回的值是一个导航 // 条件名称,如果它为 Null,则返回到同一页。 String roleName = textField_roleName.getValue().toString().trim(); String memo = (String) textArea_memo.getText(); String[] selectedPopedomList = (String[]) addRemoveList_configPopedom.getSelected(); TRole trole = new TRole(); TRoleUtil.save(roleName, memo); for (int i = 0; (selectedPopedomList != null) && (i < selectedPopedomList.length); i++) { TRolePopedomUtil.saveRolePopedom(roleName, selectedPopedomList[i]); } getSessionBean1().getSessionMap().put("roleName_insertSuccessful", roleName); return "toSuccess"; } catch (HibernateException ex) { return "toDBConnectionError"; } }
protected void showSubCatAddFields(boolean adding) { txtSubCat.setVisible(adding); btnConfirmAddSubCat.setVisible(adding); btnCancelAddSubCat.setVisible(adding); }
private void populateSimpleFields(String name, String desc, String notes) { txtName.setText(name); txtDesc.setText(desc); txtNotes.setText(notes); }
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()); }