11package root .javafx .CustomView ;
22
33import java .io .IOException ;
4- import java .util .ArrayList ;
54import java .util .HashMap ;
6- import java .util .List ;
75import java .util .Map ;
86
9- import javafx .event .ActionEvent ;
10- import javafx .event .EventHandler ;
11- import javafx .fxml .FXML ;
127import javafx .fxml .FXMLLoader ;
13- import javafx .scene .layout .FlowPane ;
14- import javafx .scene .layout .HBox ;
158import javafx .scene .layout .VBox ;
16- import 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 ;
9+ import root .core .domain .enums .MonitoringType ;
2210import root .javafx .DI .DependencyInjection ;
2311
2412public class MonitoringYNVBox extends VBox {
2513
26- private static final Paint PARENT_TOGGLE_COLOR = Paint .valueOf ("#0132ac" );
27- private static final Paint PARENT_TOGGLE_LINE_COLOR = Paint .valueOf ("#6e93ea" );
28- private static final Paint CHILD_TOGGLE_COLOR = Paint .valueOf ("#009688" );
29- 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 ;
32-
33- @ FXML
34- HBox archiveUsageParentHBox ;
35-
36- @ FXML
37- FlowPane archiveUsageChildFlowPane ;
38-
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 ;
62-
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 <>();
14+ Map <MonitoringType , ToggleGroupVBox > toggleGroupVBoxs = new HashMap <>();
7015
7116 public MonitoringYNVBox () {
7217 try {
@@ -77,18 +22,6 @@ public MonitoringYNVBox() {
7722 } catch (IOException e ) {
7823 e .printStackTrace ();
7924 }
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 );
9225 }
9326
9427 /**
@@ -97,86 +30,25 @@ public MonitoringYNVBox() {
9730 * @param type 모니터링 타입
9831 * @param text 토글 우글 라벨 텍스트
9932 */
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 <>());
33+ public void addParentToggle (MonitoringType type , String text ) {
34+ if (!toggleGroupVBoxs .containsKey (type )) {
35+ toggleGroupVBoxs .put (type , new ToggleGroupVBox ());
10436 }
10537
106- ToggleHBox parentToggle = parentToggleMap .get (type );
107- parentToggle .setLabelText (text );
108- parentToggle .setToggle (PARENT_TOGGLE_SIZE , PARENT_TOGGLE_COLOR , PARENT_TOGGLE_LINE_COLOR );
109- parentToggle .setToggleSelected (false );
110- parentToggle .setToggleAction (new EventHandler <ActionEvent >() {
111-
112- @ Override
113- public void handle (ActionEvent e ) {
114- for (ToggleHBox t : childToggleListMap .get (type )) {
115- t .setToggleSelected (parentToggle .isToggleSelected ());
116- }
117- }
118- });
119-
120- parentHBoxMap .get (type ).getChildren ().add (parentToggle );
121- }
38+ ToggleGroupVBox parentToggle = toggleGroupVBoxs .get (type );
39+ parentToggle .setParentToggle (text );
12240
123- /**
124- * 자식 토글 버튼을 추가한다.
125- *
126- * @param type 모니터링 타입
127- * @param text 토글 우측 라벨 텍스트
128- * @param isSelected 토글 선택 여부
129- */
130- public void addChildToggle (Class <?> type , String text , boolean isSelected ) {
131- addChildToggle (type , text , CHILD_TOGGLE_COLOR , CHILD_TOGGLE_LINE_COLOR , isSelected );
41+ getChildren ().add (parentToggle );
13242 }
13343
13444 /**
13545 * 자식 토글 버튼을 추가한다.
13646 *
13747 * @param type 모니터링 타입
13848 * @param text 토글 우측 라벨 텍스트
139- * @param color 토글 색
140- * @param lineColor 토글 라인 색
14149 * @param isSelected 토글 선택 여부
14250 */
143- public void addChildToggle (Class <?> type , String text , Paint color , Paint lineColor , boolean isSelected ) {
144- ToggleHBox toggleHBox = new ToggleHBox ();
145- toggleHBox .setLabelText (text );
146- toggleHBox .setToggle (CHILD_TOGGLE_SIZE , color , lineColor );
147- toggleHBox .setToggleSelected (isSelected );
148- toggleHBox .setToggleAction (new EventHandler <ActionEvent >() {
149-
150- @ Override
151- public void handle (ActionEvent e ) {
152- if (toggleHBox .isToggleSelected ()) {
153- parentToggleMap .get (type ).setToggleSelected (true );
154- } else {
155- parentToggleMap .get (type ).setToggleSelected (!isAllNotSelected (type ));
156- }
157- }
158- });
159-
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 ;
51+ public void addChildToggle (MonitoringType type , String text , boolean isSelected ) {
52+ toggleGroupVBoxs .get (type ).addChildToggle (text , isSelected );
18153 }
18254}
0 commit comments