forked from Unidata/netcdf-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToolsUI.java
More file actions
1616 lines (1375 loc) · 51.1 KB
/
Copy pathToolsUI.java
File metadata and controls
1616 lines (1375 loc) · 51.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 1998-2019 University Corporation for Atmospheric Research/Unidata
* See LICENSE for license information.
*/
package ucar.nc2.ui;
import thredds.client.catalog.ServiceType;
import thredds.client.catalog.tools.DataFactory;
import thredds.ui.catalog.ThreddsUI;
import ucar.httpservices.HTTPException;
import ucar.httpservices.HTTPSession;
import ucar.nc2.*;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.dataset.*;
import ucar.nc2.dods.DODSNetcdfFile;
import ucar.nc2.dt.GridDataset;
import ucar.nc2.dt.RadialDatasetSweep;
import ucar.nc2.ffi.netcdf.NetcdfClibrary;
import ucar.nc2.ft.point.PointDatasetImpl;
import ucar.nc2.ft2.coverage.*;
import ucar.nc2.grib.GribIndexCache;
import ucar.nc2.grib.collection.GribCdmIndex;
import ucar.nc2.internal.ncml.NcmlReader;
import ucar.nc2.iosp.hdf5.H5iosp;
import ucar.nc2.jni.netcdf.Nc4Iosp;
import ucar.nc2.ncml.Aggregation;
import ucar.nc2.stream.CdmRemote;
import ucar.nc2.ui.dialog.DiskCache2Form;
import ucar.nc2.ui.grib.*;
import ucar.nc2.ui.menu.*;
import ucar.nc2.ui.op.*;
import ucar.nc2.ui.util.SocketMessage;
import ucar.nc2.ui.widget.URLDumpPane;
import ucar.nc2.ui.widget.UrlAuthenticatorDialog;
import ucar.nc2.write.NetcdfCopier;
import ucar.ui.widget.*;
import ucar.ui.widget.ProgressMonitor;
import ucar.nc2.util.CancelTask;
import ucar.nc2.util.DebugFlags;
import ucar.nc2.util.DiskCache2;
import ucar.nc2.util.IO;
import ucar.nc2.util.cache.FileCache;
import ucar.nc2.util.xml.RuntimeConfigParser;
import ucar.unidata.io.RandomAccessFile;
import ucar.util.prefs.PreferencesExt;
import ucar.util.prefs.XMLStore;
import ucar.ui.prefs.Debug;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.*;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Proxy;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
/** Netcdf Tools user interface. */
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 = 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";
public static final String FRAME_SIZE = "FrameSize";
public static final String GRIDVIEW_FRAME_SIZE = "GridUIWindowSize";
public static final String GRIDIMAGE_FRAME_SIZE = "GridImageWindowSize";
private static boolean debugListen = false;
private static ToolsUI ui;
private static JFrame frame;
private static PreferencesExt prefs;
private static XMLStore store;
private static boolean done;
private static String wantDataset;
private final JFrame parentFrame; // redundant? will equal static "frame" defined just above
private final FileManager fileChooser;
private final FileManager dirChooser;
private FileManager bufrFileChooser;
private final JTabbedPane tabbedPane;
private final JTabbedPane iospTabPane;
private final JTabbedPane bufrTabPane;
private final JTabbedPane gribTabPane;
private final JTabbedPane grib2TabPane;
private final JTabbedPane grib1TabPane;
private final JTabbedPane hdf5TabPane;
private final JTabbedPane ftTabPane;
private final JTabbedPane fcTabPane;
private final JTabbedPane fmrcTabPane;
private final JTabbedPane ncmlTabPane;
private final PreferencesExt mainPrefs;
// Op panels and friends
private AggPanel aggPanel;
private BufrPanel bufrPanel;
private BufrTableBPanel bufrTableBPanel;
private BufrTableDPanel bufrTableDPanel;
private ReportOpPanel bufrReportPanel;
private BufrCdmIndexOpPanel bufrCdmIndexPanel;
private BufrCodePanel bufrCodePanel;
private CdmrFeatureOpPanel cdmremotePanel;
private CdmIndexOpPanel cdmIndexPanel;
private CdmIndexScanOp cdmIndexScanOp;
private ReportOpPanel cdmIndexReportPanel;
private CollectionSpecPanel fcPanel;
private CoordSysPanel coordSysPanel;
private CoveragePanel coveragePanel;
private DatasetViewerPanel viewerPanel;
private DatasetViewerPanel nc4viewer;
private DatasetWriterPanel writerPanel;
private DirectoryPartitionPanel dirPartPanel;
private FeatureScanOpPanel ftPanel;
private FmrcPanel fmrcPanel;
private GeoGridPanel geoGridPanel;
private GeotiffPanel geotiffPanel;
private GribCodePanel gribCodePanel;
private GribFilesOpPanel gribFilesPanel;
private GribIndexOpPanel gribIdxPanel;
private GribRewriteOpPanel gribRewritePanel;
private GribTemplatePanel gribTemplatePanel;
private Grib1CollectionOpPanel grib1CollectionPanel;
private ReportOpPanel grib1ReportPanel;
private Grib1TablePanel grib1TablePanel;
private Grib2CollectionOpPanel grib2CollectionPanel;
private Grib2TablePanel grib2TablePanel;
private ReportOpPanel grib2ReportPanel;
private Grib1DataOpPanel grib1DataPanel;
private Grib2DataOpPanel grib2DataPanel;
private Hdf5ObjectPanel hdf5ObjectPanel;
private Hdf5DataPanel hdf5DataPanel;
private Hdf4Panel hdf4Panel;
private ImagePanel imagePanel;
private NcStreamOpPanel ncStreamPanel;
private NCdumpPanel ncdumpPanel;
private NcmlEditorPanel ncmlEditorPanel;
private PointFeaturePanel pointFeaturePanel;
private SimpleGeomPanel simpleGeomPanel;
private StationRadialPanel stationRadialPanel;
private RadialPanel radialPanel;
private ThreddsUI threddsUI;
private UnitsPanel unitsPanel;
private URLDumpPane urlPanel;
private WmoCCPanel wmoCommonCodePanel;
private WmsPanel wmsPanel;
// data
private final DataFactory threddsDataFactory = new DataFactory();
private boolean useRecordStructure;
private boolean useBuilders = true;
private DiskCache2Form diskCache2Form;
// debugging
private final DebugFlags debugFlags;
private ToolsUI(PreferencesExt prefs, JFrame parentFrame) {
this.mainPrefs = prefs;
this.parentFrame = parentFrame;
// FileChoosers are shared
FileFilter[] filters = {new FileManager.HDF5ExtFilter(), new FileManager.NetcdfExtFilter()};
fileChooser = new FileManager(parentFrame, null, filters, (PreferencesExt) prefs.node("FileManager"));
dirChooser = new FileManager(parentFrame, null, null, (PreferencesExt) prefs.node("FeatureScanFileManager"));
OpPanel.setFileChooser(fileChooser);
// all the tabbed panes
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
iospTabPane = new JTabbedPane(JTabbedPane.TOP);
gribTabPane = new JTabbedPane(JTabbedPane.TOP);
grib2TabPane = new JTabbedPane(JTabbedPane.TOP);
grib1TabPane = new JTabbedPane(JTabbedPane.TOP);
bufrTabPane = new JTabbedPane(JTabbedPane.TOP);
ftTabPane = new JTabbedPane(JTabbedPane.TOP);
fcTabPane = new JTabbedPane(JTabbedPane.TOP);
fmrcTabPane = new JTabbedPane(JTabbedPane.TOP);
hdf5TabPane = new JTabbedPane(JTabbedPane.TOP);
ncmlTabPane = new JTabbedPane(JTabbedPane.TOP);
// Create and attach the initially visible panel in the top level tabbed pane
viewerPanel = new DatasetViewerPanel((PreferencesExt) mainPrefs.node("varTable"), false);
tabbedPane.addTab("Viewer", viewerPanel);
// All other panels are deferred construction for fast startup
tabbedPane.addTab("Writer", new JLabel("Writer"));
tabbedPane.addTab("NCDump", new JLabel("NCDump"));
tabbedPane.addTab("Iosp", iospTabPane);
tabbedPane.addTab("CoordSys", new JLabel("CoordSys"));
tabbedPane.addTab("FeatureTypes", ftTabPane);
tabbedPane.addTab("THREDDS", new JLabel("THREDDS"));
tabbedPane.addTab("Fmrc", fmrcTabPane);
tabbedPane.addTab("GeoTiff", new JLabel("GeoTiff"));
tabbedPane.addTab("Units", new JLabel("Units"));
tabbedPane.addTab("NcML", ncmlTabPane);
tabbedPane.addTab("URLdump", new JLabel("URLdump"));
tabbedPane.setSelectedIndex(0);
tabbedPane.addChangeListener(e -> {
Component c = tabbedPane.getSelectedComponent();
if (c instanceof JLabel) {
int idx = tabbedPane.getSelectedIndex();
String title = tabbedPane.getTitleAt(idx);
makeComponent(tabbedPane, title);
}
});
setLayout(new BorderLayout());
add(tabbedPane, BorderLayout.CENTER);
// nested tab - iosp
iospTabPane.addTab("BUFR", bufrTabPane);
iospTabPane.addTab("GRIB", gribTabPane);
iospTabPane.addTab("GRIB2", grib2TabPane);
iospTabPane.addTab("GRIB1", grib1TabPane);
iospTabPane.addTab("HDF5", hdf5TabPane);
iospTabPane.addTab("HDF4", new JLabel("HDF4"));
iospTabPane.addTab("NcStream", new JLabel("NcStream"));
iospTabPane.addTab("CdmrFeature", new JLabel("CdmrFeature"));
addListeners(iospTabPane);
// nested-2 tab - bufr
bufrTabPane.addTab("BUFR", new JLabel("BUFR"));
bufrTabPane.addTab("BufrCdmIndex", new JLabel("BufrCdmIndex"));
bufrTabPane.addTab("BUFRTableB", new JLabel("BUFRTableB"));
bufrTabPane.addTab("BUFRTableD", new JLabel("BUFRTableD"));
bufrTabPane.addTab("BUFR-CODES", new JLabel("BUFR-CODES"));
bufrTabPane.addTab("BufrReports", new JLabel("BufrReports"));
addListeners(bufrTabPane);
// nested-2 tab - grib
gribTabPane.addTab("CdmIndex4", new JLabel("CdmIndex4"));
gribTabPane.addTab("CdmIndexScan", new JLabel("CdmIndexScan"));
gribTabPane.addTab("CdmIndexReport", new JLabel("CdmIndexReport"));
gribTabPane.addTab("GribIndex", new JLabel("GribIndex"));
gribTabPane.addTab("WMO-COMMON", new JLabel("WMO-COMMON"));
gribTabPane.addTab("WMO-CODES", new JLabel("WMO-CODES"));
gribTabPane.addTab("WMO-TEMPLATES", new JLabel("WMO-TEMPLATES"));
gribTabPane.addTab("GRIB-Rewrite", new JLabel("GRIB-Rewrite"));
addListeners(gribTabPane);
// nested-2 tab - grib-2
grib2TabPane.addTab("GRIB2collection", new JLabel("GRIB2collection"));
grib2TabPane.addTab("GRIB2-REPORT", new JLabel("GRIB2-REPORT"));
grib2TabPane.addTab("GRIB2data", new JLabel("GRIB2data"));
grib2TabPane.addTab("GRIB2-TABLES", new JLabel("GRIB2-TABLES"));
addListeners(grib2TabPane);
// nested-2 tab - grib-1
grib1TabPane.addTab("GRIB1collection", new JLabel("GRIB1collection"));
grib1TabPane.addTab("GRIB-FILES", new JLabel("GRIB-FILES"));
grib1TabPane.addTab("GRIB1-REPORT", new JLabel("GRIB1-REPORT"));
grib1TabPane.addTab("GRIB1data", new JLabel("GRIB1data"));
grib1TabPane.addTab("GRIB1-TABLES", new JLabel("GRIB1-TABLES"));
addListeners(grib1TabPane);
// nested-2 tab - hdf5
hdf5TabPane.addTab("HDF5-Objects", new JLabel("HDF5-Objects"));
hdf5TabPane.addTab("HDF5-Data", new JLabel("HDF5-Data"));
hdf5TabPane.addTab("Netcdf4-JNI", new JLabel("Netcdf4-JNI"));
addListeners(hdf5TabPane);
// nested tab - features
ftTabPane.addTab("FeatureScan", new JLabel("FeatureScan"));
ftTabPane.addTab("Grids", new JLabel("Grids"));
ftTabPane.addTab("Coverages", new JLabel("Coverages"));
ftTabPane.addTab("SimpleGeometry", new JLabel("SimpleGeometry"));
ftTabPane.addTab("WMS", new JLabel("WMS"));
ftTabPane.addTab("PointFeature", new JLabel("PointFeature"));
ftTabPane.addTab("Images", new JLabel("Images"));
ftTabPane.addTab("Radial", new JLabel("Radial"));
ftTabPane.addTab("FeatureScan", new JLabel("FeatureScan"));
ftTabPane.addTab("FeatureCollection", fcTabPane);
addListeners(ftTabPane);
// nested tab - feature collection
fcTabPane.addTab("DirectoryPartition", new JLabel("DirectoryPartition"));
// fcTabPane.addTab("PartitionReport", new JLabel("PartitionReport"));
fcTabPane.addTab("CollectionSpec", new JLabel("CollectionSpec"));
addListeners(fcTabPane);
// nested tab - fmrc
fmrcTabPane.addTab("Fmrc", new JLabel("Fmrc"));
fmrcTabPane.addTab("Collections", new JLabel("Collections"));
addListeners(fmrcTabPane);
// nested tab - ncml
ncmlTabPane.addTab("NcmlEditor", new JLabel("NcmlEditor"));
ncmlTabPane.addTab("Aggregation", new JLabel("Aggregation"));
addListeners(ncmlTabPane);
// dynamic proxy for DebugFlags
debugFlags = (DebugFlags) Proxy.newProxyInstance(DebugFlags.class.getClassLoader(), new Class[] {DebugFlags.class},
new DebugProxyHandler());
JMenuBar mb = makeMenuBar();
parentFrame.setJMenuBar(mb);
setDebugFlags();
}
private void addListeners(JTabbedPane tabPane) {
tabPane.addChangeListener(e -> {
Component c = tabPane.getSelectedComponent();
if (c instanceof JLabel) {
int idx = tabPane.getSelectedIndex();
String title = tabPane.getTitleAt(idx);
makeComponent(tabPane, title);
}
});
tabPane.addComponentListener(new ComponentAdapter() {
public void componentShown(ComponentEvent e) {
Component c = tabPane.getSelectedComponent();
if (c instanceof JLabel) {
int idx = tabPane.getSelectedIndex();
String title = tabPane.getTitleAt(idx);
makeComponent(tabPane, title);
}
}
});
}
/**
* deferred creation of components to minimize startup
*/
private void makeComponent(JTabbedPane parent, String title) {
if (parent == null) {
parent = tabbedPane;
}
// find the correct index
int n = parent.getTabCount();
int idx;
for (idx = 0; idx < n; idx++) {
String cTitle = parent.getTitleAt(idx);
if (cTitle.equals(title)) {
break;
}
}
if (idx >= n) {
log.debug("Cant find {} in {}", title, parent);
return;
}
Component c;
switch (title) {
case "Aggregation":
aggPanel = new AggPanel((PreferencesExt) mainPrefs.node("NcMLAggregation"));
c = aggPanel;
break;
case "BUFR":
bufrPanel = new BufrPanel((PreferencesExt) mainPrefs.node("bufr"));
c = bufrPanel;
break;
case "BUFRTableB":
bufrTableBPanel = new BufrTableBPanel((PreferencesExt) mainPrefs.node("bufr2"));
c = bufrTableBPanel;
break;
case "BUFRTableD":
bufrTableDPanel = new BufrTableDPanel((PreferencesExt) mainPrefs.node("bufrD"));
c = bufrTableDPanel;
break;
case "BufrReports": {
PreferencesExt prefs = (PreferencesExt) mainPrefs.node("bufrReports");
ReportPanel rp = new BufrReportPanel(prefs);
bufrReportPanel = new ReportOpPanel(prefs, rp);
c = bufrReportPanel;
break;
}
case "BUFR-CODES":
bufrCodePanel = new BufrCodePanel((PreferencesExt) mainPrefs.node("bufr-codes"));
c = bufrCodePanel;
break;
case "CdmrFeature":
cdmremotePanel = new CdmrFeatureOpPanel((PreferencesExt) mainPrefs.node("CdmrFeature"));
c = cdmremotePanel;
break;
case "CollectionSpec":
fcPanel = new CollectionSpecPanel((PreferencesExt) mainPrefs.node("collSpec"));
c = fcPanel;
break;
case "DirectoryPartition":
dirPartPanel = new DirectoryPartitionPanel((PreferencesExt) mainPrefs.node("dirPartition"));
c = dirPartPanel;
break;
case "NcStream":
ncStreamPanel = new NcStreamOpPanel((PreferencesExt) mainPrefs.node("NcStream"));
c = ncStreamPanel;
break;
case "GRIB1collection":
grib1CollectionPanel = new Grib1CollectionOpPanel((PreferencesExt) mainPrefs.node("grib1raw"));
c = grib1CollectionPanel;
break;
case "GRIB1data":
grib1DataPanel = new Grib1DataOpPanel((PreferencesExt) mainPrefs.node("grib1Data"));
c = grib1DataPanel;
break;
case "GRIB-FILES":
gribFilesPanel = new GribFilesOpPanel((PreferencesExt) mainPrefs.node("gribFiles"));
c = gribFilesPanel;
break;
case "GRIB2collection":
grib2CollectionPanel = new Grib2CollectionOpPanel((PreferencesExt) mainPrefs.node("gribNew"));
c = grib2CollectionPanel;
break;
case "GRIB2data":
grib2DataPanel = new Grib2DataOpPanel((PreferencesExt) mainPrefs.node("grib2Data"));
c = grib2DataPanel;
break;
case "BufrCdmIndex":
bufrCdmIndexPanel = new BufrCdmIndexOpPanel((PreferencesExt) mainPrefs.node("bufrCdmIdx"));
c = bufrCdmIndexPanel;
/*
* } else if (title.equals("CdmIndex")) {
* gribCdmIndexPanel = new GribCdmIndexPanel((PreferencesExt) mainPrefs.node("cdmIdx"));
* c = gribCdmIndexPanel;
*/
break;
case "CdmIndex4":
cdmIndexPanel = new CdmIndexOpPanel((PreferencesExt) mainPrefs.node("cdmIdx3"));
c = cdmIndexPanel;
break;
case "CdmIndexScan":
cdmIndexScanOp = new CdmIndexScanOp((PreferencesExt) mainPrefs.node("cdmIndexScan"), dirChooser);
c = cdmIndexScanOp;
break;
case "CdmIndexReport": {
PreferencesExt prefs = (PreferencesExt) mainPrefs.node("CdmIndexReport");
ReportPanel rp = new CdmIndexReportPanel(prefs);
cdmIndexReportPanel = new ReportOpPanel(prefs, rp);
c = cdmIndexReportPanel;
break;
}
case "GribIndex":
gribIdxPanel = new GribIndexOpPanel((PreferencesExt) mainPrefs.node("gribIdx"));
c = gribIdxPanel;
break;
case "GRIB1-REPORT": {
PreferencesExt prefs = (PreferencesExt) mainPrefs.node("grib1Report");
ReportPanel rp = new Grib1ReportPanel(prefs);
grib1ReportPanel = new ReportOpPanel(prefs, rp);
c = grib1ReportPanel;
break;
}
case "GRIB2-REPORT": {
PreferencesExt prefs = (PreferencesExt) mainPrefs.node("gribReport");
ReportPanel rp = new Grib2ReportPanel(prefs);
grib2ReportPanel = new ReportOpPanel(prefs, rp);
c = grib2ReportPanel;
break;
}
case "WMO-COMMON":
wmoCommonCodePanel = new WmoCCPanel((PreferencesExt) mainPrefs.node("wmo-common"));
c = wmoCommonCodePanel;
break;
case "WMO-CODES":
gribCodePanel = new GribCodePanel((PreferencesExt) mainPrefs.node("wmo-codes"));
c = gribCodePanel;
break;
case "WMO-TEMPLATES":
gribTemplatePanel = new GribTemplatePanel((PreferencesExt) mainPrefs.node("wmo-templates"));
c = gribTemplatePanel;
break;
case "GRIB1-TABLES":
grib1TablePanel = new Grib1TablePanel((PreferencesExt) mainPrefs.node("grib1-tables"));
c = grib1TablePanel;
break;
case "GRIB2-TABLES":
grib2TablePanel = new Grib2TablePanel((PreferencesExt) mainPrefs.node("grib2-tables"));
c = grib2TablePanel;
break;
case "GRIB-Rewrite":
gribRewritePanel = new GribRewriteOpPanel((PreferencesExt) mainPrefs.node("grib-rewrite"));
c = gribRewritePanel;
break;
case "CoordSys":
coordSysPanel = new CoordSysPanel((PreferencesExt) mainPrefs.node("CoordSys"));
c = coordSysPanel;
break;
case "FeatureScan":
ftPanel = new FeatureScanOpPanel((PreferencesExt) mainPrefs.node("ftPanel"), dirChooser);
c = ftPanel;
break;
case "GeoTiff":
geotiffPanel = new GeotiffPanel((PreferencesExt) mainPrefs.node("WCS"));
c = geotiffPanel;
break;
case "Grids":
geoGridPanel = new GeoGridPanel((PreferencesExt) mainPrefs.node("grid"));
c = geoGridPanel;
break;
case "SimpleGeometry":
simpleGeomPanel = new SimpleGeomPanel((PreferencesExt) mainPrefs.node("simpleGeom"));
c = simpleGeomPanel;
break;
case "Coverages":
coveragePanel = new CoveragePanel((PreferencesExt) mainPrefs.node("coverage2"));
c = coveragePanel;
break;
case "HDF5-Objects":
hdf5ObjectPanel = new Hdf5ObjectPanel((PreferencesExt) mainPrefs.node("hdf5"), useBuilders);
c = hdf5ObjectPanel;
break;
case "HDF5-Data":
hdf5DataPanel = new Hdf5DataPanel((PreferencesExt) mainPrefs.node("hdf5data"), useBuilders);
c = hdf5DataPanel;
break;
case "Netcdf4-JNI":
nc4viewer = new DatasetViewerPanel((PreferencesExt) mainPrefs.node("nc4viewer"), true);
c = nc4viewer;
break;
case "HDF4":
hdf4Panel = new Hdf4Panel((PreferencesExt) mainPrefs.node("hdf4"), useBuilders);
c = hdf4Panel;
break;
case "Images":
imagePanel = new ImagePanel((PreferencesExt) mainPrefs.node("images"));
c = imagePanel;
break;
case "Fmrc":
fmrcPanel = new FmrcPanel((PreferencesExt) mainPrefs.node("fmrc2"));
c = fmrcPanel;
break;
case "NCDump":
ncdumpPanel = new NCdumpPanel((PreferencesExt) mainPrefs.node("NCDump"));
c = ncdumpPanel;
break;
case "NcmlEditor":
ncmlEditorPanel = new NcmlEditorPanel((PreferencesExt) mainPrefs.node("NcmlEditor"));
c = ncmlEditorPanel;
break;
case "PointFeature":
pointFeaturePanel = new PointFeaturePanel((PreferencesExt) mainPrefs.node("pointFeature"));
c = pointFeaturePanel;
break;
case "Radial":
radialPanel = new RadialPanel((PreferencesExt) mainPrefs.node("radial"));
c = radialPanel;
break;
case "StationRadial":
stationRadialPanel = new StationRadialPanel((PreferencesExt) mainPrefs.node("stationRadar"));
c = stationRadialPanel;
break;
case "THREDDS":
threddsUI = new ThreddsUI(parentFrame, (PreferencesExt) mainPrefs.node("thredds"));
threddsUI.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
if (e.getPropertyName().equals("InvAccess")) {
thredds.client.catalog.Access access = (thredds.client.catalog.Access) e.getNewValue();
jumptoThreddsDatatype(access);
}
if (e.getPropertyName().equals("Dataset") || e.getPropertyName().equals("CoordSys")
|| e.getPropertyName().equals("File")) {
thredds.client.catalog.Dataset ds = (thredds.client.catalog.Dataset) e.getNewValue();
setThreddsDatatype(ds, e.getPropertyName());
}
}
});
c = threddsUI;
break;
case "Units":
unitsPanel = new UnitsPanel((PreferencesExt) mainPrefs.node("units"));
c = unitsPanel;
break;
case "URLdump":
urlPanel = new URLDumpPane((PreferencesExt) mainPrefs.node("urlDump"));
c = urlPanel;
break;
case "Viewer":
c = viewerPanel;
break;
case "Writer":
writerPanel = new DatasetWriterPanel((PreferencesExt) mainPrefs.node("writer"));
c = writerPanel;
break;
case "WMS":
wmsPanel = new WmsPanel((PreferencesExt) mainPrefs.node("wms"));
c = wmsPanel;
break;
default:
log.warn("tabbedPane unknown component {}", title);
return;
}
parent.setComponentAt(idx, c);
log.trace("tabbedPane changed {} added ", title);
}
private JMenuBar makeMenuBar() {
JMenuBar mb = new JMenuBar();
/// System menu
JMenu sysMenu = new SystemMenu(this);
mb.add(sysMenu);
// Add modes Menu
JMenu modeMenu = new ModesMenu(this);
mb.add(modeMenu);
// Add debug Menu
JMenu debugMenu = new DebugMenu(this);
mb.add(debugMenu);
// Add help/about Menu
JMenu helpMenu = new HelpMenu(this);
mb.add(helpMenu);
return mb;
}
public DatasetViewerPanel getDatasetViewerPanel() {
return viewerPanel;
}
public void setDebugFlags() {
log.debug("setDebugFlags");
NetcdfFile.setDebugFlags(debugFlags);
H5iosp.setDebugFlags(debugFlags);
NcmlReader.setDebugFlags(debugFlags);
DODSNetcdfFile.setDebugFlags(debugFlags);
CdmRemote.setDebugFlags(debugFlags);
Nc4Iosp.setDebugFlags(debugFlags);
DataFactory.setDebugFlags(debugFlags);
NetcdfCopier.setDebugFlags(debugFlags);
ucar.nc2.ft.point.standard.PointDatasetStandardFactory.setDebugFlags(debugFlags);
ucar.nc2.grib.collection.Grib.setDebugFlags(debugFlags);
}
public void setUseRecordStructure(boolean use) {
useRecordStructure = use;
}
public void setUseBuilders(boolean use) {
useBuilders = use;
}
public boolean getUseBuilders() {
return useBuilders;
}
public void setGribDiskCache() {
if (diskCache2Form == null) {
diskCache2Form = new DiskCache2Form(parentFrame, GribIndexCache.getDiskCache2());
}
diskCache2Form.setVisible(true);
}
private void save() {
fileChooser.save();
if (aggPanel != null) {
aggPanel.save();
}
if (bufrFileChooser != null) {
bufrFileChooser.save();
}
if (bufrPanel != null) {
bufrPanel.save();
}
if (bufrTableBPanel != null) {
bufrTableBPanel.save();
}
if (bufrTableDPanel != null) {
bufrTableDPanel.save();
}
if (bufrReportPanel != null) {
bufrReportPanel.save();
}
if (bufrCodePanel != null) {
bufrCodePanel.save();
}
if (coordSysPanel != null) {
coordSysPanel.save();
}
if (coveragePanel != null) {
coveragePanel.save();
}
if (cdmIndexPanel != null) {
cdmIndexPanel.save();
}
if (cdmIndexScanOp != null) {
cdmIndexScanOp.save();
}
if (cdmIndexReportPanel != null) {
cdmIndexReportPanel.save();
}
if (cdmremotePanel != null) {
cdmremotePanel.save();
}
if (dirPartPanel != null) {
dirPartPanel.save();
}
if (bufrCdmIndexPanel != null) {
bufrCdmIndexPanel.save();
}
if (fcPanel != null) {
fcPanel.save();
}
if (ftPanel != null) {
ftPanel.save();
}
if (fmrcPanel != null) {
fmrcPanel.save();
}
if (geotiffPanel != null) {
geotiffPanel.save();
}
if (gribFilesPanel != null) {
gribFilesPanel.save();
}
if (grib2CollectionPanel != null) {
grib2CollectionPanel.save();
}
if (grib2DataPanel != null) {
grib2DataPanel.save();
}
if (grib1DataPanel != null) {
grib1DataPanel.save();
}
if (gribCodePanel != null) {
gribCodePanel.save();
}
if (gribIdxPanel != null) {
gribIdxPanel.save();
}
if (gribTemplatePanel != null) {
gribTemplatePanel.save();
}
if (grib1CollectionPanel != null) {
grib1CollectionPanel.save();
}
if (grib1ReportPanel != null) {
grib1ReportPanel.save();
}
if (grib2ReportPanel != null) {
grib2ReportPanel.save();
}
if (grib1TablePanel != null) {
grib1TablePanel.save();
}
if (grib2TablePanel != null) {
grib2TablePanel.save();
}
if (gribRewritePanel != null) {
gribRewritePanel.save();
}
if (geoGridPanel != null) {
geoGridPanel.save();
}
if (hdf5ObjectPanel != null) {
hdf5ObjectPanel.save();
}
if (hdf5DataPanel != null) {
hdf5DataPanel.save();
}
if (hdf4Panel != null) {
hdf4Panel.save();
}
if (imagePanel != null) {
imagePanel.save();
}
if (ncdumpPanel != null) {
ncdumpPanel.save();
}
if (ncStreamPanel != null) {
ncStreamPanel.save();
}
if (nc4viewer != null) {
nc4viewer.save();
}
if (ncmlEditorPanel != null) {
ncmlEditorPanel.save();
}
if (pointFeaturePanel != null) {
pointFeaturePanel.save();
}
// if (pointObsPanel != null) pointObsPanel.save();
if (radialPanel != null) {
radialPanel.save();
}
// if (stationObsPanel != null) stationObsPanel.save();
if (stationRadialPanel != null) {
stationRadialPanel.save();
}
// if (trajTablePanel != null) trajTablePanel.save();
if (threddsUI != null) {
threddsUI.storePersistentData();
}
if (unitsPanel != null) {
unitsPanel.save();
}
if (urlPanel != null) {
urlPanel.save();
}
if (viewerPanel != null) {
viewerPanel.save();
}
if (writerPanel != null) {
writerPanel.save();
}
if (wmoCommonCodePanel != null) {
wmoCommonCodePanel.save();
}
if (wmsPanel != null) {
wmsPanel.save();
}
}
///
/// The following are hooks and shortcuts allowing OpPanel classes to interact with the UI.
///
public static ToolsUI getToolsUI() {
return ui;
}
public static JFrame getToolsFrame() {
return ui.getFramePriv();
}
private JFrame getFramePriv() {
return parentFrame;
}
public static DataFactory getThreddsDataFactory() {
return ui.getThreddsDataFactoryPriv();
}
private DataFactory getThreddsDataFactoryPriv() {
return threddsDataFactory;
}
public static FileManager getBufrFileChooser() {
return ui.getBufrFileChooserPriv();
}
private FileManager getBufrFileChooserPriv() {
if (bufrFileChooser == null) {
bufrFileChooser = new FileManager(parentFrame, null, null, (PreferencesExt) mainPrefs.node("bufrFileManager"));
}
return bufrFileChooser;
}
public static void setNCdumpPanel(NetcdfFile ds) {
ui.setNCdumpPanelPriv(ds);
}
private void setNCdumpPanelPriv(NetcdfFile ds) {
if (ncdumpPanel == null) {
log.debug("make ncdumpPanel");
makeComponent(tabbedPane, "NCDump");
}
ncdumpPanel.setNetcdfFile(ds);
tabbedPane.setSelectedComponent(ncdumpPanel);
}
public static Object getPrefsBean(String key, Object defaultVal) {
return ui.getPrefsBeanPriv(key, defaultVal);
}
private Object getPrefsBeanPriv(String key, Object defaultVal) {
return mainPrefs.getBean(key, defaultVal);
}
public static void putPrefsBeanObject(String key, Object newVal) {
ui.putPrefsBeanObjectPriv(key, newVal);
}
private void putPrefsBeanObjectPriv(String key, Object newVal) {
mainPrefs.putBean(key, newVal);
}
public void openNetcdfFile(String datasetName) {
makeComponent(tabbedPane, "Viewer");
viewerPanel.doit(datasetName);
tabbedPane.setSelectedComponent(viewerPanel);
}
public void openNetcdfFile(NetcdfFile ncfile) {
makeComponent(tabbedPane, "Viewer");
viewerPanel.setDataset(ncfile);
tabbedPane.setSelectedComponent(viewerPanel);
}
public void openCoordSystems(String datasetName) {
makeComponent(tabbedPane, "CoordSys");
coordSysPanel.doit(datasetName);
tabbedPane.setSelectedComponent(coordSysPanel);
}
public void openCoordSystems(NetcdfDataset dataset) {
makeComponent(tabbedPane, "CoordSys");
coordSysPanel.setDataset(dataset);
tabbedPane.setSelectedComponent(coordSysPanel);
}
public void openNcML(String datasetName) {
makeComponent(ncmlTabPane, "NcmlEditor");
ncmlEditorPanel.doit(datasetName);
tabbedPane.setSelectedComponent(ncmlTabPane);
ncmlTabPane.setSelectedComponent(ncmlEditorPanel);
}
public void openPointFeatureDataset(String datasetName) {
makeComponent(ftTabPane, "PointFeature");
pointFeaturePanel.setPointFeatureDataset(FeatureType.ANY_POINT, datasetName);
tabbedPane.setSelectedComponent(ftTabPane);
ftTabPane.setSelectedComponent(pointFeaturePanel);
}
public void openGrib1Collection(String collection) {
makeComponent(grib1TabPane, "GRIB1collection"); // LOOK - does this aleays make component ?
grib1CollectionPanel.setCollection(collection);
tabbedPane.setSelectedComponent(iospTabPane);
iospTabPane.setSelectedComponent(grib1TabPane);
grib1TabPane.setSelectedComponent(grib1CollectionPanel);
}
public void openGrib2Collection(String collection) {
makeComponent(grib2TabPane, "GRIB2collection");
grib2CollectionPanel.setCollection(collection);
tabbedPane.setSelectedComponent(iospTabPane);