Updates to GUI
This commit is contained in:
parent
306675421f
commit
db9b2bf307
6 changed files with 212 additions and 50 deletions
50
src/zutil/log/netlog/NLExceptionData.java
Normal file
50
src/zutil/log/netlog/NLExceptionData.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package zutil.log.netlog;
|
||||
|
||||
public class NLExceptionData {
|
||||
|
||||
private int count;
|
||||
private String name;
|
||||
private String message;
|
||||
private String stackTrace;
|
||||
|
||||
NLExceptionData(String name, String message, String stackTrace){
|
||||
this.count = 0;
|
||||
this.name = name;
|
||||
this.message = message;
|
||||
this.stackTrace = stackTrace;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getStackTrace() {
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
public void setStackTrace(String stackTrace) {
|
||||
this.stackTrace = stackTrace;
|
||||
}
|
||||
}
|
||||
39
src/zutil/log/netlog/NLLogData.java
Normal file
39
src/zutil/log/netlog/NLLogData.java
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package zutil.log.netlog;
|
||||
|
||||
public class NLLogData {
|
||||
|
||||
private String level;
|
||||
private long timestamp;
|
||||
private String log;
|
||||
|
||||
NLLogData(String level, long timestamp, String log){
|
||||
this.level = level;
|
||||
this.timestamp = timestamp;
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getLog() {
|
||||
return log;
|
||||
}
|
||||
|
||||
public void setLog(String log) {
|
||||
this.log = log;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package zutil.log.netlog;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
|
|
@ -7,7 +9,9 @@ import javafx.fxml.FXMLLoader;
|
|||
import javafx.stage.Stage;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
public class NetLoggerClient extends Application{
|
||||
public static final String VERSION = "0.1";
|
||||
|
|
@ -30,11 +34,11 @@ public class NetLoggerClient extends Application{
|
|||
stage.show();
|
||||
}
|
||||
|
||||
// Menu Actioins
|
||||
// Menu Actions
|
||||
@FXML
|
||||
protected void handleConnectAction(ActionEvent event) {
|
||||
try{
|
||||
tabPane.getTabs().add(new NetLoggerClientInstance("koc.se", 8080));
|
||||
tabPane.getTabs().add(new NetLoggerClientTab("koc.se", 8080));
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -49,4 +53,19 @@ public class NetLoggerClient extends Application{
|
|||
protected void handleAboutAction(ActionEvent event) {
|
||||
|
||||
}
|
||||
|
||||
private class NetLoggerClientTab extends Tab{
|
||||
public NetLoggerClientTab(String host, int port) throws IOException{
|
||||
this.setText( host+":"+port );
|
||||
|
||||
Parent tabRoot = FXMLLoader.load(getClass().getResource("NetLoggerClientInstance.fxml"));
|
||||
this.setContent(tabRoot);
|
||||
AnchorPane.setRightAnchor(tabRoot, 0.0);
|
||||
//this.setOnClosed(new EventHandler<Event>() {
|
||||
// public void handle(Event e) {
|
||||
// handleDisconnectAction(e);
|
||||
// }
|
||||
//});
|
||||
}
|
||||
}
|
||||
}
|
||||
30
src/zutil/log/netlog/NetLoggerClientInstance.css
Normal file
30
src/zutil/log/netlog/NetLoggerClientInstance.css
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
|
||||
/* LOG LEVELS */
|
||||
.WARNING {
|
||||
-fx-control-inner-background: paleyellow;
|
||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
||||
}
|
||||
|
||||
.FINE {
|
||||
-fx-control-inner-background: skyblue;
|
||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
||||
}
|
||||
.FINER {
|
||||
-fx-control-inner-background: skyblue;
|
||||
-fx-accent: derive(-fx-control-inner-background, -25%);
|
||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
||||
}
|
||||
.FINEST {
|
||||
-fx-control-inner-background: skyblue;
|
||||
-fx-accent: derive(-fx-control-inner-background, -10%);
|
||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
||||
}
|
||||
|
||||
.ERROR {
|
||||
-fx-control-inner-background: palevioletred;
|
||||
-fx-accent: derive(-fx-control-inner-background, -40%);
|
||||
-fx-cell-hover-color: derive(-fx-control-inner-background, -20%);
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import java.net.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.collections.*?>
|
||||
<?import javafx.scene.*?>
|
||||
|
|
@ -15,7 +16,7 @@
|
|||
<ProgressBar fx:id="progressBar" prefWidth="200.0" progress="0.0" style="" />
|
||||
<Region HBox.Hgrow="ALWAYS" />
|
||||
<Separator orientation="VERTICAL" prefHeight="200.0" valignment="CENTER" />
|
||||
<Label fx:id="logCountLb" text="80">
|
||||
<Label fx:id="logCountLable" text="80">
|
||||
<graphic>
|
||||
<Label text="Log Count:" />
|
||||
</graphic>
|
||||
|
|
@ -28,23 +29,23 @@
|
|||
<items>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
||||
<children>
|
||||
<TableView fx:id="logTb" prefHeight="146.0" prefWidth="598.0" tableMenuButtonVisible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<TableView fx:id="logTable" prefHeight="146.0" prefWidth="598.0" tableMenuButtonVisible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columns>
|
||||
<TableColumn editable="false" prefWidth="75.0" sortable="false" text="#" />
|
||||
<TableColumn editable="false" prefWidth="75.0" sortable="false" text="Timestamp" />
|
||||
<TableColumn editable="false" prefWidth="75.0" sortable="false" text="Level" />
|
||||
<TableColumn editable="false" prefWidth="400.0" sortable="false" text="Log" />
|
||||
<TableColumn editable="false" prefWidth="75.0" sortable="false" text="Timestamp" fx:id="logTimestampColumn" />
|
||||
<TableColumn editable="false" prefWidth="75.0" sortable="false" text="Level" fx:id="logLevelColumn" />
|
||||
<TableColumn editable="false" prefWidth="400.0" sortable="false" text="Log" fx:id="logColumn" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
||||
<children>
|
||||
<TableView fx:id="exceptionTb" prefHeight="147.0" prefWidth="598.0" tableMenuButtonVisible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<TableView fx:id="exceptionTable" prefHeight="147.0" prefWidth="598.0" tableMenuButtonVisible="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columns>
|
||||
<TableColumn editable="false" prefWidth="75.0" text="Count" />
|
||||
<TableColumn editable="false" prefWidth="75.0" text="Exception" />
|
||||
<TableColumn editable="false" prefWidth="450.0" text="StackTrace" />
|
||||
<TableColumn editable="false" prefWidth="45.0" style="-fx-alignment: TOP_CENTER;" text="#" fx:id="exCountColumn" />
|
||||
<TableColumn editable="false" prefWidth="250.0" style="-fx-alignment: TOP_LEFT; -fx-font-weight: bold;" text="Exception" fx:id="exNameColumn" />
|
||||
<TableColumn editable="false" prefWidth="300.0" style="-fx-alignment: TOP_LEFT;" text="Message" fx:id="exMessageColumn" />
|
||||
<TableColumn editable="false" prefWidth="450.0" text="StackTrace" fx:id="exStackTraceColumn" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
|
|
@ -52,10 +53,13 @@
|
|||
</items>
|
||||
</SplitPane>
|
||||
</center>
|
||||
<stylesheets>
|
||||
<URL value="@NetLoggerClientInstance.css" />
|
||||
</stylesheets>
|
||||
<top>
|
||||
<ToolBar maxHeight="30.0" minHeight="22.0" prefHeight="30.0" prefWidth="839.0">
|
||||
<items>
|
||||
<ToggleButton fx:id="pauseBt" mnemonicParsing="false" onAction="#handlePauseAction" text="Pause" />
|
||||
<ToggleButton fx:id="pauseButton" mnemonicParsing="false" onAction="#handlePauseAction" text="Pause" />
|
||||
<Region HBox.Hgrow="ALWAYS" />
|
||||
<Group id="Group">
|
||||
<children>
|
||||
|
|
|
|||
|
|
@ -1,63 +1,78 @@
|
|||
package zutil.log.netlog;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ProgressBar;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import java.io.IOException;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
|
||||
public class NetLoggerClientInstance extends Tab{
|
||||
public class NetLoggerClientInstance implements Initializable {
|
||||
private enum Status{RUNNING, PAUSED, DISCONNECTED}
|
||||
|
||||
// Logic variables
|
||||
private Status status;
|
||||
|
||||
private final ObservableList<NLExceptionData> exceptionData =
|
||||
FXCollections.observableArrayList(
|
||||
new NLExceptionData("java.lang.NullPointerException", "", " at com.example.myproject.Book.getTitle(Book.java:16) \n at com.example.myproject.Author.getBookTitles(Author.java:25) \n at com.example.myproject.Bootstrap.main(Bootstrap.java:14)"),
|
||||
new NLExceptionData("java.lang.NullPointerException", "", " at com.example.myproject.Book.getTitle(Book.java:16) \n at com.example.myproject.Author.getBookTitles(Author.java:25) \n at com.example.myproject.Bootstrap.main(Bootstrap.java:14)"),
|
||||
new NLExceptionData("java.io.FileNotFoundException", "fred.txt", " at java.io.FileInputStream.<init>(FileInputStream.java) \n at java.io.FileInputStream.<init>(FileInputStream.java) \n at ExTest.readMyFile(ExTest.java:19) \n at ExTest.main(ExTest.java:7)")
|
||||
);
|
||||
|
||||
// UI elements
|
||||
@FXML
|
||||
private ToggleButton statusBt;
|
||||
@FXML private ToggleButton pauseButton;
|
||||
|
||||
@FXML
|
||||
private TableView logTb;
|
||||
@FXML
|
||||
private TableView exceptionTb;
|
||||
|
||||
@FXML
|
||||
private Label logCountLb;
|
||||
@FXML
|
||||
private ProgressBar progressBar;
|
||||
@FXML private TableView<NLLogData> logTable;
|
||||
@FXML private TableColumn<NLLogData, Long> logTimestampColumn;
|
||||
@FXML private TableColumn<NLLogData, String> logLevelColumn;
|
||||
@FXML private TableColumn<NLLogData, String> logColumn;
|
||||
|
||||
public NetLoggerClientInstance(){}
|
||||
@FXML private TableView<NLExceptionData> exceptionTable;
|
||||
@FXML private TableColumn<NLExceptionData, Long> exCountColumn;
|
||||
@FXML private TableColumn<NLExceptionData, String> exNameColumn;
|
||||
@FXML private TableColumn<NLExceptionData, String> exMessageColumn;
|
||||
@FXML private TableColumn<NLExceptionData, String> exStackTraceColumn;
|
||||
|
||||
public NetLoggerClientInstance(String host, int port) throws IOException{
|
||||
this.setText( host+":"+port );
|
||||
|
||||
Parent tabRoot = FXMLLoader.load(getClass().getResource("NetLoggerClientInstance.fxml"));
|
||||
this.setContent(tabRoot);
|
||||
AnchorPane.setRightAnchor(tabRoot, 0.0);
|
||||
this.setOnClosed(new EventHandler<Event>() {
|
||||
public void handle(Event e) {
|
||||
handleDisconnectAction(e);
|
||||
}
|
||||
});
|
||||
@FXML private Label logCountLabel;
|
||||
@FXML private ProgressBar progressBar;
|
||||
|
||||
|
||||
public void initialize(URL arg0, ResourceBundle arg1) {
|
||||
status = Status.RUNNING;
|
||||
updateStatus();
|
||||
|
||||
logTimestampColumn.setCellValueFactory(new PropertyValueFactory<NLLogData, Long>("timestamp"));
|
||||
logLevelColumn.setCellValueFactory(new PropertyValueFactory<NLLogData, String>("level"));
|
||||
logColumn.setCellValueFactory(new PropertyValueFactory<NLLogData, String>("log"));
|
||||
|
||||
exCountColumn.setCellValueFactory(new PropertyValueFactory<NLExceptionData, Long>("count"));
|
||||
exNameColumn.setCellValueFactory(new PropertyValueFactory<NLExceptionData, String>("name"));
|
||||
exMessageColumn.setCellValueFactory(new PropertyValueFactory<NLExceptionData, String>("message"));
|
||||
exStackTraceColumn.setCellValueFactory(new PropertyValueFactory<NLExceptionData, String>("stackTrace"));
|
||||
|
||||
//logTable.setItems(logData);
|
||||
exceptionTable.setItems(exceptionData);
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void handlePauseAction(ActionEvent event) {
|
||||
System.out.println("Pause changed");
|
||||
if(status == Status.RUNNING){
|
||||
status = Status.PAUSED;
|
||||
System.out.println("Logging Paused");
|
||||
}
|
||||
else if(status == Status.PAUSED){
|
||||
status = Status.RUNNING;
|
||||
System.out.println("Logging Unpaused");
|
||||
}
|
||||
updateStatus();
|
||||
}
|
||||
|
|
@ -80,20 +95,25 @@ public class NetLoggerClientInstance extends Tab{
|
|||
}
|
||||
|
||||
private void updateStatus(){
|
||||
if(progressBar == null || statusBt == null)
|
||||
if(progressBar == null || pauseButton == null){
|
||||
System.out.println("progressBar="+progressBar+" pauseButton="+pauseButton);
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Status: "+status);
|
||||
|
||||
if(status == Status.RUNNING){
|
||||
progressBar.setProgress(1);
|
||||
statusBt.setText("Pause");
|
||||
progressBar.setProgress(-1.0);
|
||||
pauseButton.setText("Pause");
|
||||
}
|
||||
else if(status == Status.PAUSED){
|
||||
progressBar.setProgress(-1);
|
||||
statusBt.setText("Unpause");
|
||||
progressBar.setProgress(1.0);
|
||||
pauseButton.setText("Unpause");
|
||||
}
|
||||
else if(status == Status.DISCONNECTED){
|
||||
progressBar.setProgress(0);
|
||||
statusBt.disableProperty();
|
||||
pauseButton.disableProperty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue