diff --git a/src/main/java/com/rohitawate/restaurant/dashboard/DashboardController.java b/src/main/java/com/rohitawate/restaurant/dashboard/DashboardController.java index 628ac29..fa44c18 100644 --- a/src/main/java/com/rohitawate/restaurant/dashboard/DashboardController.java +++ b/src/main/java/com/rohitawate/restaurant/dashboard/DashboardController.java @@ -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 parentLoader = new Task() { + @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 diff --git a/src/main/java/com/rohitawate/restaurant/dashboard/HeaderFieldController.java b/src/main/java/com/rohitawate/restaurant/dashboard/HeaderFieldController.java new file mode 100644 index 0000000..0c19b13 --- /dev/null +++ b/src/main/java/com/rohitawate/restaurant/dashboard/HeaderFieldController.java @@ -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 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())); + } +} diff --git a/src/main/java/com/rohitawate/restaurant/dashboard/HeaderTabController.java b/src/main/java/com/rohitawate/restaurant/dashboard/HeaderTabController.java new file mode 100644 index 0000000..faef751 --- /dev/null +++ b/src/main/java/com/rohitawate/restaurant/dashboard/HeaderTabController.java @@ -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(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/rohitawate/restaurant/main/Main.java b/src/main/java/com/rohitawate/restaurant/main/Main.java index 4b8d3f1..afc824b 100644 --- a/src/main/java/com/rohitawate/restaurant/main/Main.java +++ b/src/main/java/com/rohitawate/restaurant/main/Main.java @@ -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(); diff --git a/src/main/resources/assets/LogoWithName.png b/src/main/resources/assets/LogoWithName.png deleted file mode 100644 index beb4ed6..0000000 Binary files a/src/main/resources/assets/LogoWithName.png and /dev/null differ diff --git a/src/main/resources/assets/Plus.png b/src/main/resources/assets/Plus.png new file mode 100644 index 0000000..6db5b31 Binary files /dev/null and b/src/main/resources/assets/Plus.png differ diff --git a/src/main/resources/assets/RoundLogo_Black.png b/src/main/resources/assets/RoundLogo_Black.png deleted file mode 100644 index 81f359e..0000000 Binary files a/src/main/resources/assets/RoundLogo_Black.png and /dev/null differ diff --git a/src/main/resources/assets/RoundLogo_White.png b/src/main/resources/assets/RoundLogo_White.png deleted file mode 100644 index 65fba0f..0000000 Binary files a/src/main/resources/assets/RoundLogo_White.png and /dev/null differ diff --git a/src/main/resources/assets/editables/LogoWithName.xcf b/src/main/resources/assets/editables/LogoWithName.xcf deleted file mode 100644 index dcc2668..0000000 Binary files a/src/main/resources/assets/editables/LogoWithName.xcf and /dev/null differ diff --git a/src/main/resources/assets/editables/RoundLogo.svg b/src/main/resources/assets/editables/RoundLogo.svg deleted file mode 100644 index dd1d0a0..0000000 --- a/src/main/resources/assets/editables/RoundLogo.svg +++ /dev/null @@ -1 +0,0 @@ -Created by Aldric Rodríguezfrom the Noun Project \ No newline at end of file diff --git a/src/main/resources/css/Default.css b/src/main/resources/css/Default.css index cee124e..6f3a7e5 100644 --- a/src/main/resources/css/Default.css +++ b/src/main/resources/css/Default.css @@ -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; } diff --git a/src/main/resources/fxml/Dashboard.fxml b/src/main/resources/fxml/dashboard/Dashboard.fxml similarity index 84% rename from src/main/resources/fxml/Dashboard.fxml rename to src/main/resources/fxml/dashboard/Dashboard.fxml index 2e0fecb..b7892a1 100644 --- a/src/main/resources/fxml/Dashboard.fxml +++ b/src/main/resources/fxml/dashboard/Dashboard.fxml @@ -1,5 +1,21 @@ + + @@ -7,7 +23,7 @@
@@ -17,7 +33,7 @@ - + @@ -52,6 +68,17 @@ + + + + + + + + + + - +