Added new NetLogger UI, currently no logic and server side

This commit is contained in:
Ziver Koc 2013-05-02 12:51:41 +00:00
parent 7bbec55626
commit ea6ef5e265
4 changed files with 292 additions and 0 deletions

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml" fx:controller="zutil.log.netlog.NetLoggerClient">
<children>
<MenuBar prefWidth="598.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" onAction="#handleConnectAction" text="Connect" />
<Menu mnemonicParsing="false" text="Previous">
<items>
<MenuItem mnemonicParsing="false" text="Koc.se:8080" />
<MenuItem mnemonicParsing="false" text="localhost:8080" />
</items>
</Menu>
<SeparatorMenuItem mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" text="Export" />
<SeparatorMenuItem disable="true" mnemonicParsing="false" />
<MenuItem mnemonicParsing="false" onAction="#handleExitAction" text="Exit" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem disable="true" mnemonicParsing="false" text="Copy" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" onAction="#handleAboutAction" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
<TabPane fx:id="tabPane" prefHeight="364.0" prefWidth="586.0" tabClosingPolicy="ALL_TABS" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="22.0" />
</children>
</AnchorPane>

View file

@ -0,0 +1,52 @@
package zutil.log.netlog;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.Parent;
import javafx.scene.control.TabPane;
public class NetLoggerClient extends Application{
public static final String VERSION = "0.1";
// UI elements
@FXML
private TabPane tabPane;
public static void main(String[] args) {
Application.launch(NetLoggerClient.class, args);
}
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("NetLoggerClient.fxml"));
stage.setTitle("NetLoggerClient ("+VERSION+")");
stage.setScene(new Scene(root));
stage.show();
}
// Menu Actioins
@FXML
protected void handleConnectAction(ActionEvent event) {
try{
tabPane.getTabs().add(new NetLoggerClientInstance("koc.se", 8080));
}catch(Exception e){
e.printStackTrace();
}
}
@FXML
protected void handleExitAction(ActionEvent event) {
System.exit(0);
}
@FXML
protected void handleAboutAction(ActionEvent event) {
}
}

View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="zutil.log.netlog.NetLoggerClientInstance">
<bottom>
<ToolBar maxHeight="22.0" minHeight="19.0" prefHeight="22.0" prefWidth="839.0">
<items>
<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">
<graphic>
<Label text="Log Count:" />
</graphic>
</Label>
</items>
</ToolBar>
</bottom>
<center>
<SplitPane dividerPositions="0.7491525423728813" focusTraversable="true" orientation="VERTICAL" prefHeight="297.0" prefWidth="600.0">
<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">
<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" />
</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">
<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" />
</columns>
</TableView>
</children>
</AnchorPane>
</items>
</SplitPane>
</center>
<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" />
<Region HBox.Hgrow="ALWAYS" />
<Group id="Group">
<children>
<Label layoutX="0.0" layoutY="-7.0" text="Log Level: " />
<ComboBox layoutX="60.0" layoutY="-9.0" onAction="#handleLevelChanged">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="01 - ERROR" />
<String fx:value="02 - WARNING" />
<String fx:value="03 - INFO" />
<String fx:value="04 - FINE" />
<String fx:value="05 - FINER" />
<String fx:value="06 - FINEST" />
</FXCollections>
</items>
</ComboBox>
</children>
</Group>
<Group id="Group">
<children>
<Label alignment="CENTER_RIGHT" layoutX="0.0" layoutY="-7.0" prefWidth="60.0" text="Interval: " />
<ComboBox layoutX="65.0" layoutY="-9.0" onAction="#handleIntervalChanged">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Instant" />
<String fx:value="3 sec" />
<String fx:value="5 sec" />
<String fx:value="10 sec" />
<String fx:value="30 sec" />
<String fx:value="60 sec" />
</FXCollections>
</items>
</ComboBox>
</children>
</Group>
</items>
</ToolBar>
</top>
</BorderPane>

View file

@ -0,0 +1,99 @@
package zutil.log.netlog;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.ProgressBar;
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;
public class NetLoggerClientInstance extends Tab{
private enum Status{RUNNING, PAUSED, DISCONNECTED}
// Logic variables
private Status status;
// UI elements
@FXML
private ToggleButton statusBt;
@FXML
private TableView logTb;
@FXML
private TableView exceptionTb;
@FXML
private Label logCountLb;
@FXML
private ProgressBar progressBar;
public NetLoggerClientInstance(){}
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);
}
});
updateStatus();
}
@FXML
protected void handlePauseAction(ActionEvent event) {
System.out.println("Pause changed");
if(status == Status.RUNNING){
status = Status.PAUSED;
}
else if(status == Status.PAUSED){
status = Status.RUNNING;
}
updateStatus();
}
@FXML
protected void handleDisconnectAction(Event event) {
System.out.println("Disconnected changed");
status = Status.DISCONNECTED;
updateStatus();
}
@FXML
protected void handleLevelChanged(ActionEvent event) {
System.out.println("Level changed");
}
@FXML
protected void handleIntervalChanged(ActionEvent event) {
System.out.println("Interval changed");
}
private void updateStatus(){
if(progressBar == null || statusBt == null)
return;
if(status == Status.RUNNING){
progressBar.setProgress(1);
statusBt.setText("Pause");
}
else if(status == Status.PAUSED){
progressBar.setProgress(-1);
statusBt.setText("Unpause");
}
else if(status == Status.DISCONNECTED){
progressBar.setProgress(0);
statusBt.disableProperty();
}
}
}