Merge syntax-highlighting branch with master
This commit is contained in:
commit
26c9d7673a
17 changed files with 429 additions and 115 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -12,4 +12,5 @@ dependency-reduced-pom.xml
|
|||
|
||||
/BugReporter/src/META-INF/
|
||||
BugReporter/src/META-INF/
|
||||
Everest/
|
||||
out/
|
6
pom.xml
6
pom.xml
|
@ -108,5 +108,11 @@
|
|||
<artifactId>guava</artifactId>
|
||||
<version>24.1-jre</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.fxmisc.richtext/richtextfx -->
|
||||
<dependency>
|
||||
<groupId>org.fxmisc.richtext</groupId>
|
||||
<artifactId>richtextfx</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package com.rohitawate.everest.controllers;
|
||||
|
||||
import com.rohitawate.everest.controllers.codearea.EverestCodeArea;
|
||||
import com.rohitawate.everest.controllers.codearea.EverestCodeArea.HighlightMode;
|
||||
import com.rohitawate.everest.models.DashboardState;
|
||||
import com.rohitawate.everest.models.requests.DataDispatchRequest;
|
||||
import com.rohitawate.everest.util.Services;
|
||||
|
@ -24,9 +26,14 @@ import javafx.fxml.FXML;
|
|||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.stage.Window;
|
||||
import org.fxmisc.flowless.VirtualizedScrollPane;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
|
@ -46,12 +53,13 @@ public class BodyTabController implements Initializable {
|
|||
@FXML
|
||||
ComboBox<String> rawInputTypeBox;
|
||||
@FXML
|
||||
TextArea rawInputArea;
|
||||
@FXML
|
||||
Tab rawTab, binaryTab, formTab, urlTab;
|
||||
@FXML
|
||||
TextField filePathField;
|
||||
@FXML
|
||||
private VBox rawVBox;
|
||||
|
||||
EverestCodeArea rawInputArea;
|
||||
FormDataTabController formDataTabController;
|
||||
URLTabController urlTabController;
|
||||
|
||||
|
@ -60,6 +68,30 @@ public class BodyTabController implements Initializable {
|
|||
rawInputTypeBox.getItems().addAll("PLAIN TEXT", "JSON", "XML", "HTML");
|
||||
rawInputTypeBox.getSelectionModel().select(0);
|
||||
|
||||
rawInputArea = new EverestCodeArea();
|
||||
ThemeManager.setSyntaxTheme(rawInputArea);
|
||||
rawInputArea.setPrefHeight(1500); // Hack to make the EverestCodeArea stretch with the Composer
|
||||
rawVBox.getChildren().add(new VirtualizedScrollPane<>(rawInputArea));
|
||||
|
||||
rawInputTypeBox.valueProperty().addListener(change -> {
|
||||
String type = rawInputTypeBox.getValue();
|
||||
HighlightMode mode;
|
||||
switch (type) {
|
||||
case "JSON":
|
||||
mode = HighlightMode.JSON;
|
||||
break;
|
||||
case "XML":
|
||||
mode = HighlightMode.XML;
|
||||
break;
|
||||
case "HTML":
|
||||
mode = HighlightMode.HTML;
|
||||
break;
|
||||
default:
|
||||
mode = HighlightMode.PLAIN;
|
||||
}
|
||||
rawInputArea.setMode(mode);
|
||||
});
|
||||
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/homewindow/FormDataTab.fxml"));
|
||||
formTab.setContent(loader.load());
|
||||
|
@ -172,7 +204,23 @@ public class BodyTabController implements Initializable {
|
|||
}
|
||||
|
||||
private void setRawTab(DashboardState dashboardState, String contentType) {
|
||||
rawInputArea.setText(dashboardState.getBody());
|
||||
HighlightMode mode;
|
||||
|
||||
switch (contentType) {
|
||||
case MediaType.APPLICATION_JSON:
|
||||
mode = HighlightMode.JSON;
|
||||
break;
|
||||
case MediaType.APPLICATION_XML:
|
||||
mode = HighlightMode.XML;
|
||||
break;
|
||||
case MediaType.TEXT_HTML:
|
||||
mode = HighlightMode.HTML;
|
||||
break;
|
||||
default:
|
||||
mode = HighlightMode.PLAIN;
|
||||
}
|
||||
|
||||
rawInputArea.setText(dashboardState.getBody(), mode);
|
||||
rawInputTypeBox.getSelectionModel().select(contentType);
|
||||
bodyTabPane.getSelectionModel().select(rawTab);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||
import com.jfoenix.controls.JFXButton;
|
||||
import com.jfoenix.controls.JFXProgressBar;
|
||||
import com.jfoenix.controls.JFXSnackbar;
|
||||
import com.rohitawate.everest.controllers.codearea.EverestCodeArea;
|
||||
import com.rohitawate.everest.controllers.codearea.EverestCodeArea.HighlightMode;
|
||||
import com.rohitawate.everest.exceptions.RedirectException;
|
||||
import com.rohitawate.everest.exceptions.UnreliableResponseException;
|
||||
import com.rohitawate.everest.models.DashboardState;
|
||||
|
@ -30,7 +32,6 @@ import com.rohitawate.everest.requestmanager.DataDispatchRequestManager;
|
|||
import com.rohitawate.everest.requestmanager.RequestManager;
|
||||
import com.rohitawate.everest.util.EverestUtilities;
|
||||
import com.rohitawate.everest.util.Services;
|
||||
import com.rohitawate.everest.util.settings.Settings;
|
||||
import com.rohitawate.everest.util.themes.ThemeManager;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
|
@ -45,6 +46,7 @@ import javafx.scene.input.KeyCode;
|
|||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import org.fxmisc.flowless.VirtualizedScrollPane;
|
||||
|
||||
import javax.ws.rs.ProcessingException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
@ -66,16 +68,14 @@ public class DashboardController implements Initializable {
|
|||
@FXML
|
||||
TextField addressField;
|
||||
@FXML
|
||||
ComboBox<String> httpMethodBox;
|
||||
ComboBox<String> httpMethodBox, responseTypeBox;
|
||||
@FXML
|
||||
private VBox responseBox, loadingLayer, promptLayer, errorLayer, paramsBox;
|
||||
@FXML
|
||||
private HBox responseDetails;
|
||||
@FXML
|
||||
private TextArea responseArea;
|
||||
@FXML
|
||||
private Label statusCode, statusCodeDescription, responseTime,
|
||||
responseSize, errorTitle, errorDetails, responseType;
|
||||
responseSize, errorTitle, errorDetails;
|
||||
@FXML
|
||||
private JFXButton cancelButton, copyBodyButton;
|
||||
@FXML
|
||||
|
@ -83,7 +83,7 @@ public class DashboardController implements Initializable {
|
|||
@FXML
|
||||
Tab paramsTab, authTab, headersTab, bodyTab;
|
||||
@FXML
|
||||
private Tab visualizerTab, responseHeadersTab;
|
||||
private Tab responseBodyTab, visualizerTab, responseHeadersTab;
|
||||
@FXML
|
||||
private JFXProgressBar progressBar;
|
||||
|
||||
|
@ -102,11 +102,10 @@ public class DashboardController implements Initializable {
|
|||
private DataDispatchRequest dataRequest;
|
||||
private DELETERequest deleteRequest;
|
||||
private HashMap<String, String> params;
|
||||
private EverestCodeArea responseArea;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
applyDashboardSettings();
|
||||
|
||||
try {
|
||||
// Loading the headers tab
|
||||
FXMLLoader headerTabLoader = new FXMLLoader(getClass().getResource("/fxml/homewindow/HeaderTab.fxml"));
|
||||
|
@ -158,12 +157,41 @@ public class DashboardController implements Initializable {
|
|||
snackbar.show("Response body copied to clipboard.", 5000);
|
||||
});
|
||||
|
||||
responseTypeBox.getItems().addAll("JSON", "XML", "HTML", "PLAIN TEXT");
|
||||
|
||||
responseTypeBox.valueProperty().addListener(change -> {
|
||||
String type = responseTypeBox.getValue();
|
||||
try {
|
||||
switch (type) {
|
||||
case "JSON":
|
||||
JsonNode node = EverestUtilities.jsonMapper.readTree(responseArea.getText());
|
||||
responseArea.setText(EverestUtilities.jsonMapper.writeValueAsString(node), HighlightMode.JSON);
|
||||
break;
|
||||
case "XML":
|
||||
responseArea.setText(responseArea.getText(), HighlightMode.XML);
|
||||
break;
|
||||
case "HTML":
|
||||
responseArea.setText(responseArea.getText(), HighlightMode.HTML);
|
||||
break;
|
||||
default:
|
||||
responseArea.setText(responseArea.getText(), HighlightMode.PLAIN);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Services.loggingService.logWarning("Response could not be parsed.", e, LocalDateTime.now());
|
||||
}
|
||||
});
|
||||
|
||||
errorTitle.setText("Oops... That's embarrassing!");
|
||||
errorDetails.setText("Something went wrong. Try to make another request.\nRestart Everest if that doesn't work.");
|
||||
|
||||
visualizer = new Visualizer();
|
||||
visualizerTab.setContent(visualizer);
|
||||
|
||||
responseArea = new EverestCodeArea();
|
||||
responseArea.setEditable(false);
|
||||
ThemeManager.setSyntaxTheme(responseArea);
|
||||
responseBodyTab.setContent(new VirtualizedScrollPane<>(responseArea));
|
||||
|
||||
responseHeadersViewer = new ResponseHeadersViewer();
|
||||
responseHeadersTab.setContent(responseHeadersViewer);
|
||||
}
|
||||
|
@ -184,6 +212,12 @@ public class DashboardController implements Initializable {
|
|||
try {
|
||||
String address = addressField.getText();
|
||||
|
||||
if (address.equals("")) {
|
||||
promptLayer.setVisible(true);
|
||||
snackbar.show("Please enter an address.", 3000);
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepends "https://" to the address if not already done.
|
||||
if (!(address.startsWith("https://") || address.startsWith("http://"))) {
|
||||
address = "https://" + address;
|
||||
|
@ -191,11 +225,6 @@ public class DashboardController implements Initializable {
|
|||
responseArea.requestFocus();
|
||||
}
|
||||
|
||||
if (address.equals("")) {
|
||||
promptLayer.setVisible(true);
|
||||
snackbar.show("Please enter an address.", 3000);
|
||||
return;
|
||||
}
|
||||
switch (httpMethodBox.getValue()) {
|
||||
case "GET":
|
||||
if (getRequest == null)
|
||||
|
@ -383,27 +412,27 @@ public class DashboardController implements Initializable {
|
|||
|
||||
switch (type.toLowerCase()) {
|
||||
case "application/json":
|
||||
responseType.setText("JSON");
|
||||
JsonNode node = EverestUtilities.mapper.readTree(responseBody);
|
||||
responseArea.setText(EverestUtilities.mapper.writeValueAsString(node));
|
||||
responseTypeBox.setValue("JSON");
|
||||
JsonNode node = EverestUtilities.jsonMapper.readTree(responseBody);
|
||||
responseArea.setText(EverestUtilities.jsonMapper.writeValueAsString(node), HighlightMode.JSON);
|
||||
visualizerTab.setDisable(false);
|
||||
visualizer.populate(node);
|
||||
break;
|
||||
case "application/xml":
|
||||
responseType.setText("XML");
|
||||
responseArea.setText(EverestUtilities.mapper.writeValueAsString(responseBody));
|
||||
responseTypeBox.setValue("XML");
|
||||
responseArea.setText(responseBody, HighlightMode.XML);
|
||||
break;
|
||||
case "text/html":
|
||||
responseType.setText("HTML");
|
||||
responseArea.setText(responseBody);
|
||||
responseTypeBox.setValue("HTML");
|
||||
responseArea.setText(responseBody, HighlightMode.HTML);
|
||||
break;
|
||||
default:
|
||||
responseType.setText("PLAIN TEXT");
|
||||
responseArea.setText(responseBody);
|
||||
responseTypeBox.setValue("PLAIN TEXT");
|
||||
responseArea.setText(responseBody, HighlightMode.PLAIN);
|
||||
}
|
||||
} else {
|
||||
responseType.setText("NONE");
|
||||
responseArea.setText("No body found in the response.");
|
||||
responseTypeBox.setValue("PLAIN");
|
||||
responseArea.setText("No body found in the response.", HighlightMode.PLAIN);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
snackbar.show("Response could not be parsed.", 5000);
|
||||
|
@ -414,12 +443,6 @@ public class DashboardController implements Initializable {
|
|||
}
|
||||
}
|
||||
|
||||
private void applyDashboardSettings() {
|
||||
String responseAreaCSS = "-fx-font-family: " + Settings.responseAreaFont + ";" +
|
||||
"-fx-font-size: " + Settings.responseAreaFontSize;
|
||||
responseArea.setStyle(responseAreaCSS);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void clearResponseArea() {
|
||||
responseBox.getChildren().remove(0);
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package com.rohitawate.everest.controllers.codearea;
|
||||
|
||||
import com.rohitawate.everest.controllers.codearea.highlighters.Highlighter;
|
||||
import com.rohitawate.everest.controllers.codearea.highlighters.JSONHighlighter;
|
||||
import com.rohitawate.everest.controllers.codearea.highlighters.PlaintextHighlighter;
|
||||
import com.rohitawate.everest.controllers.codearea.highlighters.XMLHighlighter;
|
||||
import com.rohitawate.everest.util.settings.Settings;
|
||||
import javafx.geometry.Insets;
|
||||
import org.fxmisc.richtext.CodeArea;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class EverestCodeArea extends CodeArea {
|
||||
public enum HighlightMode {
|
||||
JSON, XML, HTML, PLAIN
|
||||
}
|
||||
|
||||
private Highlighter highlighter;
|
||||
|
||||
private static JSONHighlighter jsonHighlighter;
|
||||
private static XMLHighlighter xmlHighlighter;
|
||||
private static PlaintextHighlighter plaintextHighlighter;
|
||||
|
||||
public EverestCodeArea() {
|
||||
this.getStylesheets().add(getClass().getResource("/css/syntax/Moondust.css").toString());
|
||||
this.getStyleClass().add("everest-code-area");
|
||||
this.setWrapText(Settings.editorWrapText);
|
||||
this.setPadding(new Insets(5));
|
||||
|
||||
jsonHighlighter = new JSONHighlighter();
|
||||
xmlHighlighter = new XMLHighlighter();
|
||||
plaintextHighlighter = new PlaintextHighlighter();
|
||||
|
||||
setMode(HighlightMode.PLAIN);
|
||||
|
||||
this.multiPlainChanges()
|
||||
.successionEnds(Duration.ofMillis(1))
|
||||
.subscribe(ignore -> this.setStyleSpans(0, highlighter.computeHighlighting(getText())));
|
||||
}
|
||||
|
||||
public void setMode(HighlightMode mode) {
|
||||
switch (mode) {
|
||||
case JSON:
|
||||
highlighter = jsonHighlighter;
|
||||
break;
|
||||
case XML:
|
||||
case HTML:
|
||||
highlighter = xmlHighlighter;
|
||||
break;
|
||||
default:
|
||||
highlighter = plaintextHighlighter;
|
||||
}
|
||||
|
||||
// Re-computes the highlighting for the new mode
|
||||
this.setStyleSpans(0, highlighter.computeHighlighting(getText()));
|
||||
}
|
||||
|
||||
public void setText(String text, HighlightMode mode) {
|
||||
clear();
|
||||
appendText(text);
|
||||
setMode(mode);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.rohitawate.everest.controllers.codearea.highlighters;
|
||||
|
||||
import org.fxmisc.richtext.model.StyleSpans;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface Highlighter {
|
||||
StyleSpans<Collection<String>> computeHighlighting(String text);
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.rohitawate.everest.controllers.codearea.highlighters;
|
||||
|
||||
import org.fxmisc.richtext.model.StyleSpans;
|
||||
import org.fxmisc.richtext.model.StyleSpansBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class JSONHighlighter implements Highlighter {
|
||||
|
||||
private static final String JSON_CURLY = "(?<JSONCURLY>\\{|\\})";
|
||||
private static final String JSON_PROPERTY = "(?<JSONPROPERTY>\\\".*\\\")\\s*:\\s*";
|
||||
private static final String JSON_VALUE = "(?<JSONVALUE>\\\".*\\\")";
|
||||
private static final String JSON_ARRAY = "\\[(?<JSONARRAY>.*)\\]";
|
||||
private static final String JSON_NUMBER = "(?<JSONNUMBER>\\d*.?\\d*)";
|
||||
private static final String JSON_BOOL = "(?<JSONBOOL>true|false)";
|
||||
|
||||
private static final Pattern FINAL_REGEX = Pattern.compile(
|
||||
JSON_CURLY + "|"
|
||||
+ JSON_PROPERTY + "|"
|
||||
+ JSON_VALUE + "|"
|
||||
+ JSON_ARRAY + "|"
|
||||
+ JSON_BOOL + "|"
|
||||
+ JSON_NUMBER
|
||||
);
|
||||
|
||||
@Override
|
||||
public StyleSpans<Collection<String>> computeHighlighting(String text) {
|
||||
Matcher matcher = FINAL_REGEX.matcher(text);
|
||||
int lastKwEnd = 0;
|
||||
StyleSpansBuilder<Collection<String>> spansBuilder
|
||||
= new StyleSpansBuilder<>();
|
||||
while (matcher.find()) {
|
||||
String styleClass
|
||||
= matcher.group("JSONPROPERTY") != null ? "json_property"
|
||||
: matcher.group("JSONVALUE") != null ? "json_value"
|
||||
: matcher.group("JSONARRAY") != null ? "json_array"
|
||||
: matcher.group("JSONCURLY") != null ? "json_curly"
|
||||
: matcher.group("JSONBOOL") != null ? "json_bool"
|
||||
: matcher.group("JSONNUMBER") != null ? "json_number"
|
||||
: null;
|
||||
/* never happens */
|
||||
assert styleClass != null;
|
||||
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
|
||||
spansBuilder.add(Collections.singleton(styleClass), matcher.end() - matcher.start());
|
||||
lastKwEnd = matcher.end();
|
||||
}
|
||||
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
|
||||
return spansBuilder.create();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.rohitawate.everest.controllers.codearea.highlighters;
|
||||
|
||||
import org.fxmisc.richtext.model.StyleSpans;
|
||||
import org.fxmisc.richtext.model.StyleSpansBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class PlaintextHighlighter implements Highlighter {
|
||||
@Override
|
||||
public StyleSpans<Collection<String>> computeHighlighting(String text) {
|
||||
StyleSpansBuilder<Collection<String>> spansBuilder
|
||||
= new StyleSpansBuilder<>();
|
||||
|
||||
spansBuilder.add(Collections.singleton("plain-text"), text.length());
|
||||
return spansBuilder.create();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.rohitawate.everest.controllers.codearea.highlighters;
|
||||
|
||||
import org.fxmisc.richtext.model.StyleSpans;
|
||||
import org.fxmisc.richtext.model.StyleSpansBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class XMLHighlighter implements Highlighter {
|
||||
|
||||
private static final Pattern XML_TAG = Pattern.compile("(?<ELEMENT>(</?\\h*)(\\w+)([^<>]*)(\\h*/?>))"
|
||||
+ "|(?<COMMENT><!--[^<>]+-->)");
|
||||
|
||||
private static final Pattern ATTRIBUTES = Pattern.compile("(\\w+\\h*)(=)(\\h*\"[^\"]+\")");
|
||||
|
||||
private static final int GROUP_OPEN_BRACKET = 2;
|
||||
private static final int GROUP_ELEMENT_NAME = 3;
|
||||
private static final int GROUP_ATTRIBUTES_SECTION = 4;
|
||||
private static final int GROUP_CLOSE_BRACKET = 5;
|
||||
private static final int GROUP_ATTRIBUTE_NAME = 1;
|
||||
private static final int GROUP_EQUAL_SYMBOL = 2;
|
||||
private static final int GROUP_ATTRIBUTE_VALUE = 3;
|
||||
|
||||
@Override
|
||||
public StyleSpans<Collection<String>> computeHighlighting(String text) {
|
||||
Matcher matcher = XML_TAG.matcher(text);
|
||||
int lastKwEnd = 0;
|
||||
StyleSpansBuilder<Collection<String>> spansBuilder = new StyleSpansBuilder<>();
|
||||
while (matcher.find()) {
|
||||
|
||||
spansBuilder.add(Collections.emptyList(), matcher.start() - lastKwEnd);
|
||||
if (matcher.group("COMMENT") != null) {
|
||||
spansBuilder.add(Collections.singleton("xml_comment"), matcher.end() - matcher.start());
|
||||
} else {
|
||||
if (matcher.group("ELEMENT") != null) {
|
||||
String attributesText = matcher.group(GROUP_ATTRIBUTES_SECTION);
|
||||
|
||||
spansBuilder.add(Collections.singleton("xml_bracket"), matcher.end(GROUP_OPEN_BRACKET) - matcher.start(GROUP_OPEN_BRACKET));
|
||||
spansBuilder.add(Collections.singleton("xml_tag"), matcher.end(GROUP_ELEMENT_NAME) - matcher.end(GROUP_OPEN_BRACKET));
|
||||
|
||||
if (!attributesText.isEmpty()) {
|
||||
|
||||
lastKwEnd = 0;
|
||||
|
||||
Matcher amatcher = ATTRIBUTES.matcher(attributesText);
|
||||
while (amatcher.find()) {
|
||||
spansBuilder.add(Collections.emptyList(), amatcher.start() - lastKwEnd);
|
||||
spansBuilder.add(Collections.singleton("xml_attribute"), amatcher.end(GROUP_ATTRIBUTE_NAME) - amatcher.start(GROUP_ATTRIBUTE_NAME));
|
||||
spansBuilder.add(Collections.singleton("xml_bracket"), amatcher.end(GROUP_EQUAL_SYMBOL) - amatcher.end(GROUP_ATTRIBUTE_NAME));
|
||||
spansBuilder.add(Collections.singleton("xml_attribute_value"), amatcher.end(GROUP_ATTRIBUTE_VALUE) - amatcher.end(GROUP_EQUAL_SYMBOL));
|
||||
lastKwEnd = amatcher.end();
|
||||
}
|
||||
if (attributesText.length() > lastKwEnd)
|
||||
spansBuilder.add(Collections.emptyList(), attributesText.length() - lastKwEnd);
|
||||
}
|
||||
|
||||
lastKwEnd = matcher.end(GROUP_ATTRIBUTES_SECTION);
|
||||
spansBuilder.add(Collections.singleton("xml_bracket"), matcher.end(GROUP_CLOSE_BRACKET) - lastKwEnd);
|
||||
}
|
||||
}
|
||||
lastKwEnd = matcher.end();
|
||||
}
|
||||
spansBuilder.add(Collections.emptyList(), text.length() - lastKwEnd);
|
||||
return spansBuilder.create();
|
||||
}
|
||||
}
|
|
@ -28,11 +28,11 @@ import java.nio.file.StandardCopyOption;
|
|||
import java.time.LocalDateTime;
|
||||
|
||||
public class EverestUtilities {
|
||||
public static ObjectMapper mapper;
|
||||
public static ObjectMapper jsonMapper;
|
||||
|
||||
static {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
|
||||
jsonMapper = new ObjectMapper();
|
||||
jsonMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,9 +21,6 @@ package com.rohitawate.everest.util.settings;
|
|||
* get overwritten by SettingsLoader.
|
||||
*/
|
||||
public class Settings {
|
||||
public static String responseAreaFont = "\"Liberation Mono\"";
|
||||
public static int responseAreaFontSize = 18;
|
||||
|
||||
public static boolean connectionTimeOutEnable = false;
|
||||
public static int connectionTimeOut = 10000;
|
||||
|
||||
|
@ -31,5 +28,8 @@ public class Settings {
|
|||
public static int connectionReadTimeOut = 30000;
|
||||
|
||||
public static String theme = "Adreana";
|
||||
public static String syntaxTheme = "Moondust";
|
||||
public static int showHistoryRange = 7;
|
||||
|
||||
public static boolean editorWrapText = false;
|
||||
}
|
||||
|
|
|
@ -43,10 +43,7 @@ public class SettingsLoader implements Runnable {
|
|||
|
||||
System.out.println("Settings file found. Loading settings... ");
|
||||
|
||||
nodes = EverestUtilities.mapper.readTree(settingsFile);
|
||||
|
||||
Settings.responseAreaFont = setStringSetting(Settings.responseAreaFont, "responseAreaFont");
|
||||
Settings.responseAreaFontSize = setIntegerSetting(Settings.responseAreaFontSize, "responseAreaFontSize");
|
||||
nodes = EverestUtilities.jsonMapper.readTree(settingsFile);
|
||||
|
||||
Settings.connectionTimeOutEnable = setBooleanSetting(Settings.connectionTimeOutEnable, "connectionTimeOutEnable");
|
||||
if (Settings.connectionTimeOutEnable)
|
||||
|
@ -56,7 +53,10 @@ public class SettingsLoader implements Runnable {
|
|||
if (Settings.connectionReadTimeOutEnable)
|
||||
Settings.connectionReadTimeOut = setIntegerSetting(Settings.connectionReadTimeOut, "connectionReadTimeOut");
|
||||
|
||||
Settings.editorWrapText = setBooleanSetting(Settings.editorWrapText, "editorWrapText");
|
||||
|
||||
Settings.theme = EverestUtilities.trimString(setStringSetting(Settings.theme, "theme"));
|
||||
Settings.syntaxTheme = EverestUtilities.trimString(setStringSetting(Settings.syntaxTheme, "syntaxTheme"));
|
||||
Settings.showHistoryRange = setIntegerSetting(Settings.showHistoryRange, "showHistoryRange");
|
||||
} catch (IOException IOE) {
|
||||
Services.loggingService.logInfo("Settings file not found. Using defaults.", LocalDateTime.now());
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.rohitawate.everest.util.themes;
|
||||
|
||||
import com.rohitawate.everest.controllers.codearea.EverestCodeArea;
|
||||
import com.rohitawate.everest.util.Services;
|
||||
import com.rohitawate.everest.util.settings.Settings;
|
||||
import javafx.scene.Parent;
|
||||
|
@ -28,6 +29,7 @@ import java.util.List;
|
|||
public class ThemeManager {
|
||||
private static List<Parent> parentNodes = new ArrayList<>();
|
||||
private static File themeFile = new File("Everest/themes/" + Settings.theme + ".css");
|
||||
private static File syntaxThemeFile = new File("Everest/themes/syntax/" + Settings.syntaxTheme + ".css");
|
||||
|
||||
/**
|
||||
* Refreshes the theme of all the registered parents by replacing
|
||||
|
@ -61,4 +63,14 @@ public class ThemeManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSyntaxTheme(EverestCodeArea everestCodeArea) {
|
||||
if (!Settings.syntaxTheme.equals("Moondust")) {
|
||||
if (syntaxThemeFile.exists()) {
|
||||
everestCodeArea.getStylesheets().add(syntaxThemeFile.toURI().toString());
|
||||
} else {
|
||||
Services.loggingService.logInfo(Settings.syntaxTheme + ": No such theme file found.", LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,20 +79,6 @@
|
|||
-fx-background-color: #822f2f;
|
||||
}
|
||||
|
||||
.text-area {
|
||||
-fx-font-family: "Liberation Mono", monospace;
|
||||
-fx-text-fill: #a1a1a1;
|
||||
-fx-background-radius: 0;
|
||||
-fx-background-insets: 0;
|
||||
-fx-background-color: transparent;
|
||||
-fx-border-width: 0px;
|
||||
}
|
||||
|
||||
.text-area .content {
|
||||
-fx-background-radius: 0;
|
||||
-fx-background-color: #2a2a2a;
|
||||
}
|
||||
|
||||
#loadingLayer {
|
||||
-fx-background-color: #bf8829;
|
||||
}
|
||||
|
@ -136,6 +122,8 @@
|
|||
#headersBox,
|
||||
.scroll-pane,
|
||||
.scroll-pane .viewport,
|
||||
.virtualized-scroll-pane .scroll-bar:vertical,
|
||||
.virtualized-scroll-pane .scroll-bar:horizontal,
|
||||
.scroll-pane .scroll-bar:vertical,
|
||||
.scroll-pane .scroll-bar:horizontal {
|
||||
-fx-background-color: #3d3d3d;
|
||||
|
@ -191,6 +179,7 @@
|
|||
-fx-background-color: #3d3d3d;
|
||||
}
|
||||
|
||||
.virtualized-scroll-pane .scroll-bar .thumb,
|
||||
.scroll-pane .scroll-bar .thumb {
|
||||
-fx-background-color: #808080;
|
||||
}
|
||||
|
|
63
src/main/resources/css/syntax/Moondust.css
Normal file
63
src/main/resources/css/syntax/Moondust.css
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*General rules for EverestCodeArea*/
|
||||
|
||||
.everest-code-area {
|
||||
-fx-background-color: #282828;
|
||||
}
|
||||
|
||||
.everest-code-area .text {
|
||||
-fx-fill: #ababab;
|
||||
-fx-font-family: "Liberation Mono", monospace;
|
||||
-fx-font-size: 17px;
|
||||
}
|
||||
|
||||
.everest-code-area .caret {
|
||||
-fx-stroke: white;
|
||||
}
|
||||
|
||||
.plain-text {
|
||||
-fx-fill: azure !important;
|
||||
}
|
||||
|
||||
/*Common to JSON and XML*/
|
||||
|
||||
.xml_bracket,
|
||||
.json_curly {
|
||||
-fx-fill: coral !important;
|
||||
}
|
||||
|
||||
.xml_tag,
|
||||
.json_property {
|
||||
-fx-fill: orange !important;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.xml_attribute_value,
|
||||
.json_value {
|
||||
-fx-fill: cornflowerblue !important;
|
||||
}
|
||||
|
||||
/*JSON-specific*/
|
||||
|
||||
.json_array {
|
||||
-fx-fill: limegreen !important;
|
||||
}
|
||||
|
||||
.json_bool {
|
||||
-fx-fill: crimson !important;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
.json_number {
|
||||
-fx-fill: greenyellow !important;
|
||||
-fx-font-weight: bold;
|
||||
}
|
||||
|
||||
/*XML-specific*/
|
||||
|
||||
.xml_attribute {
|
||||
-fx-fill: darkviolet !important;
|
||||
}
|
||||
|
||||
.xml_comment {
|
||||
-fx-fill: teal !important;
|
||||
}
|
|
@ -28,32 +28,15 @@
|
|||
<Tab fx:id="urlTab" text="URL ENCODED"/>
|
||||
<Tab fx:id="rawTab" text="RAW">
|
||||
<content>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER">
|
||||
<content>
|
||||
<VBox alignment="CENTER">
|
||||
<children>
|
||||
<HBox alignment="CENTER_LEFT" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<ComboBox fx:id="rawInputTypeBox" HBox.hgrow="ALWAYS">
|
||||
<HBox.margin>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</HBox.margin>
|
||||
</ComboBox>
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets/>
|
||||
</VBox.margin>
|
||||
</HBox>
|
||||
<TextArea fx:id="rawInputArea" promptText="Raw data goes here..." wrapText="true"
|
||||
VBox.vgrow="ALWAYS">
|
||||
<VBox.margin>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0"/>
|
||||
</VBox.margin>
|
||||
</TextArea>
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<VBox fx:id="rawVBox">
|
||||
<children>
|
||||
<ComboBox fx:id="rawInputTypeBox" maxHeight="30.0" visibleRowCount="5" VBox.vgrow="SOMETIMES">
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</VBox.margin>
|
||||
</ComboBox>
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab fx:id="binaryTab" text="BINARY">
|
||||
|
|
|
@ -16,29 +16,15 @@
|
|||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import com.jfoenix.controls.JFXProgressBar?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.control.Tab?>
|
||||
<?import javafx.scene.control.TabPane?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.control.Tooltip?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<?import com.jfoenix.controls.*?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<StackPane fx:id="dashboard" 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>
|
||||
<VBox prefHeight="200.0" prefWidth="100.0">
|
||||
<VBox>
|
||||
<children>
|
||||
<HBox alignment="CENTER" maxHeight="100.0" minHeight="100.0" spacing="20.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
|
@ -167,11 +153,7 @@
|
|||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
<Label fx:id="responseType" text="JSON" textFill="#2dcd2d">
|
||||
<font>
|
||||
<Font name="Liberation Mono Bold" size="17.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<ComboBox fx:id="responseTypeBox" minHeight="30.0" prefWidth="100.0"/>
|
||||
<Label fx:id="responseTime" text="151 ms" textFill="WHITE" HBox.hgrow="ALWAYS">
|
||||
<HBox.margin>
|
||||
<Insets />
|
||||
|
@ -218,11 +200,7 @@
|
|||
<children>
|
||||
<TabPane fx:id="responseTabPane" side="BOTTOM" tabMinWidth="100.0">
|
||||
<tabs>
|
||||
<Tab closable="false" text="BODY">
|
||||
<content>
|
||||
<TextArea fx:id="responseArea" editable="false" wrapText="true" />
|
||||
</content>
|
||||
</Tab>
|
||||
<Tab fx:id="responseBodyTab" closable="false" text="BODY"/>
|
||||
<Tab fx:id="visualizerTab" closable="false" text="VISUALIZER" />
|
||||
<Tab fx:id="responseHeadersTab" closable="false" text="HEADERS" />
|
||||
</tabs>
|
||||
|
|
Loading…
Reference in a new issue