Added request options tabs with basics of Headers tab

This commit is contained in:
Rohit Awate 2018-01-29 13:48:11 +05:30
parent 6b49c86836
commit d4f14f4056
14 changed files with 295 additions and 10 deletions

View file

@ -22,12 +22,13 @@ import com.rohitawate.restaurant.models.responses.RestaurantResponse;
import com.rohitawate.restaurant.requestsmanager.GETRequestManager;
import com.rohitawate.restaurant.requestsmanager.RequestManager;
import com.rohitawate.restaurant.settings.Settings;
import javafx.beans.binding.Bindings;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.Parent;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
@ -54,6 +55,8 @@ public class DashboardController implements Initializable {
private Label statusCode, statusCodeDescription, responseTime, responseSize;
@FXML
private JFXButton cancelButton;
@FXML
private Tab authTab, headersTab, bodyTab;
private JFXSnackbar snackBar;
private final String[] httpMethods = {"GET", "POST", "PUT", "DELETE", "PATCH"};
@ -62,12 +65,25 @@ public class DashboardController implements Initializable {
@Override
public void initialize(URL url, ResourceBundle rb) {
applySettings();
Task<Parent> parentLoader = new Task<Parent>() {
@Override
protected Parent call() throws Exception {
return FXMLLoader.load(getClass().getResource("/fxml/dashboard/HeaderTab.fxml"));
}
};
parentLoader.setOnSucceeded(event -> headersTab.setContent(parentLoader.getValue()));
parentLoader.setOnFailed(event -> parentLoader.getException().printStackTrace());
new Thread(parentLoader).start();
addressField.setText("https://api.chucknorris.io/jokes/random");
responseBox.getChildren().remove(0);
httpMethodBox.getItems().addAll(httpMethods);
httpMethodBox.setValue("GET");
snackBar = new JFXSnackbar(dashboard);
bodyTab.disableProperty().bind(Bindings.and(httpMethodBox.valueProperty().isNotEqualTo("POST"),
httpMethodBox.valueProperty().isNotEqualTo("PUT")));
}
@FXML

View file

@ -0,0 +1,47 @@
/*
* Copyright 2018 Rohit Awate.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.rohitawate.restaurant.dashboard;
import com.jfoenix.controls.JFXCheckBox;
import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TextField;
import javafx.util.Pair;
import java.net.URL;
import java.util.ResourceBundle;
public class HeaderFieldController implements Initializable {
@FXML
private TextField keyField, valueField;
@FXML
private JFXCheckBox checkBox;
public Pair<String, String> getHeader() {
return new Pair<>(keyField.getText(), valueField.getText());
}
public boolean isChecked() {
return checkBox.isSelected();
}
@Override
public void initialize(URL location, ResourceBundle resources) {
checkBox.disableProperty().bind(Bindings.or(keyField.textProperty().isEmpty(), valueField.textProperty().isEmpty()));
}
}

View file

@ -0,0 +1,47 @@
/*
* Copyright 2018 Rohit Awate.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.rohitawate.restaurant.dashboard;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.layout.VBox;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
public class HeaderTabController implements Initializable {
@FXML
private VBox headersBox;
@Override
public void initialize(URL location, ResourceBundle resources) {
addHeader();
}
@FXML
private void addHeader() {
try {
Parent headerField = FXMLLoader.load(getClass().getResource("/fxml/dashboard/HeaderField.fxml"));
headersBox.getChildren().add(headerField);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -20,6 +20,7 @@ import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
public class Main extends Application {
@ -27,8 +28,9 @@ public class Main extends Application {
public void start(Stage primaryStage) throws Exception {
SettingsLoader settingsLoader = new SettingsLoader();
settingsLoader.SettingsLoaderThread.join();
Parent dashboard = FXMLLoader.load(getClass().getResource("/fxml/Dashboard.fxml"));
Parent dashboard = FXMLLoader.load(getClass().getResource("/fxml/dashboard/Dashboard.fxml"));
Stage dashboardStage = new Stage();
dashboardStage.getIcons().add(new Image(getClass().getResource("/assets/LogoWithoutText.png").toExternalForm()));
dashboardStage.setScene(new Scene(dashboard));
dashboardStage.setTitle("RESTaurant");
dashboardStage.show();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View file

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 125" enable-background="new 0 0 100 100" xml:space="preserve"><path d="M99.207,50.077c0,27.06-21.934,49.001-49.001,49.001c-27.064,0-48.995-21.941-48.995-49.001 C1.211,23.02,23.142,1.08,50.206,1.08C77.273,1.08,99.207,23.02,99.207,50.077L99.207,50.077z M35.417,19.477 c0-0.438-0.349-0.804-0.8-0.804h-0.358c-0.438,0-0.801,0.365-0.801,0.804v16.077c0,1.822,1.475,3.304,3.304,3.304 c0.685,0,1.245,0.551,1.245,1.238v42.3c0,0.688,0.555,1.248,1.249,1.248h3.077c0.685,0,1.242-0.561,1.242-1.248v-42.3 c0-0.688,0.558-1.238,1.248-1.238c1.82,0,3.308-1.481,3.308-3.304V19.477c0-0.438-0.358-0.804-0.801-0.804h-0.371 c-0.436,0-0.791,0.365-0.791,0.804v9.124c0,0.448-0.361,0.801-0.8,0.801h-0.671c-0.451,0-0.804-0.353-0.804-0.801v-9.124 c0-0.438-0.361-0.804-0.8-0.804h-0.362c-0.448,0-0.8,0.365-0.8,0.804v9.124c0,0.448-0.362,0.801-0.797,0.801h-0.678 c-0.438,0-0.803-0.353-0.803-0.801v-9.124c0-0.438-0.362-0.804-0.801-0.804h-0.361c-0.448,0-0.797,0.365-0.797,0.804v9.124 c0,0.448-0.365,0.801-0.801,0.801h-0.677c-0.436,0-0.801-0.353-0.801-0.801V19.477 M57.132,26.679 c-0.136,0.202-0.209,0.441-0.209,0.687v32.589c0,0.68,0.564,1.242,1.245,1.242h1.026v21.199c0,0.688,0.558,1.248,1.241,1.248h3.085 c0.688,0,1.248-0.561,1.248-1.248V17.76c0-0.441-0.361-0.793-0.8-0.793c-0.27,0-0.524,0.129-0.671,0.358L57.132,26.679"/><text x="0" y="115" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">Created by Aldric Rodríguez</text><text x="0" y="120" fill="#000000" font-size="5px" font-weight="bold" font-family="'Helvetica Neue', Helvetica, Arial-Unicode, Arial, Sans-serif">from the Noun Project</text></svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -60,6 +60,59 @@
-fx-background-color: black;
}
.tab-pane:top .tab-header-area .tab-header-background {
-fx-background-color: #1b1b1b;
}
.tab-pane .tab-content-area,
#headerTabContent,
#headerField {
-fx-background-color: #282828;
}
.tab-pane:top .tab-header-area .headers-region .tab:top {
-fx-background-color: #6a6a6a;
-fx-background-insets: 0 1 0 1;
-fx-background-radius: 5 5 0 0;
}
.tab-pane:top .tab-header-area .headers-region .tab:selected:top {
-fx-background-color: #55a15c;
}
.tab-pane:top .tab-header-area .headers-region .tab:top .tab-container .tab-label .text {
-fx-fill: #b8b8b8;
}
.tab-pane:top .tab-header-area .headers-region .tab:selected:top .tab-container .tab-label .text {
-fx-fill: white;
}
.tab {
-fx-focus-color: transparent;
-fx-faint-focus-color: transparent;
}
.scroll-pane,
.scroll-pane .viewport {
-fx-background-insets: 0;
-fx-background-color: #282828;
}
.scroll-pane .scroll-bar:vertical {
-fx-background-color: #282828;
}
#keyField, #valueField {
-fx-prompt-text-fill: #2b2b2b;
-fx-background-color: #7a7a7a;
-fx-text-fill: white;
}
#addHeaderButton {
-fx-background-color: orangered;
}
#footer {
-fx-background-color: #8b8b8b;
}

View file

@ -1,5 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 Rohit Awate.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<?import com.jfoenix.controls.JFXButton?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
@ -7,7 +23,7 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<BorderPane fx:id="dashboard" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="720.0" prefWidth="1280.0" stylesheets="@../css/Default.css"
prefHeight="720.0" prefWidth="1280.0" stylesheets="@../../css/Default.css"
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.rohitawate.restaurant.dashboard.DashboardController">
<center>
@ -17,7 +33,7 @@
<children>
<ImageView fitHeight="80.0" fitWidth="80.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../assets/LogoWithoutText.png"/>
<Image url="@../../assets/LogoWithoutText.png"/>
</image>
<HBox.margin>
<Insets right="20.0"/>
@ -52,6 +68,17 @@
<Insets bottom="20.0" top="20.0" />
</padding>
</HBox>
<TabPane fx:id="requestTabs" maxHeight="200.0" tabClosingPolicy="UNAVAILABLE" tabMinWidth="150.0"
VBox.vgrow="ALWAYS">
<tabs>
<Tab fx:id="authTab" text="AUTHORIZATION"/>
<Tab fx:id="headersTab" text="HEADERS"/>
<Tab fx:id="bodyTab" text="BODY"/>
</tabs>
<VBox.margin>
<Insets bottom="10.0"/>
</VBox.margin>
</TabPane>
<VBox fx:id="responseBox" alignment="CENTER" VBox.vgrow="ALWAYS">
<children>
<HBox fx:id="responseDetails" alignment="CENTER_RIGHT" maxHeight="50.0" minHeight="50.0"
@ -102,7 +129,7 @@
<ImageView fitHeight="150.0" fitWidth="100.0" pickOnBounds="true"
preserveRatio="true">
<image>
<Image url="@../assets/LoadingCircle_WhiteOnOrange.gif"/>
<Image url="@../../assets/LoadingCircle_WhiteOnOrange.gif"/>
</image>
</ImageView>
<Label text="LOADING" textFill="WHITE">
@ -118,7 +145,7 @@
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true"
preserveRatio="true">
<image>
<Image url="@../assets/CrossMark.png"/>
<Image url="@../../assets/CrossMark.png"/>
</image>
</ImageView>
</graphic>

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 Rohit Awate.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<?import com.jfoenix.controls.JFXCheckBox?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<HBox fx:id="headerField" alignment="CENTER" spacing="10.0" stylesheets="@../../css/Default.css"
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.rohitawate.restaurant.dashboard.HeaderFieldController">
<children>
<JFXCheckBox fx:id="checkBox" checkedColor="ORANGERED" unCheckedColor="#7a7a7a" HBox.hgrow="ALWAYS"/>
<TextField fx:id="keyField" prefWidth="400.0" promptText="KEY" HBox.hgrow="ALWAYS"/>
<TextField fx:id="valueField" layoutX="10.0" layoutY="10.0" prefWidth="400.0" promptText="VALUE"
HBox.hgrow="ALWAYS"/>
</children>
<padding>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0"/>
</padding>
</HBox>

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 Rohit Awate.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<?import com.jfoenix.controls.JFXButton?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<VBox fx:id="headerTabContent" alignment="CENTER" stylesheets="@../../css/Default.css"
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.rohitawate.restaurant.dashboard.HeaderTabController">
<children>
<HBox alignment="CENTER_LEFT" VBox.vgrow="NEVER">
<VBox.margin>
<Insets/>
</VBox.margin>
<children>
<JFXButton fx:id="addHeaderButton" buttonType="RAISED" onAction="#addHeader" text=" NEW HEADER"
textFill="WHITE" HBox.hgrow="ALWAYS">
<padding>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0"/>
</padding>
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../assets/Plus.png"/>
</image>
</ImageView>
</graphic>
</JFXButton>
</children>
<padding>
<Insets bottom="10.0" left="25.0" right="10.0" top="15.0"/>
</padding>
</HBox>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" vbarPolicy="ALWAYS" VBox.vgrow="ALWAYS">
<content>
<VBox fx:id="headersBox" alignment="TOP_CENTER"/>
</content>
</ScrollPane>
</children>
</VBox>