Browse Source

JavaDoc LogController

master
Johannes Oehm 10 years ago
parent
commit
e112ee3d4c
1 changed files with 36 additions and 11 deletions
  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 View File

@@ -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 { public class LogController {
/**
* The superior controller
*/
final MainController mainController; final MainController mainController;


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


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


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


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

private TableColumn<HL7LogEntry, HL7LogEntry.Direction> colLogDirection;


@FXML @FXML
Button btnRefresh;
private Button btnRefresh;

private Task<List<HL7LogEntry>> loadLogEntryTask = null; 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) { public LogController(MainController mainController) {
this.mainController = mainController; this.mainController = mainController;
} }


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


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


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


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




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


Loading…
Cancel
Save