瀏覽代碼

JavaDoc LogController

master
Johannes Oehm 10 年之前
父節點
當前提交
e112ee3d4c
共有 1 個文件被更改,包括 36 次插入11 次删除
  1. +36
    -11
      src/main/java/de/uniluebeck/mi/projmi6/controller/LogController.java

+ 36
- 11
src/main/java/de/uniluebeck/mi/projmi6/controller/LogController.java 查看文件

@@ -14,46 +14,65 @@ import java.util.List;


/**
* Created by 631806 on 19.11.15.
* Controller for the HL7 Log Tab.
*
* The log data is stored in the MySQL DB. The controller handles loading and showing of the data.
*
* Created by Johannes on 19.11.15.
* @author Johannes
*/
public class LogController {
/**
* The superior controller
*/
final MainController mainController;

@FXML
TableView<HL7LogEntry> tblLog;
private TableView<HL7LogEntry> tblLog;

@FXML
TableColumn<HL7LogEntry, String> colLogIp, colLogMessage;
private TableColumn<HL7LogEntry, String> colLogIp, colLogMessage;

@FXML
TableColumn<HL7LogEntry, LocalDateTime> colLogTime;
private TableColumn<HL7LogEntry, LocalDateTime> colLogTime;

@FXML
TableColumn<HL7LogEntry, HL7LogEntry.Direction> colLogDirection;

private TableColumn<HL7LogEntry, HL7LogEntry.Direction> colLogDirection;

@FXML
Button btnRefresh;
private Button btnRefresh;

private Task<List<HL7LogEntry>> loadLogEntryTask = null;

/**
* Constructor. Instance is created by the main controller.
* @param mainController The main controller instance that creates this controller instance
*/
public LogController(MainController mainController) {
this.mainController = mainController;
}

/**
* FXMLLoaders initialize()-method
*/
@FXML
private void initialize() {
initColumns();
refreshLogFromDb();
}

/**
* Init cell value factories for the table columns
*/
private void initColumns() {
colLogDirection.setCellValueFactory(new PropertyValueFactory<HL7LogEntry, HL7LogEntry.Direction>("direction"));
colLogIp.setCellValueFactory(new PropertyValueFactory<HL7LogEntry, String>("source"));
colLogTime.setCellValueFactory(new PropertyValueFactory<HL7LogEntry, LocalDateTime>("timestamp"));
colLogMessage.setCellValueFactory(new PropertyValueFactory<HL7LogEntry, String>("message"));

colLogMessage.setCellFactory(column -> {
return new TableCell<HL7LogEntry, String>() {
//Change cell factory cuz we need scrollable fields
colLogMessage.setCellFactory(column ->
new TableCell<HL7LogEntry, String>() {
private TextArea textArea = new TextArea();

{
@@ -73,10 +92,13 @@ public class LogController {
textArea.setWrapText(true);
this.setGraphic(textArea);
}
};
});
});
}

/**
* Starts reloading the log data from db.
*/
public void refreshLogFromDb() {
if (this.loadLogEntryTask != null && this.loadLogEntryTask.isRunning()) {
return;
@@ -122,6 +144,9 @@ public class LogController {
}


/**
* EventHandler for {@link #btnRefresh}
*/
@FXML
private void clickedRefresh() {
refreshLogFromDb();


Loading…
取消
儲存