1818import javafx .event .EventHandler ;
1919import javafx .fxml .FXML ;
2020import javafx .fxml .Initializable ;
21+ import javafx .geometry .Insets ;
2122import javafx .scene .control .Alert .AlertType ;
2223import javafx .scene .control .DatePicker ;
24+ import javafx .scene .control .ScrollPane ;
25+ import javafx .scene .control .ScrollPane .ScrollBarPolicy ;
2326import javafx .scene .control .TextField ;
2427import javafx .scene .input .KeyCode ;
2528import javafx .scene .input .KeyEvent ;
2629import javafx .scene .layout .AnchorPane ;
30+ import javafx .scene .layout .HBox ;
2731import javafx .scene .layout .StackPane ;
2832import lombok .extern .slf4j .Slf4j ;
2933import root .common .server .implement .JschServer ;
4347import root .javafx .CustomView .AlertLogListViewCell ;
4448import root .javafx .CustomView .AlertLogMonitoringSummaryAP ;
4549import root .javafx .CustomView .NumberTextFormatter ;
50+ import root .javafx .CustomView .TagBar ;
4651import root .javafx .CustomView .dateCell .DisableAfterTodayDateCell ;
4752import root .utils .AlertUtils ;
4853
@@ -71,6 +76,9 @@ public class AlertLogMonitoringMenuController implements Initializable {
7176 @ FXML
7277 StackPane alertLogSummarySP ;
7378
79+ @ FXML
80+ HBox searchKeywordHBox ;
81+
7482 @ FXML
7583 TextField navigatorTF ;
7684
@@ -83,6 +91,8 @@ public class AlertLogMonitoringMenuController implements Initializable {
8391 @ FXML
8492 AnchorPane summaryNodataAP ;
8593
94+ TagBar tagBar = new TagBar ();
95+
8696 Map <String , AlertLog > alertLogMonitoringResultMap ;
8797
8898 public AlertLogMonitoringMenuController () {
@@ -124,12 +134,20 @@ public void initialize(URL location, ResourceBundle resources) {
124134 }
125135
126136 private void changeAlertLogListViewData (String serverID ) {
137+ // AlertLog ListView
138+ String [] hightlightKeywords = tagBar .getTags ().toArray (new String [0 ]);
139+ alertLogLV .setCellFactory (categoryList -> new AlertLogListViewCell (hightlightKeywords ));
140+
127141 alertLogLV .getItems ().clear ();
128142 AlertLog alertLog = alertLogMonitoringResultMap .get (serverID );
129143 if (alertLog != null ) {
130144 // Alert Log ListView
131145 alertLogLV .getItems ().addAll (alertLog .getAlertLogs ());
132-
146+ Platform .runLater (() -> {
147+ alertLogLV .scrollTo (0 );
148+ alertLogLV .getSelectionModel ().select (0 );
149+ });
150+
133151 // Alert Log Summary
134152 alertLogSummarySP .getChildren ().add (new AlertLogMonitoringSummaryAP (alertLog ));
135153 } else {
@@ -168,9 +186,6 @@ private void initAlertLogMonitoringElements() {
168186 }
169187 });
170188
171- // AlertLog ListView
172- alertLogLV .setCellFactory (categoryList -> new AlertLogListViewCell ());
173-
174189 // AlertLog Navigator
175190 navigatorTF .setTextFormatter (new NumberTextFormatter ());
176191 navigatorTF .setOnKeyReleased (new EventHandler <KeyEvent >() {
@@ -183,6 +198,21 @@ public void handle(KeyEvent e) {
183198 }
184199 });
185200
201+ // Search Keyword Tagbar
202+ ScrollPane tagBarWrapper = new ScrollPane (tagBar );
203+ tagBarWrapper .setStyle ("-fx-border-width: 0.2px; -fx-border-color: gray;" );
204+ tagBarWrapper .getStyleClass ().add ("gray-scrollbar" );
205+ tagBarWrapper .setMaxWidth (375 );
206+ tagBarWrapper .setMinHeight (45 );
207+ tagBarWrapper .setFitToHeight (true );
208+ tagBarWrapper .prefHeightProperty ().bind (searchKeywordHBox .heightProperty ());
209+ tagBarWrapper .setHbarPolicy (ScrollBarPolicy .AS_NEEDED );
210+ HBox .setMargin (tagBarWrapper , new Insets (0 , 0 , 0 , 25 ));
211+ searchKeywordHBox .getChildren ().add (tagBarWrapper );
212+
213+ tagBar .setMaxWidth (355 );
214+ tagBarWrapper .vvalueProperty ().bind (tagBar .heightProperty ());
215+
186216 // Set view visible
187217 mainNodataAP .setVisible (true );
188218 alertLogLV .setVisible (false );
@@ -248,7 +278,9 @@ public void monitoringAlertLog(ActionEvent e) throws Exception {
248278 }
249279 ServerMonitoringUsecase usecase = new ServerMonitoringUsecaseImpl (repo , ReportFileRepo .getInstance ());
250280
251- AlertLog result = usecase .getAlertLogDuringPeriod (connInfo .getAlc (), alertLogStartDay , alertLogEndDay );
281+ String [] searchKeywords = tagBar .getTags ().toArray (new String [0 ]);
282+ AlertLog result = usecase .getAlertLogDuringPeriod (connInfo .getAlc (), alertLogStartDay , alertLogEndDay ,
283+ searchKeywords );
252284 alertLogMonitoringResultMap .put (selectedServer , result );
253285
254286 changeAlertLogListViewData (alertLogServerComboBox .getSelectionModel ().getSelectedItem ());
@@ -271,7 +303,7 @@ public void prevAlertLog(ActionEvent e) {
271303 updateStatusMessage ("첫번째 Log입니다." );
272304 return ;
273305 }
274-
306+
275307 navigatorTF .setText (String .valueOf (toIndex ));
276308 focusAlertLog (e );
277309 }
@@ -282,13 +314,12 @@ public void nextAlertLog(ActionEvent e) {
282314 return ;
283315 }
284316
285-
286317 int toIndex = Integer .parseInt (input ) + 1 ;
287318 if (toIndex > alertLogLV .getItems ().size ()) {
288319 updateStatusMessage ("마지막 Log입니다." );
289320 return ;
290321 }
291-
322+
292323 navigatorTF .setText (String .valueOf (toIndex ));
293324 focusAlertLog (e );
294325 }
0 commit comments