private void getDatas(SearchBean searchBean) { totalNumber = codeDictMapper.getCount(searchBean); if (null != pageTool) { pageTool.setTotalNumber(totalNumber); pageTool.setBounds( new Rectangle(668 - pageTool.getPanelLength(), 455, pageTool.getPanelLength() - 3, 22)); } List<CodeDictBean> codeDictBeanList = codeDictMapper.selectCodeDictsByParams(searchBean); if (CollectionUtils.isNotEmpty(codeDictBeanList)) { rowData.clear(); parent.clear(); Map<String, Object> black = new HashMap<String, Object>(); black.put("label", ""); black.put("value", null); parent.add(black); for (CodeDictBean codeDictBean : codeDictBeanList) { rowData.add(buildVectorData(codeDictBean)); Map<String, Object> item = new HashMap<String, Object>(); item.put("label", codeDictBean.getId() + " - " + codeDictBean.getValue()); item.put("value", codeDictBean.getId()); parent.add(item); } } else { rowData.clear(); } if (table != null) { table.updateTable(); table.getColumnModel().getColumn(4).setCellEditor(new ComboBoxEditor(parent)); table.rows.clear(); } }
private void saveUpdateData() { List<Map<String, Object>> datas = table.getSelectRowValue(); if (CollectionUtils.isNotEmpty(datas)) { for (Map<String, Object> data : datas) { try { if (StringUtils.isEmpty( (Object) data.get(CodeDictColumnEnum.getCodeDictColumnValueByKey("id").getValue()))) { codeDictMapper.insertCodeDict(data); } else { codeDictMapper.updateCodeDict(data); } } catch (Exception e1) { e1.printStackTrace(); } } SearchBean searchBean = new SearchBean(); searchBean.setPageNumber(new Long(1)); searchBean.setPageSize(new Long(15)); getDatas(searchBean); } else { JOptionPane.showMessageDialog(null, "请先选择需要保存的数据!"); } }