Skip to content

Commit ae17e73

Browse files
committed
Separate the method according to each monitoring execution step
1 parent 504b9e1 commit ae17e73

File tree

2 files changed

+151
-111
lines changed

2 files changed

+151
-111
lines changed

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

Lines changed: 147 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
import java.net.URL;
44
import java.util.ArrayList;
5-
import java.util.HashSet;
5+
import java.util.Arrays;
66
import java.util.List;
77
import java.util.ResourceBundle;
8-
import java.util.Set;
98
import java.util.stream.Collectors;
109

1110
import org.apache.commons.lang.StringUtils;
@@ -15,6 +14,7 @@
1514
import com.jfoenix.controls.JFXToggleButton;
1615

1716
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
17+
import javafx.collections.FXCollections;
1818
import javafx.event.ActionEvent;
1919
import javafx.fxml.FXML;
2020
import javafx.fxml.Initializable;
@@ -100,107 +100,22 @@ public class RunMenuController implements Initializable {
100100
@FXML
101101
Label step4Label;
102102

103+
private MonitoringTableView<ArchiveUsage> archiveTable;
104+
private MonitoringTableView<TableSpaceUsage> tableSpaceTable;
105+
private MonitoringTableView<ASMDiskUsage> asmDiskTable;
106+
private MonitoringTableView<OSDiskUsage> osDiskTable;
107+
103108
@Override
104109
public void initialize(URL location, ResourceBundle resources) {
105110

106-
/* 1. 모니터링 접속정보 설정 */
107-
// 1-1. 모니터링 접속정보 설정파일 콤보박스 아이템 설정
108-
List<String> connInfoFileList = propService.getConnectionInfoList();
109-
if (connInfoFileList == null || ArrayUtils.isEmpty(connInfoFileList.toArray())) {
110-
// TODO 접속정보 설정파일이 없는 경우
111-
addMonitoringConnInfoPreview(new ArrayList<>(), new ArrayList<>());
112-
} else {
113-
connInfoFileListComboBox.getItems().addAll(connInfoFileList);
114-
}
115-
116-
// 1-2. 모니터링 접속정보 설정파일 콤보박스 아이템 변경 리스너 설정
117-
connInfoFileListComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
118-
propService.loadConnectionInfoConfig(newValue);
119-
List<String> dbNames = propService.getMonitoringDBNameList();
120-
List<String> serverNames = propService.getMonitoringServerNameList();
121-
addMonitoringConnInfoPreview(dbNames, serverNames);
122-
});
123-
124-
// 1-3. 모니터링 접속정보 설정파일 콤보박스 초기값 설정
125-
String lastUseConnInfoFile = propService.getLastUseConnectionInfoFilePath();
126-
if (StringUtils.isEmpty(lastUseConnInfoFile) || !connInfoFileList.contains(lastUseConnInfoFile)) {
127-
// 최근 사용된 접속정보 설정파일이 없거나 현재 존재하지 않는 경우, 첫 번째 설정파일 선택
128-
connInfoFileListComboBox.getSelectionModel().selectFirst();
129-
} else {
130-
connInfoFileListComboBox.getSelectionModel().select(lastUseConnInfoFile);
131-
}
132-
133-
/* 2. 모니터링 여부 설정 */
134-
// 2-1. 모니터링 여부 Preset 콤보박스 아이템 설정
135-
String curConnInfoFile = connInfoFileListComboBox.getSelectionModel().getSelectedItem();
136-
propService.loadMonitoringInfoConfig(curConnInfoFile);
137-
List<String> presetFileList = propService.getMonitoringPresetNameList();
138-
if (presetFileList == null || presetFileList.size() == 0) {
139-
// TODO 모니터링 여부 Preset 설정파일이 없는 경우
140-
addMonitoringPresetPreview(new ArrayList<>(), new ArrayList<>());
141-
} else {
142-
presetFileListComboBox.getItems().addAll(presetFileList);
143-
}
144-
145-
// 2-2. 모니터링 여부 Preset 콤보박스 아이템 변경 리스너 설정
146-
presetFileListComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
147-
List<MonitoringYN> dbYnList = propService.getDBMonitoringYnList(newValue);
148-
List<MonitoringYN> serverYnList = propService.getServerMonitoringYnList(newValue);
149-
addMonitoringPresetPreview(dbYnList, serverYnList);
150-
});
151-
152-
// 2-3. 모니터링 여부 Preset 콤보박스 초기값 설정
153-
String lastUsePresetFileName = propService.getLastUsePresetFileName(curConnInfoFile);
154-
if (StringUtils.isEmpty(lastUsePresetFileName) || !presetFileList.contains(lastUsePresetFileName)) {
155-
// 최근 사용된 모니터링 여부 Preset 설정파일이 없거나 현재 존재하지 않는 경우, 첫 번째 설정파일 선택
156-
presetFileListComboBox.getSelectionModel().selectFirst();
157-
} else {
158-
presetFileListComboBox.getSelectionModel().select(lastUsePresetFileName);
159-
}
111+
/* 1. 모니터링 접속정보 설정 + 2. 모니터링 여부 설정 */
112+
initRunStep1();
160113

