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