22
33import java .io .IOException ;
44import java .util .ArrayList ;
5+ import java .util .HashMap ;
56import java .util .List ;
7+ import java .util .Map ;
68
79import javafx .event .ActionEvent ;
810import javafx .event .EventHandler ;
1214import javafx .scene .layout .HBox ;
1315import javafx .scene .layout .VBox ;
1416import javafx .scene .paint .Paint ;
17+ import root .core .domain .ASMDiskUsage ;
18+ import root .core .domain .AlertLog ;
19+ import root .core .domain .ArchiveUsage ;
20+ import root .core .domain .OSDiskUsage ;
21+ import root .core .domain .TableSpaceUsage ;
1522import root .javafx .DI .DependencyInjection ;
1623
1724public class MonitoringYNVBox extends VBox {
@@ -20,16 +27,46 @@ public class MonitoringYNVBox extends VBox {
2027 private static final Paint PARENT_TOGGLE_LINE_COLOR = Paint .valueOf ("#6e93ea" );
2128 private static final Paint CHILD_TOGGLE_COLOR = Paint .valueOf ("#009688" );
2229 private static final Paint CHILD_TOGGLE_LINE_COLOR = Paint .valueOf ("#77c2bb" );
30+ private static final int PARENT_TOGGLE_SIZE = 6 ;
31+ private static final int CHILD_TOGGLE_SIZE = 4 ;
2332
2433 @ FXML
25- HBox parentHBox ;
34+ HBox archiveUsageParentHBox ;
2635
2736 @ FXML
28- FlowPane childFlowPane ;
37+ FlowPane archiveUsageChildFlowPane ;
2938
30- ToggleHBox parentToggle ;
39+ @ FXML
40+ HBox tableSpaceUsageParentHBox ;
41+
42+ @ FXML
43+ FlowPane tableSpaceUsageChildFlowPane ;
44+
45+ @ FXML
46+ HBox asmDiskUsageParentHBox ;
47+
48+ @ FXML
49+ FlowPane asmDiskUsageChildFlowPane ;
50+
51+ @ FXML
52+ HBox osDiskUsageParentHBox ;
53+
54+ @ FXML
55+ FlowPane osDiskUsageChildFlowPane ;
56+
57+ @ FXML
58+ HBox alertLogParentHBox ;
59+
60+ @ FXML
61+ FlowPane alertLogChildFlowPane ;
3162
32- List <ToggleHBox > childToggleList = new ArrayList <>();
63+ Map <Class <?>, HBox > parentHBoxMap = new HashMap <>();
64+
65+ Map <Class <?>, FlowPane > childFlowPaneMap = new HashMap <>();
66+
67+ Map <Class <?>, ToggleHBox > parentToggleMap = new HashMap <>();
68+
69+ Map <Class <?>, List <ToggleHBox >> childToggleListMap = new HashMap <>();
3370
3471 public MonitoringYNVBox () {
3572 try {
@@ -40,79 +77,106 @@ public MonitoringYNVBox() {
4077 } catch (IOException e ) {
4178 e .printStackTrace ();
4279 }
80+
81+ parentHBoxMap .put (ArchiveUsage .class , archiveUsageParentHBox );
82+ parentHBoxMap .put (TableSpaceUsage .class , tableSpaceUsageParentHBox );
83+ parentHBoxMap .put (ASMDiskUsage .class , asmDiskUsageParentHBox );
84+ parentHBoxMap .put (OSDiskUsage .class , osDiskUsageParentHBox );
85+ parentHBoxMap .put (AlertLog .class , alertLogParentHBox );
86+
87+ childFlowPaneMap .put (ArchiveUsage .class , archiveUsageChildFlowPane );
88+ childFlowPaneMap .put (TableSpaceUsage .class , tableSpaceUsageChildFlowPane );
89+ childFlowPaneMap .put (ASMDiskUsage .class , asmDiskUsageChildFlowPane );
90+ childFlowPaneMap .put (OSDiskUsage .class , osDiskUsageChildFlowPane );
91+ childFlowPaneMap .put (AlertLog .class , alertLogChildFlowPane );
4392 }
4493
4594 /**
4695 * 부모 토글 버튼을 추가한다.
4796 *
48- * @param text 토글 우글 라벨 텍스트
49- * @param size 토글 크기
50- * @param isSelected 트글 선택 여부
97+ * @param type 모니터링 타입
98+ * @param text 토글 우글 라벨 텍스트
5199 */
52- public void addParentToggle (String text , int size , boolean isSelected ) {
53- parentToggle = new ToggleHBox ();
100+ public void addParentToggle (Class <?> type , String text ) {
101+ if (!parentToggleMap .containsKey (type )) {
102+ parentToggleMap .put (type , new ToggleHBox ());
103+ childToggleListMap .put (type , new ArrayList <>());
104+ }
105+
106+ ToggleHBox parentToggle = parentToggleMap .get (type );
54107 parentToggle .setLabelText (text );
55- parentToggle .setToggle (size , PARENT_TOGGLE_COLOR , PARENT_TOGGLE_LINE_COLOR );
56- parentToggle .setToggleSelected (isSelected );
108+ parentToggle .setToggle (PARENT_TOGGLE_SIZE , PARENT_TOGGLE_COLOR , PARENT_TOGGLE_LINE_COLOR );
109+ parentToggle .setToggleSelected (false );
57110 parentToggle .setToggleAction (new EventHandler <ActionEvent >() {
58111
59112 @ Override
60113 public void handle (ActionEvent e ) {
61- for (ToggleHBox t : childToggleList ) {
114+ for (ToggleHBox t : childToggleListMap . get ( type ) ) {
62115 t .setToggleSelected (parentToggle .isToggleSelected ());
63116 }
64117 }
65118 });
66119
67- parentHBox .getChildren ().add (parentToggle );
120+ parentHBoxMap . get ( type ) .getChildren ().add (parentToggle );
68121 }
69122
70123 /**
71124 * 자식 토글 버튼을 추가한다.
72125 *
126+ * @param type 모니터링 타입
73127 * @param text 토글 우측 라벨 텍스트
74- * @param size 토글 크기
75128 * @param isSelected 토글 선택 여부
76129 */
77- public void addChildToggle (String text , int size , boolean isSelected ) {
78- addChildToggle (text , size , CHILD_TOGGLE_COLOR , CHILD_TOGGLE_LINE_COLOR , isSelected );
130+ public void addChildToggle (Class <?> type , String text , boolean isSelected ) {
131+ addChildToggle (type , text , CHILD_TOGGLE_COLOR , CHILD_TOGGLE_LINE_COLOR , isSelected );
79132 }
80133
81134 /**
82135 * 자식 토글 버튼을 추가한다.
83136 *
137+ * @param type 모니터링 타입
84138 * @param text 토글 우측 라벨 텍스트
85- * @param size 토글 크기
86139 * @param color 토글 색
87140 * @param lineColor 토글 라인 색
88141 * @param isSelected 토글 선택 여부
89142 */
90- public void addChildToggle (String text , int size , Paint color , Paint lineColor , boolean isSelected ) {
143+ public void addChildToggle (Class <?> type , String text , Paint color , Paint lineColor , boolean isSelected ) {
91144 ToggleHBox toggleHBox = new ToggleHBox ();
92145 toggleHBox .setLabelText (text );
93- toggleHBox .setToggle (size , color , lineColor );
146+ toggleHBox .setToggle (CHILD_TOGGLE_SIZE , color , lineColor );
94147 toggleHBox .setToggleSelected (isSelected );
95148 toggleHBox .setToggleAction (new EventHandler <ActionEvent >() {
96149
97150 @ Override
98151 public void handle (ActionEvent e ) {
99-
100152 if (toggleHBox .isToggleSelected ()) {
101- parentToggle .setToggleSelected (true );
153+ parentToggleMap . get ( type ) .setToggleSelected (true );
102154 } else {
103- boolean isAllNotSelected = true ;
104- for (ToggleHBox t : childToggleList ) {
105- if (t .isToggleSelected ()) {
106- isAllNotSelected = false ;
107- break ;
108- }
109- }
110- parentToggle .setToggleSelected (!isAllNotSelected );
155+ parentToggleMap .get (type ).setToggleSelected (!isAllNotSelected (type ));
111156 }
112157 }
113158 });
114159
115- childFlowPane .getChildren ().add (toggleHBox );
116- childToggleList .add (toggleHBox );
160+ parentToggleMap .get (type ).setToggleSelected (!isAllNotSelected (type ));
161+
162+ childFlowPaneMap .get (type ).getChildren ().add (toggleHBox );
163+ childToggleListMap .get (type ).add (toggleHBox );
164+ }
165+
166+ /**
167+ * 자식 토글 버튼이 모두 선택되지 않았는지 여부를 반환한다.
168+ *
169+ * @param type 모니터링 타입
170+ * @return
171+ */
172+ private boolean isAllNotSelected (Class <?> type ) {
173+ boolean isAllNotSelected = true ;
174+ for (ToggleHBox t : childToggleListMap .get (type )) {
175+ if (t .isToggleSelected ()) {
176+ isAllNotSelected = false ;
177+ break ;
178+ }
179+ }
180+ return isAllNotSelected ;
117181 }
118182}
0 commit comments