private void refreshPathwayListForCurrentNetwork() {
    Set<String> selectedPathwaySet = new HashSet<String>();
    for (int i : currentTable.getSelectedRows())
      selectedPathwaySet.add(currentTable.getValueAt(i, 0).toString());
    currentModel.setRowCount(0);

    SortedSet<String> pathwaySet;
    CyNetwork network = Cytoscape.getCurrentNetwork();
    NetworkData networkData =
        MetScapePlugin.getPluginData().getNetworkData(Networks.getUUID(network));
    NetworkType networkType = null;
    if (networkData != null) networkType = networkData.getNetworkType();

    if (networkType == NetworkType.COMPOUND_REACTION
        || networkType == NetworkType.CREG) { // for C-R and C-R-E-G
      pathwaySet = getPathwaySetFromReactionNodes(network);
    } else if (networkType == NetworkType.COMPOUND) {
      pathwaySet = getPathwaySetFromReactionEdges(network);
    } else if (networkType == NetworkType.COMPOUND_GENE) {
      pathwaySet = getPathwaySetFromEnzymeReactionEdges(network);
    } else {
      pathwaySet = new TreeSet<String>();
    }
    for (String pathway : pathwaySet) {
      currentModel.addRow(new Object[] {pathway});
      if (selectedPathwaySet.contains(pathway))
        currentTable.addRowSelectionInterval(
            currentTable.getRowCount() - 1, currentTable.getRowCount() - 1);
    }
    applySelectionToNetwork();
  }
  private void createControls() {
    buttonPanel = new JPanel();

    selectAll = new JButton("Select All Pathways");
    selectAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selectAll();
          }
        });
    buttonPanel.add(selectAll);

    deselectAll = new JButton("Deselect All Pathways");
    deselectAll.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deselectAll();
          }
        });
    buttonPanel.add(deselectAll);

    createSubnetwork = new JButton("Create Subnetwork");
    createSubnetwork.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            buildSubnetwork();
          }
        });
    buttonPanel.add(createSubnetwork);

    reapplySelection = new JButton("Reapply Selection");
    reapplySelection.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applySelectionToNetwork();
          }
        });
    buttonPanel.add(reapplySelection);

    close = new JButton("Close");
    close.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            close();
          }
        });
    buttonPanel.add(close);

    add(buttonPanel, BorderLayout.NORTH);
    tables = new HashMap<CyNetwork, ExtendedJTable>();
    currentTable = new ExtendedJTable();
    tables.put(Cytoscape.getCurrentNetwork(), currentTable);
    currentTable.getSelectionModel().addListSelectionListener(this);
    currentModel = (ExtendedTableModel) currentTable.getModel();
    currentModel.addColumn("Pathways");
    currentTable.getRowSorter().toggleSortOrder(0);
    scrollPane = new JScrollPane(currentTable);
    refreshPathwayListForCurrentNetwork();

    add(scrollPane, BorderLayout.CENTER);
    addComponentListener(this);
  }