コード例 #1
0
 public void actionPerformed(ActionEvent e) {
   progressBar.progress.setValue(LocalConfig.getInstance().getProgress());
   progressBar.progress.repaint();
   if (LocalConfig.getInstance().getProgress() == 100) {
     progressBar.setVisible(false);
     progressBar.dispose();
   }
 }
コード例 #2
0
 @Override
 protected Void doInBackground() throws Exception {
   int progress = 0;
   TextReactionsModelReader reader = new TextReactionsModelReader();
   reader.load(
       GraphicalInterface.getReactionsCSVFile(), LocalConfig.getInstance().getDatabaseName());
   while (progress < 100) {
     try {
       Thread.sleep(1000);
     } catch (InterruptedException ignore) {
     }
   }
   t.stop();
   return null;
 }
コード例 #3
0
  public void write(String file, String databaseName) {
    String queryString = "jdbc:sqlite:" + databaseName + ".db";
    try {
      Class.forName("org.sqlite.JDBC");
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    try {
      Connection conn = DriverManager.getConnection(queryString);
      // String extension = ".csv";
      CSVWriter writer;
      try {
        writer = new CSVWriter(new FileWriter(file), GraphicalInterface.getSplitCharacter());

        String headerNames = "";
        // start with 1 to avoid reading database id
        for (int i = 1; i < GraphicalInterfaceConstants.REACTIONS_COLUMN_NAMES.length; i++) {
          headerNames += GraphicalInterfaceConstants.REACTIONS_COLUMN_NAMES[i] + "#";
        }

        ReactionsMetaColumnManager reactionsMetaColumnManager = new ReactionsMetaColumnManager();

        int metaColumnCount =
            reactionsMetaColumnManager.getMetaColumnCount(
                LocalConfig.getInstance().getDatabaseName());
        for (int j = 1; j < metaColumnCount + 1; j++) {
          headerNames +=
              reactionsMetaColumnManager.getColumnName(
                      LocalConfig.getInstance().getDatabaseName(), j)
                  + "#";
        }

        String[] header = (headerNames.substring(0, headerNames.length() - 1)).split("#");

        writer.writeNext(header);
        int numReactions = GraphicalInterface.reactionsTable.getModel().getRowCount();
        for (int n = 0; n < numReactions; n++) {
          int viewRow = GraphicalInterface.reactionsTable.convertRowIndexToModel(n);

          String knockout = "false";
          String fluxValue = "0.0";
          String reactionAbbreviation = " ";
          String reactionName = " ";
          String reactionString = " ";
          String reversible = " ";
          String lowerBound = "-999999";
          String upperBound = "999999";
          String objective = "0.0";
          String meta1 = " ";
          String meta2 = " ";
          String meta3 = " ";
          String meta4 = " ";
          String meta5 = " ";
          String meta6 = " ";
          String meta7 = " ";
          String meta8 = " ";
          String meta9 = " ";
          String meta10 = " ";
          String meta11 = " ";
          String meta12 = " ";
          String meta13 = " ";
          String meta14 = " ";
          String meta15 = " ";

          // check if null before toString() to avoid null pointer error
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.KO_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.KO_COLUMN)
                    .toString()
                    .length()
                > 0) {
              knockout =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(viewRow, GraphicalInterfaceConstants.KO_COLUMN);
            } else {
              knockout = "false";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.FLUX_VALUE_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.FLUX_VALUE_COLUMN)
                    .toString()
                    .length()
                > 0) {
              fluxValue =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(viewRow, GraphicalInterfaceConstants.FLUX_VALUE_COLUMN);
            } else {
              fluxValue = "0.0";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_ABBREVIATION_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_ABBREVIATION_COLUMN)
                    .toString()
                    .length()
                > 0) {
              reactionAbbreviation =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(
                              viewRow, GraphicalInterfaceConstants.REACTION_ABBREVIATION_COLUMN);
            } else {
              reactionAbbreviation = " ";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_NAME_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_NAME_COLUMN)
                    .toString()
                    .length()
                > 0) {
              reactionName =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_NAME_COLUMN);
            } else {
              reactionName = " ";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_STRING_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_STRING_COLUMN)
                    .toString()
                    .length()
                > 0) {
              reactionString =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_STRING_COLUMN);
            } else {
              reactionString = " ";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.REVERSIBLE_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REVERSIBLE_COLUMN)
                    .toString()
                    .length()
                > 0) {
              reversible =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(viewRow, GraphicalInterfaceConstants.REVERSIBLE_COLUMN);
            } else {
              reversible = " ";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.LOWER_BOUND_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.LOWER_BOUND_COLUMN)
                    .toString()
                    .length()
                > 0) {
              lowerBound =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(viewRow, GraphicalInterfaceConstants.LOWER_BOUND_COLUMN);
            } else {
              lowerBound = "-999999";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.UPPER_BOUND_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.UPPER_BOUND_COLUMN)
                    .toString()
                    .length()
                > 0) {
              upperBound =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(viewRow, GraphicalInterfaceConstants.UPPER_BOUND_COLUMN);
            } else {
              upperBound = "999999";
            }
          }
          if (GraphicalInterface.reactionsTable
                  .getModel()
                  .getValueAt(viewRow, GraphicalInterfaceConstants.BIOLOGICAL_OBJECTIVE_COLUMN)
              != null) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.BIOLOGICAL_OBJECTIVE_COLUMN)
                    .toString()
                    .length()
                > 0) {
              objective =
                  (String)
                      GraphicalInterface.reactionsTable
                          .getModel()
                          .getValueAt(
                              viewRow, GraphicalInterfaceConstants.BIOLOGICAL_OBJECTIVE_COLUMN);
            } else {
              objective = "0.0";
            }
          }

          String metaString = "";
          if (metaColumnCount > 0) {
            // check if null before toString() to avoid null pointer error
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META1_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META1_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta1 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META1_COLUMN);
              }
            }
            metaString += meta1 + "#";
          }
          if (metaColumnCount > 1) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META2_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META2_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta2 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META2_COLUMN);
              }
            }
            metaString += meta2 + "#";
          }
          if (metaColumnCount > 2) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META3_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META3_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta3 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META3_COLUMN);
              }
            }
            metaString += meta3 + "#";
          }
          if (metaColumnCount > 3) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META4_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META4_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta4 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META4_COLUMN);
              }
            }
            metaString += meta4 + "#";
          }
          if (metaColumnCount > 4) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META5_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META5_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta5 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META5_COLUMN);
              }
            }
            metaString += meta5 + "#";
          }
          if (metaColumnCount > 5) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META6_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META6_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta6 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META6_COLUMN);
              }
            }
            metaString += meta6 + "#";
          }
          if (metaColumnCount > 6) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META7_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META7_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta7 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META7_COLUMN);
              }
            }
            metaString += meta7 + "#";
          }
          if (metaColumnCount > 7) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META8_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META8_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta8 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META8_COLUMN);
              }
            }
            metaString += meta8 + "#";
          }
          if (metaColumnCount > 8) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META9_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META9_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta9 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META9_COLUMN);
              }
            }
            metaString += meta9 + "#";
          }
          if (metaColumnCount > 9) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META10_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META10_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta10 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(
                                viewRow, GraphicalInterfaceConstants.REACTION_META10_COLUMN);
              }
            }
            metaString += meta10 + "#";
          }
          if (metaColumnCount > 10) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META11_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META11_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta11 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(
                                viewRow, GraphicalInterfaceConstants.REACTION_META11_COLUMN);
              }
            }
            metaString += meta11 + "#";
          }
          if (metaColumnCount > 11) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META12_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META12_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta12 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(
                                viewRow, GraphicalInterfaceConstants.REACTION_META12_COLUMN);
              }
            }
            metaString += meta12 + "#";
          }
          if (metaColumnCount > 12) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META13_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META13_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta13 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(
                                viewRow, GraphicalInterfaceConstants.REACTION_META13_COLUMN);
              }
            }
            metaString += meta13 + "#";
          }
          if (metaColumnCount > 13) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META14_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META14_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta14 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(
                                viewRow, GraphicalInterfaceConstants.REACTION_META14_COLUMN);
              }
            }
            metaString += meta14 + "#";
          }
          if (metaColumnCount > 14) {
            if (GraphicalInterface.reactionsTable
                    .getModel()
                    .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META15_COLUMN)
                != null) {
              if (GraphicalInterface.reactionsTable
                      .getModel()
                      .getValueAt(viewRow, GraphicalInterfaceConstants.REACTION_META15_COLUMN)
                      .toString()
                      .length()
                  > 0) {
                meta15 =
                    (String)
                        GraphicalInterface.reactionsTable
                            .getModel()
                            .getValueAt(
                                viewRow, GraphicalInterfaceConstants.REACTION_META15_COLUMN);
              }
            }
            metaString += meta15 + "#";
          }

          if (metaString.length() > 0) {
            String[] entries =
                (knockout
                        + "#"
                        + fluxValue
                        + "#"
                        + reactionAbbreviation
                        + "#"
                        + reactionName
                        + "#"
                        + reactionString
                        + "#"
                        + reversible
                        + "#"
                        + lowerBound
                        + "#"
                        + upperBound
                        + "#"
                        + objective
                        + "#"
                        + metaString.substring(0, metaString.length() - 1))
                    .split("#");
            writer.writeNext(entries);
          } else {
            String[] entries =
                (knockout
                        + "#"
                        + fluxValue
                        + "#"
                        + reactionAbbreviation
                        + "#"
                        + reactionName
                        + "#"
                        + reactionString
                        + "#"
                        + reversible
                        + "#"
                        + lowerBound
                        + "#"
                        + upperBound
                        + "#"
                        + objective)
                    .split("#");
            writer.writeNext(entries);
          }
        }
        writer.close();
        conn.close();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #4
