private void initData() { typeData.clear(); typeData.addAll(ToolType.allToolTypes()); List<ToolsTray> bandejaList = dao.query(ToolsTray.class, Cnd.where("toolType", "=", C.TOOL_TYPE_TRAY_FOLDER)); superData.clear(); ToolsTray bandeja1 = new ToolsTray(); bandeja1.setId(C.ROOT_PARENT_ID); bandeja1.setTrayName("--无父目录--"); superData.add(bandeja1); superData.addAll(bandejaList); searchData.clear(); ToolsTray bandeja = new ToolsTray(); bandeja.setTrayName("--全部--"); searchData.add(bandeja); searchData.add(bandeja1); searchData.addAll(bandejaList); tableData.clear(); tableData.addAll(dao.query(ToolsTray.class, null)); }
public void confirm(ActionEvent event) { String name = nameField.getText(); if (S.isEmpty(name)) { tipsLabel.setText("错误:工具名字不能为空!"); nameField.requestFocus(); return; } String command = commandText.getText(); String order = orderField.getText(); ToolsTray bandeja = (ToolsTray) parentCombo.getSelectionModel().getSelectedItem(); Integer parentId = bandeja.getId(); ToolType toolType = (ToolType) typeCombo.getSelectionModel().getSelectedItem(); String type = toolType.getToolType(); ToolsTray toolsTray = new ToolsTray(); toolsTray.setTrayName(name); toolsTray.setCommand(command); toolsTray.setParentId(parentId); toolsTray.setToolOrder(order); toolsTray.setToolType(type); if (null == id) { dao.insert(toolsTray); id = toolsTray.getId(); tipsLabel.setText("添加成功:" + name); } else { toolsTray.setId(id); dao.update(toolsTray); tipsLabel.setText("更新成功:" + name); } refresh(null); }