Skip to content

Commit

Permalink
🐞 fix: 主要修复了一大堆 bug,次要完善了界面逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
freekatz committed May 1, 2020
1 parent 45dafae commit 8971467
Show file tree
Hide file tree
Showing 51 changed files with 1,644 additions and 1,413 deletions.
143 changes: 143 additions & 0 deletions pkit/src/main/java/gui/ctrl/AnalysisView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package gui.ctrl;

import gui.model.AnalysisMenuProperty;
import gui.model.SettingProperty;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import util.ViewHandle;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedHashMap;

public class AnalysisView implements View{
View view;
String path;

WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();
TreeView<String> menuTree;

@FXML
AnchorPane menuPane;

@FXML
AnchorPane chartPane;

public AnalysisView() {}

public void initialize() {

AnalysisMenuProperty menuProperty = new AnalysisMenuProperty();
LinkedHashMap<String, String> traffic = new LinkedHashMap<>();
traffic.put("NIF Statistic", "NIF Statistic1");
traffic.put("IO LineChart", SettingProperty.ioLineChartPath);
traffic.put("Protocol PieChart", SettingProperty.protocolPieChartPath);
traffic.put("IPv4 Statistic", SettingProperty.ipv4StatBarChartPath);
traffic.put("IPv6 Statistic", SettingProperty.ipv6StatBarChartPath);

LinkedHashMap<String, String> communication = new LinkedHashMap<>();
LinkedHashMap<String, String> relation = new LinkedHashMap<>();
LinkedHashMap<String, String> description = new LinkedHashMap<>();

menuProperty.setTraffic(traffic);
menuProperty.setCommunication(communication);
menuProperty.setRelation(relation);
menuProperty.setDescription(description);

menuTree = ViewHandle.InitializeMenuTree(menuProperty);
assert menuTree != null;
menuTree.setShowRoot(false);

menuPane.getChildren().add(menuTree);
menuPane.setPrefWidth(200);
AnchorPane.setTopAnchor(menuTree, 0.0);
AnchorPane.setLeftAnchor(menuTree, 0.0);
AnchorPane.setRightAnchor(menuTree, 0.0);
AnchorPane.setBottomAnchor(menuTree, 0.0);

chartPane.getChildren().add(webView);
webView.setPrefHeight(600);
webView.setPrefWidth(800);

AnchorPane.setTopAnchor(webView, 0.0);
AnchorPane.setLeftAnchor(webView, 0.0);
AnchorPane.setRightAnchor(webView, 0.0);
AnchorPane.setBottomAnchor(webView, 0.0);

this.setPath(SettingProperty.analysisWelcomePath);

menuTree.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
if (menuTree.getSelectionModel().getSelectedItem()==null)
return;
String name = (String) ((TreeItem)menuTree.getSelectionModel().getSelectedItem()).getValue();
String p;
if (traffic.containsKey(name))
p = traffic.get(name);
else if (communication.containsKey(name))
p = communication.get(name);
else if (relation.containsKey(name))
p = relation.get(name);
else if (description.containsKey(name))
p = description.get(name);
else return;
if (p.equals(path))
return;
setPath(p);

}
});


}

private void setPath(String path) {
this.path = path;
try {
File file = new File(path);
URL url = file.toURI().toURL();
webEngine.load(url.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
}
}

public View getView() {
return view;
}

public void setView(View view) {
this.view = view;
IndexView indexView = (IndexView) view;
indexView.StartCapture("analysis");
}

@Override
public String getType() {
return null;
}

@Override
public void setType(String type) {

}

@Override
public void close(Event event) {

}
}
27 changes: 20 additions & 7 deletions pkit/src/main/java/gui/ctrl/CaptureConfigView.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gui.ctrl;

import gui.ctrl.bar.CaptureToolBar;
import gui.ctrl.bar.IndexStatusBar;
import gui.ctrl.bar.StatusBar;
import gui.model.CaptureProperty;
import gui.model.Property;
import gui.model.SettingProperty;
Expand All @@ -17,9 +16,9 @@
import util.FileHandle;
import util.ViewHandle;

public class CaptureConfigView {
public class CaptureConfigView implements View{

IndexStatusBar indexStatusBar;
StatusBar statusBar;

@FXML
TableView<Property> configTable;
Expand Down Expand Up @@ -164,8 +163,8 @@ public Object fromString(String s) {

}

public void setIndexStatusBar(IndexStatusBar bar) {
this.indexStatusBar = bar;
public void setStatusBar(StatusBar bar) {
this.statusBar = bar;
}


Expand Down Expand Up @@ -203,7 +202,7 @@ private void CopyButtonOnClicked() {

@FXML
private void OkButtonOnClicked(Event event) {
indexStatusBar.UpdateContextMenu();
statusBar.UpdateContextMenu();
Stage stage = (Stage)((Button)(event).getSource()).getScene().getWindow();
stage.close();
// apply 过滤器
Expand All @@ -219,4 +218,18 @@ private void CancelButtonOnClicked(Event event) {
private void HelpButtonOnClicked() {
}

@Override
public String getType() {
return null;
}

@Override
public void setType(String type) {

}

@Override
public void close(Event event) {

}
}
Loading

0 comments on commit 8971467

Please sign in to comment.