コード例 #1
0
 private void saveData() {
   String path = jtfConfigPath.getText();
   if (path == null || path.length() < 1) {
     JOptionPane.showMessageDialog(this, "文件目录不能为空!");
     return;
   }
   List<String> addList = new ArrayList<>();
   List<String> upList = new ArrayList<>();
   Properties config = LocalResourcesUtil.getProperties(path);
   for (int i = 0; i < tmDbInfo.getRowCount(); i++) {
     String code = tmDbInfo.getValueAt(i, 0).toString();
     if (config.containsKey(code)) {
       upList.add(config.getProperty(code));
       config.remove(code);
     } else {
       addList.add(StringUtils.unite(code, "DBConfig.properties"));
     }
   }
   StringBuilder sb = new StringBuilder();
   sb.append(StringUtils.unite("本次\r\n新增:", addList, "\r\n"));
   sb.append(StringUtils.unite("修改:", upList, "\r\n"));
   sb.append(StringUtils.unite("删除:", config.values(), "\r\n"));
   int isOk =
       JOptionPane.showConfirmDialog(this, sb.toString(), "确认要保存吗?", JOptionPane.OK_CANCEL_OPTION);
   if (isOk == 0) {
     if (tmDbInfo.saveList(path)) {
       JOptionPane.showMessageDialog(this, "保存成功!");
     } else {
       JOptionPane.showMessageDialog(this, "保存失败。");
     }
   }
 }
コード例 #2
0
 private void addData() {
   DBType dbType =
       (DBType)
           JOptionPane.showInputDialog(
               null,
               "请选择模版:",
               "数据库类型",
               JOptionPane.PLAIN_MESSAGE,
               null,
               DBType.values(),
               DBType.valueOf("MYSQL"));
   if (dbType == null) {
     return;
   }
   DBConnectionInfo dbInfo = ConfigDbUtil.init().getInitDBConnectionInfo(dbType);
   tmDbInfo.addRow(dbInfo);
   jtDbinfo.updateUI();
 }
コード例 #3
0
 public void loadFile() {
   if (jtfConfigPath.getText().trim().length() < 1) {
     JOptionPane.showMessageDialog(this, "文件目录不能为空!");
     return;
   }
   new Thread() {
     public void run() {
       load();
     }
   }.start();
   Properties properties = LocalResourcesUtil.getProperties(jtfConfigPath.getText());
   Iterator<Object> dbsKeys = properties.keySet().iterator();
   String path = jtfConfigPath.getText();
   path = path.substring(0, path.lastIndexOf(File.separator) + 1);
   while (dbsKeys.hasNext()) {
     String key = dbsKeys.next().toString().trim();
     String value = properties.getProperty(key).trim();
     Properties dbConfig = LocalResourcesUtil.getProperties(StringUtils.unite(path, value));
     DBConnectionInfo dbinfo = new DBConnectionInfo(key, dbConfig);
     tmDbInfo.addRow(dbinfo);
   }
   jtDbinfo.updateUI();
   jpbLoading.setValue(100);
 }
コード例 #4
0
 private void removeDatas() {
   tmDbInfo.removeRows();
   jtDbinfo.updateUI();
 }
コード例 #5
0
 private void removeData() {
   tmDbInfo.removeRow(jtDbinfo.getSelectedRows());
   jtDbinfo.updateUI();
 }