| | |
| | | import com.example.server.progressTrack.model.DjJdgzNetworkLevel2; |
| | | import com.example.server.progressTrack.model.DjJdgzNetworkLevel2List; |
| | | import com.example.server.progressTrack.service.*; |
| | | import com.example.server.user.model.SysUser; |
| | | import com.example.server.utils.UserAndSiteUtils; |
| | | import com.mxgraph.swing.mxGraphComponent; |
| | | import com.mxgraph.view.mxGraph; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "yyyy-MM-dd"); |
| | | timeSpinner.setEditor(timeEditor); |
| | | |
| | | /* JButton btnInsert = new JButton("新增");*/ |
| | | JButton btnInsert = new JButton("新增"); |
| | | JButton btnImport = new JButton("导入数据"); |
| | | JButton btnSave= new JButton("保存"); |
| | | |
| | | JLabel label1 = new JLabel("起始时间"); |
| | | /* JLabel label1 = new JLabel("起始时间"); |
| | | JXDatePicker beginDate = new JXDatePicker(); |
| | | beginDate.setPreferredSize(new Dimension(180, 28)); |
| | | SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | |
| | | lineNum.setText(String.valueOf(data.getLineNodeNum())); |
| | | }else{ |
| | | lineNum.setText("10"); |
| | | } |
| | | }*/ |
| | | |
| | | topJpanel.add(btnImport, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); |
| | | topJpanel.add(label1, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); |
| | | topJpanel.add(beginDate, new GBC(2, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); |
| | | |
| | | topJpanel.add(label2, new GBC(0, 1, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); |
| | | topJpanel.add(diagramWidth, new GBC(1, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); |
| | | topJpanel.add(label3, new GBC(2, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); |
| | | topJpanel.add(lineNum, new GBC(3, 1, 1, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); |
| | | |
| | | topJpanel.add(btnInsert, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); |
| | | topJpanel.add(btnImport, new GBC(1, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); |
| | | topJpanel.add(btnSave, new GBC(2, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); |
| | | |
| | | // 创建子表格 |
| | | List<ColumnDto> columnDto = new ArrayList<>(); |
| | |
| | | |
| | | /* List<TableButton> buttonList = new ArrayList<>(); |
| | | buttonList.add(new TableButton("del", "删除"));*/ |
| | | List<TableButton> buttonList = new ArrayList<>(); |
| | | buttonList.add(new TableButton("del", "删除")); |
| | | |
| | | |
| | | columnDto.add(new ColumnDto("序号", "", 50, "autoCreate", false, null,null)); |
| | | columnDto.add(new ColumnDto("工程专业", "majorName", 180, null, false, null,null)); |
| | | columnDto.add(new ColumnDto("节点名称", "ProcessName", 160, null, false, null,null)); |
| | | columnDto.add(new ColumnDto("要求完成时间", "requiredCompletionTime", 120, null, false, null,null)); |
| | | columnDto.add(new ColumnDto("序号", "", 50, "autoCreate", true, null,null)); |
| | | //columnDto.add(new ColumnDto("工程专业", "majorName", 180, null, false, null,null)); |
| | | columnDto.add(new ColumnDto("节点名称", "ProcessName", 160, null, true, null,null)); |
| | | columnDto.add(new ColumnDto("要求完成时间", "requiredCompletionTime", 120, "selectDate", true, null,null)); |
| | | columnDto.add(new ColumnDto("操作", "", 85, "", true, buttonList,null)); |
| | | |
| | | JTable subTable = CommonTable.createCommonTable(list, columnDto); |
| | | subTable.setRowHeight(25); |
| | | subTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); |
| | | |
| | | subTable.getModel().addTableModelListener(e -> { |
| | | // 检查事件类型 |
| | | if (e.getType() == TableModelEvent.UPDATE) { |
| | | // 获取变化的行和列 |
| | | int row = e.getFirstRow(); |
| | | int column = e.getColumn(); |
| | | |
| | | // 获取新的值 |
| | | Object newValue = subTable.getModel().getValueAt(row, column); |
| | | // 输出变化信息 |
| | | if (newValue.equals("del")) { |
| | | DefaultTableModel model = (DefaultTableModel) subTable.getModel(); |
| | | model.removeRow(row); |
| | | DjJdgzNetworkLevel2List djJdgzNetworkLevel2List = list.get(row); |
| | | level2ListService.deleteLogic(djJdgzNetworkLevel2List.getId()); |
| | | list.remove(row); |
| | | } else { |
| | | |
| | | } |
| | | System.out.println("单元格变化: 行=" + row + ", 列=" + column + ", 新值=" + newValue); |
| | | } |
| | | }); |
| | | |
| | | JScrollPane scrollTable = new JScrollPane(subTable); |
| | | jLeft.add(topJpanel, BorderLayout.NORTH); |
| | |
| | | |
| | | mxGraph graph = new mxGraph(); |
| | | DjJdgzNetworkLevel2 djJdgzNetworkLevel2 = level2Service.get(data.getId()); |
| | | graph = netWorkDiagramService.getCsDiagram(graph,djJdgzNetworkLevel2.getContent(),null,diagram.getWidth(),diagram.getHeight()); |
| | | graph = netWorkDiagramService.getCsDiagram(graph,djJdgzNetworkLevel2.getContent(),null,diagram.getWidth(),diagram.getHeight(),null); |
| | | mxGraphComponent graphComponent = new mxGraphComponent(graph); |
| | | graphComponent.setConnectable(false); |
| | | graphComponent.setDragEnabled(false); |
| | | graphComponent.zoomTo(2, true); |
| | | graphComponent.zoomTo(1, true); |
| | | diagram.add(graphComponent); |
| | | |
| | | mxGraph finalGraph = graph; |
| | |
| | | } |
| | | }); |
| | | |
| | | btnInsert.addActionListener(new ActionListener() { |
| | | @Override |
| | | public void actionPerformed(ActionEvent e) { |
| | | TableModel model = subTable.getModel(); |
| | | DefaultTableModel defaultModel = (DefaultTableModel) model; |
| | | int columnCount = subTable.getColumnCount(); |
| | | Object[] emptyRow = new Object[columnCount]; |
| | | defaultModel.addRow(emptyRow); |
| | | list.add(new DjJdgzNetworkLevel2List()); |
| | | } |
| | | }); |
| | | |
| | | mxGraph finalGraph1 = graph; |
| | | btnSave.addActionListener(new ActionListener() { |
| | | @Override |
| | | public void actionPerformed(ActionEvent e) { |
| | | SysUser user = (SysUser) UserAndSiteUtils.get("user","user"); |
| | | if (user==null){ |
| | | JOptionPane.showMessageDialog(null, "用户失效请退出并重新登录", "提示", JOptionPane.WARNING_MESSAGE); |
| | | return; |
| | | } |
| | | if (subTable.isEditing()) { |
| | | subTable.getCellEditor().stopCellEditing(); |
| | | } |
| | | CommonTable.saveTableList(list,subTable,columnDto); |
| | | level2ListService.save(list,data.getId(),diagram, finalGraph); |
| | | JOptionPane.showMessageDialog(null, "保存成功", "提示", JOptionPane.WARNING_MESSAGE); |
| | | |
| | | } |
| | | }); |
| | | |
| | | btnImport.addActionListener(new ActionListener() { |
| | | @Override |
| | | public void actionPerformed(ActionEvent e) { |
| | | importService.FileUpload(data.getId(),columnDto,subTable,diagram,finalGraph1); |
| | | importService.FileUpload(data.getId(),columnDto,subTable,diagram,finalGraph); |
| | | } |
| | | }); |
| | | } |