delayed refresh after CRUD
This commit is contained in:
@@ -11,6 +11,7 @@ import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.image.ImageView;
|
||||
@@ -83,7 +84,6 @@ public class ProductController {
|
||||
//data declaration
|
||||
private ObservableList<ProductDTO> data = FXCollections.observableArrayList();
|
||||
private String mode = null;
|
||||
private Timeline refreshTimer;
|
||||
|
||||
/**
|
||||
* Set up the table view for products and display it when starting up
|
||||
@@ -134,14 +134,6 @@ public class ProductController {
|
||||
}
|
||||
});
|
||||
|
||||
refreshTimer = new Timeline(new KeyFrame(Duration.seconds(30), e -> applyFilters()));
|
||||
refreshTimer.setCycleCount(Timeline.INDEFINITE);
|
||||
refreshTimer.play();
|
||||
tvProducts.sceneProperty().addListener((obs, oldScene, newScene) -> {
|
||||
if (newScene == null && refreshTimer != null) {
|
||||
refreshTimer.stop();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -236,8 +228,7 @@ public class ProductController {
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
//refresh display and reset inputs
|
||||
displayProduct();
|
||||
displayProductWithFollowUp();
|
||||
btnDelete.setDisable(true);
|
||||
btnEdit.setDisable(true);
|
||||
txtSearch.setText("");
|
||||
@@ -263,6 +254,11 @@ public class ProductController {
|
||||
* Filter the table given the string from the searchbar
|
||||
* @param filter word to filter table
|
||||
*/
|
||||
private void displayProductWithFollowUp() {
|
||||
displayProduct();
|
||||
new Timeline(new KeyFrame(Duration.seconds(2), e -> applyFilters())).play();
|
||||
}
|
||||
|
||||
private void displayFilteredProduct(String filter){
|
||||
if ((txtSearch.getText() == null || txtSearch.getText().isEmpty()) && selectedCategoryId() == null){
|
||||
displayProduct();
|
||||
@@ -360,8 +356,7 @@ public class ProductController {
|
||||
dialogStage.setScene(scene);
|
||||
dialogStage.showAndWait();
|
||||
|
||||
//When dialog closes update table view and disable edit and delete buttons, and reset search bar
|
||||
displayProduct();
|
||||
displayProductWithFollowUp();
|
||||
btnDelete.setDisable(true);
|
||||
btnEdit.setDisable(true);
|
||||
txtSearch.setText("");
|
||||
|
||||
Reference in New Issue
Block a user