Skip to content

Commit f7a3d9b

Browse files
committed
Implements 'Monitoring Execution Step1' (initial value, change listener)
1 parent 596b9bc commit f7a3d9b

File tree

5 files changed

+120
-16
lines changed

5 files changed

+120
-16
lines changed

src/main/java/root/core/service/contracts/PropertyService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@
88

99
public interface PropertyService {
1010

11+
/**
12+
* 모니터링 접속정보 설정파일의 경로를 반환한다.
13+
*
14+
* @return
15+
*/
16+
List<String> getConnectionInfoList();
17+
18+
/**
19+
* 최근 사용된 접속정보 설정파일을 경로를 반환한다.
20+
*
21+
* @return
22+
*/
23+
String getLastUseConnectionInfo();
24+
25+
void loadConnectionInfoConfig(String filePath);
26+
1127
Map<String, String> getMonitoringPresetMap();
1228

1329
List<String> getMonitoringPresetFilePathList();

src/main/java/root/core/service/implement/FilePropertyService.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ public FilePropertyService(PropertyRepository propRepo) {
2727
this.propRepo = propRepo;
2828
}
2929

30+
/**
31+
* ./config/connectioninfo/ 디렉터리 하위에 있는 접속정보 설정파일 리스트를 반환한다.
32+
*/
33+
@Override
34+
public List<String> getConnectionInfoList() {
35+
return new ArrayList<>(Arrays.asList(propRepo.getConnectionInfoFileNames()));
36+
}
37+
38+
/**
39+
* 최근 사용된 접속정보 설정파일 경로를 반환한다.
40+
*/
41+
@Override
42+
public String getLastUseConnectionInfo() {
43+
return propRepo.getLastUseConnInfoFilePath();
44+
}
45+
46+
/**
47+
* 접속정보 설정파일을 Load 한다.
48+
*/
49+
@Override
50+
public void loadConnectionInfoConfig(String filePath) {
51+
propRepo.loadConnectionInfoConfig(filePath);
52+
}
53+
3054
@Override
3155
public Map<String, String> getMonitoringPresetMap() {
3256
return StreamSupport
@@ -74,4 +98,5 @@ public List<JschConnectionInfo> getJschConnInfoList(List<String> serverNames) {
7498
return serverNames.stream().sorted().collect(
7599
Collectors.mapping(serverName -> propRepo.getJschConnectionInfo(serverName), Collectors.toList()));
76100
}
101+
77102
}

src/main/java/root/javafx/Controller/RunMenuController.java

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
package root.javafx.Controller;
22

33
import java.net.URL;
4+
import java.sql.SQLException;
45
import java.util.ArrayList;
5-
import java.util.Arrays;
66
import java.util.List;
77
import java.util.ResourceBundle;
88

9+
import org.apache.commons.lang.StringUtils;
10+
import org.apache.commons.lang3.ArrayUtils;
11+
12+
import com.jfoenix.controls.JFXComboBox;
13+
914
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
15+
import javafx.beans.value.ChangeListener;
16+
import javafx.beans.value.ObservableValue;
1017
import javafx.fxml.FXML;
1118
import javafx.fxml.Initializable;
1219
import javafx.scene.Node;
@@ -20,6 +27,9 @@
2027
import root.core.domain.MonitoringResult;
2128
import root.core.domain.OSDiskUsage;
2229
import root.core.domain.TableSpaceUsage;
30+
import root.core.repository.implement.PropertyRepositoryImpl;
31+
import root.core.service.contracts.PropertyService;
32+
import root.core.service.implement.FilePropertyService;
2333
import root.javafx.CustomView.CustomTreeTableView;
2434
import root.javafx.CustomView.CustomTreeView;
2535
import root.javafx.CustomView.MonitoringTableView;
@@ -28,9 +38,15 @@
2838

2939
public class RunMenuController implements Initializable {
3040

41+
/* Dependency Injection */
42+
PropertyService propService = new FilePropertyService(PropertyRepositoryImpl.getInstance());
43+
3144
@FXML
3245
AnchorPane connInfoSettingAP;
3346

47+
@FXML
48+
JFXComboBox<String> connInfoFileListComboBox;
49+
3450
@FXML
3551
AnchorPane presetSettingAP;
3652

@@ -70,13 +86,32 @@ public class RunMenuController implements Initializable {
7086
@Override
7187
public void initialize(URL location, ResourceBundle resources) {
7288

73-
// 접속정보 리스트 TreeView
74-
CustomTreeView connInfoCtv = new CustomTreeView("접속정보 리스트", FontAwesomeIcon.LIST, true);
75-
connInfoCtv.addTreeItem("DB", new ArrayList<>(Arrays.asList("DB1", "DB2", "DB3")), FontAwesomeIcon.DATABASE);
76-
connInfoCtv.addTreeItem("Server", new ArrayList<>(Arrays.asList("Server1", "Server2", "Server3", "Server4")),
77-
FontAwesomeIcon.SERVER);
78-
setAnchorPaneAnchor(connInfoCtv, 80, 0, 0, 0);
79-
connInfoSettingAP.getChildren().add(connInfoCtv);
89+
/* 1. 모니터링 접속정보 설정 */
90+
// 1-1. 모니터링 접속정보 설정파일 콤보박스 아이템 설정
91+
List<String> connInfoFileList = propService.getConnectionInfoList();
92+
if (connInfoFileList == null || ArrayUtils.isEmpty(connInfoFileList.toArray())) {
93+
// TODO 접속정보 설정파일이 없는 경우
94+
addMonitoringConnInfoPreview(new ArrayList<>(), new ArrayList<>());
95+
} else {
96+
connInfoFileListComboBox.getItems().addAll(connInfoFileList);
97+
}
98+
99+
// 1-2. 모니터링 접속정보 설정파일 콤보박스 아이템 변경 리스너 설정
100+
connInfoFileListComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
101+
propService.loadConnectionInfoConfig(newValue);
102+
List<String> dbNames = propService.getMonitoringDBNameList();
103+
List<String> serverNames = propService.getMonitoringServerNameList();
104+
addMonitoringConnInfoPreview(dbNames, serverNames);
105+
});
106+
107+
// 1-3. 모니터링 접속정보 설정파일 콤보박스 초기값 설정
108+
String lastUseConnInfoFile = propService.getLastUseConnectionInfo();
109+
if (StringUtils.isEmpty(lastUseConnInfoFile) || !connInfoFileList.contains(lastUseConnInfoFile)) {
110+
// 최근 사용된 접속정보 설정파일이 없거나 현재 존재하지 않는 경우, 첫 번째 설정파일 선택
111+
connInfoFileListComboBox.getSelectionModel().selectFirst();
112+
} else {
113+
connInfoFileListComboBox.getSelectionModel().select(lastUseConnInfoFile);
114+
}
80115

81116
// 모니터링 여부 리스트 TreeTableView
82117
List<DBMonitoringYN> list1 = new ArrayList<>();
@@ -174,4 +209,19 @@ private <T> MonitoringTableView<T> addMonitoringTableView(AnchorPane parent,
174209
parent.getChildren().add(tableView);
175210
return tableView;
176211
}
212+
213+
/**
214+
* 모니터링 접속정보를 보여주는 TreeView를 생성 및 추가한다.
215+
*
216+
* @param dbNameList
217+
* @param serverNameList
218+
*/
219+
private void addMonitoringConnInfoPreview(List<String> dbNameList, List<String> serverNameList) {
220+
// 접속정보 리스트 TreeView
221+
CustomTreeView connInfoCtv = new CustomTreeView("접속정보 리스트", FontAwesomeIcon.LIST, true);
222+
connInfoCtv.addTreeItem("DB", dbNameList, FontAwesomeIcon.DATABASE);
223+
connInfoCtv.addTreeItem("Server", serverNameList, FontAwesomeIcon.SERVER);
224+
setAnchorPaneAnchor(connInfoCtv, 80, 0, 0, 0);
225+
connInfoSettingAP.getChildren().add(connInfoCtv);
226+
}
177227
}

src/main/resources/css/javaFx.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
-fx-alignment: CENTER;
6262
-fx-text-fill: #2381E9;
6363
-fx-font-weight: bold;
64-
-fx-font-family: NanumGothic;
64+
-fx-font-family: "Noto Sans Korean Regular";
6565
}
6666

