public void showAtts() { if (ds == null) return; if (attTable == null) { // global attributes attTable = new BeanTableSorted( AttributeBean.class, (PreferencesExt) prefs.node("AttributeBeans"), false); PopupMenu varPopup = new ucar.nc2.ui.widget.PopupMenu(attTable.getJTable(), "Options"); varPopup.addAction( "Show Attribute", new AbstractAction() { public void actionPerformed(ActionEvent e) { AttributeBean bean = (AttributeBean) attTable.getSelectedBean(); if (bean != null) { infoTA.setText(bean.att.toString()); infoTA.gotoTop(); infoWindow.show(); } } }); attWindow = new IndependentWindow("Global Attributes", BAMutil.getImage("netcdfUI"), attTable); attWindow.setBounds( (Rectangle) prefs.getBean("AttWindowBounds", new Rectangle(300, 100, 500, 800))); } List<AttributeBean> attlist = new ArrayList<AttributeBean>(); for (Attribute att : ds.getGlobalAttributes()) { attlist.add(new AttributeBean(att)); } attTable.setBeans(attlist); attWindow.show(); }
public void save() { dumpPane.save(); for (NestedTable nt : nestedTableList) { nt.saveState(); } prefs.putBeanObject("InfoWindowBounds", infoWindow.getBounds()); prefs.putBeanObject("DumpWindowBounds", dumpWindow.getBounds()); if (attWindow != null) prefs.putBeanObject("AttWindowBounds", attWindow.getBounds()); prefs.putInt("mainSplit", mainSplit.getDividerLocation()); }
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))); }
void saveState() { table.saveState(false); if (split != null) myPrefs.putInt("splitPos" + level, split.getDividerLocation()); }
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(); } }