| | |
| | | |
| | | public JPanel FileUpload(JFrame frame, Integer width, Integer heigth) { |
| | | JPanel jPanel = new JPanel(); |
| | | /*GridBagLayout layout = new GridBagLayout(); |
| | | jPanel.setLayout(layout);*/ |
| | | jPanel.setPreferredSize(new Dimension(width, heigth)); |
| | | |
| | | JTable table = new JTable(); |
| | |
| | | |
| | | |
| | | JScrollPane scrolltable = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); |
| | | |
| | | scrolltable.setPreferredSize(new Dimension(width-150,heigth)); |
| | | scrolltable.setViewportView(table); |
| | | scrolltable.getViewport().setBackground(Color.WHITE); |
| | | |
| | | JButton browseButton = new JButton("选择文件"); |
| | | jPanel.add(browseButton); |
| | | |
| | | jPanel.add(scrolltable); |
| | | jPanel.add(browseButton); |
| | | |
| | | |
| | | browseButton.addActionListener(new ActionListener() { |
| | | @Override |
| | |
| | | |
| | | model.setDataVector(data, columnIdentifiers); |
| | | table.setModel(model); |
| | | table.getColumnModel().getColumn(0).setPreferredWidth(600); |
| | | table.getColumnModel().getColumn(1).setPreferredWidth(100); |
| | | table.getColumnModel().getColumn(0).setPreferredWidth(550); |
| | | table.getColumnModel().getColumn(1).setPreferredWidth(150); |
| | | |
| | | |
| | | table.getColumnModel().getColumn(0).setCellRenderer(new TableViewRenderer()); |
| | |
| | | }); |
| | | return jPanel; |
| | | } |
| | | public String UnzipFile(){ |
| | | public String UnzipFile(JTextArea tips){ |
| | | String massage = ""; |
| | | String filePath = model.getValueAt(0, 0).toString(); |
| | | String outputDirectory = UnzipPath; |
| | | try { |
| | | |
| | | File zipFile = new File(filePath); |
| | | if (!zipFile.exists()) { |
| | | massage = "ZIP文件不存在:" + filePath; |
| | | tips.setText(tips.getText() + massage); |
| | | throw new FileNotFoundException("ZIP文件不存在:" + filePath); |
| | | } |
| | | if (!zipFile.canRead()) { |
| | | massage = "无法读取ZIP文件,请检查文件权限:" + filePath; |
| | | tips.setText(tips.getText() + massage); |
| | | System.err.println("无法读取ZIP文件,请检查文件权限:" + filePath); |
| | | return "false"; |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | System.out.println("文件解压完成,目标目录:" + outputDirectory); |
| | | dataSyncService.importData(); |
| | | massage = "文件解压完成,目标目录:" + outputDirectory; |
| | | tips.setText(tips.getText() + massage); |
| | | dataSyncService.importData(tips); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | return "false"; |