public DatasetViewer(PreferencesExt prefs, FileManager fileChooser) { this.prefs = prefs; this.fileChooser = fileChooser; // create the variable table(s) tablePanel = new JPanel(new BorderLayout()); setNestedTable(0, null); // the tree view datasetTree = new DatasetTreeView(); datasetTree.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { setSelected((Variable) e.getNewValue()); } }); // layout mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, datasetTree, tablePanel); mainSplit.setDividerLocation(prefs.getInt("mainSplit", 100)); setLayout(new BorderLayout()); add(mainSplit, BorderLayout.CENTER); // the info window infoTA = new TextHistoryPane(); infoWindow = new IndependentWindow("Variable Information", BAMutil.getImage("netcdfUI"), infoTA); infoWindow.setBounds( (Rectangle) prefs.getBean("InfoWindowBounds", new Rectangle(300, 300, 500, 300))); // the data Table dataTable = new StructureTable((PreferencesExt) prefs.node("structTable")); dataWindow = new IndependentWindow("Data Table", BAMutil.getImage("netcdfUI"), dataTable); dataWindow.setBounds( (Rectangle) prefs.getBean("dataWindow", new Rectangle(50, 300, 1000, 600))); // the ncdump Pane dumpPane = new NCdumpPane((PreferencesExt) prefs.node("dumpPane")); dumpWindow = new IndependentWindow("NCDump Variable Data", BAMutil.getImage("netcdfUI"), dumpPane); dumpWindow.setBounds( (Rectangle) prefs.getBean("DumpWindowBounds", new Rectangle(300, 300, 300, 200))); }
NestedTable(int level) { this.level = level; myPrefs = (PreferencesExt) prefs.node("NestedTable" + level); table = new BeanTableSorted(VariableBean.class, myPrefs, false); JTable jtable = table.getJTable(); PopupMenu csPopup = new PopupMenu(jtable, "Options"); csPopup.addAction( "Show Declaration", new AbstractAction() { public void actionPerformed(ActionEvent e) { showDeclaration(table, false); } }); csPopup.addAction( "Show NcML", new AbstractAction() { public void actionPerformed(ActionEvent e) { showDeclaration(table, true); } }); csPopup.addAction( "NCdump Data", "Dump", new AbstractAction() { public void actionPerformed(ActionEvent e) { dumpData(table); } }); if (level == 0) { csPopup.addAction( "Data Table", new AbstractAction() { public void actionPerformed(ActionEvent e) { dataTable(table); } }); } // get selected variable, see if its a structure table.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { Variable v = getCurrentVariable(table); if ((v != null) && (v instanceof Structure)) { hideNestedTable(NestedTable.this.level + 2); setNestedTable(NestedTable.this.level + 1, (Structure) v); } else { hideNestedTable(NestedTable.this.level + 1); } if (eventsOK) datasetTree.setSelected(v); } }); // layout if (currentComponent == null) { currentComponent = table; tablePanel.add(currentComponent, BorderLayout.CENTER); isShowing = true; } else { split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, currentComponent, table); splitPos = myPrefs.getInt("splitPos" + level, 500); if (splitPos > 0) split.setDividerLocation(splitPos); show(); } }