Skip to content

Commit e5f49ea

Browse files
committed
Add keyboard shortcuts via hidden menu bars and improve "Request" menu discoverability.
1 parent 2a62c6a commit e5f49ea

File tree

8 files changed

+100
-23
lines changed

8 files changed

+100
-23
lines changed

pom.xml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -301,29 +301,9 @@
301301
<scope>test</scope>
302302
</dependency>
303303

304-
<!-- JavaScript engine for script execution -->
305-
<dependency>
306-
<groupId>org.graalvm.sdk</groupId>
307-
<artifactId>graal-sdk</artifactId>
308-
<version>${graalvm.version}</version>
309-
</dependency>
310-
<dependency>
311-
<groupId>org.graalvm.truffle</groupId>
312-
<artifactId>truffle-api</artifactId>
313-
<version>${graalvm.version}</version>
314-
</dependency>
315-
<dependency>
316-
<groupId>org.graalvm.js</groupId>
317-
<artifactId>js-scriptengine</artifactId>
318-
<version>${graalvm.js.version}</version>
319-
</dependency>
320-
<!-- GraalJS engine and dependencies for JSR-223 -->
321-
<!-- Removed org.graalvm.js:js for GraalVM >=23 as coordinates changed; keep scriptengine + truffle/sdk -->
322-
<dependency>
323-
<groupId>org.graalvm.regex</groupId>
324-
<artifactId>regex</artifactId>
325-
<version>22.3.3</version>
326-
</dependency>
304+
<!-- JavaScript (GraalJS) dependencies are moved to the 'scripts' profile
305+
to avoid putting GraalVM builder classes (graal-sdk, svm) on the
306+
Native Image classpath during GluonFX builds. -->
327307

328308
</dependencies>
329309

@@ -796,5 +776,33 @@
796776
<profile>
797777
<id>desktop</id>
798778
</profile>
779+
<!-- Optional profile to include GraalJS on the JVM when you want
780+
script execution while running with a regular JDK. Intentionally
781+
NOT activated for native-image builds. Enable with -Pscripts. -->
782+
<profile>
783+
<id>scripts</id>
784+
<dependencies>
785+
<dependency>
786+
<groupId>org.graalvm.sdk</groupId>
787+
<artifactId>graal-sdk</artifactId>
788+
<version>${graalvm.version}</version>
789+
</dependency>
790+
<dependency>
791+
<groupId>org.graalvm.truffle</groupId>
792+
<artifactId>truffle-api</artifactId>
793+
<version>${graalvm.version}</version>
794+
</dependency>
795+
<dependency>
796+
<groupId>org.graalvm.js</groupId>
797+
<artifactId>js-scriptengine</artifactId>
798+
<version>${graalvm.js.version}</version>
799+
</dependency>
800+
<dependency>
801+
<groupId>org.graalvm.regex</groupId>
802+
<artifactId>regex</artifactId>
803+
<version>22.3.3</version>
804+
</dependency>
805+
</dependencies>
806+
</profile>
799807
</profiles>
800808
</project>

src/main/java/io/github/ozkanpakdil/swaggerific/ui/MainController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,20 @@ public void reportBugOrFeatureRequestFromHelpMenu(ActionEvent ignoredEvent) {
786786
}
787787
}
788788

