Skip to content

Commit

Permalink
Rename FileHandler class to FileHandlerNode
Browse files Browse the repository at this point in the history
  • Loading branch information
besidev committed Nov 29, 2023
1 parent 9a1670c commit 26b7a5c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ public class FileHandlerApp extends JProApplication {

@Override
public void start(Stage stage) {

FileHandler fileHandler = new FileHandler();

FileHandlerNode fileHandlerNode = new FileHandlerNode();

Button downloadButton = new Button("Download");
downloadButton.setDisable(true);
downloadButton.setOnAction(event -> {
try {
getWebAPI().downloadURL(fileHandler.fileHandler.getUploadedFile().toURI().toURL());
var url = fileHandlerNode.getFileHandler().getUploadedFile().toURI().toURL();
getWebAPI().downloadURL(url);
} catch (Exception e) {
e.printStackTrace();
}
});
fileHandler.fileHandler.progressProperty().addListener((obs, oldV, newV) -> {

fileHandlerNode.getFileHandler().progressProperty().addListener((obs, oldV, newV) -> {
if (newV.doubleValue() == 1.0) {
downloadButton.setDisable(false);
}
});

VBox root = new VBox(fileHandler, downloadButton);
VBox root = new VBox(fileHandlerNode, downloadButton);
root.setSpacing(50);
root.setAlignment(Pos.CENTER);
Scene scene = new Scene(root, 500, 500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import com.jpro.webapi.WebAPI;
import javafx.scene.control.Label;

public class FileHandler extends Label {
public class FileHandlerNode extends Label {

public WebAPI.FileUploader fileHandler = null;
private WebAPI.FileUploader fileHandler = null;

FileHandler() {
FileHandlerNode() {
setText("Click or Drop File");
getStyleClass().add("file-handler");
setWrapText(true);
Expand Down Expand Up @@ -36,9 +36,12 @@ public class FileHandler extends Label {
});
}

public WebAPI.FileUploader getFileHandler() {
return fileHandler;
}

private void updateText() {
String percentages = "";
percentages = (int) (fileHandler.getProgress() * 100) + "%";
String percentages = " " + (int) (fileHandler.getProgress() * 100) + "%";
setText(fileHandler.selectedFileProperty().getValue() + percentages);
}

Expand Down

0 comments on commit 26b7a5c

Please sign in to comment.