0
  public ReactionColumnNameInterface(final Connection con, ArrayList<String> columnNamesFromFile)
      throws SQLException {

    final ArrayList<Image> icons = new ArrayList<Image>();
    icons.add(new ImageIcon("etc/most16.jpg").getImage());
    icons.add(new ImageIcon("etc/most32.jpg").getImage());

    LocalConfig.getInstance().setProgress(0);
    progressBar.pack();
    progressBar.setIconImages(icons);
    progressBar.setSize(200, 70);
    progressBar.setTitle("Loading...");
    progressBar.setVisible(false);

    setColumnNamesFromFile(columnNamesFromFile);

    setTitle(ColumnInterfaceConstants.REACTIONS_COLUMN_NAME_INTERFACE_TITLE);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    cbKnockout.setEditable(true);
    cbFluxValue.setEditable(true);
    cbReactionAbbreviation.setEditable(true);
    cbReactionName.setEditable(true);
    cbReactionEquation.setEditable(true);
    cbReversible.setEditable(true);
    cbLowerBound.setEditable(true);
    cbUpperBound.setEditable(true);
    cbObjective.setEditable(true);

    cbKnockout.setPreferredSize(new Dimension(250, 30));
    cbKnockout.setMaximumSize(new Dimension(250, 30));
    cbKnockout.setMinimumSize(new Dimension(250, 30));

    cbFluxValue.setPreferredSize(new Dimension(250, 30));
    cbFluxValue.setMaximumSize(new Dimension(250, 30));
    cbFluxValue.setMinimumSize(new Dimension(250, 30));

    cbReactionAbbreviation.setPreferredSize(new Dimension(250, 30));
    cbReactionAbbreviation.setMaximumSize(new Dimension(250, 30));
    cbReactionAbbreviation.setMinimumSize(new Dimension(250, 30));

    cbReactionName.setPreferredSize(new Dimension(250, 30));
    cbReactionName.setMaximumSize(new Dimension(250, 30));
    cbReactionName.setMinimumSize(new Dimension(250, 30));

    cbReactionEquation.setPreferredSize(new Dimension(250, 30));
    cbReactionEquation.setMaximumSize(new Dimension(250, 30));
    cbReactionEquation.setMinimumSize(new Dimension(250, 30));

    cbReversible.setPreferredSize(new Dimension(250, 30));
    cbReversible.setMaximumSize(new Dimension(250, 30));
    cbReversible.setMinimumSize(new Dimension(250, 30));

    cbLowerBound.setPreferredSize(new Dimension(250, 30));
    cbLowerBound.setMaximumSize(new Dimension(250, 30));
    cbLowerBound.setMinimumSize(new Dimension(250, 30));

    cbUpperBound.setPreferredSize(new Dimension(250, 30));
    cbUpperBound.setMaximumSize(new Dimension(250, 30));
    cbUpperBound.setMinimumSize(new Dimension(250, 30));

    cbObjective.setPreferredSize(new Dimension(250, 30));
    cbObjective.setMaximumSize(new Dimension(250, 30));
    cbObjective.setMinimumSize(new Dimension(250, 30));

    JTextField fieldKnockout = (JTextField) cbKnockout.getEditor().getEditorComponent();
    fieldKnockout.addKeyListener(new ComboKeyHandler(cbKnockout));

    JTextField fieldFluxValue = (JTextField) cbFluxValue.getEditor().getEditorComponent();
    fieldFluxValue.addKeyListener(new ComboKeyHandler(cbFluxValue));

    JTextField fieldReactionAbbreviation =
        (JTextField) cbReactionAbbreviation.getEditor().getEditorComponent();
    fieldReactionAbbreviation.addKeyListener(new ComboKeyHandler(cbReactionAbbreviation));

    JTextField fieldReactionName = (JTextField) cbReactionName.getEditor().getEditorComponent();
    fieldReactionName.addKeyListener(new ComboKeyHandler(cbReactionName));

    JTextField fieldReactionEquation =
        (JTextField) cbReactionEquation.getEditor().getEditorComponent();
    fieldReactionEquation.addKeyListener(new ComboKeyHandler(cbReactionEquation));

    JTextField fieldReversible = (JTextField) cbReversible.getEditor().getEditorComponent();
    fieldReversible.addKeyListener(new ComboKeyHandler(cbReversible));

    JTextField fieldLowerBound = (JTextField) cbLowerBound.getEditor().getEditorComponent();
    fieldLowerBound.addKeyListener(new ComboKeyHandler(cbLowerBound));

    JTextField fieldUpperBound = (JTextField) cbUpperBound.getEditor().getEditorComponent();
    fieldUpperBound.addKeyListener(new ComboKeyHandler(cbUpperBound));

    JTextField fieldObjective = (JTextField) cbObjective.getEditor().getEditorComponent();
    fieldObjective.addKeyListener(new ComboKeyHandler(cbObjective));

    populateNamesFromFileBoxes(columnNamesFromFile);

    // box layout
    Box vb = Box.createVerticalBox();

    Box hbLabels = Box.createHorizontalBox();
    Box hb1 = Box.createHorizontalBox();
    Box hb2 = Box.createHorizontalBox();
    Box hb3 = Box.createHorizontalBox();
    Box hb4 = Box.createHorizontalBox();
    Box hb5 = Box.createHorizontalBox();
    Box hb6 = Box.createHorizontalBox();
    Box hb7 = Box.createHorizontalBox();
    Box hb8 = Box.createHorizontalBox();
    Box hb9 = Box.createHorizontalBox();
    Box hbTop = Box.createHorizontalBox();
    Box hbKnockoutLabel = Box.createHorizontalBox();
    Box hbKnockout = Box.createHorizontalBox();
    Box hbFluxValueLabel = Box.createHorizontalBox();
    Box hbFluxValue = Box.createHorizontalBox();
    Box hbReactionAbbreviationLabel = Box.createHorizontalBox();
    Box hbReactionAbbreviation = Box.createHorizontalBox();
    Box hbReactionNameLabel = Box.createHorizontalBox();
    Box hbReactionName = Box.createHorizontalBox();
    Box hbReactionEquationLabel = Box.createHorizontalBox();
    Box hbReactionEquation = Box.createHorizontalBox();
    Box hbReversibleLabel = Box.createHorizontalBox();
    Box hbReversible = Box.createHorizontalBox();
    Box hbLowerBoundLabel = Box.createHorizontalBox();
    Box hbLowerBound = Box.createHorizontalBox();
    Box hbUpperBoundLabel = Box.createHorizontalBox();
    Box hbUpperBound = Box.createHorizontalBox();
    Box hbObjectiveLabel = Box.createHorizontalBox();
    Box hbObjective = Box.createHorizontalBox();

    Box hbButton = Box.createHorizontalBox();

    // top label
    JLabel topLabel = new JLabel();
    topLabel.setText(ColumnInterfaceConstants.REACTIONS_TOP_LABEL);
    topLabel.setSize(new Dimension(300, 30));
    // top, left, bottom. right
    topLabel.setBorder(BorderFactory.createEmptyBorder(20, 30, 20, 200));
    topLabel.setAlignmentX(LEFT_ALIGNMENT);

    hbTop.add(topLabel);
    hbTop.setAlignmentX(LEFT_ALIGNMENT);

    hbLabels.add(hbTop);

    // knockout Label and combo
    JLabel knockoutLabel = new JLabel();
    knockoutLabel.setText(ColumnInterfaceConstants.KO_LABEL);
    knockoutLabel.setSize(new Dimension(300, 20));
    knockoutLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 80));
    knockoutLabel.setAlignmentX(LEFT_ALIGNMENT);
    // knockoutLabel.setAlignmentY(TOP_ALIGNMENT);

    JPanel panelKnockoutLabel = new JPanel();
    panelKnockoutLabel.setLayout(new BoxLayout(panelKnockoutLabel, BoxLayout.X_AXIS));
    panelKnockoutLabel.add(knockoutLabel);
    panelKnockoutLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbKnockoutLabel.add(panelKnockoutLabel);
    hbKnockoutLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelKnockout = new JPanel();
    panelKnockout.setLayout(new BoxLayout(panelKnockout, BoxLayout.X_AXIS));
    panelKnockout.add(cbKnockout);
    panelKnockout.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelKnockout.setAlignmentX(RIGHT_ALIGNMENT);

    hbKnockout.add(panelKnockout);
    hbKnockout.setAlignmentX(RIGHT_ALIGNMENT);

    hb1.add(hbKnockoutLabel);
    hb1.add(hbKnockout);

    // flux value label and combo
    JLabel fluxValueLabel = new JLabel();
    fluxValueLabel.setText(ColumnInterfaceConstants.FLUX_VALUE_LABEL);
    fluxValueLabel.setSize(new Dimension(300, 20));
    fluxValueLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    fluxValueLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelFluxValueLabel = new JPanel();
    panelFluxValueLabel.setLayout(new BoxLayout(panelFluxValueLabel, BoxLayout.X_AXIS));
    panelFluxValueLabel.add(fluxValueLabel);
    panelFluxValueLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbFluxValueLabel.add(panelFluxValueLabel);
    hbFluxValueLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelFluxValue = new JPanel();
    panelFluxValue.setLayout(new BoxLayout(panelFluxValue, BoxLayout.X_AXIS));
    panelFluxValue.add(cbFluxValue);
    panelFluxValue.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelFluxValue.setAlignmentX(RIGHT_ALIGNMENT);

    hbFluxValue.add(panelFluxValue);
    hbFluxValue.setAlignmentX(RIGHT_ALIGNMENT);

    hb2.add(hbFluxValueLabel);
    hb2.add(hbFluxValue);

    // reaction abbreviation label and combo
    JLabel reactionAbbreviationLabel = new JLabel();
    reactionAbbreviationLabel.setText(ColumnInterfaceConstants.REACTION_ABBREVIATION_LABEL);
    reactionAbbreviationLabel.setSize(new Dimension(300, 20));
    reactionAbbreviationLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    reactionAbbreviationLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReactionAbbreviationLabel = new JPanel();
    panelReactionAbbreviationLabel.setLayout(
        new BoxLayout(panelReactionAbbreviationLabel, BoxLayout.X_AXIS));
    panelReactionAbbreviationLabel.add(reactionAbbreviationLabel);
    panelReactionAbbreviationLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbReactionAbbreviationLabel.add(panelReactionAbbreviationLabel);
    hbReactionAbbreviationLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReactionAbbreviation = new JPanel();
    panelReactionAbbreviation.setLayout(new BoxLayout(panelReactionAbbreviation, BoxLayout.X_AXIS));
    panelReactionAbbreviation.add(cbReactionAbbreviation);
    panelReactionAbbreviation.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelReactionAbbreviation.setAlignmentX(RIGHT_ALIGNMENT);

    hbReactionAbbreviation.add(panelReactionAbbreviation);
    hbReactionAbbreviation.setAlignmentX(RIGHT_ALIGNMENT);

    hb3.add(hbReactionAbbreviationLabel);
    hb3.add(hbReactionAbbreviation);

    // reaction name label and combo
    JLabel reactionNameLabel = new JLabel();
    reactionNameLabel.setText(ColumnInterfaceConstants.REACTION_NAME_LABEL);
    reactionNameLabel.setSize(new Dimension(300, 20));
    reactionNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    reactionNameLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReactionNameLabel = new JPanel();
    panelReactionNameLabel.setLayout(new BoxLayout(panelReactionNameLabel, BoxLayout.X_AXIS));
    panelReactionNameLabel.add(reactionNameLabel);
    panelReactionNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbReactionNameLabel.add(panelReactionNameLabel);
    hbReactionNameLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReactionName = new JPanel();
    panelReactionName.setLayout(new BoxLayout(panelReactionName, BoxLayout.X_AXIS));
    panelReactionName.add(cbReactionName);
    panelReactionName.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelReactionName.setAlignmentX(RIGHT_ALIGNMENT);

    hbReactionName.add(panelReactionName);
    hbReactionName.setAlignmentX(RIGHT_ALIGNMENT);

    hb4.add(hbReactionNameLabel);
    hb4.add(hbReactionName);

    // reaction equation label and combo
    JLabel reactionEquationLabel = new JLabel();
    reactionEquationLabel.setText(ColumnInterfaceConstants.REACTION_EQUATION_LABEL);
    reactionEquationLabel.setSize(new Dimension(300, 20));
    reactionEquationLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    reactionEquationLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReactionEquationLabel = new JPanel();
    panelReactionEquationLabel.setLayout(
        new BoxLayout(panelReactionEquationLabel, BoxLayout.X_AXIS));
    panelReactionEquationLabel.add(reactionEquationLabel);
    panelReactionEquationLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbReactionEquationLabel.add(panelReactionEquationLabel);
    hbReactionEquationLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReactionEquation = new JPanel();
    panelReactionEquation.setLayout(new BoxLayout(panelReactionEquation, BoxLayout.X_AXIS));
    panelReactionEquation.add(cbReactionEquation);
    panelReactionEquation.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelReactionEquation.setAlignmentX(RIGHT_ALIGNMENT);

    hbReactionEquation.add(panelReactionEquation);
    hbReactionEquation.setAlignmentX(RIGHT_ALIGNMENT);

    hb5.add(hbReactionEquationLabel);
    hb5.add(hbReactionEquation);

    // reversible label and combo
    JLabel reversibleLabel = new JLabel();
    reversibleLabel.setText(ColumnInterfaceConstants.REVERSIBLE_LABEL);
    reversibleLabel.setSize(new Dimension(300, 20));
    reversibleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    reversibleLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReversibleLabel = new JPanel();
    panelReversibleLabel.setLayout(new BoxLayout(panelReversibleLabel, BoxLayout.X_AXIS));
    panelReversibleLabel.add(reversibleLabel);
    panelReversibleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbReversibleLabel.add(panelReversibleLabel);
    hbReversibleLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelReversible = new JPanel();
    panelReversible.setLayout(new BoxLayout(panelReversible, BoxLayout.X_AXIS));
    panelReversible.add(cbReversible);
    panelReversible.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelReversible.setAlignmentX(RIGHT_ALIGNMENT);

    hbReversible.add(panelReversible);
    hbReversible.setAlignmentX(RIGHT_ALIGNMENT);

    hb6.add(hbReversibleLabel);
    hb6.add(hbReversible);

    // lower bound label and combo
    JLabel lowerBoundLabel = new JLabel();
    lowerBoundLabel.setText(ColumnInterfaceConstants.LOWER_BOUND_LABEL);
    lowerBoundLabel.setSize(new Dimension(300, 20));
    lowerBoundLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    lowerBoundLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelLowerBoundLabel = new JPanel();
    panelLowerBoundLabel.setLayout(new BoxLayout(panelLowerBoundLabel, BoxLayout.X_AXIS));
    panelLowerBoundLabel.add(lowerBoundLabel);
    panelLowerBoundLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbLowerBoundLabel.add(panelLowerBoundLabel);
    hbLowerBoundLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelLowerBound = new JPanel();
    panelLowerBound.setLayout(new BoxLayout(panelLowerBound, BoxLayout.X_AXIS));
    panelLowerBound.add(cbLowerBound);
    panelLowerBound.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelLowerBound.setAlignmentX(RIGHT_ALIGNMENT);

    hbLowerBound.add(panelLowerBound);
    hbLowerBound.setAlignmentX(RIGHT_ALIGNMENT);

    hb7.add(hbLowerBoundLabel);
    hb7.add(hbLowerBound);

    // upper bound label and combo
    JLabel upperBoundLabel = new JLabel();
    upperBoundLabel.setText(ColumnInterfaceConstants.UPPER_BOUND_LABEL);
    upperBoundLabel.setSize(new Dimension(300, 20));
    upperBoundLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    upperBoundLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelUpperBoundLabel = new JPanel();
    panelUpperBoundLabel.setLayout(new BoxLayout(panelUpperBoundLabel, BoxLayout.X_AXIS));
    panelUpperBoundLabel.add(upperBoundLabel);
    panelUpperBoundLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbUpperBoundLabel.add(panelUpperBoundLabel);
    hbUpperBoundLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelUpperBound = new JPanel();
    panelUpperBound.setLayout(new BoxLayout(panelUpperBound, BoxLayout.X_AXIS));
    panelUpperBound.add(cbUpperBound);
    panelUpperBound.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelUpperBound.setAlignmentX(RIGHT_ALIGNMENT);

    hbUpperBound.add(panelUpperBound);
    hbUpperBound.setAlignmentX(RIGHT_ALIGNMENT);

    hb8.add(hbUpperBoundLabel);
    hb8.add(hbUpperBound);

    // objective label and combo
    JLabel objectiveLabel = new JLabel();
    objectiveLabel.setText(ColumnInterfaceConstants.BIOLOGICAL_OBJECTIVE_LABEL);
    objectiveLabel.setSize(new Dimension(300, 20));
    objectiveLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 80));
    objectiveLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelObjectiveLabel = new JPanel();
    panelObjectiveLabel.setLayout(new BoxLayout(panelObjectiveLabel, BoxLayout.X_AXIS));
    panelObjectiveLabel.add(objectiveLabel);
    panelObjectiveLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));

    hbObjectiveLabel.add(panelObjectiveLabel);
    hbObjectiveLabel.setAlignmentX(LEFT_ALIGNMENT);

    JPanel panelObjective = new JPanel();
    panelObjective.setLayout(new BoxLayout(panelObjective, BoxLayout.X_AXIS));
    panelObjective.add(cbObjective);
    panelObjective.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
    panelObjective.setAlignmentX(RIGHT_ALIGNMENT);

    hbObjective.add(panelObjective);
    hbObjective.setAlignmentX(RIGHT_ALIGNMENT);

    hb9.add(hbObjectiveLabel);
    hb9.add(hbObjective);

    okButton.setMnemonic(KeyEvent.VK_O);
    JLabel blank = new JLabel("    ");
    cancelButton.setMnemonic(KeyEvent.VK_C);
    JLabel blank2 = new JLabel("    ");
    nextRowButton.setMnemonic(KeyEvent.VK_N);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(okButton);
    buttonPanel.add(blank);
    buttonPanel.add(cancelButton);
    buttonPanel.add(blank2);
    buttonPanel.add(nextRowButton);
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 20, 20));

    hbButton.add(buttonPanel);

    vb.add(hbLabels);
    vb.add(hb1);
    vb.add(hb2);
    vb.add(hb3);
    vb.add(hb4);
    vb.add(hb5);
    vb.add(hb6);
    vb.add(hb7);
    vb.add(hb8);
    vb.add(hb9);
    vb.add(hbButton);

    add(vb);

    ActionListener okButtonActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent prodActionEvent) {
            // add metacolumn names to db
            ReactionsMetaColumnManager reactionsMetaColumnManager =
                new ReactionsMetaColumnManager();
            ArrayList<String> metaColumnNames = new ArrayList();
            ArrayList<Integer> usedIndices = new ArrayList();
            ArrayList<Integer> metaColumnIndexList = new ArrayList();

            if (getColumnNamesFromFile().contains(cbKnockout.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setKnockoutColumnIndex(
                      getColumnNamesFromFile().indexOf(cbKnockout.getSelectedItem()));
              usedIndices.add(getColumnNamesFromFile().indexOf(cbKnockout.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbFluxValue.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setFluxValueColumnIndex(
                      getColumnNamesFromFile().indexOf(cbFluxValue.getSelectedItem()));
              usedIndices.add(getColumnNamesFromFile().indexOf(cbFluxValue.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbReactionAbbreviation.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setReactionAbbreviationColumnIndex(
                      getColumnNamesFromFile().indexOf(cbReactionAbbreviation.getSelectedItem()));
              usedIndices.add(
                  getColumnNamesFromFile().indexOf(cbReactionAbbreviation.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbReactionName.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setReactionNameColumnIndex(
                      getColumnNamesFromFile().indexOf(cbReactionName.getSelectedItem()));
              usedIndices.add(getColumnNamesFromFile().indexOf(cbReactionName.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbReactionEquation.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setReactionEquationColumnIndex(
                      getColumnNamesFromFile().indexOf(cbReactionEquation.getSelectedItem()));
              usedIndices.add(
                  getColumnNamesFromFile().indexOf(cbReactionEquation.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbReversible.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setReversibleColumnIndex(
                      getColumnNamesFromFile().indexOf(cbReversible.getSelectedItem()));
              usedIndices.add(getColumnNamesFromFile().indexOf(cbReversible.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbLowerBound.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setLowerBoundColumnIndex(
                      getColumnNamesFromFile().indexOf(cbLowerBound.getSelectedItem()));
              usedIndices.add(getColumnNamesFromFile().indexOf(cbLowerBound.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbUpperBound.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setUpperBoundColumnIndex(
                      getColumnNamesFromFile().indexOf(cbUpperBound.getSelectedItem()));
              usedIndices.add(getColumnNamesFromFile().indexOf(cbUpperBound.getSelectedItem()));
            }
            if (getColumnNamesFromFile().contains(cbObjective.getSelectedItem())) {
              LocalConfig.getInstance()
                  .setBiologicalObjectiveColumnIndex(
                      getColumnNamesFromFile().indexOf(cbObjective.getSelectedItem()));
              usedIndices.add(getColumnNamesFromFile().indexOf(cbObjective.getSelectedItem()));
            }
            for (int i = 0; i < getColumnNamesFromFile().size(); i++) {
              if (!usedIndices.contains(i)) {
                metaColumnNames.add(getColumnNamesFromFile().get(i));
                metaColumnIndexList.add(
                    getColumnNamesFromFile().indexOf(getColumnNamesFromFile().get(i)));
              }
            }

            reactionsMetaColumnManager.addColumnNames(
                LocalConfig.getInstance().getDatabaseName(), metaColumnNames);
            LocalConfig.getInstance().setReactionsMetaColumnIndexList(metaColumnIndexList);

            setVisible(false);
            dispose();

            progressBar.setVisible(true);

            t.start();

            task = new Task();
            task.execute();
          }
        };

    okButton.addActionListener(okButtonActionListener);

    ActionListener cancelButtonActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent prodActionEvent) {
            setVisible(false);
            dispose();
            // this is a hack, same as clear method in gui
            try {
              Class.forName("org.sqlite.JDBC");
              DatabaseCreator databaseCreator = new DatabaseCreator();
              LocalConfig.getInstance().setDatabaseName(ConfigConstants.DEFAULT_DATABASE_NAME);
              Connection con =
                  DriverManager.getConnection(
                      "jdbc:sqlite:" + ConfigConstants.DEFAULT_DATABASE_NAME + ".db");
              databaseCreator.createDatabase(LocalConfig.getInstance().getDatabaseName());
              databaseCreator.addRows(
                  LocalConfig.getInstance().getDatabaseName(),
                  GraphicalInterfaceConstants.BLANK_DB_NUMBER_OF_ROWS,
                  GraphicalInterfaceConstants.BLANK_DB_NUMBER_OF_ROWS);
            } catch (ClassNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        };

    cancelButton.addActionListener(cancelButtonActionListener);

    ActionListener nextRowButtonActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent prodActionEvent) {
            TextReactionsModelReader reader = new TextReactionsModelReader();
            int correction = LocalConfig.getInstance().getReactionsNextRowCorrection();
            if ((correction + 1) < reader.numberOfLines(GraphicalInterface.getReactionsCSVFile())) {
              LocalConfig.getInstance().setReactionsNextRowCorrection(correction + 1);
              System.out.println(
                  "corr " + LocalConfig.getInstance().getReactionsNextRowCorrection());
              ArrayList<String> newColumnNamesFromFile =
                  reader.columnNamesFromFile(
                      GraphicalInterface.getReactionsCSVFile(),
                      LocalConfig.getInstance().getReactionsNextRowCorrection());
              setColumnNamesFromFile(newColumnNamesFromFile);
              populateNamesFromFileBoxes(newColumnNamesFromFile);
            }
          }
        };

    nextRowButton.addActionListener(nextRowButtonActionListener);
  }
コード例 #5
0
  public void populateNamesFromFileBoxes(ArrayList<String> columnNamesFromFile) {

    LocalConfig.getInstance().setKnockoutColumnIndex(-1);
    LocalConfig.getInstance().setFluxValueColumnIndex(-1);
    LocalConfig.getInstance().setReversibleColumnIndex(-1);
    LocalConfig.getInstance().setLowerBoundColumnIndex(-1);
    LocalConfig.getInstance().setUpperBoundColumnIndex(-1);
    LocalConfig.getInstance().setBiologicalObjectiveColumnIndex(-1);
    cbKnockout.removeAllItems();
    cbFluxValue.removeAllItems();
    cbReactionAbbreviation.removeAllItems();
    cbReactionName.removeAllItems();
    cbReactionEquation.removeAllItems();
    cbReversible.removeAllItems();
    cbLowerBound.removeAllItems();
    cbUpperBound.removeAllItems();
    cbObjective.removeAllItems();
    // add all column names to from file comboboxes
    for (int c = 0; c < columnNamesFromFile.size(); c++) {
      cbKnockout.addItem(columnNamesFromFile.get(c));
      cbFluxValue.addItem(columnNamesFromFile.get(c));
      cbReactionAbbreviation.addItem(columnNamesFromFile.get(c));
      cbReactionName.addItem(columnNamesFromFile.get(c));
      cbReactionEquation.addItem(columnNamesFromFile.get(c));
      cbReversible.addItem(columnNamesFromFile.get(c));
      cbLowerBound.addItem(columnNamesFromFile.get(c));
      cbUpperBound.addItem(columnNamesFromFile.get(c));
      cbObjective.addItem(columnNamesFromFile.get(c));
    }
    cbKnockout.setSelectedIndex(-1);
    cbFluxValue.setSelectedIndex(-1);
    cbReversible.setSelectedIndex(-1);
    cbLowerBound.setSelectedIndex(-1);
    cbUpperBound.setSelectedIndex(-1);
    cbObjective.setSelectedIndex(-1);
    for (int c = 0; c < columnNamesFromFile.size(); c++) {
      // filters to match column names from file to required column names in table
      if ((columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.KNOCKOUT_COLUMN_FILTER[0])
              == 0
          || (columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.KNOCKOUT_COLUMN_FILTER[1])
              == 0) {
        cbKnockout.setSelectedIndex(c);
        LocalConfig.getInstance().setKnockoutColumnIndex(c);
      } else if ((columnNamesFromFile.get(c).toLowerCase())
          .contains(GraphicalInterfaceConstants.FLUX_VALUE_COLUMN_FILTER[0])) {
        cbFluxValue.setSelectedIndex(c);
        LocalConfig.getInstance().setFluxValueColumnIndex(c);
      } else if ((columnNamesFromFile.get(c).toLowerCase())
          .contains(GraphicalInterfaceConstants.REVERSIBLE_COLUMN_FILTER[0])) {
        cbReversible.setSelectedIndex(c);
        LocalConfig.getInstance().setReversibleColumnIndex(c);
      } else if ((columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.LOWER_BOUND_FILTER[0])
              == 0
          || (columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.LOWER_BOUND_FILTER[1])
              == 0
          || (columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.LOWER_BOUND_FILTER[2])
              == 0) {
        cbLowerBound.setSelectedIndex(c);
        LocalConfig.getInstance().setLowerBoundColumnIndex(c);
      } else if ((columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.UPPER_BOUND_FILTER[0])
              == 0
          || (columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.UPPER_BOUND_FILTER[1])
              == 0
          || (columnNamesFromFile.get(c).toLowerCase())
                  .compareTo(GraphicalInterfaceConstants.UPPER_BOUND_FILTER[2])
              == 0) {
        cbUpperBound.setSelectedIndex(c);
        LocalConfig.getInstance().setUpperBoundColumnIndex(c);
      } else if ((columnNamesFromFile.get(c).toLowerCase())
          .contains(GraphicalInterfaceConstants.BIOLOGICAL_OBJECTIVE_FILTER[0])) {
        cbObjective.setSelectedIndex(c);
        LocalConfig.getInstance().setBiologicalObjectiveColumnIndex(c);
      }
    }

    // csv files written by TextReactionWriter will have KO and fluxValue as col 1 and 2
    if ((columnNamesFromFile.get(0).toLowerCase())
                .compareTo(GraphicalInterfaceConstants.KNOCKOUT_COLUMN_FILTER[0])
            == 0
        || (columnNamesFromFile.get(0).toLowerCase())
                .compareTo(GraphicalInterfaceConstants.KNOCKOUT_COLUMN_FILTER[1])
            == 0) {
      cbReactionAbbreviation.setSelectedIndex(2);
      LocalConfig.getInstance().setReactionAbbreviationColumnIndex(2);
      cbReactionName.setSelectedIndex(3);
      LocalConfig.getInstance().setReactionNameColumnIndex(3);
      cbReactionEquation.setSelectedIndex(4);
      LocalConfig.getInstance().setReactionEquationColumnIndex(4);
    } else {
      // first two columns are recommended to be column 1 and 2: abbreviation (id), and name
      cbReactionAbbreviation.setSelectedIndex(0);
      LocalConfig.getInstance().setReactionAbbreviationColumnIndex(0);
      cbReactionName.setSelectedIndex(1);
      LocalConfig.getInstance().setReactionNameColumnIndex(1);
      cbReactionEquation.setSelectedIndex(2);
      LocalConfig.getInstance().setReactionEquationColumnIndex(2);
    }
  }