corefx - consolidation of details panel code and updates to linkoptions to reflect current value types
This commit is contained in:
parent
5f7d46aacd
commit
7ecac387a0
8 changed files with 225 additions and 254 deletions
|
@ -87,33 +87,32 @@ public class CoreGrpcClient implements ICoreClient {
|
|||
|
||||
private CoreProto.LinkOptions linkOptionsToProto(CoreLinkOptions options) {
|
||||
CoreProto.LinkOptions.Builder builder = CoreProto.LinkOptions.newBuilder();
|
||||
boolean unidirectional = false;
|
||||
if (options.getUnidirectional() != null && options.getUnidirectional() == 1) {
|
||||
unidirectional = true;
|
||||
if (options.getUnidirectional() != null) {
|
||||
builder.setUnidirectional(options.getUnidirectional());
|
||||
}
|
||||
if (options.getBandwidth() != null) {
|
||||
builder.setBandwidth(options.getBandwidth().intValue());
|
||||
builder.setBandwidth(options.getBandwidth());
|
||||
}
|
||||
if (options.getBurst() != null) {
|
||||
builder.setBurst(options.getBurst().intValue());
|
||||
builder.setBurst(options.getBurst());
|
||||
}
|
||||
if (options.getDelay() != null) {
|
||||
builder.setDelay(options.getDelay().intValue());
|
||||
builder.setDelay(options.getDelay());
|
||||
}
|
||||
if (options.getDup() != null) {
|
||||
builder.setDup(options.getDup().intValue());
|
||||
builder.setDup(options.getDup());
|
||||
}
|
||||
if (options.getJitter() != null) {
|
||||
builder.setJitter(options.getJitter().intValue());
|
||||
builder.setJitter(options.getJitter());
|
||||
}
|
||||
if (options.getMburst() != null) {
|
||||
builder.setMburst(options.getMburst().intValue());
|
||||
builder.setMburst(options.getMburst());
|
||||
}
|
||||
if (options.getMer() != null) {
|
||||
builder.setMer(options.getMer().intValue());
|
||||
builder.setMer(options.getMer());
|
||||
}
|
||||
if (options.getPer() != null) {
|
||||
builder.setPer(options.getPer().intValue());
|
||||
builder.setPer(options.getPer().floatValue());
|
||||
}
|
||||
if (options.getKey() != null) {
|
||||
builder.setKey(options.getKey());
|
||||
|
@ -121,7 +120,6 @@ public class CoreGrpcClient implements ICoreClient {
|
|||
if (options.getOpaque() != null) {
|
||||
builder.setOpaque(options.getOpaque());
|
||||
}
|
||||
builder.setUnidirectional(unidirectional);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
@ -212,19 +210,19 @@ public class CoreGrpcClient implements ICoreClient {
|
|||
|
||||
CoreLinkOptions options = new CoreLinkOptions();
|
||||
CoreProto.LinkOptions protoOptions = linkProto.getOptions();
|
||||
options.setBandwidth((double) protoOptions.getBandwidth());
|
||||
options.setDelay((double) protoOptions.getDelay());
|
||||
options.setDup((double) protoOptions.getDup());
|
||||
options.setJitter((double) protoOptions.getJitter());
|
||||
options.setBandwidth((int) protoOptions.getBandwidth());
|
||||
options.setDelay((int) protoOptions.getDelay());
|
||||
options.setDup((int) protoOptions.getDup());
|
||||
options.setJitter((int) protoOptions.getJitter());
|
||||
options.setPer((double) protoOptions.getPer());
|
||||
options.setBurst((double) protoOptions.getBurst());
|
||||
options.setBurst((int) protoOptions.getBurst());
|
||||
if (protoOptions.hasField(CoreProto.LinkOptions.getDescriptor().findFieldByName("key"))) {
|
||||
options.setKey(protoOptions.getKey());
|
||||
}
|
||||
options.setMburst((double) protoOptions.getMburst());
|
||||
options.setMer((double) protoOptions.getMer());
|
||||
options.setMburst((int) protoOptions.getMburst());
|
||||
options.setMer((int) protoOptions.getMer());
|
||||
options.setOpaque(protoOptions.getOpaque());
|
||||
options.setUnidirectional(protoOptions.getUnidirectional() ? 1 : 0);
|
||||
options.setUnidirectional(protoOptions.getUnidirectional());
|
||||
link.setOptions(options);
|
||||
|
||||
return link;
|
||||
|
|
|
@ -8,14 +8,14 @@ import lombok.NoArgsConstructor;
|
|||
public class CoreLinkOptions {
|
||||
private String opaque;
|
||||
private Integer session;
|
||||
private Double jitter;
|
||||
private Integer jitter;
|
||||
private Integer key;
|
||||
private Double mburst;
|
||||
private Double mer;
|
||||
private Integer mburst;
|
||||
private Integer mer;
|
||||
private Double per;
|
||||
private Double bandwidth;
|
||||
private Double burst;
|
||||
private Double delay;
|
||||
private Double dup;
|
||||
private Integer unidirectional;
|
||||
private Integer bandwidth;
|
||||
private Integer burst;
|
||||
private Integer delay;
|
||||
private Integer dup;
|
||||
private Boolean unidirectional;
|
||||
}
|
||||
|
|
171
corefx/src/main/java/com/core/ui/DetailsPanel.java
Normal file
171
corefx/src/main/java/com/core/ui/DetailsPanel.java
Normal file
|
@ -0,0 +1,171 @@
|
|||
package com.core.ui;
|
||||
|
||||
import com.core.Controller;
|
||||
import com.core.data.CoreInterface;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.ui.textfields.DoubleFilter;
|
||||
import com.core.utils.FxmlUtils;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import inet.ipaddr.IPAddress;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Separator;
|
||||
import javafx.scene.control.TextFormatter;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.util.converter.DoubleStringConverter;
|
||||
import javafx.util.converter.IntegerStringConverter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
abstract class DetailsPanel extends ScrollPane {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final int START_INDEX = 1;
|
||||
final Controller controller;
|
||||
@FXML Label title;
|
||||
@FXML ScrollPane scrollPane;
|
||||
@FXML GridPane gridPane;
|
||||
int index = START_INDEX;
|
||||
|
||||
DetailsPanel(Controller controller) {
|
||||
this.controller = controller;
|
||||
FxmlUtils.loadRootController(this, "/fxml/details_panel.fxml");
|
||||
setPrefWidth(400);
|
||||
}
|
||||
|
||||
void setTitle(String text) {
|
||||
title.setText(text);
|
||||
}
|
||||
|
||||
void addButton(String text, EventHandler<ActionEvent> handler) {
|
||||
JFXButton emaneButton = new JFXButton(text);
|
||||
emaneButton.getStyleClass().add("core-button");
|
||||
emaneButton.setMaxWidth(Double.MAX_VALUE);
|
||||
emaneButton.setOnAction(handler);
|
||||
gridPane.add(emaneButton, 0, index++, 2, 1);
|
||||
}
|
||||
|
||||
void addLabel(String text) {
|
||||
Label label = new Label(text);
|
||||
label.getStyleClass().add("details-label");
|
||||
gridPane.add(label, 0, index++, 2, 1);
|
||||
}
|
||||
|
||||
void addSeparator() {
|
||||
Separator separator = new Separator(Orientation.HORIZONTAL);
|
||||
gridPane.add(separator, 0, index++, 2, 1);
|
||||
GridPane.setMargin(separator, new Insets(10, 0, 0, 0));
|
||||
}
|
||||
|
||||
void addInterface(CoreInterface coreInterface, CoreNode linkedNode) {
|
||||
if (linkedNode != null) {
|
||||
addRow("Linked To", linkedNode.getName(), true);
|
||||
}
|
||||
addRow("Interface", coreInterface.getName(), true);
|
||||
if (coreInterface.getMac() != null) {
|
||||
addRow("MAC", coreInterface.getMac(), true);
|
||||
}
|
||||
addAddress("IP4", coreInterface.getIp4());
|
||||
addAddress("IP6", coreInterface.getIp6());
|
||||
}
|
||||
|
||||
void addInterface(CoreInterface coreInterface) {
|
||||
addInterface(coreInterface, null);
|
||||
}
|
||||
|
||||
JFXTextField addRow(String labelText, String value, boolean disabled) {
|
||||
Label label = new Label(labelText);
|
||||
JFXTextField textField = new JFXTextField(value);
|
||||
textField.setDisable(disabled);
|
||||
gridPane.addRow(index++, label, textField);
|
||||
return textField;
|
||||
}
|
||||
|
||||
JFXTextField addDoubleRow(String labelText, Double value) {
|
||||
Label label = new Label(labelText);
|
||||
String valueString = null;
|
||||
if (value != null) {
|
||||
valueString = value.toString();
|
||||
}
|
||||
JFXTextField textField = new JFXTextField();
|
||||
TextFormatter<Double> formatter = new TextFormatter<>(
|
||||
new DoubleStringConverter(), null, new DoubleFilter());
|
||||
textField.setTextFormatter(formatter);
|
||||
textField.setText(valueString);
|
||||
gridPane.addRow(index++, label, textField);
|
||||
return textField;
|
||||
}
|
||||
|
||||
Double getDouble(JFXTextField textField) {
|
||||
if (textField.getText() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Double value = null;
|
||||
try {
|
||||
logger.info("double field text: {}", textField.getText());
|
||||
value = Double.parseDouble(textField.getText());
|
||||
} catch (NumberFormatException ex) {
|
||||
logger.error("error getting double value", ex);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
JFXTextField addIntegerRow(String labelText, Integer value) {
|
||||
Label label = new Label(labelText);
|
||||
String valueString = null;
|
||||
if (value != null) {
|
||||
valueString = value.toString();
|
||||
}
|
||||
JFXTextField textField = new JFXTextField();
|
||||
UnaryOperator<TextFormatter.Change> filter = change -> {
|
||||
String text = change.getText();
|
||||
if (text.matches("[0-9]*")) {
|
||||
return change;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
TextFormatter<Integer> formatter = new TextFormatter<>(
|
||||
new IntegerStringConverter(), null, filter);
|
||||
textField.setTextFormatter(formatter);
|
||||
textField.setText(valueString);
|
||||
gridPane.addRow(index++, label, textField);
|
||||
return textField;
|
||||
}
|
||||
|
||||
Integer getInteger(JFXTextField textField) {
|
||||
if (textField.getText() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Integer value = null;
|
||||
try {
|
||||
logger.info("integer field text: {}", textField.getText());
|
||||
value = Integer.parseInt(textField.getText());
|
||||
} catch (NumberFormatException ex) {
|
||||
logger.error("error getting integer value", ex);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private void addAddress(String label, IPAddress ip) {
|
||||
if (ip == null) {
|
||||
return;
|
||||
}
|
||||
addRow(label, ip.toString(), true);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
if (gridPane.getChildren().size() > START_INDEX) {
|
||||
gridPane.getChildren().remove(START_INDEX, gridPane.getChildren().size());
|
||||
}
|
||||
index = START_INDEX;
|
||||
}
|
||||
}
|
|
@ -267,6 +267,7 @@ public class GraphToolbar extends VBox {
|
|||
pickingButton.fire();
|
||||
devicesButton.setDisable(true);
|
||||
nodesButton.setDisable(true);
|
||||
containersButton.setDisable(true);
|
||||
runButton.pseudoClassStateChanged(START_CLASS, false);
|
||||
runButton.pseudoClassStateChanged(STOP_CLASS, true);
|
||||
if (runButton.getGraphic() != stopIcon) {
|
||||
|
@ -278,6 +279,7 @@ public class GraphToolbar extends VBox {
|
|||
Platform.runLater(() -> {
|
||||
devicesButton.setDisable(false);
|
||||
nodesButton.setDisable(false);
|
||||
containersButton.setDisable(false);
|
||||
runButton.pseudoClassStateChanged(START_CLASS, true);
|
||||
runButton.pseudoClassStateChanged(STOP_CLASS, false);
|
||||
if (runButton.getGraphic() != startIcon) {
|
||||
|
|
|
@ -7,44 +7,25 @@ import com.core.data.CoreLink;
|
|||
import com.core.data.CoreLinkOptions;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.graph.NetworkGraph;
|
||||
import com.core.ui.textfields.DoubleFilter;
|
||||
import com.core.utils.FxmlUtils;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import inet.ipaddr.IPAddress;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Separator;
|
||||
import javafx.scene.control.TextFormatter;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import javafx.util.converter.DoubleStringConverter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class LinkDetails extends ScrollPane {
|
||||
public class LinkDetails extends DetailsPanel {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final int START_INDEX = 1;
|
||||
private final Controller controller;
|
||||
private int index = START_INDEX;
|
||||
@FXML private GridPane gridPane;
|
||||
|
||||
public LinkDetails(Controller controller) {
|
||||
this.controller = controller;
|
||||
FxmlUtils.loadRootController(this, "/fxml/link_details.fxml");
|
||||
setPrefWidth(400);
|
||||
super(controller);
|
||||
}
|
||||
|
||||
public void setLink(CoreLink link) {
|
||||
NetworkGraph graph = controller.getNetworkGraph();
|
||||
ICoreClient coreClient = controller.getCoreClient();
|
||||
clear();
|
||||
|
||||
setTitle("Link Details");
|
||||
addSeparator();
|
||||
|
||||
CoreNode nodeOne = graph.getVertex(link.getNodeOne());
|
||||
|
@ -62,18 +43,18 @@ public class LinkDetails extends ScrollPane {
|
|||
}
|
||||
|
||||
addLabel("Properties");
|
||||
JFXTextField bandwidthField = addRow("Bandwidth (bps)", link.getOptions().getBandwidth());
|
||||
JFXTextField delayField = addRow("Delay (us)", link.getOptions().getDelay());
|
||||
JFXTextField jitterField = addRow("Jitter (us)", link.getOptions().getJitter());
|
||||
JFXTextField lossField = addRow("Loss (%)", link.getOptions().getPer());
|
||||
JFXTextField dupsField = addRow("Duplicate (%)", link.getOptions().getDup());
|
||||
JFXTextField bandwidthField = addIntegerRow("Bandwidth (bps)", link.getOptions().getBandwidth());
|
||||
JFXTextField delayField = addIntegerRow("Delay (us)", link.getOptions().getDelay());
|
||||
JFXTextField jitterField = addIntegerRow("Jitter (us)", link.getOptions().getJitter());
|
||||
JFXTextField lossField = addDoubleRow("Loss (%)", link.getOptions().getPer());
|
||||
JFXTextField dupsField = addIntegerRow("Duplicate (%)", link.getOptions().getDup());
|
||||
addButton("Update", event -> {
|
||||
CoreLinkOptions options = link.getOptions();
|
||||
options.setBandwidth(getDouble(bandwidthField));
|
||||
options.setDelay(getDouble(delayField));
|
||||
options.setJitter(getDouble(jitterField));
|
||||
options.setBandwidth(getInteger(bandwidthField));
|
||||
options.setDelay(getInteger(delayField));
|
||||
options.setJitter(getInteger(jitterField));
|
||||
options.setPer(getDouble(lossField));
|
||||
options.setDup(getDouble(dupsField));
|
||||
options.setDup(getInteger(dupsField));
|
||||
|
||||
if (coreClient.isRunning()) {
|
||||
try {
|
||||
|
@ -85,86 +66,4 @@ public class LinkDetails extends ScrollPane {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Double getDouble(JFXTextField textField) {
|
||||
if (textField.getText() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Double value = null;
|
||||
try {
|
||||
logger.info("double field text: {}", textField.getText());
|
||||
value = Double.parseDouble(textField.getText());
|
||||
} catch (NumberFormatException ex) {
|
||||
logger.error("error getting double value", ex);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private void addButton(String text, EventHandler<ActionEvent> handler) {
|
||||
JFXButton button = new JFXButton(text);
|
||||
button.getStyleClass().add("core-button");
|
||||
button.setMaxWidth(Double.MAX_VALUE);
|
||||
button.setOnAction(handler);
|
||||
gridPane.add(button, 0, index++, 2, 1);
|
||||
GridPane.setMargin(button, new Insets(10, 0, 0, 0));
|
||||
}
|
||||
|
||||
private void addLabel(String text) {
|
||||
Label label = new Label(text);
|
||||
label.getStyleClass().add("details-label");
|
||||
gridPane.add(label, 0, index++, 2, 1);
|
||||
}
|
||||
|
||||
private void addSeparator() {
|
||||
Separator separator = new Separator(Orientation.HORIZONTAL);
|
||||
gridPane.add(separator, 0, index++, 2, 1);
|
||||
GridPane.setMargin(separator, new Insets(10, 0, 0, 0));
|
||||
}
|
||||
|
||||
private void addInterface(CoreInterface coreInterface) {
|
||||
addRow("Interface", coreInterface.getName(), true);
|
||||
addRow("MAC", coreInterface.getMac(), true);
|
||||
addAddress("IP4", coreInterface.getIp4());
|
||||
addAddress("IP6", coreInterface.getIp6());
|
||||
}
|
||||
|
||||
private void addRow(String labelText, String value, boolean disabled) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
Label label = new Label(labelText);
|
||||
JFXTextField textField = new JFXTextField(value);
|
||||
textField.setDisable(disabled);
|
||||
gridPane.addRow(index++, label, textField);
|
||||
}
|
||||
|
||||
private JFXTextField addRow(String labelText, Double value) {
|
||||
Label label = new Label(labelText);
|
||||
String doubleString = null;
|
||||
if (value != null) {
|
||||
doubleString = value.toString();
|
||||
}
|
||||
JFXTextField textField = new JFXTextField();
|
||||
TextFormatter<Double> formatter = new TextFormatter<>(
|
||||
new DoubleStringConverter(), null, new DoubleFilter());
|
||||
textField.setTextFormatter(formatter);
|
||||
textField.setText(doubleString);
|
||||
gridPane.addRow(index++, label, textField);
|
||||
return textField;
|
||||
}
|
||||
|
||||
private void addAddress(String label, IPAddress ip) {
|
||||
if (ip == null) {
|
||||
return;
|
||||
}
|
||||
addRow(label, ip.toString(), true);
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
if (gridPane.getChildren().size() > START_INDEX) {
|
||||
gridPane.getChildren().remove(START_INDEX, gridPane.getChildren().size());
|
||||
}
|
||||
index = START_INDEX;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,47 +5,27 @@ import com.core.data.CoreInterface;
|
|||
import com.core.data.CoreLink;
|
||||
import com.core.data.CoreNode;
|
||||
import com.core.data.NodeType;
|
||||
import com.core.utils.FxmlUtils;
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXListView;
|
||||
import com.jfoenix.controls.JFXScrollPane;
|
||||
import com.jfoenix.controls.JFXTextField;
|
||||
import inet.ipaddr.IPAddress;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Separator;
|
||||
import javafx.scene.layout.GridPane;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class NodeDetails extends ScrollPane {
|
||||
public class NodeDetails extends DetailsPanel {
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
private static final int START_INDEX = 1;
|
||||
private final Controller controller;
|
||||
@FXML private Label title;
|
||||
@FXML private ScrollPane scrollPane;
|
||||
@FXML private GridPane gridPane;
|
||||
private int index = START_INDEX;
|
||||
|
||||
public NodeDetails(Controller controller) {
|
||||
this.controller = controller;
|
||||
FxmlUtils.loadRootController(this, "/fxml/node_details.fxml");
|
||||
setPrefWidth(400);
|
||||
super(controller);
|
||||
}
|
||||
|
||||
public void setNode(CoreNode node) {
|
||||
clear();
|
||||
boolean sessionRunning = controller.getCoreClient().isRunning();
|
||||
|
||||
title.setText(node.getName());
|
||||
setTitle(node.getName());
|
||||
addSeparator();
|
||||
|
||||
addLabel("Properties");
|
||||
|
@ -55,10 +35,13 @@ public class NodeDetails extends ScrollPane {
|
|||
} else {
|
||||
addRow("Type", node.getNodeType().getDisplay(), true);
|
||||
}
|
||||
addRow("EMANE", node.getEmane(), true);
|
||||
addRow("X", node.getPosition().getX().toString(), true);
|
||||
addRow("Y", node.getPosition().getY().toString(), true);
|
||||
|
||||
if (node.getType() == NodeType.EMANE) {
|
||||
addRow("EMANE", node.getEmane(), true);
|
||||
}
|
||||
|
||||
if (node.getType() == NodeType.DOCKER || node.getType() == NodeType.LXC) {
|
||||
setContainerDetails(node, sessionRunning);
|
||||
}
|
||||
|
@ -126,60 +109,12 @@ public class NodeDetails extends ScrollPane {
|
|||
|
||||
private void setContainerDetails(CoreNode node, boolean sessionRunning) {
|
||||
JFXTextField imageField = addRow("Image", node.getImage(), sessionRunning);
|
||||
addButton("Update", event -> {
|
||||
if (node.getType() == NodeType.DOCKER || node.getType() == NodeType.LXC) {
|
||||
node.setImage(imageField.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addButton(String text, EventHandler<ActionEvent> handler) {
|
||||
JFXButton emaneButton = new JFXButton(text);
|
||||
emaneButton.getStyleClass().add("core-button");
|
||||
emaneButton.setMaxWidth(Double.MAX_VALUE);
|
||||
emaneButton.setOnAction(handler);
|
||||
gridPane.add(emaneButton, 0, index++, 2, 1);
|
||||
}
|
||||
|
||||
private void addLabel(String text) {
|
||||
Label label = new Label(text);
|
||||
label.getStyleClass().add("details-label");
|
||||
gridPane.add(label, 0, index++, 2, 1);
|
||||
}
|
||||
|
||||
private void addSeparator() {
|
||||
Separator separator = new Separator(Orientation.HORIZONTAL);
|
||||
gridPane.add(separator, 0, index++, 2, 1);
|
||||
GridPane.setMargin(separator, new Insets(10, 0, 0, 0));
|
||||
}
|
||||
|
||||
private void addInterface(CoreInterface coreInterface, CoreNode linkedNode) {
|
||||
addRow("Linked To", linkedNode.getName(), true);
|
||||
addRow("Interface", coreInterface.getName(), true);
|
||||
addRow("MAC", coreInterface.getMac(), true);
|
||||
addAddress("IP4", coreInterface.getIp4());
|
||||
addAddress("IP6", coreInterface.getIp6());
|
||||
}
|
||||
|
||||
private JFXTextField addRow(String labelText, String value, boolean disabled) {
|
||||
Label label = new Label(labelText);
|
||||
JFXTextField textField = new JFXTextField(value);
|
||||
textField.setDisable(disabled);
|
||||
gridPane.addRow(index++, label, textField);
|
||||
return textField;
|
||||
}
|
||||
|
||||
private void addAddress(String label, IPAddress ip) {
|
||||
if (ip == null) {
|
||||
return;
|
||||
if (!sessionRunning) {
|
||||
addButton("Update", event -> {
|
||||
if (node.getType() == NodeType.DOCKER || node.getType() == NodeType.LXC) {
|
||||
node.setImage(imageField.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
addRow(label, ip.toString(), true);
|
||||
}
|
||||
|
||||
private void clear() {
|
||||
if (gridPane.getChildren().size() > START_INDEX) {
|
||||
gridPane.getChildren().remove(START_INDEX, gridPane.getChildren().size());
|
||||
}
|
||||
index = START_INDEX;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.ColumnConstraints?>
|
||||
<?import javafx.scene.layout.GridPane?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<fx:root fitToWidth="true" prefHeight="418.0" prefWidth="300.0" type="ScrollPane" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<content>
|
||||
<GridPane fx:id="gridPane" hgap="5.0" prefWidth="300.0" vgap="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<padding>
|
||||
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
|
||||
</padding>
|
||||
<children>
|
||||
<Label styleClass="details-title" text="Link Details" GridPane.columnSpan="2147483647">
|
||||
<font>
|
||||
<Font name="System Bold" size="17.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</GridPane>
|
||||
</content>
|
||||
</fx:root>
|
Loading…
Reference in a new issue