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); }