Skip to content

Commit d24344d

Browse files
committed
Fix netCDF file writing in ToolsUI
Fixes #643
1 parent aad3e65 commit d24344d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

uicdm/src/main/java/ucar/nc2/ui/dialog/NetcdfOutputChooser.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/*
2+
* Copyright (c) 1998-2025 John Caron and University Corporation for Atmospheric Research/Unidata
3+
* See LICENSE for license information.
4+
*
25
* Created by JFormDesigner on Thu Nov 15 14:02:02 MST 2012
36
*/
47

58
package ucar.nc2.ui.dialog;
69

7-
import ucar.nc2.NetcdfFileWriter;
10+
import java.util.Arrays;
811
import ucar.nc2.util.ListenerManager;
912
import ucar.nc2.write.Nc4Chunking;
1013
import javax.swing.*;
@@ -44,8 +47,8 @@ public void setOutputFilename(String filename) {
4447
location = location.substring(0, pos);
4548

4649
// change suffix
47-
NetcdfFileWriter.Version version = (NetcdfFileWriter.Version) netcdfVersion.getSelectedItem();
48-
String suffix = (version == null) ? ".nc" : version.getSuffix();
50+
NetcdfFileFormat version = (NetcdfFileFormat) netcdfVersion.getSelectedItem();
51+
String suffix = (version != null && version.isNetcdf4Format()) ? ".nc4" : ".nc";
4952
if (filename.endsWith(".nc") && suffix.equals(".nc"))
5053
suffix = ".sub.nc";
5154
location += suffix;
@@ -105,10 +108,11 @@ private void initComponents() {
105108
label1 = new JLabel();
106109
outputFilename = new JTextField();
107110
label2 = new JLabel();
108-
netcdfVersion = new JComboBox(NetcdfFileWriter.Version.values());
111+
netcdfVersion = new JComboBox<>(
112+
Arrays.stream(NetcdfFileFormat.values()).filter(format -> format != NetcdfFileFormat.INVALID).toArray());
109113
panel1 = new JPanel();
110114
label3 = new JLabel();
111-
chunking = new JComboBox(Nc4Chunking.Strategy.values());
115+
chunking = new JComboBox<>(Nc4Chunking.Strategy.values());
112116
deflate = new JCheckBox();
113117
shuffle = new JCheckBox();
114118
buttonBar = new JPanel();

0 commit comments

Comments
 (0)