77import java .util .Map ;
88import java .util .ResourceBundle ;
99
10+ import org .apache .commons .lang3 .StringUtils ;
11+
1012import com .jfoenix .controls .JFXComboBox ;
1113import com .jfoenix .controls .JFXListView ;
1214
15+ import javafx .application .Platform ;
1316import javafx .event .ActionEvent ;
1417import javafx .fxml .FXML ;
1518import javafx .fxml .Initializable ;
1619import javafx .scene .control .Alert .AlertType ;
1720import javafx .scene .control .DatePicker ;
21+ import javafx .scene .control .TextField ;
1822import javafx .scene .layout .AnchorPane ;
1923import javafx .scene .layout .StackPane ;
24+ import lombok .extern .slf4j .Slf4j ;
2025import root .common .server .implement .JschServer ;
2126import root .core .domain .AlertLog ;
2227import root .core .domain .JschConnectionInfo ;
3338import root .core .usecase .implement .ServerMonitoringUsecaseImpl ;
3439import root .javafx .CustomView .AlertLogListViewCell ;
3540import root .javafx .CustomView .AlertLogMonitoringSummaryAP ;
41+ import root .javafx .CustomView .NumberTextFormatter ;
3642import root .javafx .CustomView .dateCell .DisableAfterTodayDateCell ;
3743import root .utils .AlertUtils ;
3844
45+ @ Slf4j
3946public class AlertLogMonitoringMenuController implements Initializable {
4047
4148 /* Dependency Injection */
@@ -60,6 +67,12 @@ public class AlertLogMonitoringMenuController implements Initializable {
6067 @ FXML
6168 StackPane alertLogSummarySP ;
6269
70+ @ FXML
71+ TextField navigatorTF ;
72+
73+ @ FXML
74+ TextField statusTF ;
75+
6376 @ FXML
6477 AnchorPane mainNodataAP ;
6578
@@ -154,6 +167,9 @@ private void initAlertLogMonitoringElements() {
154167 // AlertLog ListView
155168 alertLogLV .setCellFactory (categoryList -> new AlertLogListViewCell ());
156169
170+ // AlertLog Navigator
171+ navigatorTF .setTextFormatter (new NumberTextFormatter ());
172+
157173 // Set view visible
158174 mainNodataAP .setVisible (true );
159175 alertLogLV .setVisible (false );
@@ -230,4 +246,68 @@ public void monitoringAlertLog(ActionEvent e) throws Exception {
230246 summaryNodataAP .setVisible (false );
231247 summaryNodataAP .toBack ();
232248 }
249+
250+ public void focusAlertLog (ActionEvent e ) {
251+ String input = navigatorTF .getText ();
252+ if (!validateAlertLogNavigatorInput (input )) {
253+ return ;
254+ }
255+
256+ int toIndex = Integer .parseInt (input );
257+ alertLogLV .scrollTo (toIndex - 1 );
258+ alertLogLV .getSelectionModel ().select (toIndex - 1 );
259+ updateStatusMessage (String .format ("[%d]번째 Log로 이동합니다." , toIndex ));
260+ }
261+
262+ private boolean validateAlertLogNavigatorInput (String input ) {
263+ if (StringUtils .isEmpty (input )) {
264+ updateStatusMessage ("조회를 원하는 Log index를 입력해주세요." );
265+ return false ;
266+ }
267+
268+ int toIndex = 0 ;
269+ try {
270+ toIndex = Integer .parseInt (input );
271+ } catch (NumberFormatException ex ) {
272+ updateStatusMessage ("숫자만 입력하실 수 있습니다." );
273+ return false ;
274+ }
275+
276+ int alertLogSize = alertLogLV .getItems ().size ();
277+ if (alertLogSize == 0 ) {
278+ updateStatusMessage ("Alert Log 조회 후 이용해주세요." );
279+ return false ;
280+ }
281+
282+ if (toIndex <= 0 || toIndex > alertLogSize ) {
283+ updateStatusMessage (String .format ("Log index를 올바르게 입력해주세요. (가능한 입력값 범위: 1 ~ %d)" , alertLogSize ));
284+ return false ;
285+ }
286+
287+ return true ;
288+ }
289+
290+ /**
291+ * Update message at bottom status TextField region
292+ *
293+ * @param message
294+ */
295+ private void updateStatusMessage (String message ) {
296+ Thread statusTextUpdateThread = new Thread (() -> {
297+ Platform .runLater (() -> {
298+ statusTF .setText (message );
299+ });
300+
301+ try {
302+ Thread .sleep (1000 );
303+ } catch (InterruptedException e ) {
304+ log .error (e .getMessage ());
305+ }
306+ Platform .runLater (() -> {
307+ statusTF .setText ("" );
308+ });
309+ });
310+ statusTextUpdateThread .setDaemon (true );
311+ statusTextUpdateThread .start ();
312+ }
233313}
0 commit comments