Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions uicdm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,14 @@ application {
}

jar.manifest.attributes 'Main-Class': 'ucar.nc2.ui.ToolsUI'

def genBuildInfo = tasks.register("generateBuildInfo", WriteProperties) {
destinationFile = getLayout().buildDirectory.file("resources/main/toolsui.properties")
comment = "Application configuration generated by Gradle"
encoding = "UTF-8"

property("toolsui.version", project.version)
property("toolsui.buildTimestamp", project.buildTimestamp) // Defined in root project.
}

processResources.dependsOn(genBuildInfo)
42 changes: 42 additions & 0 deletions uicdm/src/main/java/ucar/nc2/ui/BuildInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2025 University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/

package ucar.nc2.ui;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class BuildInfo {

private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BuildInfo.class);

private final String version, timestamp;

BuildInfo(String version, String timestamp) {
this.version = version;
this.timestamp = timestamp;
}

public String getVersion() {
return version;
}

public String getTimestamp() {
return timestamp;
}

static BuildInfo getToolsUIBuildInfo() {
Properties buildProps = new Properties();
try (InputStream stream = ToolsUI.class.getClassLoader().getResourceAsStream("toolsui.properties")) {
buildProps.load(stream);
} catch (IOException e) {
log.error("Error reading build properties");
}
return new BuildInfo(buildProps.getProperty("toolsui.version", "Unknown"),
buildProps.getProperty("toolsui.buildTimestamp", "Unknown"));
}

}
29 changes: 4 additions & 25 deletions uicdm/src/main/java/ucar/nc2/ui/ToolsAboutWindow.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
* Copyright (c) 1998-2019 University Corporation for Atmospheric Research/Unidata
* Copyright (c) 1998-2025 University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/

package ucar.nc2.ui;

import java.nio.charset.StandardCharsets;
import ucar.ui.util.Resource;
import ucar.ui.widget.BAMutil;
import java.awt.BorderLayout;
Expand All @@ -19,10 +18,6 @@
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
Expand All @@ -42,7 +37,8 @@ public ToolsAboutWindow(JFrame parent) {
super(parent);

JLabel lab1 = new JLabel("<html> <body bgcolor=\"#FFECEC\"> <center>"
+ "<h1>Netcdf Tools User Interface (ToolsUI)</h1>" + "<b>" + getVersion() + "</b>"
+ "<h1>Netcdf Tools User Interface (ToolsUI)</h1>" + "<b>" + BuildInfo.getToolsUIBuildInfo().getVersion()
+ "</b>" + "<br>Build Date: " + "<b>" + BuildInfo.getToolsUIBuildInfo().getTimestamp() + "</b>"
+ "<br><i>https://www.unidata.ucar.edu/software/netcdf-java/</i>"
+ "<br><b><i>Developers:</b> John Caron, Sean Arms, Dennis Heimbinger, Ryan May, Christian Ward-Garrison</i></b>"
+ "</center>" + "<br><br>With thanks to these <b>Open Source</b> contributors:" + "<ul>"
Expand Down Expand Up @@ -120,23 +116,6 @@ public void mousePressed(MouseEvent e) {
*
*/
private String getVersion() {
String version;
try (InputStream is = Resource.getFileResource("/README")) {
if (is == null) {
return "5.0";
}
BufferedReader dataIS = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
StringBuilder sbuff = new StringBuilder();
for (int i = 0; i < 3; i++) {
sbuff.append(dataIS.readLine());
sbuff.append("<br>");
}
version = sbuff.toString();
} catch (IOException ioe) {
ioe.printStackTrace();
version = "version unknown";
}

return version;
return BuildInfo.getToolsUIBuildInfo().getVersion();
}
}
2 changes: 1 addition & 1 deletion uicdm/src/main/java/ucar/nc2/ui/ToolsSplashScreen.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2019 University Corporation for Atmospheric Research/Unidata
* Copyright (c) 1998-2025 University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/

Expand Down
7 changes: 5 additions & 2 deletions uicdm/src/main/java/ucar/nc2/ui/ToolsUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
public class ToolsUI extends JPanel {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

private static final String DIALOG_VERSION = "5.0";
private static final String DIALOG_VERSION = BuildInfo.getToolsUIBuildInfo().getVersion();

public static final String WORLD_DETAIL_MAP = "/resources/ui/maps/Countries.shp";
public static final String US_MAP = "/resources/ui/maps/us_state.shp";
Expand Down Expand Up @@ -1524,11 +1524,14 @@ public void setMessage(SocketMessage.Event event) {
}

if (!configRead) {
// if System.getProperty("user.home") is set, look under user_home/.unidata for nj22Config.xml,
// otherwise look under the relative directory .unidata
String filename = XMLStore.makeStandardFilename(".unidata", "nj22Config.xml");
File f = new File(filename);
if (f.exists()) {
try (FileInputStream fis = new FileInputStream(filename)) {
StringBuilder errlog = new StringBuilder();
RuntimeConfigParser.read(fis, errlog);
System.out.println(errlog);
} catch (IOException ioe) {
log.warn("Error reading {} = {}", filename, ioe.getMessage());
Expand Down Expand Up @@ -1600,7 +1603,7 @@ public void setMessage(SocketMessage.Event event) {
} catch (HTTPException e) {
log.error("Failed to set global credentials");
}
HTTPSession.setGlobalUserAgent("ToolsUI v5.0");
HTTPSession.setGlobalUserAgent(String.format("ToolsUI v%s", BuildInfo.getToolsUIBuildInfo().getVersion()));

java.net.Authenticator.setDefault(provider);
});
Expand Down