From 52407287c61d35e7d9ec00f5d278808d05f75e91 Mon Sep 17 00:00:00 2001 From: brutzman <brutzman@nps.edu> Date: Wed, 23 Oct 2024 05:53:32 -0700 Subject: [PATCH] add button for issues list to console --- .../xj3d/ui/awt/widgets/AWTConsoleWindow.java | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/java/org/xj3d/ui/awt/widgets/AWTConsoleWindow.java b/src/java/org/xj3d/ui/awt/widgets/AWTConsoleWindow.java index 5a7d1f41..5126bb6d 100644 --- a/src/java/org/xj3d/ui/awt/widgets/AWTConsoleWindow.java +++ b/src/java/org/xj3d/ui/awt/widgets/AWTConsoleWindow.java @@ -17,6 +17,9 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; // Local imports import org.web3d.util.Xj3dVersionInformation; @@ -33,15 +36,17 @@ import org.web3d.vrml.sav.DocumentLocator; * @author Justin Couch * @version $Revision: 1.1 $ */ -public class AWTConsoleWindow extends Frame - implements ActionListener, ErrorHandler { - +public class AWTConsoleWindow extends Frame implements ActionListener, ErrorHandler +{ /** The textfield to put the error information in */ private TextArea errorField; /** Clear button to remove stuff from window */ private Button clearButton; + /** Issues button to launch issues list */ + private Button issuesButton; + /** DocumentLocator used for printing out line/column information */ private DocumentLocator docLocator; @@ -63,9 +68,14 @@ public class AWTConsoleWindow extends Frame clearButton = new Button("Clear"); clearButton.addActionListener(AWTConsoleWindow.this); - p1.add(clearButton); + issuesButton = new Button("Issues list"); + issuesButton.addActionListener(AWTConsoleWindow.this); + if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) + p1.add(issuesButton); + else System.out.println("Unable to support issues button, this installation does not support Java Desktop"); + setSize(800, 600); // wide enough for typical paths setLocation(80, 80); @@ -249,7 +259,26 @@ public class AWTConsoleWindow extends Frame public void actionPerformed(ActionEvent evt) { Object src = evt.getSource(); - if(src == clearButton) + if (src == clearButton) + { errorField.setText(""); } + else if (src == issuesButton) + { + String issuesUrl = "https://gitlab.nps.edu/Savage/xj3d/issues"; + // https://stackoverflow.com/questions/5226212/how-to-open-url-in-default-webbrowser-using-java + if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) + { + try + { + URI issuesURI = new URI(issuesUrl); + Desktop.getDesktop().browse(issuesURI); + } + catch (IOException | URISyntaxException e) + { + System.err.println("Unable to connect to " + issuesUrl); + } + } + } + } } -- GitLab