161114
/* 3. 기타 설정 및 실행 */
162-
// 3-1. 조회결과 단위 콤보박스
163-
// 조회결과 단위 콤보박스 아이템 설정
164-
fileSizeCB.getItems().addAll(FileSize.values());
165-
fileSizeCB.getSelectionModel().select(propService.getDefaultFileSizeUnit());
166-
167-
// 3-2. 반올림 자릿수 콤보박스
168-
roundingDigitsCB.getItems().addAll(RoundingDigits.values());
169-
roundingDigitsCB.getSelectionModel().select(propService.getDefaultRoundingDigits());
170-
roundingDigitsCB.setConverter(new StringConverter<RoundingDigits>() {
171-
@Override
172-
public String toString(RoundingDigits digits) {
173-
return String.valueOf(digits.getDigits());
174-
}
175-
176-
@Override
177-
public RoundingDigits fromString(String digits) {
178-
return RoundingDigits.find(digits);
179-
}
180-
});
181-
182-
// 3-3. 모니터링 결과 저장 여부
183-
resultSaveToggleBtn.selectedProperty().set(true);
115+
initRunStep3();
184116

185-
// 실행결과 TableView 생성 및 Column 추가
186-
MonitoringTableView<ArchiveUsage> archiveTable = addMonitoringTableView(archiveAP, ArchiveUsage.class);
187-
archiveTable.addColumn("Archive", "archiveName");
188-
archiveTable.addColumn("사용량(%)", "usedPercent");
189-
190-
MonitoringTableView<TableSpaceUsage> tableSpaceTable = addMonitoringTableView(tableSpaceAP,
191-
TableSpaceUsage.class);
192-
tableSpaceTable.addColumn("테이블스페이스", "tableSpaceName");
193-
tableSpaceTable.addColumn("사용량(%)", "usedPercent");
194-
195-
MonitoringTableView<ASMDiskUsage> asmDiskTable = addMonitoringTableView(asmDiskAP, ASMDiskUsage.class);
196-
asmDiskTable.addColumn("디스크 그룹", "asmDiskGroupName");
197-
asmDiskTable.addColumn("디스크 타입", "asmDiskGroupType");
198-
asmDiskTable.addColumn("사용량(%)", "usedPercent");
199-
200-
MonitoringTableView<OSDiskUsage> osDiskTable = addMonitoringTableView(osDiskAP, OSDiskUsage.class);
201-
osDiskTable.addColumn("파일 시스템", "fileSystem");
202-
osDiskTable.addColumn("마운트 위치", "mountedOn");
203-
osDiskTable.addColumn("사용량(%)", "usedPercent");
117+
/* 4. 실행결과 */
118+
initRunStep4();
204119
}
205120

