Skip to content

Commit

Permalink
Deprecated the WebView consumer constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Jul 31, 2024
1 parent 64d75d4 commit 586d93d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/javaFxStub/java/javafx/embed/swing/JFXPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

public class JFXPanel extends JComponent {

public native Scene getScene();

public native void setScene(final Scene scene);

}
2 changes: 2 additions & 0 deletions src/javaFxStub/java/javafx/scene/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ public class Scene {
public Scene(final Parent root, final double width, final double height) {
}

public native Parent getRoot();

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public StepJfxWebViewMsaCode(final ApplicationDetails applicationDetails, final
protected MsaCode execute(final ILogger logger, final HttpClient httpClient, final JavaFxWebView javaFxWebViewCallback) throws Exception {
logger.info(this, "Opening JavaFX WebView window for MSA login...");

final JFXPanel jfxPanel = new JFXPanel();
final URL authenticationUrl = new URLWrapper(this.applicationDetails.getOAuthEnvironment().getAuthorizeUrl()).wrapQuery().addQueries(this.applicationDetails.getOAuthParameters()).apply().toURL();
final CompletableFuture<MsaCode> msaCodeFuture = new CompletableFuture<>();

final JFXPanel jfxPanel = new JFXPanel();
final JFrame window = new JFrame("MinecraftAuth - Microsoft Login");
window.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
window.setSize(800, 600);
Expand Down Expand Up @@ -108,7 +108,7 @@ public void windowClosing(WindowEvent e) {
if (javaFxWebViewCallback == null) {
window.setVisible(true);
} else {
javaFxWebViewCallback.openCallback.accept(window, webView);
javaFxWebViewCallback.openCallback.accept(window);
}
});

Expand Down Expand Up @@ -138,16 +138,20 @@ public void windowClosing(WindowEvent e) {
@EqualsAndHashCode(callSuper = false)
public static class JavaFxWebView extends AbstractStep.InitialInput {

BiConsumer<JFrame, WebView> openCallback;
Consumer<JFrame> openCallback;
Consumer<JFrame> closeCallback;

public JavaFxWebView() {
this.openCallback = (window, webView) -> window.setVisible(true);
this.openCallback = window -> window.setVisible(true);
this.closeCallback = JFrame::dispose;
}

public JavaFxWebView(final Consumer<JFrame> openCallback, final Consumer<JFrame> closeCallback) {
this.openCallback = (window, webview) -> openCallback.accept(window);
@Deprecated
public JavaFxWebView(final BiConsumer<JFrame, WebView> openCallback, final Consumer<JFrame> closeCallback) {
this.openCallback = window -> {
final WebView webView = (WebView) ((JFXPanel) window.getContentPane()).getScene().getRoot();
openCallback.accept(window, webView);
};
this.closeCallback = closeCallback;
}

Expand Down

0 comments on commit 586d93d

Please sign in to comment.