Skip to content

Commit

Permalink
Added support for opening URLs on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Warxim committed Jun 25, 2022
1 parent 8abc2dc commit d40c9d9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public void start(Stage stage) throws Exception {
Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
StyleManager.getInstance().addUserAgentStylesheet(getClass().getResource(GuiConstant.MAIN_CSS_PATH).toString());

// Store host services inside GUI bundle
GuiBundle.getInstance().setHostServices(getHostServices());

var fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/Application.fxml"));
fxmlLoader.setController(new ApplicationController());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.warxim.vucsa.client.gui;

import com.warxim.vucsa.client.gui.controller.ApplicationController;
import javafx.application.HostServices;
import javafx.scene.image.Image;
import lombok.Getter;

Expand All @@ -42,6 +43,11 @@ public final class GuiBundle {
*/
private ApplicationController applicationController;

/**
* Host services
*/
private HostServices hostServices;

private GuiBundle() {
logo = new Image(Objects.requireNonNull(getClass().getResourceAsStream("/img/Logo.png")));
}
Expand Down Expand Up @@ -78,6 +84,22 @@ public void setApplicationController(ApplicationController controller) {
applicationController = controller;
}

/**
* Obtains host services
* @return Host services
*/
public HostServices getHostServices() {
return hostServices;
}

/**
* Sets host services
* @param hostServices Host services
*/
public void setHostServices(HostServices hostServices) {
this.hostServices = hostServices;
}

/**
* Destroys the bundle.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public static void show() {
*/
private static void onWebClick(ActionEvent event) {
try {
Desktop.getDesktop().browse(new URI(Constant.WEB));
} catch (IOException | URISyntaxException e) {
GuiBundle.getInstance().getHostServices().showDocument(Constant.WEB);
} catch (Exception e) {
Logger.getGlobal().log(Level.SEVERE, "Could not open VuCSA link.");
}
}
Expand Down

0 comments on commit d40c9d9

Please sign in to comment.