206121
/**
@@ -272,13 +187,11 @@ private void addMonitoringConnInfoPreview(List<String> dbNameList, List<String>
272187
*/
273188
private void addMonitoringPresetPreview(List<MonitoringYN> dbYnList, List<MonitoringYN> serverYnList) {
274189

275-
Set<MonitoringType> dbMonitoringTypeList = new HashSet<>();
276-
dbYnList.stream().map(m -> m.getDistinctMonitoringTypes()).collect(Collectors.toList())
277-
.forEach(type -> dbMonitoringTypeList.addAll(type));
190+
List<MonitoringType> dbMonitoringTypeList = Arrays.asList(MonitoringType.values()).stream()
191+
.filter(m -> m.getCategory().equals("DB")).collect(Collectors.toList());
278192

279-
Set<MonitoringType> serverMonitoringTypeList = new HashSet<>();
280-
serverYnList.stream().map(m -> m.getDistinctMonitoringTypes()).collect(Collectors.toList())
281-
.forEach(type -> serverMonitoringTypeList.addAll(type));
193+
List<MonitoringType> serverMonitoringTypeList = Arrays.asList(MonitoringType.values()).stream()
194+
.filter(m -> m.getCategory().equals("SERVER")).collect(Collectors.toList());
282195

283196
// 모니터링 여부 리스트 TreeTableView - DB
284197
CustomTreeTableView dbCtv = new CustomTreeTableView("", FontAwesomeIcon.LIST);
@@ -302,15 +215,142 @@ private void addMonitoringPresetPreview(List<MonitoringYN> dbYnList, List<Monito
302215
*
303216
* @param e
304217
*/
305-
public void monitoringRunBtn(ActionEvent e) {
218+
public void runMonitoring(ActionEvent e) {
306219
// TODO 선택된 접속정보 설정 파일, 모니터링 여부 설정파일, 기타 설정을 모두 읽어와 모니터링을 실행한다.
307-
308220
}
309221

310222
/**
311223
* 모니터링 결과를 TableView에 렌더링한다.
312224
*/
313-
public void showMonitoringResult() {
314-
// TODO 모니터링 결과를 매개변수로 전달받아 TableView에 렌더링한다.
225+
public <T> void setMonitoringResult(MonitoringTableView<T> tableView, List<T> result) {
226+
tableView.setItems(FXCollections.observableArrayList(result));
227+
}
228+
229+
/**
230+
* 1. 모니터링 접속정보 설정 영역의 View를 초기화한다.
231+
*/
232+
private void initRunStep1() {
233+
// 1-0. Clear
234+
if (connInfoFileListComboBox.getItems().size() != 0) {
235+
connInfoFileListComboBox.getItems().clear();
236+
}
237+
238+
// 1-1. 모니터링 접속정보 설정파일 콤보박스 아이템 설정
239+
List<String> connInfoFileList = propService.getConnectionInfoList();
240+
if (connInfoFileList == null || ArrayUtils.isEmpty(connInfoFileList.toArray())) {
241+
// TODO 접속정보 설정파일이 없는 경우
242+
addMonitoringConnInfoPreview(new ArrayList<>(), new ArrayList<>());
243+
} else {
244+
connInfoFileListComboBox.getItems().addAll(connInfoFileList);
245+
}
246+
247+
// 1-2. 모니터링 접속정보 설정파일 콤보박스 아이템 변경 리스너 설정
248+
connInfoFileListComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
249+
propService.loadConnectionInfoConfig(newValue);
250+
List<String> dbNames = propService.getMonitoringDBNameList();
251+
List<String> serverNames = propService.getMonitoringServerNameList();
252+
addMonitoringConnInfoPreview(dbNames, serverNames);
253+
initRunStep2();
254+
});
255+
256+
// 1-3. 모니터링 접속정보 설정파일 콤보박스 초기값 설정
257+
String lastUseConnInfoFile = propService.getLastUseConnectionInfoFilePath();
258+
if (StringUtils.isEmpty(lastUseConnInfoFile) || !connInfoFileList.contains(lastUseConnInfoFile)) {
259+
// 최근 사용된 접속정보 설정파일이 없거나 현재 존재하지 않는 경우, 첫 번째 설정파일 선택
260+
connInfoFileListComboBox.getSelectionModel().selectFirst();
261+
} else {
262+
connInfoFileListComboBox.getSelectionModel().select(lastUseConnInfoFile);
263+
}
264+
}
265+
266+
/**
267+
* 2. 모니터링 여부 설정 영역의 View를 초기화한다.
268+
*/
269+
private void initRunStep2() {
270+
// 2-0. Clear
271+
if (presetFileListComboBox.getItems().size() != 0) {
272+
presetFileListComboBox.getItems().clear();
273+
}
274+
275+
// 2-1. 모니터링 여부 Preset 콤보박스 아이템 설정
276+
String curConnInfoFile = connInfoFileListComboBox.getSelectionModel().getSelectedItem();
277+
propService.loadMonitoringInfoConfig(curConnInfoFile);
278+
List<String> presetFileList = propService.getMonitoringPresetNameList();
279+
if (presetFileList == null || presetFileList.size() == 0) {
280+
// TODO 모니터링 여부 Preset 설정파일이 없는 경우
281+
addMonitoringPresetPreview(new ArrayList<>(), new ArrayList<>());
282+
} else {
283+
presetFileListComboBox.getItems().addAll(presetFileList);
284+
}
285+
286+
// 2-2. 모니터링 여부 Preset 콤보박스 아이템 변경 리스너 설정
287+
presetFileListComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
288+
if (newValue != null) {
289+
List<MonitoringYN> dbYnList = propService.getDBMonitoringYnList(newValue);
290+
List<MonitoringYN> serverYnList = propService.getServerMonitoringYnList(newValue);
291+
addMonitoringPresetPreview(dbYnList, serverYnList);
292+
}
293+
});
294+
295+
// 2-3. 모니터링 여부 Preset 콤보박스 초기값 설정
296+
String lastUsePresetFileName = propService.getLastUsePresetFileName(curConnInfoFile);
297+
if (StringUtils.isEmpty(lastUsePresetFileName) || !presetFileList.contains(lastUsePresetFileName)) {
298+
// 최근 사용된 모니터링 여부 Preset 설정파일이 없거나 현재 존재하지 않는 경우, 첫 번째 설정파일 선택
299+
presetFileListComboBox.getSelectionModel().selectFirst();
300+
} else {
301+
presetFileListComboBox.getSelectionModel().select(lastUsePresetFileName);
302+
}
303+
}
304+
305+
/**
306+
* 3. 기타 설정 및 실행 영역의 View를 초기화한다.
307+
*/
308+
private void initRunStep3() {
309+
// 3-1. 조회결과 단위 콤보박스
310+
// 조회결과 단위 콤보박스 아이템 설정
311+
fileSizeCB.getItems().addAll(FileSize.values());
312+
fileSizeCB.getSelectionModel().select(propService.getDefaultFileSizeUnit());
313+
314+
// 3-2. 반올림 자릿수 콤보박스
315+
roundingDigitsCB.getItems().addAll(RoundingDigits.values());
316+
roundingDigitsCB.getSelectionModel().select(propService.getDefaultRoundingDigits());
317+
roundingDigitsCB.setConverter(new StringConverter<RoundingDigits>() {
318+
@Override
319+
public String toString(RoundingDigits digits) {
320+
return String.valueOf(digits.getDigits());
321+
}
322+
323+
@Override
324+
public RoundingDigits fromString(String digits) {
325+
return RoundingDigits.find(digits);
326+
}
327+
});
328+
329+
// 3-3. 모니터링 결과 저장 여부
330+
resultSaveToggleBtn.selectedProperty().set(true);
331+
}
332+
333+
/**
334+
* 4. 실행결과 영역의 View를 초기화한다.
335+
*/
336+
private void initRunStep4() {
337+
// 4-1. 실행결과 TableView 생성 및 Column 추가
338+
archiveTable = addMonitoringTableView(archiveAP, ArchiveUsage.class);
339+
archiveTable.addColumn("Archive", "archiveName");
340+
archiveTable.addColumn("사용량(%)", "usedPercent");
341+
342+
tableSpaceTable = addMonitoringTableView(tableSpaceAP, TableSpaceUsage.class);
343+
tableSpaceTable.addColumn("테이블스페이스", "tableSpaceName");
344+
tableSpaceTable.addColumn("사용량(%)", "usedPercent");
345+
346+
asmDiskTable = addMonitoringTableView(asmDiskAP, ASMDiskUsage.class);
347+
asmDiskTable.addColumn("디스크 그룹", "asmDiskGroupName");
348+
asmDiskTable.addColumn("디스크 타입", "asmDiskGroupType");
349+
asmDiskTable.addColumn("사용량(%)", "usedPercent");
350+
351+
osDiskTable = addMonitoringTableView(osDiskAP, OSDiskUsage.class);
352+
osDiskTable.addColumn("파일 시스템", "fileSystem");
353+
osDiskTable.addColumn("마운트 위치", "mountedOn");
354+
osDiskTable.addColumn("사용량(%)", "usedPercent");
315355
}
316356
}

