Fix issues where LoadingLayer's progressBar was frozen and while sending new request while one is already being sent

This commit is contained in:
Rohit Awate 2018-07-31 20:06:42 +05:30
parent 3dcb57070c
commit 22973d1c95
No known key found for this signature in database
GPG key ID: 1051D7B79CF2EE25
4 changed files with 18 additions and 8 deletions

View file

@ -78,7 +78,7 @@ public class DashboardController implements Initializable {
private Label statusCode, statusCodeDescription, responseTime,
responseSize, errorTitle, errorDetails;
@FXML
private JFXButton cancelButton, copyBodyButton;
private JFXButton sendButton, cancelButton, copyBodyButton;
@FXML
TabPane requestOptionsTab, responseTabPane;
@FXML
@ -204,6 +204,12 @@ public class DashboardController implements Initializable {
@FXML
void sendRequest() {
if (requestManager != null) {
while (requestManager.isRunning())
requestManager.cancel();
requestManager.reset();
}
if (responseBox.getChildren().size() == 2) {
responseBox.getChildren().remove(0);
responseArea.clear();
@ -349,18 +355,19 @@ public class DashboardController implements Initializable {
private void onCancelled(Event event) {
showLayer(ResponseLayer.PROMPT);
snackbar.show("Request canceled.", 2000);
requestManager.reset();
addressField.requestFocus();
}
private void onSucceeded(Event event) {
showResponse(requestManager.getValue());
showLayer(ResponseLayer.RESPONSE);
showResponse(requestManager.getValue());
requestManager.reset();
}
private void whileRunning(Event event) {
progressBar.requestLayout();
progressBar.progressProperty().bind(requestManager.progressProperty());
responseArea.clear();
showLayer(ResponseLayer.LOADING);
}
@ -398,6 +405,9 @@ public class DashboardController implements Initializable {
}
private void showResponse(EverestResponse response) {
if (response == null)
return;
prettifyResponseBody(response);
statusCode.setText(Integer.toString(response.getStatusCode()));
statusCodeDescription.setText(Response.Status.fromStatusCode(response.getStatusCode()).getReasonPhrase());
@ -491,7 +501,6 @@ public class DashboardController implements Initializable {
private void prettifyResponseBody(EverestResponse response) {
String type;
if (response.getMediaType() != null)
type = response.getMediaType().toString();
else

View file

@ -251,7 +251,8 @@ public class HomeWindowController implements Initializable {
addTab();
}
} catch (IOException e) {
Services.loggingService.logWarning("Application state file is possibly corrupted. State recovery failed. Loading default state.", e, LocalDateTime.now());
Services.loggingService.logWarning("Application state file is either corrupted or outdated. State recovery failed. Loading default state.", e, LocalDateTime.now());
addTab();
} finally {
Services.loggingService.logInfo("Application loaded.", LocalDateTime.now());
}

View file

@ -22,7 +22,7 @@
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<VBox fx:id="dashboard" alignment="CENTER" stylesheets="@../../css/Adreana.css" xmlns="http://javafx.com/javafx/8.0.111"
<VBox fx:id="dashboard" alignment="CENTER" stylesheets="@../../css/Adreana.css" xmlns="http://javafx.com/javafx/8.0.141"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.rohitawate.everest.controllers.DashboardController">
<children>
<HBox alignment="CENTER" maxHeight="100.0" minHeight="100.0" spacing="20.0" VBox.vgrow="ALWAYS">

View file

@ -22,7 +22,7 @@
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<StackPane fx:id="homeWindowSP" stylesheets="@../../css/Adreana.css" xmlns="http://javafx.com/javafx/8.0.111"
<StackPane fx:id="homeWindowSP" stylesheets="@../../css/Adreana.css" xmlns="http://javafx.com/javafx/8.0.141"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.rohitawate.everest.controllers.HomeWindowController">
<children>
<SplitPane fx:id="splitPane">
@ -32,7 +32,7 @@
<HBox VBox.vgrow="NEVER">
<children>
<JFXButton fx:id="newTabButton" contentDisplay="CENTER" minHeight="35.0" minWidth="40.0"
onAction="#addTab" HBox.hgrow="ALWAYS">
onAction="#addTab" ripplerFill="WHITE" HBox.hgrow="ALWAYS">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true"
preserveRatio="true">