4444import javafx .util .StringConverter ;
4545import root .core .domain .JdbcConnectionInfo ;
4646import root .core .domain .JschConnectionInfo ;
47+ import root .core .domain .enums .RoundingDigits ;
4748import root .core .domain .enums .UsageUIType ;
4849import root .core .repository .constracts .PropertyRepository ;
4950import root .core .repository .implement .PropertyRepositoryImpl ;
@@ -94,7 +95,7 @@ public class SettingMenuController implements Initializable {
9495 JFXComboBox <FileSize > fileSizeCB ;
9596
9697 @ FXML
97- JFXComboBox <Integer > roundingDigitsCB ;
98+ JFXComboBox <RoundingDigits > roundingDigitsCB ;
9899
99100 @ FXML
100101 JFXComboBox <UsageUIType > usageUICB ;
@@ -129,10 +130,10 @@ public void initialize(URL location, ResourceBundle resources) {
129130 setVisible (noMonitoringConfigAP , true );
130131 }
131132
132- /* 실행 설정 탭 - 조회결과 단위 설정 콤보박스 */
133- // 조회결과 단위 설정 콤보박스 아이템 설정
133+ /* 실행 설정 탭 - 조회결과 단위 콤보박스 */
134+ // 조회결과 단위 콤보박스 아이템 설정
134135 fileSizeCB .getItems ().addAll (FileSize .values ());
135-
136+
136137 // 아이템 변경 리스너
137138 fileSizeCB .valueProperty ().addListener ((options , oldValue , newValue ) -> {
138139 Map <String , Object > map = new HashMap <>();
@@ -141,27 +142,49 @@ public void initialize(URL location, ResourceBundle resources) {
141142 });
142143
143144 // 초기값 - 설정된 값 없다면 기본값 GB
144- FileSize fileSize = FileSize .of (propRepo .getCommonResource ("unit.filesize" ));
145- fileSizeCB .getSelectionModel ().select (fileSize == null ? FileSize . GB : fileSize );
145+ FileSize fileSize = FileSize .find (propRepo .getCommonResource ("unit.filesize" ));
146+ fileSizeCB .getSelectionModel ().select (fileSize );
146147
147- /* 실행 설정 탭 - 반올림 자릿수 설정 콤보박스 */
148- // 반올림 자릿수 설정 콤보박스 아이템 설정
149- roundingDigitsCB .getItems ().addAll (List . of ( 1 , 2 , 3 , 4 , 5 ));
148+ /* 실행 설정 탭 - 반올림 자릿수 콤보박스 */
149+ // 반올림 자릿수 콤보박스 아이템 설정
150+ roundingDigitsCB .getItems ().addAll (RoundingDigits . values ( ));
150151
151152 // 아이템 변경 리스너
152153 roundingDigitsCB .valueProperty ().addListener ((options , oldValue , newValue ) -> {
153154 Map <String , Object > map = new HashMap <>();
154- map .put ("unit.rounding" , newValue );
155+ map .put ("unit.rounding" , newValue . getDigits () );
155156 propRepo .saveCommonConfig (map );
156157 });
157158
159+ // Converter
160+ roundingDigitsCB .setConverter (new StringConverter <RoundingDigits >() {
161+ @ Override
162+ public String toString (RoundingDigits digits ) {
163+ return String .valueOf (digits .getDigits ());
164+ }
165+
166+ @ Override
167+ public RoundingDigits fromString (String digits ) {
168+ return RoundingDigits .find (digits );
169+ }
170+ });
171+
158172 // 초기값 - 설정된 값 없다면 기본값 2
159- String roundingDigits = propRepo .getCommonResource ("unit.rounding" );
160- roundingDigitsCB .getSelectionModel ().select (roundingDigits == null ? 2 : Integer . valueOf ( roundingDigits ) );
173+ RoundingDigits roundingDigits = RoundingDigits . find ( propRepo .getCommonResource ("unit.rounding" ) );
174+ roundingDigitsCB .getSelectionModel ().select (roundingDigits );
161175
176+ /* 실행 설정 탭 - 사용량 표시방법 콤보박스 */
177+ // 사용량 표시방법 콤보박스 아이템 설정
178+ usageUICB .getItems ().addAll (UsageUIType .values ());
162179
163- // Set usage UI type comboBox items and Set setting value;
164- String usageUICode = propRepo .getCommonResource ("usage-ui-type" );
180+ // 아이템 변경 리스너
181+ usageUICB .valueProperty ().addListener ((options , oldValue , newValue ) -> {
182+ Map <String , Object > map = new HashMap <>();
183+ map .put ("usage-ui-type" , newValue .getCode ());
184+ propRepo .saveCommonConfig (map );
185+ });
186+
187+ // Converter
165188 usageUICB .setConverter (new StringConverter <UsageUIType >() {
166189 @ Override
167190 public String toString (UsageUIType uiType ) {
@@ -170,16 +193,13 @@ public String toString(UsageUIType uiType) {
170193
171194 @ Override
172195 public UsageUIType fromString (String string ) {
173- return usageUICB . getItems (). stream (). filter ( ui -> ui . getName (). equals ( string )). findFirst (). orElse ( null );
196+ return UsageUIType . find ( string );
174197 }
175198 });
176- this .usageUICB .getItems ().addAll (UsageUIType .values ());
177- this .usageUICB .getSelectionModel ().select (UsageUIType .find (usageUICode ));
178- usageUICB .getSelectionModel ().selectedItemProperty ().addListener ((options , oldValue , newValue ) -> {
179- Map <String , Object > map = new HashMap <>();
180- map .put ("usage-ui-type" , newValue .getCode ());
181- propRepo .saveCommonConfig (map );
182- });
199+
200+ // 초기값 - 설정된 값 없다면 기본값 GRAPHIC_BAR
201+ String usageUICode = propRepo .getCommonResource ("usage-ui-type" );
202+ usageUICB .getSelectionModel ().select (UsageUIType .find (usageUICode ));
183203 }
184204
185205 /**
0 commit comments