コード例 #1
0
ファイル: DatasetViewer.java プロジェクト: mazl123321/thredds
    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();
      }
    }