Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Continuing implementation of a CFDP UI application (for easy testing)
Browse files Browse the repository at this point in the history
  • Loading branch information
dariol83 committed Sep 27, 2021
1 parent 9cfe520 commit e76cf81
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class CfdpFxTestTool extends Application {
public void start(Stage primaryStage) {
try {
VBox root = FXMLLoader.load(CfdpFxTestTool.class.getResource("/eu/dariolucia/ccsds/cfdp/fx/fxml/Main.fxml"));
Scene scene = new Scene(root,1600,960);
Scene scene = new Scene(root,1150,768);
primaryStage.getIcons().add(new Image(CfdpFxTestTool.class.getResourceAsStream("/eu/dariolucia/ccsds/cfdp/fx/images/monitor.png")));
primaryStage.setScene(scene);
primaryStage.setTitle(NAME + " " + VERSION + " - CFDP Entity: " + cfdpEntity.getMib().getLocalEntity().getLocalEntityId() + " - Filestore: " + filestorePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Modality;
import javafx.util.Pair;
Expand Down Expand Up @@ -125,23 +124,15 @@ public class MainController implements Initializable, ICfdpEntitySubscriber {

private ICfdpEntity cfdpEntity;


@SuppressWarnings("unchecked")
@Override
public void initialize(URL location, ResourceBundle resources) {
this.cfdpEntity = CfdpFxTestTool.getCfdpEntity();

this.transactionTable.setPlaceholder(new Label("No transactions"));

// Button graphics
{
Image image = new Image(getClass()
.getResourceAsStream("/eu/dariolucia/ccsds/cfdp/fx/images/save.png"));
this.saveAsLogButton.setGraphic(new ImageView(image));
}
{
Image image = new Image(getClass()
.getResourceAsStream("/eu/dariolucia/ccsds/cfdp/fx/images/trash-2.png"));
this.clearLogButton.setGraphic(new ImageView(image));
}
DialogUtils.attachImage(getClass(), this.saveAsLogButton, "/eu/dariolucia/ccsds/cfdp/fx/images/save.png");
DialogUtils.attachImage(getClass(), this.clearLogButton, "/eu/dariolucia/ccsds/cfdp/fx/images/trash-2.png");

// Register this subscriber to the CFDP entity
this.cfdpEntity.register(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
public class PutRequestDialogController implements Initializable {

private static final Logger LOG = Logger.getLogger(PutRequestDialogController.class.getName());
public static final String ADD_IMAGE = "/eu/dariolucia/ccsds/cfdp/fx/images/plus.png";
public static final String REMOVE_IMAGE = "/eu/dariolucia/ccsds/cfdp/fx/images/minus.png";
public static final String MOVE_UP_IMAGE = "/eu/dariolucia/ccsds/cfdp/fx/images/arrowhead-up.png";
public static final String MOVE_DOWN_IMAGE = "/eu/dariolucia/ccsds/cfdp/fx/images/arrowhead-down.png";

@FXML
private ChoiceBox<Long> destinationEntityCombo;
Expand Down Expand Up @@ -137,9 +141,9 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
faultHandlerMoveUpButton.disableProperty().bind(faultHandlerListView.getSelectionModel().selectedItemProperty().isNull());
faultHandlerMoveDownButton.disableProperty().bind(faultHandlerListView.getSelectionModel().selectedItemProperty().isNull());

messageToUserRemoveButton.disableProperty().bind(faultHandlerListView.getSelectionModel().selectedItemProperty().isNull());
messageToUserMoveUpButton.disableProperty().bind(faultHandlerListView.getSelectionModel().selectedItemProperty().isNull());
messageToUserMoveDownButton.disableProperty().bind(faultHandlerListView.getSelectionModel().selectedItemProperty().isNull());
messageToUserRemoveButton.disableProperty().bind(messageToUserListView.getSelectionModel().selectedItemProperty().isNull());
messageToUserMoveUpButton.disableProperty().bind(messageToUserListView.getSelectionModel().selectedItemProperty().isNull());
messageToUserMoveDownButton.disableProperty().bind(messageToUserListView.getSelectionModel().selectedItemProperty().isNull());

closureCheckbox.disableProperty().bind(acknowledgedCheckbox.selectedProperty());

Expand All @@ -148,6 +152,22 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
segmentationControlCheckbox.disableProperty().bind(fileTransferCheckbox.selectedProperty().not());

flowLabelTextField.disableProperty().bind(flowLabelCheckbox.selectedProperty().not());

// Graphics
DialogUtils.attachImage(getClass(), messageToUserAddButton, ADD_IMAGE);
DialogUtils.attachImage(getClass(), messageToUserRemoveButton, REMOVE_IMAGE);
DialogUtils.attachImage(getClass(), messageToUserMoveUpButton, MOVE_UP_IMAGE);
DialogUtils.attachImage(getClass(), messageToUserMoveDownButton, MOVE_DOWN_IMAGE);

DialogUtils.attachImage(getClass(), faultHandlerAddButton, ADD_IMAGE);
DialogUtils.attachImage(getClass(), faultHandlerRemoveButton, REMOVE_IMAGE);
DialogUtils.attachImage(getClass(), faultHandlerMoveUpButton, MOVE_UP_IMAGE);
DialogUtils.attachImage(getClass(), faultHandlerMoveDownButton, MOVE_DOWN_IMAGE);

DialogUtils.attachImage(getClass(), filestoreRequestAddButton, ADD_IMAGE);
DialogUtils.attachImage(getClass(), filestoreRequestRemoveButton, REMOVE_IMAGE);
DialogUtils.attachImage(getClass(), filestoreRequestMoveUpButton, MOVE_UP_IMAGE);
DialogUtils.attachImage(getClass(), filestoreRequestMoveDownButton, MOVE_DOWN_IMAGE);
}

public void filestoreRequestAddButtonClicked(ActionEvent actionEvent) {
Expand Down Expand Up @@ -202,6 +222,11 @@ private <T> void moveDownSelected(ListView<T> list) {
public void messageToUserAddButtonClicked(ActionEvent actionEvent) {
String hex = messageToUserTextField.getText().trim();
if(!hex.isBlank()) {
// Match with
if(!"[0-9|a-f|A-F]*".matches(hex)) {
DialogUtils.showError("Error parsing string", "The provided string is not a valid hex dump");
return;
}
try {
byte[] message = StringUtil.toByteArray(hex);
messageToUserListView.getItems().add(new MessageToUserTLV(message));
Expand Down Expand Up @@ -245,7 +270,7 @@ public void faultHandlerMoveDownButtonClicked(ActionEvent actionEvent) {

public void bindOkButton(Button okButton) {
this.okButton = okButton;
// TODO: maybe it should be a bit better than this, but this is a test tool after all...
// Maybe it should be a bit better than this, but this is a test tool after all...
this.okButton.disableProperty().bind(destinationEntityCombo.getSelectionModel().selectedItemProperty().isNull());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
package eu.dariolucia.ccsds.cfdp.fx.dialogs;

import javafx.scene.Node;
import javafx.scene.control.Alert;
import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;

Expand All @@ -33,41 +32,9 @@

public class DialogUtils {

public static void showLogRecordDetails(String title, LogRecord record) {
Alert dialog = new Alert(AlertType.INFORMATION);
dialog.setTitle(title + " - " + new Date(record.getMillis()));
dialog.setHeaderText(null);
dialog.setContentText(record.getLevel() + "\n\n" + record.getMessage());

if(record.getThrown() != null) {
Throwable ex = record.getThrown();

// Create expandable Exception.
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String exceptionText = sw.toString();

Label label = new Label("Exception stacktrace:");

TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);

textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);

GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);

dialog.getDialogPane().setExpandableContent(expContent);
}

dialog.showAndWait();
public static void attachImage(Class<?> clazz, Button b, String path) {
Image image = new Image(clazz.getResourceAsStream(path));
b.setGraphic(new ImageView(image));
}

public static void showInfo(String title, String text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
<TableColumn fx:id="sourceIdColumn" prefWidth="75.0" text="Source ID" />
<TableColumn fx:id="destinationIdColumn" prefWidth="75.0" text="Dest. ID" />
<TableColumn fx:id="directionColumn" prefWidth="75.0" text="Direction" />
<TableColumn fx:id="sourceFileNameColumn" prefWidth="175.0" text="Source File" />
<TableColumn fx:id="destinationFileNameColumn" prefWidth="175.0" text="Dest. File" />
<TableColumn fx:id="sourceFileNameColumn" prefWidth="200.0" text="Source File" />
<TableColumn fx:id="destinationFileNameColumn" prefWidth="200.0" text="Dest. File" />
<TableColumn fx:id="fileSizeColumn" prefWidth="75.0" text="Size" />
<TableColumn fx:id="ackTypeColumn" prefWidth="75.0" text="Class" />
<TableColumn fx:id="statusColumn" prefWidth="75.0" text="Status" />
<TableColumn fx:id="progressColumn" prefWidth="200.0" text="Progress" />
<TableColumn fx:id="ackTypeColumn" prefWidth="100.0" text="Class" />
<TableColumn fx:id="statusColumn" prefWidth="100.0" text="Status" />
<TableColumn fx:id="progressColumn" prefWidth="100.0" text="Progress" />
</columns>
</TableView>
</children></HBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
<ListView fx:id="filestoreRequestListView" maxHeight="130.0" HBox.hgrow="ALWAYS" />
<VBox spacing="5.0">
<children>
<Button fx:id="filestoreRequestAddButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestAddButtonClicked" text="+" />
<Button fx:id="filestoreRequestRemoveButton" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestRemoveButtonClicked" text="-" />
<Button fx:id="filestoreRequestMoveUpButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestMoveUpButtonClicked" text="^" />
<Button fx:id="filestoreRequestMoveDownButton" layoutX="10.0" layoutY="34.0" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestMoveDownButtonClicked" text="v" />
<Button fx:id="filestoreRequestAddButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestAddButtonClicked" />
<Button fx:id="filestoreRequestRemoveButton" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestRemoveButtonClicked" />
<Button fx:id="filestoreRequestMoveUpButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestMoveUpButtonClicked" />
<Button fx:id="filestoreRequestMoveDownButton" layoutX="10.0" layoutY="34.0" minWidth="32.0" mnemonicParsing="false" onAction="#filestoreRequestMoveDownButtonClicked" />
</children>
</VBox>
</children>
Expand All @@ -71,17 +71,17 @@
<HBox spacing="5.0">
<children>
<TextField fx:id="messageToUserTextField" minWidth="200.0" promptText="Use hex dump" HBox.hgrow="ALWAYS" />
<Button fx:id="messageToUserAddButton" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserAddButtonClicked" text="+" />
<Button fx:id="messageToUserAddButton" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserAddButtonClicked" />
</children>
</HBox>
<HBox prefHeight="100.0" prefWidth="200.0" spacing="5.0">
<children>
<ListView fx:id="messageToUserListView" maxHeight="100.0" HBox.hgrow="ALWAYS" />
<VBox spacing="5.0" HBox.hgrow="NEVER">
<children>
<Button fx:id="messageToUserRemoveButton" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserRemoveButtonClicked" text="-" />
<Button fx:id="messageToUserMoveUpButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserMoveUpButtonClicked" text="^" />
<Button fx:id="messageToUserMoveDownButton" layoutX="10.0" layoutY="34.0" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserMoveDownButtonClicked" text="v" />
<Button fx:id="messageToUserRemoveButton" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserRemoveButtonClicked" />
<Button fx:id="messageToUserMoveUpButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserMoveUpButtonClicked" />
<Button fx:id="messageToUserMoveDownButton" layoutX="10.0" layoutY="34.0" minWidth="32.0" mnemonicParsing="false" onAction="#messageToUserMoveDownButtonClicked" />
</children>
</VBox>
</children>
Expand All @@ -103,17 +103,17 @@
<ChoiceBox fx:id="faultHandlerActionCombo" minWidth="200.0" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<Button fx:id="faultHandlerAddButton" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerAddButtonClicked" text="+" />
<Button fx:id="faultHandlerAddButton" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerAddButtonClicked" />
</children>
</HBox>
<HBox spacing="5.0">
<children>
<ListView fx:id="faultHandlerListView" maxHeight="100.0" HBox.hgrow="ALWAYS" />
<VBox spacing="5.0" HBox.hgrow="NEVER">
<children>
<Button fx:id="faultHandlerRemoveButton" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerRemoveButtonClicked" text="-" />
<Button fx:id="faultHandlerMoveUpButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerMoveUpButtonClicked" text="^" />
<Button fx:id="faultHandlerMoveDownButton" layoutX="10.0" layoutY="34.0" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerMoveDownButtonClicked" text="v" />
<Button fx:id="faultHandlerRemoveButton" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerRemoveButtonClicked" />
<Button fx:id="faultHandlerMoveUpButton" layoutX="10.0" layoutY="10.0" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerMoveUpButtonClicked" />
<Button fx:id="faultHandlerMoveDownButton" layoutX="10.0" layoutY="34.0" minWidth="32.0" mnemonicParsing="false" onAction="#faultHandlerMoveDownButtonClicked" />
</children>
</VBox>
</children>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e76cf81

Please sign in to comment.