789+
/**
790+
* Triggered from the Request -> Send menu item. Delegates to the active request tab.
791+
*/
792+
public void requestSendFromMenu() {
793+
try {
794+
var tab = getSelectedTab();
795+
if (tab != null) {
796+
tab.btnSendRequest(null);
797+
}
798+
} catch (Exception ex) {
799+
log.warn("Failed to send request from menu: {}", ex.getMessage());
800+
}
801+
}
802+
789803
/**
790804
* Opens the Environment Variables management window.
791805
*

src/main/java/io/github/ozkanpakdil/swaggerific/ui/MenuController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public void openEnvironmentVariables(ActionEvent event) {
5555
mainController.openEnvironmentVariables(event);
5656
}
5757

58+
public void menuRequestSend(ActionEvent event) {
59+
if (mainController != null) {
60+
mainController.requestSendFromMenu();
61+
}
62+
}
63+
5864
public void setMainController(MainController mainController) {
5965
this.mainController = mainController;
6066
}

src/main/resources/io/github/ozkanpakdil/swaggerific/edit/environments.fxml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
<BorderPane prefHeight="500.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="io.github.ozkanpakdil.swaggerific.ui.edit.EnvironmentController">
2020
<top>
2121
<VBox spacing="10.0" BorderPane.alignment="CENTER">
22+
<!-- Hidden menu bar used only to register keyboard accelerators (e.g., Shortcut+S) -->
23+
<MenuBar managed="false" visible="false">
24+
<menus>
25+
<Menu text="Hidden">
26+
<items>
27+
<MenuItem text="New Environment" onAction="#handleNewEnvironment" accelerator="Shortcut+N"/>
28+
<MenuItem text="Edit Environment" onAction="#handleEditEnvironment" accelerator="Shortcut+E"/>
29+
<MenuItem text="Delete Environment" onAction="#handleDeleteEnvironment" accelerator="Shortcut+DELETE"/>
30+
<MenuItem text="Save" onAction="#handleSaveEnvironment" accelerator="Shortcut+S"/>
31+
<MenuItem text="Close" onAction="#handleClose" accelerator="Shortcut+W"/>
32+
</items>
33+
</Menu>
34+
</menus>
35+
</MenuBar>
2236
<children>
2337
<HBox alignment="CENTER_LEFT" spacing="10.0">
2438
<children>

src/main/resources/io/github/ozkanpakdil/swaggerific/edit/settings/Proxy.fxml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
AnchorPane.topAnchor="0.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1"
1010
fx:controller="io.github.ozkanpakdil.swaggerific.ui.edit.Proxy">
1111
<children>
12+
<!-- Hidden menu bar used only to register keyboard accelerators for this view -->
13+
<MenuBar managed="false" visible="false">
14+
<menus>
15+
<Menu text="Hidden">
16+
<items>
17+
<MenuItem text="Save" onAction="#saveProxySettings" accelerator="Shortcut+S"/>
18+
</items>
19+
</Menu>
20+
</menus>
21+
</MenuBar>
1222
<Label text="Default Proxy Configuration" GridPane.columnIndex="0" GridPane.rowIndex="0" GridPane.columnSpan="2"/>
1323
<Label text="Swaggerific uses the system's proxy configurations by default to connect to any online services, or to send API requests." GridPane.columnIndex="0" GridPane.rowIndex="1" GridPane.columnSpan="2"/>
1424
<CheckBox fx:id="proxyRequiresAuth" text="This proxy requires authentication" GridPane.columnIndex="0" GridPane.rowIndex="2" GridPane.columnSpan="2"/>

src/main/resources/io/github/ozkanpakdil/swaggerific/edit/settings/Shortcuts.fxml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
fx:controller="io.github.ozkanpakdil.swaggerific.ui.edit.Shortcuts"
88
AnchorPane.bottomAnchor="0.0"
99
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
10+
<!-- Hidden menu bar used only to register keyboard accelerators for this view -->
11+
<MenuBar managed="false" visible="false">
12+
<menus>
13+
<Menu text="Hidden">
14+
<items>
15+
<MenuItem text="Save" onAction="#save" accelerator="Shortcut+S"/>
16+
<MenuItem text="Reset to Defaults" onAction="#resetDefaults" accelerator="Shortcut+R"/>
17+
</items>
18+
</Menu>
19+
</menus>
20+
</MenuBar>
1021
<columnConstraints>
1122
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="200.0"/>
1223
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0"/>

src/main/resources/io/github/ozkanpakdil/swaggerific/menu-bar.fxml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
<MenuItem text="_Expand All Tree" onAction="#expandAllTree"/>
4949
<MenuItem text="_Collapse All Tree" onAction="#collapseAllTree"/>
5050
</Menu>
51+
<!-- New visible Request menu for discoverability -->
52+
<Menu text="_Request">
53+
<MenuItem text="_Send" onAction="#menuRequestSend" accelerator="Shortcut+ENTER"/>
54+
</Menu>
5155
<Menu text="_Help">
5256
<MenuItem disable="true" text="Search"/>
5357
<MenuItem text="Online Manual" visible="false"/>

src/main/resources/io/github/ozkanpakdil/swaggerific/tab-request.fxml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
<SplitPane dividerPositions="0.3" maxHeight="-Infinity" maxWidth="-Infinity" orientation="VERTICAL" prefHeight="600.0" prefWidth="800.0"
1414
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
1515
<AnchorPane VBox.vgrow="ALWAYS">
16+
<!-- Hidden menu bar used only to register keyboard accelerators (e.g., Shortcut+S) -->
17+
<MenuBar managed="false" visible="false">
18+
<menus>
19+
<Menu text="Hidden">
20+
<items>
21+
<MenuItem text="Send" onAction="#btnSendRequest" accelerator="Shortcut+S"/>
22+
</items>
23+
</Menu>
24+
</menus>
25+
</MenuBar>
1626
<VBox fx:id="boxParams" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" VBox.vgrow="ALWAYS">
1727
<HBox>
1828
<ComboBox fx:id="cmbHttpMethod" minWidth="-Infinity" styleClass="cmbHttpMethod" maxWidth="10"/>

0 commit comments

Comments
 (0)