Minor optimizations to ResponseHeadersViewer and move 'state' package
This commit is contained in:
parent
a8413e8b5c
commit
65f689be47
17 changed files with 48 additions and 46 deletions
|
@ -18,10 +18,10 @@ package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.codearea.EverestCodeArea;
|
import com.rohitawate.everest.controllers.codearea.EverestCodeArea;
|
||||||
import com.rohitawate.everest.controllers.codearea.highlighters.HighlighterFactory;
|
import com.rohitawate.everest.controllers.codearea.highlighters.HighlighterFactory;
|
||||||
import com.rohitawate.everest.controllers.state.ComposerState;
|
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.misc.ThemeManager;
|
import com.rohitawate.everest.misc.ThemeManager;
|
||||||
|
import com.rohitawate.everest.state.ComposerState;
|
||||||
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
|
|
@ -20,13 +20,10 @@ import com.jfoenix.controls.JFXProgressBar;
|
||||||
import com.jfoenix.controls.JFXSnackbar;
|
import com.jfoenix.controls.JFXSnackbar;
|
||||||
import com.rohitawate.everest.controllers.codearea.EverestCodeArea;
|
import com.rohitawate.everest.controllers.codearea.EverestCodeArea;
|
||||||
import com.rohitawate.everest.controllers.codearea.highlighters.HighlighterFactory;
|
import com.rohitawate.everest.controllers.codearea.highlighters.HighlighterFactory;
|
||||||
import com.rohitawate.everest.controllers.state.ComposerState;
|
|
||||||
import com.rohitawate.everest.controllers.state.DashboardState;
|
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
|
||||||
import com.rohitawate.everest.controllers.visualizers.TreeVisualizer;
|
import com.rohitawate.everest.controllers.visualizers.TreeVisualizer;
|
||||||
import com.rohitawate.everest.controllers.visualizers.Visualizer;
|
import com.rohitawate.everest.controllers.visualizers.Visualizer;
|
||||||
import com.rohitawate.everest.exceptions.RedirectException;
|
|
||||||
import com.rohitawate.everest.exceptions.NullResponseException;
|
import com.rohitawate.everest.exceptions.NullResponseException;
|
||||||
|
import com.rohitawate.everest.exceptions.RedirectException;
|
||||||
import com.rohitawate.everest.format.FormatterFactory;
|
import com.rohitawate.everest.format.FormatterFactory;
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.misc.EverestUtilities;
|
import com.rohitawate.everest.misc.EverestUtilities;
|
||||||
|
@ -34,11 +31,13 @@ import com.rohitawate.everest.misc.Services;
|
||||||
import com.rohitawate.everest.misc.ThemeManager;
|
import com.rohitawate.everest.misc.ThemeManager;
|
||||||
import com.rohitawate.everest.models.requests.DELETERequest;
|
import com.rohitawate.everest.models.requests.DELETERequest;
|
||||||
import com.rohitawate.everest.models.requests.DataRequest;
|
import com.rohitawate.everest.models.requests.DataRequest;
|
||||||
import com.rohitawate.everest.models.requests.EverestRequest;
|
|
||||||
import com.rohitawate.everest.models.requests.GETRequest;
|
import com.rohitawate.everest.models.requests.GETRequest;
|
||||||
import com.rohitawate.everest.models.responses.EverestResponse;
|
import com.rohitawate.everest.models.responses.EverestResponse;
|
||||||
import com.rohitawate.everest.requestmanager.RequestManager;
|
import com.rohitawate.everest.requestmanager.RequestManager;
|
||||||
import com.rohitawate.everest.requestmanager.RequestManagersPool;
|
import com.rohitawate.everest.requestmanager.RequestManagersPool;
|
||||||
|
import com.rohitawate.everest.state.ComposerState;
|
||||||
|
import com.rohitawate.everest.state.DashboardState;
|
||||||
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
|
|
@ -18,7 +18,7 @@ package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXCheckBox;
|
import com.jfoenix.controls.JFXCheckBox;
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
package com.rohitawate.everest.controllers;
|
package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.misc.ThemeManager;
|
import com.rohitawate.everest.misc.ThemeManager;
|
||||||
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
package com.rohitawate.everest.controllers;
|
package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.misc.ThemeManager;
|
import com.rohitawate.everest.misc.ThemeManager;
|
||||||
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
package com.rohitawate.everest.controllers;
|
package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.search.Searchable;
|
import com.rohitawate.everest.controllers.search.Searchable;
|
||||||
import com.rohitawate.everest.controllers.state.ComposerState;
|
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
|
import com.rohitawate.everest.state.ComposerState;
|
||||||
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
package com.rohitawate.everest.controllers;
|
package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.search.SearchablePaneController;
|
import com.rohitawate.everest.controllers.search.SearchablePaneController;
|
||||||
import com.rohitawate.everest.controllers.state.ComposerState;
|
|
||||||
import com.rohitawate.everest.misc.Services;
|
import com.rohitawate.everest.misc.Services;
|
||||||
|
import com.rohitawate.everest.state.ComposerState;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.input.MouseButton;
|
import javafx.scene.input.MouseButton;
|
||||||
|
|
|
@ -17,12 +17,12 @@
|
||||||
package com.rohitawate.everest.controllers;
|
package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.rohitawate.everest.controllers.state.ComposerState;
|
|
||||||
import com.rohitawate.everest.controllers.state.DashboardState;
|
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.misc.EverestUtilities;
|
import com.rohitawate.everest.misc.EverestUtilities;
|
||||||
import com.rohitawate.everest.misc.KeyMap;
|
import com.rohitawate.everest.misc.KeyMap;
|
||||||
import com.rohitawate.everest.misc.ThemeManager;
|
import com.rohitawate.everest.misc.ThemeManager;
|
||||||
|
import com.rohitawate.everest.state.ComposerState;
|
||||||
|
import com.rohitawate.everest.state.DashboardState;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.Observable;
|
import javafx.beans.Observable;
|
||||||
import javafx.beans.property.StringProperty;
|
import javafx.beans.property.StringProperty;
|
||||||
|
|
|
@ -25,10 +25,14 @@ import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
class ResponseHeadersViewer extends ScrollPane {
|
public class ResponseHeadersViewer extends ScrollPane {
|
||||||
private VBox container;
|
private VBox container;
|
||||||
private HashMap<String, String> map;
|
private HashMap<String, String> map;
|
||||||
|
|
||||||
|
private static final String responseHeaderLabel = "response-header-label";
|
||||||
|
private static final String keyLabelStyleClass = "response-header-key-label";
|
||||||
|
private static final String valueLabelStyleClass = "response-header-value-label";
|
||||||
|
|
||||||
ResponseHeadersViewer() {
|
ResponseHeadersViewer() {
|
||||||
this.container = new VBox();
|
this.container = new VBox();
|
||||||
container.setPadding(new Insets(10, 20, 10, 20));
|
container.setPadding(new Insets(10, 20, 10, 20));
|
||||||
|
@ -57,10 +61,10 @@ class ResponseHeadersViewer extends ScrollPane {
|
||||||
|
|
||||||
map.forEach((key, value) -> {
|
map.forEach((key, value) -> {
|
||||||
Label keyLabel = new Label(key + ": ");
|
Label keyLabel = new Label(key + ": ");
|
||||||
keyLabel.getStyleClass().addAll("visualizerKeyLabel", "visualizerLabel");
|
keyLabel.getStyleClass().addAll(keyLabelStyleClass, responseHeaderLabel);
|
||||||
|
|
||||||
Label valueLabel = new Label(value);
|
Label valueLabel = new Label(value);
|
||||||
valueLabel.getStyleClass().addAll("visualizerValueLabel", "visualizerLabel");
|
valueLabel.getStyleClass().addAll(valueLabelStyleClass, responseHeaderLabel);
|
||||||
|
|
||||||
container.getChildren().add(new HBox(keyLabel, valueLabel));
|
container.getChildren().add(new HBox(keyLabel, valueLabel));
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,7 +18,7 @@ package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXCheckBox;
|
import com.jfoenix.controls.JFXCheckBox;
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
package com.rohitawate.everest.controllers;
|
package com.rohitawate.everest.controllers;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.misc.ThemeManager;
|
import com.rohitawate.everest.misc.ThemeManager;
|
||||||
|
import com.rohitawate.everest.state.FieldState;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.property.IntegerProperty;
|
import javafx.beans.property.IntegerProperty;
|
||||||
import javafx.beans.property.SimpleIntegerProperty;
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
|
|
|
@ -18,12 +18,12 @@ package com.rohitawate.everest.history;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.rohitawate.everest.controllers.state.ComposerState;
|
|
||||||
import com.rohitawate.everest.controllers.state.FieldState;
|
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.misc.EverestUtilities;
|
import com.rohitawate.everest.misc.EverestUtilities;
|
||||||
import com.rohitawate.everest.misc.Services;
|
import com.rohitawate.everest.misc.Services;
|
||||||
import com.rohitawate.everest.settings.Settings;
|
import com.rohitawate.everest.settings.Settings;
|
||||||
|
import com.rohitawate.everest.state.ComposerState;
|
||||||
|
import com.rohitawate.everest.state.FieldState;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package com.rohitawate.everest.requestmanager;
|
package com.rohitawate.everest.requestmanager;
|
||||||
|
|
||||||
import com.rohitawate.everest.exceptions.RedirectException;
|
|
||||||
import com.rohitawate.everest.exceptions.NullResponseException;
|
import com.rohitawate.everest.exceptions.NullResponseException;
|
||||||
|
import com.rohitawate.everest.exceptions.RedirectException;
|
||||||
import com.rohitawate.everest.models.requests.DELETERequest;
|
import com.rohitawate.everest.models.requests.DELETERequest;
|
||||||
import com.rohitawate.everest.models.requests.DataRequest;
|
import com.rohitawate.everest.models.requests.DataRequest;
|
||||||
import com.rohitawate.everest.models.requests.EverestRequest;
|
import com.rohitawate.everest.models.requests.EverestRequest;
|
||||||
|
@ -50,19 +50,19 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages all the requests made through Everest.
|
* Manages all the requests made through Everest.
|
||||||
* Converts EverestRequests into JAX-RS Invocations are then processed by Jersey.
|
* Converts EverestRequests into JAX-RS Invocations, which are then processed by Jersey.
|
||||||
* Also, parses the response and returns EverestResponses.
|
* Also parses the ServerResponse and returns an EverestResponse.
|
||||||
*
|
*
|
||||||
* Previously, Everest used separate managers for GET, Data (POST, PUT and PATCH) and DELETE
|
* Previously, Everest used separate managers for GET, Data (POST, PUT and PATCH) and DELETE requests.
|
||||||
* requests. However, RequestManager extends JavaFX's Service class which is expensive to create objects of.
|
* However, RequestManager extends JavaFX's Service class, which is expensive to create objects of.
|
||||||
* This made the creation of separate pools for every kind of RequestManager too expensive memory-wise.
|
* This made the creation of separate pools for every kind of RequestManager too expensive, memory-wise.
|
||||||
* Thus, now a single class manages all kinds of Requests thus requiring only a single kind of pool.
|
* Thus, now a single class manages all kinds of Requests thereby requiring only a single kind of pool.
|
||||||
* Also, this enables us to re-use inactive RequestManagers for all kinds of Requests. For example, previously,
|
* Also, this enables us to re-use inactive RequestManagers for all kinds of requests.
|
||||||
* if a GETRequestManager was requested, and all GETRequestManagers were running, a new one would be created even
|
* For example, previously, if a GETRequestManager was requested by Everest, and all GETRequestManagers were running,
|
||||||
* if a DELETERequestManager was idle.
|
* a new one would be created even if a DELETERequestManager was idle.
|
||||||
*
|
*
|
||||||
* TLDR: At the cost of some reduced semantic clarity, the old, separate-for-every-type-of-request RequestManagers
|
* TLDR: At the cost of some reduced semantic clarity, the old, separate-for-every-type-of-request RequestManagers
|
||||||
* are now replaced by this single works-for-all one to save some serious amount of memory and for better re-use.
|
* are now replaced by this single works-for-all one to save some serious amount of memory and to facilitate better re-use.
|
||||||
*/
|
*/
|
||||||
public class RequestManager extends Service<EverestResponse> {
|
public class RequestManager extends Service<EverestResponse> {
|
||||||
private static final Client client;
|
private static final Client client;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.rohitawate.everest.controllers.state;
|
package com.rohitawate.everest.state;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.BodyTabController.BodyTab;
|
import com.rohitawate.everest.controllers.BodyTabController.BodyTab;
|
||||||
|
|
|
@ -14,13 +14,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.rohitawate.everest.controllers.state;
|
package com.rohitawate.everest.state;
|
||||||
|
|
||||||
import com.rohitawate.everest.controllers.DashboardController.ComposerTab;
|
import com.rohitawate.everest.controllers.DashboardController.ComposerTab;
|
||||||
import com.rohitawate.everest.controllers.DashboardController.ResponseLayer;
|
import com.rohitawate.everest.controllers.DashboardController.ResponseLayer;
|
||||||
import com.rohitawate.everest.controllers.DashboardController.ResponseTab;
|
import com.rohitawate.everest.controllers.DashboardController.ResponseTab;
|
||||||
import com.rohitawate.everest.exceptions.RedirectException;
|
|
||||||
import com.rohitawate.everest.exceptions.NullResponseException;
|
import com.rohitawate.everest.exceptions.NullResponseException;
|
||||||
|
import com.rohitawate.everest.exceptions.RedirectException;
|
||||||
import com.rohitawate.everest.logging.LoggingService;
|
import com.rohitawate.everest.logging.LoggingService;
|
||||||
import com.rohitawate.everest.models.requests.DataRequest;
|
import com.rohitawate.everest.models.requests.DataRequest;
|
||||||
import com.rohitawate.everest.models.requests.EverestRequest;
|
import com.rohitawate.everest.models.requests.EverestRequest;
|
||||||
|
@ -34,6 +34,9 @@ import java.net.MalformedURLException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the state of Everest's Dashboard.
|
||||||
|
*/
|
||||||
public class DashboardState {
|
public class DashboardState {
|
||||||
public ComposerState composer;
|
public ComposerState composer;
|
||||||
public ResponseLayer visibleResponseLayer;
|
public ResponseLayer visibleResponseLayer;
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.rohitawate.everest.controllers.state;
|
package com.rohitawate.everest.state;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
|
@ -317,27 +317,23 @@
|
||||||
-fx-background-color: #2a2a2a;
|
-fx-background-color: #2a2a2a;
|
||||||
}
|
}
|
||||||
|
|
||||||
.visualizerLabel {
|
/* Response Headers Viewer */
|
||||||
|
.response-header-label {
|
||||||
-fx-font-family: "Liberation Mono", "Consolas", "Courier New", "Monaco", "DejaVu Sans Mono", monospace;
|
-fx-font-family: "Liberation Mono", "Consolas", "Courier New", "Monaco", "DejaVu Sans Mono", monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
.visualizerRootLabel {
|
.response-header-key-label {
|
||||||
-fx-font-size: 16px;
|
|
||||||
-fx-text-fill: #dedede;
|
|
||||||
-fx-font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.visualizerKeyLabel {
|
|
||||||
-fx-font-size: 16px;
|
-fx-font-size: 16px;
|
||||||
-fx-text-fill: #bababa;
|
-fx-text-fill: #bababa;
|
||||||
-fx-font-weight: bold;
|
-fx-font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.visualizerValueLabel {
|
.response-header-value-label {
|
||||||
-fx-font-size: 16px;
|
-fx-font-size: 16px;
|
||||||
-fx-text-fill: #959595;
|
-fx-text-fill: #959595;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tree Visualizer */
|
||||||
.tree-view {
|
.tree-view {
|
||||||
-fx-padding: 5px;
|
-fx-padding: 5px;
|
||||||
-fx-background-color: #353535;
|
-fx-background-color: #353535;
|
||||||
|
|
Loading…
Reference in a new issue