6767
.tab-pane > .tab-header-area > .tab-header-background {
@@ -77,15 +77,15 @@
7777
-fx-background-color: -fx-text-box-border, white ;
7878
-fx-background-insets: 0, 0.5 0.5 0.5 0.5 ;
7979
-fx-background-radius: 0 ;
80-
-fx-font-family: NanumGothic;
80+
-fx-font-family: "Noto Sans Korean Regular";
8181
}
8282
.text-field:focused {
8383
-fx-background-color: #039ED3, -fx-background;
8484
}
8585

8686
/* Label */
8787
.gridTitleLabel {
88-
-fx-font-family: NanumGothic;
88+
-fx-font-family: "Noto Sans Korean Regular";
8989
-fx-font-size: 11px;
9090
-fx-line-spacing: 0;
9191
}
@@ -95,7 +95,8 @@
9595
-fx-background-color: -fx-text-box-border, white ;
9696
-fx-background-insets: 0, 0.5 0.5 0.5 0.5 ;
9797
-fx-background-radius: 0 ;
98-
-fx-font-family: NanumGothic;
98+
-fx-font-family: "Noto Sans Korean Regular";
99+
-fx-font-size: 10px;
99100
}
100101

101102
.jfx-combo-box:focused {

src/main/resources/fxml/RunMenu.fxml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
<Font name="Noto Sans Korean Regular" size="12.0" />
8181
</font>
8282
</Label>
83-
<JFXComboBox minWidth="200.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0" />
83+
<JFXComboBox fx:id="connInfoFileListComboBox" minHeight="22.0" promptText="모니터링 접속정보 설정파일을 선택해주세요." styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0">
84+
<padding>
85+
<Insets left="5.0" />
86+
</padding></JFXComboBox>
8487
<Label layoutX="36.0" layoutY="17.0" text="Preview" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="60.0">
8588
<graphic>
8689
<FontAwesomeIconView glyphName="ASTERISK" size="9" strokeWidth="0.0" />
@@ -134,7 +137,10 @@
134137
<Font name="Noto Sans Korean Regular" size="12.0" />
135138
</font>
136139
</Label>
137-
<JFXComboBox minWidth="200.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0" />
140+
<JFXComboBox minHeight="22.0" minWidth="200.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0">
141+
<padding>
142+
<Insets left="5.0" />
143+
</padding></JFXComboBox>
138144
<Label layoutX="36.0" layoutY="17.0" text="Preview" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="60.0">
139145
<graphic>
140146
<FontAwesomeIconView glyphName="ASTERISK" size="9" strokeWidth="0.0" />
@@ -185,7 +191,10 @@
185191
<Font name="Noto Sans Korean Regular" size="12.0" />
186192
</font>
187193
</Label>
188-
<JFXComboBox layoutY="46.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0" />
194+
<JFXComboBox layoutY="46.0" minHeight="22.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0">
195+
<padding>
196+
<Insets left="5.0" />
197+
</padding></JFXComboBox>
189198
<Label text="반올림 자릿수 설정" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="60.0">
190199
<graphic>
191200
<FontAwesomeIconView glyphName="ASTERISK" size="9" strokeWidth="0.0" />
@@ -197,7 +206,10 @@
197206
<Font name="Noto Sans Korean Regular" size="12.0" />
198207
</font>
199208
</Label>
200-
<JFXComboBox minWidth="-Infinity" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="80.0" />
209+
<JFXComboBox minHeight="22.0" minWidth="-Infinity" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="80.0">
210+
<padding>
211+
<Insets left="5.0" />
212+
</padding></JFXComboBox>
201213
<Label layoutX="10.0" layoutY="10.0" text="모니터링 결과 저장 여부" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="120.0">
202214
<graphic>
203215
<FontAwesomeIconView glyphName="ASTERISK" size="9" strokeWidth="0.0" />

0 commit comments

Comments
 (0)