2020import javafx .event .ActionEvent ;
2121import javafx .fxml .FXML ;
2222import javafx .fxml .Initializable ;
23- import javafx .geometry .Pos ;
2423import javafx .scene .Node ;
25- import javafx .scene .control .Alert ;
2624import javafx .scene .control .Alert .AlertType ;
2725import javafx .scene .control .ButtonBar .ButtonData ;
2826import javafx .scene .control .ButtonType ;
29- import javafx .scene .control .Label ;
3027import javafx .scene .control .Separator ;
3128import javafx .scene .control .SplitPane ;
3229import javafx .scene .control .TextField ;
3330import javafx .scene .control .TextInputDialog ;
3431import javafx .scene .image .Image ;
3532import javafx .scene .layout .AnchorPane ;
36- import javafx .scene .layout .FlowPane ;
37- import javafx .scene .layout .HBox ;
3833import javafx .scene .layout .VBox ;
39- import javafx .scene .paint .Paint ;
40- import javafx .scene .text .TextAlignment ;
4134import javafx .stage .FileChooser ;
4235import javafx .stage .FileChooser .ExtensionFilter ;
4336import javafx .stage .Stage ;
5245import root .core .service .implement .FilePropertyService ;
5346import root .javafx .CustomView .ConnectionInfoVBox ;
5447import root .javafx .CustomView .DBConnInfoControl ;
48+ import root .javafx .CustomView .MonitoringYNVBox ;
5549import root .javafx .CustomView .ServerConnInfoControl ;
5650import root .javafx .CustomView .dialogUI .CustomTextInputDialog ;
5751import root .utils .AlertUtils ;
@@ -263,9 +257,7 @@ public void openFileChooser(ActionEvent e) {
263257 // 파일 선택창 열고, 선택된 파일 반환받음
264258 File selectedFile = fileChooser .showOpenDialog ((Stage ) rootSplitPane .getScene ().getWindow ());
265259
266- if (selectedFile == null ) {
267- // NOTHING
268- } else {
260+ if (selectedFile != null ) {
269261 if (selectedFile .isFile () && selectedFile .exists ()) {
270262 // 올바른 파일
271263 String filePath = selectedFile .getAbsolutePath ();
@@ -283,8 +275,6 @@ public void openFileChooser(ActionEvent e) {
283275 * @param filePath
284276 */
285277 private void loadSelectedConfigFile (String absoluteFilePath ) {
286- boolean loadResult = false ;
287-
288278 try {
289279 // 1. 절대경로를 상대경로로 변환한다.
290280 int startIdx = absoluteFilePath .lastIndexOf ("\\ config" );
@@ -296,6 +286,7 @@ private void loadSelectedConfigFile(String absoluteFilePath) {
296286 // 3. 프로퍼티파일에 작성된 내용에 따라 동적 요소를 생성한다.
297287 createSettingDynamicElements ();
298288
289+ // TODO move this logic to PropertyService
299290 // 4. remember.properties 파일에 최근 사용된 설정파일 경로를 저장한다.
300291 PropertiesConfiguration rememberConfig = propRepo .getConfiguration ("rememberConfig" );
301292 rememberConfig .setProperty ("filepath.config.lastuse" , filePath .replace ("\\ " , "/" ));
@@ -304,25 +295,12 @@ private void loadSelectedConfigFile(String absoluteFilePath) {
304295 // 5. fileChooserText의 텍스트를 현재 선택된 파일경로로 변경한다.
305296 fileChooserText .setText (filePath );
306297
307- loadResult = true ;
308- } catch (Exception e1 ) {
309- e1 .printStackTrace ();
310- } finally {
311-
312- // 6. 파일 load가 완료되었다는 메시지를 띄운다.
313- if (loadResult ) {
314- Alert successAlert = new Alert (AlertType .INFORMATION );
315- successAlert .setHeaderText ("설정파일 불러오기" );
316- successAlert .setContentText ("설정파일을 정상적으로 불러왔습니다." );
317- successAlert .getDialogPane ().setStyle ("-fx-font-family: NanumGothic;" );
318- successAlert .show ();
319- } else {
320- Alert failAlert = new Alert (AlertType .ERROR );
321- failAlert .setHeaderText ("설정파일 불러오기" );
322- failAlert .setContentText ("설정파일 불러오기에 실패했습니다. 설정파일을 확인해주세요." );
323- failAlert .getDialogPane ().setStyle ("-fx-font-family: NanumGothic;" );
324- failAlert .show ();
325- }
298+ } catch (Exception e ) {
299+ e .printStackTrace ();
300+ // 6. 파일 load가 실패 시, Alert 메시지를 띄운다.
301+ String headerText = "설정파일 불러오기" ;
302+ String contentText = "설정파일 불러오기에 실패했습니다. 설정파일을 확인해주세요." ;
303+ AlertUtils .showAlert (AlertType .ERROR , headerText , contentText );
326304 }
327305 }
328306
@@ -382,6 +360,7 @@ public void saveConnInfoSettings(ActionEvent e) {
382360 * @param e
383361 */
384362 public void saveMonitoringSettings (ActionEvent e ) {
363+ // TODO move this logic to PropertyService
385364 PropertiesConfiguration config = propRepo .getConfiguration ("monitoringConfig" );
386365 String presetName = monitoringPresetComboBox .getSelectionModel ().getSelectedItem ();
387366 String monitoringFilePath = monitoringPresetMap .get (presetName );
@@ -392,13 +371,12 @@ public void saveMonitoringSettings(ActionEvent e) {
392371 config .setProperty (thisToggle .getId (), thisToggle .isSelected ());
393372 }
394373 propRepo .save (monitoringFilePath , config );
374+
395375 loadMonitoringConfigFile (monitoringFilePath );
396376
397- Alert failAlert = new Alert (AlertType .INFORMATION );
398- failAlert .setHeaderText ("설정 저장" );
399- failAlert .setContentText ("모니터링여부 설정이 저장되었습니다." );
400- failAlert .getDialogPane ().setStyle ("-fx-font-family: NanumGothic;" );
401- failAlert .show ();
377+ String headerText = "설정 저장" ;
378+ String contentText = "모니터링여부 설정이 저장되었습니다." ;
379+ AlertUtils .showAlert (AlertType .INFORMATION , headerText , contentText );
402380 }
403381 }
404382
@@ -407,130 +385,22 @@ public void saveMonitoringSettings(ActionEvent e) {
407385 *
408386 * @param rootVBox
409387 * @param monitoringElements
410- * @param elementContents
388+ * @param monitoringAlias
411389 */
412- private void createMonitoringElements (VBox rootVBox , String [] monitoringElements , String [] elementContents ) {
413- for (String mName : monitoringElements ) {
414- // String headerToggleId = mName.replaceAll("\\s", "") + "TotalToggleBtn";
415- String headerToggleId = mName .replaceAll ("\\ s" , "" ) + "TotalToggleBtn" ;
416-
417- // Header
418- VBox eachWrapVBox = new VBox ();
419- eachWrapVBox .setFillWidth (true );
420-
421- HBox headerHBox = new HBox ();
422- headerHBox .setFillHeight (true );
423- headerHBox .setPrefHeight (40 );
424-
425- Label headerLabel = new Label ();
426- headerLabel .setText (mName );
427- headerLabel .setTextAlignment (TextAlignment .LEFT );
428- headerLabel .setAlignment (Pos .CENTER_LEFT );
429- headerLabel .setPrefWidth (200 );
430- headerLabel .setPrefHeight (40 );
431- headerLabel .getStylesheets ().add (System .getProperty ("resourceBaseDir" ) + "/css/javaFx.css" );
432- headerLabel .getStyleClass ().add ("basic-font" );
433- headerLabel .setStyle ("-fx-font-size: 13px" );
434-
435- JFXToggleButton headerToggleBtn = new JFXToggleButton ();
436- headerToggleBtn .setId (headerToggleId );
437- headerToggleBtn .setSize (6 );
438- headerToggleBtn .setToggleColor (Paint .valueOf ("#0132ac" ));
439- headerToggleBtn .setToggleLineColor (Paint .valueOf ("#6e93ea" ));
440- headerToggleBtn .setAlignment (Pos .CENTER );
441- headerToggleBtn .setSelected (propRepo .isMonitoringContent (headerToggleId ));
442- headerToggleBtn .setOnAction ((ActionEvent e ) -> {
443- boolean isSelected = ((JFXToggleButton ) e .getSource ()).isSelected ();
444- for (Node n : eachWrapVBox .lookupAll ("JFXToggleButton" )) {
445- ((JFXToggleButton ) n ).setSelected (isSelected );
446- }
447- });
390+ private void createMonitoringElements (VBox rootVBox , String [] monitoringElements , String [] monitoringAlias ) {
448391
449- headerHBox .getChildren ().addAll (headerToggleBtn , headerLabel );
450-
451- // Content
452- FlowPane contentFlowPane = new FlowPane ();
453- contentFlowPane .prefWidthProperty ().bind (rootVBox .widthProperty ());
454- contentFlowPane .minWidthProperty ().bind (rootVBox .minWidthProperty ());
455-
456- for (String s : elementContents ) {
457- String contentToggleId = mName .replaceAll ("\\ s" , "" ) + s + "ToggleBtn" ;
458-
459- HBox contentHBox = new HBox ();
460- Label contentLabel = new Label ();
461- contentLabel .setText (s );
462- contentLabel .setTextAlignment (TextAlignment .LEFT );
463- contentLabel .setAlignment (Pos .CENTER_LEFT );
464- contentLabel .setMinWidth (80 );
465- contentLabel .setMaxWidth (80 );
466- contentLabel .setPrefHeight (40 );
467- contentLabel .getStylesheets ().add (System .getProperty ("resourceBaseDir" ) + "/css/javaFx.css" );
468- contentLabel .getStyleClass ().add ("basic-font" );
469-
470- JFXToggleButton contentToggleBtn = new JFXToggleButton ();
471- contentToggleBtn .setId (contentToggleId );
472- contentToggleBtn .setSize (4 );
473- contentToggleBtn .setMinWidth (40 );
474- contentToggleBtn .setMaxWidth (40 );
475- contentToggleBtn .setPrefHeight (40 );
476- contentToggleBtn .setAlignment (Pos .CENTER );
477- contentToggleBtn .setSelected (propRepo .isMonitoringContent (contentToggleId ));
478- contentToggleBtn .setOnAction ((ActionEvent e ) -> {
479- boolean isSelected = ((JFXToggleButton ) e .getSource ()).isSelected ();
480-
481- /*
482- * 1. 하위요소가 선택되었을 때, 1.1. 부모요소가 선택되었는지 확인 1.1.1. 선택됨 - break; 1.1.2. 선택안됨 -
483- * isSelected = true 2. 하위요소가 선택되지 않았을 때, 2.1. 부모요소가 선택되었는지 확인 2.1.1. 선택안됨 -
484- * break; 2.1.2. 선택됨 2.1.2.1. 모든 하위요소 선택여부 확인 2.1.2.1.1. 모든 하위요소 선택되지않음 - 부모요소
485- * isSelected = false;
486- */
487- if (isSelected == true ) {
488- for (Node n : eachWrapVBox .lookupAll ("JFXToggleButton" )) {
489- JFXToggleButton thisToggle = (JFXToggleButton ) n ;
490- if (thisToggle .getId ().equals (headerToggleId )) { // 부모 Toggle
491- if (thisToggle .isSelected () == false ) {
492- thisToggle .setSelected (true );
493- break ;
494- }
495- }
496- }
497- } else {
498- boolean isNotAllSelected = false ;
499- boolean isParentSelected = true ;
500- for (Node n : eachWrapVBox .lookupAll ("JFXToggleButton" )) {
501- JFXToggleButton thisToggle = (JFXToggleButton ) n ;
502- if (thisToggle .getId ().equals (headerToggleId ) == false ) { // 자식 Toggle
503- if (thisToggle .isSelected () == true ) {
504- isNotAllSelected = true ;
505- break ;
506- }
507- } else {
508- if (thisToggle .isSelected () == false ) {
509- isParentSelected = false ;
510- break ;
511- }
512- }
513- }
514-
515- if (isNotAllSelected == false && isParentSelected == true ) {
516- for (Node n : eachWrapVBox .lookupAll ("JFXToggleButton" )) {
517- JFXToggleButton thisToggle = (JFXToggleButton ) n ;
518- if (thisToggle .getId ().equals (headerToggleId )) { // 부모 Toggle
519- thisToggle .setSelected (false );
520- break ;
521- }
522- }
523- }
524- }
525- });
526-
527- contentHBox .getChildren ().addAll (contentToggleBtn , contentLabel );
528- contentFlowPane .getChildren ().addAll (contentHBox );
529- }
392+ for (String monitoringElement : monitoringElements ) {
530393
531- eachWrapVBox .getChildren ().addAll (headerHBox , contentFlowPane );
394+ MonitoringYNVBox monitoringYNVBox = new MonitoringYNVBox ();
395+ // TODO 초기값 설정
396+ monitoringYNVBox .addParentToggle (monitoringElement , 6 , false );
397+
398+ for (String alias : monitoringAlias ) {
399+ // TODO 초기값 설정
400+ monitoringYNVBox .addChildToggle (alias , 4 , false );
401+ }
532402
533- rootVBox .getChildren ().addAll (eachWrapVBox );
403+ rootVBox .getChildren ().addAll (monitoringYNVBox );
534404 }
535405
536406 rootVBox .getChildren ().add (new Separator ());
0 commit comments