|
13 | 13 | import java.util.Set; |
14 | 14 | import java.util.regex.Matcher; |
15 | 15 | import java.util.regex.Pattern; |
16 | | -import java.util.stream.Collectors; |
17 | 16 |
|
18 | 17 | import org.apache.commons.configuration2.PropertiesConfiguration; |
19 | 18 | import org.apache.log4j.Logger; |
|
63 | 62 | import root.core.domain.JschConnectionInfo; |
64 | 63 | import root.core.repository.constracts.PropertyRepository; |
65 | 64 | import root.core.repository.implement.PropertyRepositoryImpl; |
66 | | -import root.javafx.Service.DatabaseConnectService; |
67 | | -import root.utils.AlertUtils; |
| 65 | +import root.javafx.CustomView.ConnectionInfoVBox; |
| 66 | +import root.javafx.CustomView.DBConnectionInfoAnchorPane; |
68 | 67 | import root.utils.PropertiesUtils; |
69 | 68 |
|
70 | 69 | public class SettingMenuController implements Initializable { |
@@ -120,6 +119,9 @@ public class SettingMenuController implements Initializable { |
120 | 119 | @FXML |
121 | 120 | FlowPane connectInfoFlowPane; // DB접속정보 VBOX, Server접속정보 VOX를 담는 컨테이너 |
122 | 121 |
|
| 122 | + @FXML |
| 123 | + VBox connInfoVBox; |
| 124 | + |
123 | 125 | @FXML |
124 | 126 | StackPane dbConnInfoStackPane; // DB접속정보 설정 그리드를 담는 컨테이너 |
125 | 127 |
|
@@ -404,8 +406,8 @@ private void loadSelectedConfigFile(String absoluteFilePath) { |
404 | 406 | createSettingDynamicElements(); |
405 | 407 |
|
406 | 408 | // 4. 첫번째 접속정보를 맨 앞으로 가져온다. |
407 | | - bringFrontConnInfoAnchorPane(dbConnInfoIdxMap, 0, dbInfoCntText); |
408 | | - bringFrontConnInfoAnchorPane(serverConnInfoIdxMap, 0, serverInfoCntText); |
| 409 | + //bringFrontConnInfoAnchorPane(dbConnInfoIdxMap, 0, dbInfoCntText); |
| 410 | + //bringFrontConnInfoAnchorPane(serverConnInfoIdxMap, 0, serverInfoCntText); |
409 | 411 |
|
410 | 412 | // 5. remember.properties 파일에 최근 사용된 설정파일 경로를 저장한다. |
411 | 413 | PropertiesConfiguration rememberConfig = propertyRepository.getConfiguration("rememberConfig"); |
@@ -444,7 +446,7 @@ private void loadMonitoringConfigFile(String filePath) { |
444 | 446 |
|
445 | 447 | propertyRepository.loadMonitoringInfoConfig(filePath); |
446 | 448 |
|
447 | | - createMonitoringElements(monitoringElementsVBox, dbMonitorings, dbNames); |
| 449 | + // createMonitoringElements(monitoringElementsVBox, dbMonitorings, dbNames); |
448 | 450 | createMonitoringElements(monitoringElementsVBox, serverMonitorings, serverNames); |
449 | 451 | } |
450 | 452 |
|
@@ -1117,36 +1119,40 @@ private void createSettingDynamicElements() { |
1117 | 1119 | boolean createResult = false; |
1118 | 1120 |
|
1119 | 1121 | try { |
1120 | | - // 기존 요소 초기화 |
1121 | | - dbConnInfoIdx = 0; |
1122 | | - serverConnInfoIdx = 0; |
1123 | | - dbConnInfoStackPane.getChildren().removeIf(c -> !c.getId().contains("noPropertiesFileAP2")); |
1124 | | - serverConnInfoStackPane.getChildren().removeIf(c -> !c.getId().contains("noPropertiesFileAP1")); |
1125 | | - dbConnInfoIdxMap.clear(); |
1126 | | - serverConnInfoIdxMap.clear(); |
1127 | | - |
| 1122 | + alcMap = PropertiesUtils.getAlertLogCommandMap(); |
| 1123 | + |
1128 | 1124 | dbNames = propertyRepository.getMonitoringDBNames(); |
1129 | | - serverNames = propertyRepository.getMonitoringServerNames(); |
| 1125 | + jdbcConnInfoList = PropertiesUtils.getJdbcConnectionMap(); |
1130 | 1126 |
|
1131 | | - jdbcConnInfoList = PropertiesUtils.getJdbcConnectionMap(); |
1132 | | - jschConnInfoList = PropertiesUtils.getJschConnectionMap(); |
1133 | | - alcMap = PropertiesUtils.getAlertLogCommandMap(); |
| 1127 | + ConnectionInfoVBox dbConnVBox = new ConnectionInfoVBox(); |
| 1128 | + connInfoVBox.getChildren().add(dbConnVBox); |
1134 | 1129 |
|
1135 | | - // [설정] - [모니터링 여부 설정] |
1136 | | - reloadingMonitoringSetting(""); |
| 1130 | + for (JdbcConnectionInfo jdbc : jdbcConnInfoList) { |
| 1131 | + |
| 1132 | + DBConnectionInfoAnchorPane dbConnAP = new DBConnectionInfoAnchorPane(); |
| 1133 | + dbConnAP.getDriverCB().getItems().addAll(propertyRepository.getOracleDrivers()); |
| 1134 | + dbConnAP.setInitialValue(jdbc); |
1137 | 1135 |
|
1138 | | - // [설정] - [접속정보 설정] TAB 동적 요소 생성 |
1139 | | - if (jdbcConnInfoList.size() == 0) { // DB 접속정보 없음 |
1140 | | - dbConnInfoNoDataAP.setVisible(true); |
1141 | | - dbInfoCntText.setText("※프로퍼티파일을 열거나 접속정보를 추가해주세요."); |
1142 | | - } else { |
1143 | | - dbConnInfoNoDataAP.setVisible(true); |
1144 | | - jdbcConnInfoList.forEach(info -> { |
1145 | | - createJdbcConnInfoElements(dbConnInfoStackPane, info, info.getJdbcDBName()); |
1146 | | - }); |
1147 | | - dbInfoCntText.setText("(" + (dbConnInfoIdx + 1) + "/" + dbConnInfoIdxMap.size() + ")"); |
| 1136 | + dbConnVBox.addConnectionInfoAP(dbConnAP); |
1148 | 1137 | } |
1149 | 1138 |
|
| 1139 | + // [설정] - [접속정보 설정] TAB 동적 요소 생성 |
| 1140 | +// if (connInfoList.size() == 0) { // DB 접속정보 없음 |
| 1141 | +// connInfoNoDataAP.setVisible(true); |
| 1142 | +// connInfoCntText.setText("※프로퍼티파일을 열거나 접속정보를 추가해주세요."); |
| 1143 | +// } else { |
| 1144 | +// connInfoNoDataAP.setVisible(true); |
| 1145 | +// connInfoList.forEach(info -> { |
| 1146 | +//// createJdbcConnInfoElements(connInfoStackPane, info, "info.getJdbcDBName()"); |
| 1147 | +// }); |
| 1148 | +// connInfoCntText.setText("(" + (connInfoIdx + 1) + "/" + connInfoIdxMap.size() + ")"); |
| 1149 | +// } |
| 1150 | + |
| 1151 | + |
| 1152 | + |
| 1153 | + // [설정] - [모니터링 여부 설정] |
| 1154 | + reloadingMonitoringSetting(""); |
| 1155 | + |
1150 | 1156 | if (jschConnInfoList.size() == 0) { // 서버 접속정보 없음 |
1151 | 1157 | serverConnInfoNoDataAP.setVisible(true); |
1152 | 1158 | serverInfoCntText.setText("※프로퍼티파일을 열거나 접속정보를 추가해주세요."); |
@@ -1224,64 +1230,6 @@ private void reloadingMonitoringSetting(String presetName) { |
1224 | 1230 | } |
1225 | 1231 | } |
1226 | 1232 |
|
1227 | | - /** |
1228 | | - * [설정] - [접속정보설정] - 입력된 설정 값으로 DB 연동 테스트를 시도한다. |
1229 | | - * |
1230 | | - * @param e |
1231 | | - */ |
1232 | | - public void testDbConnection(ActionEvent e) { |
1233 | | - // TODO dbConnInfoAP에 접속정보가 입력되어있는지 확인 (입력값 검사) |
1234 | | - // TODO 입력되어있지 않으면 버튼 비활성화 |
1235 | | - |
1236 | | - // 아이콘 변경 |
1237 | | - FontAwesomeIconView icon = (FontAwesomeIconView) dbConnTestBtn.lookup("#icon"); |
1238 | | - icon.setIcon(FontAwesomeIcon.SPINNER); |
1239 | | - icon.setFill(Paint.valueOf("#484989")); |
1240 | | - icon.getStyleClass().add("fa-spin"); |
1241 | | - |
1242 | | - AnchorPane curAP = dbConnInfoIdxMap.get(dbConnInfoIdx); |
1243 | | - |
1244 | | - // Get element Id |
1245 | | - String curAPId = curAP.getId(); |
1246 | | - int startIdx = curAPId.indexOf("dbConnInfo") + 10; |
1247 | | - int endIdx = curAPId.lastIndexOf("AP"); |
1248 | | - String elementId = curAPId.substring(startIdx, endIdx); |
1249 | | - |
1250 | | - // Get TextFields |
1251 | | - Map<String, String> textFieldMap = curAP.lookupAll("TextField").stream() |
1252 | | - .collect(Collectors.toMap(Node::getId, (n) -> ((TextField) n).getText())); |
1253 | | - |
1254 | | - String jdbcUrl = textFieldMap.get(elementId + "UrlTextField"); |
1255 | | - String jdbcId = textFieldMap.get(elementId + "UserTextField"); |
1256 | | - |
1257 | | - // Get PasswordField |
1258 | | - Map<String, String> passwordFieldMap = curAP.lookupAll("PasswordField").stream() |
1259 | | - .collect(Collectors.toMap(Node::getId, (n) -> ((PasswordField) n).getText())); |
1260 | | - |
1261 | | - String jdbcPw = passwordFieldMap.get(elementId + "PasswordTextField"); |
1262 | | - |
1263 | | - // TODO JdbcDriver, Validation Query 하드코딩 변경 - DBMS에 따라 다르게 해야 함 |
1264 | | - JdbcConnectionInfo jdbc = new JdbcConnectionInfo("oracle.jdbc.driver.OracleDriver", jdbcUrl, jdbcId, jdbcPw, |
1265 | | - "SELECT 1 FROM DUAL", 1); |
1266 | | - |
1267 | | - DatabaseConnectService dbConnService = new DatabaseConnectService(jdbc); |
1268 | | - dbConnService.setOnSucceeded(s -> { |
1269 | | - AlertUtils.showAlert(AlertType.INFORMATION, "DB 연동테스트", |
1270 | | - String.format(DatabaseConnectService.SUCCESS_MSG, jdbc.getJdbcUrl(), jdbc.getJdbcDriver())); |
1271 | | - icon.setIcon(FontAwesomeIcon.CHECK); |
1272 | | - icon.setFill(Paint.valueOf("#49a157")); |
1273 | | - }); |
1274 | | - |
1275 | | - dbConnService.setOnFailed(f -> { |
1276 | | - AlertUtils.showAlert(AlertType.ERROR, "DB 연동테스트", |
1277 | | - String.format(DatabaseConnectService.FAIL_MSG, jdbc.getJdbcUrl(), jdbc.getJdbcDriver())); |
1278 | | - icon.setIcon(FontAwesomeIcon.TIMES); |
1279 | | - icon.setFill(Paint.valueOf("#c40a0a")); |
1280 | | - }); |
1281 | | - |
1282 | | - dbConnService.start(); |
1283 | | - } |
1284 | | - |
1285 | 1233 | /** |
1286 | 1234 | * [설정] - [접속정보설정] - 입력된 설정 값으로 Server 연동 테스트를 시도한다. |
1287 | 1235 | * |
|
0 commit comments