Fix issue where tabs were only visible when the window was maximized

This commit is contained in:
Rohit Awate 2018-07-18 20:46:55 +05:30
parent 9515782650
commit cef97f0fec
6 changed files with 318 additions and 308 deletions

View file

@ -37,7 +37,7 @@ public class HomeWindowController implements Initializable {
@FXML
private SplitPane splitPane;
@FXML
private TabPane homeWindowTabPane;
private TabPane tabPane;
@FXML
private TextField historyTextField;
@FXML

View file

@ -47,7 +47,6 @@ import javafx.scene.control.*;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import org.fxmisc.flowless.VirtualizedScrollPane;
@ -68,7 +67,7 @@ import java.util.ResourceBundle;
public class DashboardController implements Initializable {
@FXML
private StackPane dashboard;
private VBox dashboard;
@FXML
TextField addressField;
@FXML

View file

@ -36,7 +36,6 @@ import javafx.scene.control.SplitPane;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import java.io.File;
@ -50,26 +49,29 @@ import java.util.ResourceBundle;
public class HomeWindowController implements Initializable {
@FXML
private StackPane homeWindowSP;
private StackPane homeWindowSP, dashboardContainer;
@FXML
private SplitPane splitPane;
@FXML
private TabPane homeWindowTabPane;
@FXML
private HistoryPaneController historyPaneController;
@FXML
private VBox tabDashboardBox;
private TabPane tabPane;
private HashMap<Tab, DashboardState> tabStateMap;
private HistoryPaneController historyController;
private DashboardController dashboard;
@Override
public void initialize(URL location, ResourceBundle resources) {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/homewindow/Dashboard.fxml"));
try {
Parent dashboardFXML = loader.load();
dashboard = loader.getController();
tabDashboardBox.getChildren().add(dashboardFXML);
FXMLLoader historyLoader = new FXMLLoader(getClass().getResource("/fxml/homewindow/HistoryPane.fxml"));
Parent historyFXML = historyLoader.load();
splitPane.getItems().add(0, historyFXML);
historyController = historyLoader.getController();
historyController.addItemClickHandler(this::addTab);
FXMLLoader dashboardLoader = new FXMLLoader(getClass().getResource("/fxml/homewindow/Dashboard.fxml"));
Parent dashboardFXML = dashboardLoader.load();
dashboard = dashboardLoader.getController();
dashboardContainer.getChildren().add(dashboardFXML);
} catch (IOException e) {
e.printStackTrace();
}
@ -78,7 +80,6 @@ public class HomeWindowController implements Initializable {
tabStateMap = new LinkedHashMap<>();
recoverState();
historyPaneController.addItemClickHandler(this::addTab);
homeWindowSP.setFocusTraversable(true);
Platform.runLater(() -> {
@ -90,7 +91,7 @@ public class HomeWindowController implements Initializable {
thisStage.setOnCloseRequest(e -> saveState());
});
homeWindowTabPane.getSelectionModel().selectedItemProperty().addListener(this::onTabSwitched);
tabPane.getSelectionModel().selectedItemProperty().addListener(this::onTabSwitched);
}
/**
@ -132,7 +133,7 @@ public class HomeWindowController implements Initializable {
}
/**
* Adds a new tab to the homeWindowTabPane initialized with
* Adds a new tab to the tabPane initialized with
* the ComposerState provided.
*/
private void addTab(ComposerState composerState) {
@ -147,10 +148,10 @@ public class HomeWindowController implements Initializable {
newTab.setOnCloseRequest(e -> {
tabStateMap.remove(newTab);
homeWindowTabPane.getTabs().remove(newTab);
tabPane.getTabs().remove(newTab);
// Closes the application if the last tab is closed
if (homeWindowTabPane.getTabs().size() == 0) {
if (tabPane.getTabs().size() == 0) {
saveState();
Stage thisStage = (Stage) homeWindowSP.getScene().getWindow();
thisStage.close();
@ -168,10 +169,10 @@ public class HomeWindowController implements Initializable {
4. Switch to the new tab.
5. Call onTabSwitched() to update the Dashboard and save the oldState.
*/
Tab prevTab = homeWindowTabPane.getSelectionModel().getSelectedItem();
Tab prevTab = tabPane.getSelectionModel().getSelectedItem();
DashboardState prevState = dashboard.getState();
homeWindowTabPane.getTabs().add(newTab);
homeWindowTabPane.getSelectionModel().select(newTab);
tabPane.getTabs().add(newTab);
tabPane.getSelectionModel().select(newTab);
onTabSwitched(prevState, prevTab, newTab);
}
@ -181,7 +182,7 @@ public class HomeWindowController implements Initializable {
Other tabs will already have their states saved when they
were loaded from state.json or on a tab switch.
*/
Tab currentTab = homeWindowTabPane.getSelectionModel().getSelectedItem();
Tab currentTab = tabPane.getSelectionModel().getSelectedItem();
DashboardState currentState = dashboard.getState();
tabStateMap.put(currentTab, currentState);
@ -228,11 +229,11 @@ public class HomeWindowController implements Initializable {
}
public void addHistoryItem(ComposerState state) {
historyPaneController.addHistoryItem(state);
historyController.addHistoryItem(state);
}
private void toggleHistoryPane() {
historyPaneController.toggleVisibilityIn(splitPane);
historyController.toggleVisibilityIn(splitPane);
}
private class KeymapHandler {
@ -251,17 +252,17 @@ public class HomeWindowController implements Initializable {
} else if (KeyMap.toggleHistory.match(e)) {
toggleHistoryPane();
} else if (KeyMap.closeTab.match(e)) {
Tab activeTab = homeWindowTabPane.getSelectionModel().getSelectedItem();
Tab activeTab = tabPane.getSelectionModel().getSelectedItem();
tabStateMap.remove(activeTab);
homeWindowTabPane.getTabs().remove(activeTab);
if (homeWindowTabPane.getTabs().size() == 0) {
tabPane.getTabs().remove(activeTab);
if (tabPane.getTabs().size() == 0) {
saveState();
Stage thisStage = (Stage) homeWindowSP.getScene().getWindow();
thisStage.close();
}
homeWindowTabPane.getTabs().remove(activeTab);
tabPane.getTabs().remove(activeTab);
} else if (KeyMap.searchHistory.match(e)) {
historyPaneController.focusSearchField();
historyController.focusSearchField();
} else if (KeyMap.focusParams.match(e)) {
dashboard.requestOptionsTab.getSelectionModel().select(dashboard.paramsTab);
} else if (KeyMap.focusAuth.match(e)) {

View file

@ -96,15 +96,15 @@
}
/* Home window tab */
#homeWindowTabPane:top .tab-header-area .headers-region .tab:top .tab-container .tab-close-button {
#tabPane:top .tab-header-area .headers-region .tab:top .tab-container .tab-close-button {
-fx-background-color: white;
}
#homeWindowTabPane:top .tab-header-area .headers-region .tab:hover:top {
#tabPane:top .tab-header-area .headers-region .tab:hover:top {
-fx-background-color: orangered;
}
#homeWindowTabPane:top .tab-header-area .headers-region .tab:selected:top {
#tabPane:top .tab-header-area .headers-region .tab:selected:top {
-fx-background-color: #505050;
}

View file

@ -22,131 +22,143 @@
<?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.111"
<VBox fx:id="dashboard" alignment="CENTER" stylesheets="@../../css/Adreana.css" xmlns="http://javafx.com/javafx/8.0.111"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.rohitawate.everest.controllers.DashboardController">
<children>
<VBox>
<children>
<HBox alignment="CENTER" maxHeight="100.0" minHeight="100.0" spacing="20.0" VBox.vgrow="ALWAYS">
<children>
<ImageView fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true" HBox.hgrow="ALWAYS">
<ImageView fitHeight="50.0" fitWidth="50.0" pickOnBounds="true" preserveRatio="true"
HBox.hgrow="ALWAYS">
<image>
<Image url="@../../assets/Logo.png" />
<Image url="@../../assets/Logo.png"/>
</image>
</ImageView>
<HBox fx:id="addressSection" alignment="CENTER" maxHeight="40.0" HBox.hgrow="ALWAYS">
<children>
<StackPane fx:id="comboContainer" minHeight="40.0" minWidth="130.0">
<children>
<ComboBox fx:id="httpMethodBox" minHeight="40.0" minWidth="130.0" StackPane.alignment="CENTER" />
<ComboBox fx:id="httpMethodBox" minHeight="40.0" minWidth="130.0"
StackPane.alignment="CENTER"/>
</children>
</StackPane>
<TextField fx:id="addressField" promptText="URL" HBox.hgrow="ALWAYS">
<font>
<Font size="18.0" />
<Font size="18.0"/>
</font>
</TextField>
</children>
</HBox>
<JFXButton fx:id="sendButton" buttonType="RAISED" defaultButton="true" minWidth="110.0" onAction="#sendRequest" prefHeight="39.0" ripplerFill="WHITE" text=" SEND" textAlignment="CENTER" textFill="WHITE" HBox.hgrow="ALWAYS">
<JFXButton fx:id="sendButton" buttonType="RAISED" defaultButton="true" minWidth="110.0"
onAction="#sendRequest" prefHeight="39.0" ripplerFill="WHITE" text=" SEND"
textAlignment="CENTER" textFill="WHITE" HBox.hgrow="ALWAYS">
<padding>
<Insets bottom="5.0" left="15.0" right="15.0" top="5.0" />
<Insets bottom="5.0" left="15.0" right="15.0" top="5.0"/>
</padding>
<font>
<Font size="18.0" />
<Font size="18.0"/>
</font>
<HBox.margin>
<Insets />
<Insets/>
</HBox.margin>
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../assets/Send.png" />
<Image url="@../../assets/Send.png"/>
</image>
</ImageView>
</graphic>
</JFXButton>
</children>
<padding>
<Insets left="20.0" right="20.0" />
<Insets left="20.0" right="20.0"/>
</padding>
</HBox>
<SplitPane dividerPositions="0.1" orientation="VERTICAL" VBox.vgrow="ALWAYS">
<items>
<AnchorPane maxHeight="300.0">
<children>
<TabPane fx:id="requestOptionsTab" minHeight="190.0" tabClosingPolicy="UNAVAILABLE" tabMinWidth="150.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<TabPane fx:id="requestOptionsTab" minHeight="190.0" tabClosingPolicy="UNAVAILABLE"
tabMinWidth="150.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab fx:id="paramsTab" text="PARAMS">
<content>
<VBox>
<children>
<HBox alignment="CENTER" maxHeight="0.0" spacing="20.0" VBox.vgrow="ALWAYS">
<HBox alignment="CENTER" maxHeight="0.0" spacing="20.0"
VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets />
<Insets/>
</VBox.margin>
<children>
<JFXButton fx:id="newParamButton" onAction="#addParamField" text=" NEW PARAM" textFill="WHITE" HBox.hgrow="ALWAYS">
<JFXButton fx:id="newParamButton" onAction="#addParamField"
text=" NEW PARAM" textFill="WHITE"
HBox.hgrow="ALWAYS">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<ImageView fitHeight="15.0" fitWidth="15.0"
pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../assets/Plus.png" />
<Image url="@../../assets/Plus.png"/>
</image>
</ImageView>
</graphic>
<HBox.margin>
<Insets />
<Insets/>
</HBox.margin>
</JFXButton>
<JFXButton fx:id="appendParamsButton" onAction="#appendParams" ripplerFill="WHITE" text=" APPEND PARAMS" textFill="WHITE" HBox.hgrow="ALWAYS">
<JFXButton fx:id="appendParamsButton" onAction="#appendParams"
ripplerFill="WHITE" text=" APPEND PARAMS"
textFill="WHITE" HBox.hgrow="ALWAYS">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<ImageView fitHeight="15.0" fitWidth="15.0"
pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../assets/CheckMark.png" />
<Image url="@../../assets/CheckMark.png"/>
</image>
</ImageView>
</graphic>
<HBox.margin>
<Insets />
<Insets/>
</HBox.margin>
</JFXButton>
</children>
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</padding>
</HBox>
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER" VBox.vgrow="ALWAYS">
<ScrollPane fitToHeight="true" fitToWidth="true" hbarPolicy="NEVER"
VBox.vgrow="ALWAYS">
<content>
<VBox fx:id="paramsBox" alignment="TOP_CENTER" />
<VBox fx:id="paramsBox" alignment="TOP_CENTER"/>
</content>
</ScrollPane>
</children>
</VBox>
</content>
</Tab>
<Tab fx:id="authTab" text="AUTHORIZATION" />
<Tab fx:id="headersTab" text="HEADERS" />
<Tab fx:id="bodyTab" text="BODY" />
<Tab fx:id="authTab" text="AUTHORIZATION"/>
<Tab fx:id="headersTab" text="HEADERS"/>
<Tab fx:id="bodyTab" text="BODY"/>
</tabs>
</TabPane>
</children>
</AnchorPane>
<AnchorPane>
<children>
<VBox fx:id="responseBox" alignment="CENTER" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<VBox fx:id="responseBox" alignment="CENTER" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<StackPane VBox.vgrow="SOMETIMES">
<StackPane VBox.vgrow="ALWAYS">
<children>
<VBox fx:id="responseLayer">
<children>
<HBox fx:id="responseDetails" alignment="CENTER_RIGHT"
maxHeight="50.0" minHeight="50.0" spacing="30.0"
VBox.vgrow="ALWAYS">
<HBox fx:id="responseDetails" alignment="CENTER_RIGHT" maxHeight="50.0"
minHeight="50.0" spacing="30.0" VBox.vgrow="ALWAYS">
<children>
<HBox alignment="CENTER_LEFT" HBox.hgrow="ALWAYS">
<children>
<Label fx:id="statusCode" text="404"
textFill="WHITE" HBox.hgrow="ALWAYS">
<Label fx:id="statusCode" text="404" textFill="WHITE"
HBox.hgrow="ALWAYS">
<font>
<Font name="System Bold" size="35.0"/>
</font>
@ -154,9 +166,8 @@
<Insets right="10.0"/>
</HBox.margin>
</Label>
<Label fx:id="statusCodeDescription"
text="Not Found" textFill="WHITE"
HBox.hgrow="ALWAYS">
<Label fx:id="statusCodeDescription" text="Not Found"
textFill="WHITE" HBox.hgrow="ALWAYS">
<font>
<Font size="30.0"/>
</font>
@ -186,23 +197,19 @@
<JFXButton fx:id="copyBodyButton" textFill="WHITE">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0"
pickOnBounds="true"
preserveRatio="true">
pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../assets/Copy.png"/>
</image>
</ImageView>
</graphic>
</JFXButton>
<JFXButton fx:id="clearResponseAreaButton"
buttonType="RAISED"
onAction="#clearResponseArea"
ripplerFill="WHITE" text=" CLEAR"
textFill="WHITE" HBox.hgrow="ALWAYS">
<JFXButton fx:id="clearResponseAreaButton" buttonType="RAISED"
onAction="#clearResponseArea" ripplerFill="WHITE"
text=" CLEAR" textFill="WHITE" HBox.hgrow="ALWAYS">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0"
pickOnBounds="true"
preserveRatio="true">
pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../assets/CrossMark.png"/>
</image>
@ -218,11 +225,11 @@
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0"/>
</padding>
</HBox>
<TabPane fx:id="responseTabPane" side="BOTTOM" tabMinWidth="100.0">
<TabPane fx:id="responseTabPane" side="BOTTOM" tabMinWidth="100.0"
VBox.vgrow="ALWAYS">
<tabs>
<Tab fx:id="responseBodyTab" closable="false" text="BODY"/>
<Tab fx:id="visualizerTab" closable="false"
text="VISUALIZER"/>
<Tab fx:id="visualizerTab" closable="false" text="VISUALIZER"/>
<Tab fx:id="responseHeadersTab" closable="false"
text="HEADERS"/>
</tabs>
@ -233,15 +240,16 @@
<children>
<Label text="LOADING" textFill="WHITE">
<font>
<Font size="70.0" />
<Font size="70.0"/>
</font>
</Label>
<JFXProgressBar fx:id="progressBar" VBox.vgrow="ALWAYS" />
<JFXProgressBar fx:id="progressBar" VBox.vgrow="ALWAYS"/>
<JFXButton fx:id="cancelButton" text=" CANCEL" textFill="WHITE">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<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>
@ -250,28 +258,32 @@
</VBox>
<VBox fx:id="promptLayer" alignment="CENTER" visible="false">
<children>
<Label text="Enter an address, select a method and hit send." textFill="WHITE">
<Label text="Enter an address, select a method and hit send."
textFill="WHITE">
<font>
<Font size="32.0" />
<Font size="32.0"/>
</font>
</Label>
</children>
</VBox>
<VBox fx:id="errorLayer" alignment="CENTER" layoutX="10.0" layoutY="10.0" visible="false">
<VBox fx:id="errorLayer" alignment="CENTER" layoutX="10.0" layoutY="10.0"
visible="false">
<children>
<ImageView fitHeight="100.0" fitWidth="100.0" opacity="0.75" pickOnBounds="true" preserveRatio="true">
<ImageView fitHeight="100.0" fitWidth="100.0" opacity="0.75"
pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../../assets/Explosion.png" />
<Image url="@../../assets/Explosion.png"/>
</image>
</ImageView>
<Label fx:id="errorTitle" text="Error title" textFill="WHITE">
<font>
<Font name="System Bold" size="32.0" />
<Font name="System Bold" size="32.0"/>
</font>
</Label>
<Label fx:id="errorDetails" text="Error details" textAlignment="CENTER" textFill="#c3c3c3">
<Label fx:id="errorDetails" text="Error details" textAlignment="CENTER"
textFill="#c3c3c3">
<font>
<Font size="22.0" />
<Font size="22.0"/>
</font>
</Label>
</children>
@ -286,8 +298,6 @@
</SplitPane>
</children>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
<Insets bottom="10.0" left="10.0" right="10.0"/>
</padding>
</VBox>
</children>
</StackPane>
</VBox>

View file

@ -18,18 +18,18 @@
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<StackPane fx:id="homeWindowSP" stylesheets="@../../css/Adreana.css" xmlns="http://javafx.com/javafx/8.0.141"
<?import javafx.scene.layout.*?>
<StackPane fx:id="homeWindowSP" stylesheets="@../../css/Adreana.css" xmlns="http://javafx.com/javafx/8.0.111"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.rohitawate.everest.controllers.HomeWindowController">
<children>
<SplitPane fx:id="splitPane" dividerPositions="0.3">
<SplitPane fx:id="splitPane">
<items>
<fx:include fx:id="historyPane" source="HistoryPane.fxml" />
<VBox fx:id="tabDashboardBox" SplitPane.resizableWithParent="false">
<VBox fx:id="tabDashboardBox" alignment="TOP_CENTER" SplitPane.resizableWithParent="false">
<children>
<TabPane fx:id="homeWindowTabPane" tabClosingPolicy="ALL_TABS" tabMaxHeight="30.0"
tabMaxWidth="200.0" tabMinHeight="30.0" tabMinWidth="200.0" VBox.vgrow="ALWAYS"/>
<TabPane fx:id="tabPane" maxHeight="35.0" minHeight="35.0" tabClosingPolicy="ALL_TABS"
tabMaxHeight="35.0" tabMaxWidth="200.0" tabMinHeight="35.0" tabMinWidth="200.0"
VBox.vgrow="ALWAYS"/>
<StackPane fx:id="dashboardContainer" VBox.vgrow="ALWAYS"/>
</children>
</VBox>
</items>