|
7 | 7 | import java.util.Map; |
8 | 8 | import java.util.Optional; |
9 | 9 | import java.util.ResourceBundle; |
10 | | -import java.util.regex.Pattern; |
11 | 10 |
|
12 | 11 | import org.apache.commons.configuration2.PropertiesConfiguration; |
13 | 12 | import org.apache.log4j.Logger; |
@@ -64,8 +63,6 @@ public class SettingMenuController implements Initializable { |
64 | 63 | * - 따라서, 한 번 생성하두고 이를 재사용하는 것이 효과적이다. |
65 | 64 | * - 뿐만 아니라, 패턴 객체에 이름을 부여하여 해당 객체의 의미가 명확해진다. |
66 | 65 | */ |
67 | | - private static Pattern DB_CONNINFO_AP_NAME_PATTERN = Pattern.compile("dbConnInfo(.*)AP"); |
68 | | - private static Pattern SERVER_CONNINFO_AP_NAME_PATTERN = Pattern.compile("serverConnInfo(.*)AP"); |
69 | 66 |
|
70 | 67 | /* Dependency Injection */ |
71 | 68 | PropertyRepository propertyRepository = PropertyRepositoryImpl.getInstance(); |
@@ -187,9 +184,9 @@ public void showMonitoringPresetPopup(ActionEvent e) { |
187 | 184 | } |
188 | 185 |
|
189 | 186 | /** |
190 | | - * [설정] - [접속정보 설정] - .properties 파일을 선택하기 위한 FileChooser를 연다. 사용자가 선택한 파일의 경로에서 |
191 | | - * 파일을 읽은 후, 올바른 설정파일이라면 해당 경로를 remember.properties에 저장한다. 그렇지 않다면, '잘못된 |
192 | | - * 파일입니다'라는 경고를 띄우고 접속정보를 직접 설정하는 화면으로 이동시킨다. |
| 187 | + * [설정] - [접속정보 설정] - .properties 파일을 선택하기 위한 FileChooser를 연다. |
| 188 | + * 사용자가 선택한 파일의 경로에서 파일을 읽은 후, 올바른 설정파일이라면 해당 경로를 remember.properties에 저장한다. |
| 189 | + * 그렇지 않다면, '잘못된파일입니다'라는 경고를 띄우고 접속정보를 직접 설정하는 화면으로 이동시킨다. |
193 | 190 | * |
194 | 191 | * @param e |
195 | 192 | */ |
@@ -291,117 +288,13 @@ public void saveConnInfoSettings(ActionEvent e) { |
291 | 288 | // TODO 입력값 검사 |
292 | 289 |
|
293 | 290 | String configFilePath = fileChooserText.getText(); |
294 | | - PropertiesConfiguration config = PropertiesUtils.connInfoConfig; |
295 | 291 |
|
296 | 292 | ConnectionInfoVBox dbConnVBox = (ConnectionInfoVBox) connInfoVBox.lookup("#dbConnVBox"); |
297 | | - dbConnVBox.saveConnInfoSettings("configFilePath"); |
298 | | - |
299 | | - /* |
300 | | - * 서버 접속정보 StackPane에서 얻어내야 할 데이터 |
301 | | - * |
302 | | - * (TextField) {ServerName}HostTextField {ServerName}.server.host (TextField) |
303 | | - * {ServerName}PortTextField {ServerName}.server.port (TextField) |
304 | | - * {ServerName}NameTextField {ServerName} (TextField) |
305 | | - * {ServerName}UserNameTextField {ServerName}.server.username (TextField) |
306 | | - * {ServerName}AlertLogFilePathTextField {ServerName}.server.alertlog.filepath |
307 | | - * (PasswordField) {ServerName}PasswordTextField {ServerName}.server.password |
308 | | - * (JFXComboBox) {ServerName}AlertLogDateFormatComboBox |
309 | | - * {ServerName}.server.alertlog.dateformat |
310 | | - */ |
| 293 | + dbConnVBox.saveConnInfoSettings(configFilePath); |
311 | 294 |
|
312 | | - /* |
313 | | - List<String> serverNames = new ArrayList<String>(Arrays.asList(config.getStringArray("servernames"))); |
314 | 295 | ConnectionInfoVBox serverConnVBox = (ConnectionInfoVBox) connInfoVBox.lookup("#serverConnVBox"); |
315 | | - for (AnchorPane ap : serverConnVBox.getConnInfoAPMap().values()) { |
316 | | - String apId = ap.getId(); |
317 | | -
|
318 | | - Matcher m = SERVER_CONNINFO_AP_NAME_PATTERN.matcher(apId); |
319 | | - if (m.matches()) { |
320 | | - String elementId = m.group(1); |
321 | | - String newElementId = elementId; |
322 | | - boolean isNewConnInfo = false; |
323 | | -
|
324 | | - // 새로 추가된 접속정보 |
325 | | - if (!serverNames.contains(elementId)) { |
326 | | - Set<Node> textFields = ap.lookupAll("TextField"); |
327 | | - for (Node n : textFields) { |
328 | | - if (((TextField) n).getId().equals(elementId + "NameTextField")) { |
329 | | - isNewConnInfo = true; |
330 | | - newElementId = ((TextField) n).getText(); |
331 | | - logger.debug("NEW ServerName : " + newElementId); |
332 | | - break; |
333 | | - } |
334 | | - } |
335 | | - } |
336 | | -
|
337 | | - String elementIdLower = newElementId.toLowerCase(); |
338 | | -
|
339 | | - // ServerNames 추가 |
340 | | - if (isNewConnInfo) { |
341 | | - serverNames.add(newElementId); |
342 | | - config.setProperty("#Server", newElementId); |
343 | | - config.setProperty(elementIdLower + ".server.alertlog.readLine", 500); |
344 | | - } |
345 | | -
|
346 | | - // TextField Value Update |
347 | | - Set<Node> textFields = ap.lookupAll("TextField"); |
348 | | - for (Node n : textFields) { |
349 | | - TextField tf = (TextField) n; |
350 | | - String tfId = tf.getId(); |
351 | | - String tfText = tf.getText(); |
352 | | -
|
353 | | - if (tfId.equals(elementId + "HostTextField")) { |
354 | | - config.setProperty(elementIdLower + ".server.host", tfText); |
355 | | - } else if (tfId.equals(elementId + "PortTextField")) { |
356 | | - config.setProperty(elementIdLower + ".server.port", tfText); |
357 | | - } else if (tfId.equals(elementId + "UserNameTextField")) { |
358 | | - config.setProperty(elementIdLower + ".server.username", tfText); |
359 | | - } else if (tfId.equals(elementId + "AlertLogFilePathTextField")) { |
360 | | - config.setProperty(elementIdLower + ".server.alertlog.filepath", tfText); |
361 | | - } |
362 | | - } |
363 | | -
|
364 | | - // PasswordField Value Update |
365 | | - Set<Node> passwordFields = ap.lookupAll("PasswordField"); |
366 | | - for (Node n : passwordFields) { |
367 | | - PasswordField pf = (PasswordField) n; |
368 | | - String pfId = pf.getId(); |
369 | | - String pfText = pf.getText(); |
370 | | -
|
371 | | - if (pfId.equals(elementId + "PasswordTextField")) { |
372 | | - config.setProperty(elementIdLower + ".server.password", pfText); |
373 | | - } |
374 | | - } |
375 | | -
|
376 | | - // JFXComboBox Value Update |
377 | | - Set<Node> comboBoxs = ap.lookupAll("JFXComboBox"); |
378 | | - for (Node n : comboBoxs) { |
379 | | - @SuppressWarnings("unchecked") |
380 | | - JFXComboBox<String> cb = (JFXComboBox<String>) n; |
381 | | - String cbId = cb.getId(); |
382 | | - String cbSelectedItem = cb.getSelectionModel().getSelectedItem(); |
383 | | -
|
384 | | - if (cbId.equals(elementId + "AlertLogDateFormatComboBox")) { |
385 | | - config.setProperty(elementIdLower + ".server.alertlog.dateformat", cbSelectedItem); |
386 | | - if (isNewConnInfo) { |
387 | | - String dateFormatRegex = ""; |
388 | | - if (cbSelectedItem.equals("EEE MMM dd HH:mm:ss yyyy")) { |
389 | | - dateFormatRegex = "...\\s...\\s([0-2][0-9]|1[012])\\s\\d\\d:\\d\\d:\\d\\d\\s\\d{4}"; |
390 | | - } else if (cbSelectedItem.equals("yyyy-MM-dd")) { |
391 | | - dateFormatRegex = "\\d{4}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T"; |
392 | | - } |
393 | | - config.setProperty(elementIdLower + ".server.alertlog.dateformatregex", dateFormatRegex); |
394 | | - } |
395 | | - } |
396 | | - } |
397 | | - } |
398 | | - } |
399 | | - // ServerNames Update |
400 | | - config.setProperty("servernames", serverNames); |
401 | | - */ |
| 296 | + serverConnVBox.saveConnInfoSettings(configFilePath); |
402 | 297 |
|
403 | | - // 변경사항 저장 |
404 | | - propertyRepository.save(configFilePath, config); |
405 | 298 | // 설정파일 ReLoading |
406 | 299 | loadSelectedConfigFile(configFilePath); |
407 | 300 | } |
|
0 commit comments