src/main/resources/fxml/RunMenu.fxml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
<items>
277277
<SplitPane fx:id="upperSplitPane" dividerPositions="0.5" style="-fx-background-color: white;" SplitPane.resizableWithParent="false">
278278
<items>
279-
<AnchorPane fx:id="archiveAP" minHeight="0.0">
279+
<AnchorPane fx:id="archiveAP" minHeight="0.0" minWidth="350.0">
280280
<children>
281281
<Label text="Archive 사용량" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
282282
<graphic>
@@ -291,7 +291,7 @@
291291
</Label>
292292
</children>
293293
</AnchorPane>
294-
<AnchorPane fx:id="tableSpaceAP" minHeight="0.0">
294+
<AnchorPane fx:id="tableSpaceAP" minHeight="0.0" minWidth="350.0">
295295
<children>
296296
<Label text="TableSpace 사용량" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
297297
<graphic>
@@ -310,7 +310,7 @@
310310
</SplitPane>
311311
<SplitPane fx:id="lowerSplitPane" dividerPositions="0.5" style="-fx-background-color: white;" SplitPane.resizableWithParent="false">
312312
<items>
313-
<AnchorPane fx:id="asmDiskAP" minHeight="0.0">
313+
<AnchorPane fx:id="asmDiskAP" minHeight="0.0" minWidth="350.0">
314314
<children>
315315
<Label text="ASM Disk 사용량" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
316316
<graphic>
@@ -325,7 +325,7 @@
325325
</Label>
326326
</children>
327327
</AnchorPane>
328-
<AnchorPane fx:id="osDiskAP" minHeight="0.0">
328+
<AnchorPane fx:id="osDiskAP" minHeight="0.0" minWidth="350.0">
329329
<children>
330330
<Label text="OS Disk 사용량" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
331331
<graphic>

0 commit comments

Comments
 (0)