|
| 1 | +package root.javafx.Controller; |
| 2 | + |
| 3 | +import java.io.IOException; |
| 4 | +import java.util.ArrayList; |
| 5 | +import java.util.HashMap; |
| 6 | +import java.util.List; |
| 7 | +import java.util.Map; |
| 8 | + |
| 9 | +import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon; |
| 10 | +import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView; |
| 11 | +import javafx.collections.FXCollections; |
| 12 | +import javafx.fxml.FXML; |
| 13 | +import javafx.fxml.FXMLLoader; |
| 14 | +import javafx.scene.control.Label; |
| 15 | +import javafx.scene.layout.AnchorPane; |
| 16 | +import javafx.scene.layout.HBox; |
| 17 | +import javafx.scene.layout.StackPane; |
| 18 | +import javafx.scene.text.Font; |
| 19 | +import root.core.domain.MonitoringResult; |
| 20 | +import root.core.domain.enums.MonitoringType; |
| 21 | +import root.javafx.CustomView.MonitoringTableView; |
| 22 | +import root.javafx.DI.DependencyInjection; |
| 23 | + |
| 24 | +public class MonitoringResultTableViewAP extends AnchorPane { |
| 25 | + |
| 26 | + @FXML |
| 27 | + private Label aliasLabel; |
| 28 | + |
| 29 | + @FXML |
| 30 | + private Label monitoringTimeLabel; |
| 31 | + |
| 32 | + @FXML |
| 33 | + private StackPane tableViewSP; |
| 34 | + |
| 35 | + @FXML |
| 36 | + private HBox tableViewHBox; |
| 37 | + |
| 38 | + private static final Map<MonitoringType, String> titleMap = new HashMap<>(); |
| 39 | + static { |
| 40 | + titleMap.put(MonitoringType.ARCHIVE, "Archive 사용량"); |
| 41 | + titleMap.put(MonitoringType.TABLE_SPACE, "TableSpace 사용량"); |
| 42 | + titleMap.put(MonitoringType.ASM_DISK, "ASM Disk 사용량"); |
| 43 | + titleMap.put(MonitoringType.OS_DISK, "OS Disk 사용량"); |
| 44 | + } |
| 45 | + |
| 46 | + private Map<MonitoringType, MonitoringTableView<? extends MonitoringResult>> tableViewMap = new HashMap<>(); |
| 47 | + |
| 48 | + private Map<MonitoringType, List<Object>> tableDataListMap = new HashMap<>(); |
| 49 | + |
| 50 | + public MonitoringResultTableViewAP() { |
| 51 | + try { |
| 52 | + FXMLLoader loader = DependencyInjection.getLoader("/fxml/MonitoringResultTableViewAP.fxml"); |
| 53 | + loader.setController(this); |
| 54 | + loader.setRoot(this); |
| 55 | + loader.load(); |
| 56 | + } catch (IOException e) { |
| 57 | + e.printStackTrace(); |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * 모니터링 결과 TableView를 추가한다. |
| 63 | + * |
| 64 | + * @param type |
| 65 | + */ |
| 66 | + private void addMonitoringTableView(MonitoringType type) { |
| 67 | + AnchorPane tableViewWrapper = new AnchorPane(); |
| 68 | + tableViewWrapper.setMinWidth(350); |
| 69 | + |
| 70 | + Label titleLabel = new Label(); |
| 71 | + titleLabel.setText(titleMap.get(type)); |
| 72 | + titleLabel.setFont(Font.font("Noto Sans Korean Regular")); |
| 73 | + |
| 74 | + FontAwesomeIconView icon = new FontAwesomeIconView(FontAwesomeIcon.ASTERISK, "9"); |
| 75 | + titleLabel.setGraphic(icon); |
| 76 | + |
| 77 | + AnchorPane.setTopAnchor(titleLabel, 0.0); |
| 78 | + AnchorPane.setLeftAnchor(titleLabel, 0.0); |
| 79 | + AnchorPane.setRightAnchor(titleLabel, 0.0); |
| 80 | + |
| 81 | + MonitoringTableView<? extends MonitoringResult> tableView = new MonitoringTableView<>(); |
| 82 | + AnchorPane.setTopAnchor(tableView, 20.0); |
| 83 | + AnchorPane.setLeftAnchor(tableView, 0.0); |
| 84 | + AnchorPane.setRightAnchor(tableView, 0.0); |
| 85 | + AnchorPane.setBottomAnchor(tableView, 0.0); |
| 86 | + tableViewMap.put(type, tableView); |
| 87 | + |
| 88 | + tableViewWrapper.getChildren().addAll(titleLabel, tableView); |
| 89 | + tableViewHBox.getChildren().add(tableViewWrapper); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * TableView 컬럼을 추가한다. |
| 94 | + * |
| 95 | + * @param type |
| 96 | + * @param title |
| 97 | + * @param fieldName |
| 98 | + */ |
| 99 | + public void addTableViewColumn(MonitoringType type, String title, String fieldName) { |
| 100 | + if (tableViewMap.get(type) == null) { |
| 101 | + addMonitoringTableView(type); |
| 102 | + } |
| 103 | + tableViewMap.get(type).addColumn(title, fieldName); |
| 104 | + } |
| 105 | + |
| 106 | + public <T extends MonitoringResult> void setTableData(MonitoringType type, List<T> dataList) { |
| 107 | + List<Object> list = tableDataListMap.get(type); |
| 108 | + if (list == null) { |
| 109 | + list = new ArrayList<>(); |
| 110 | + } |
| 111 | + |
| 112 | + list.clear(); |
| 113 | + list.addAll(dataList); |
| 114 | + |
| 115 | + MonitoringTableView<T> tableView = (MonitoringTableView<T>) tableViewMap.get(type); |
| 116 | + tableView.setItems(FXCollections.observableArrayList(dataList)); |
| 117 | + } |
| 118 | +} |
0 commit comments