/**
  * Returns all parameter instances for that job
  *
  * @param row
  * @return null, if there was an error
  */
 public ArrayList<ParameterInstance> getParameters(int row) {
   try {
     SolverConfiguration sc =
         SolverConfigurationDAO.getSolverConfigurationById(jobs.get(row).getSolverConfigId());
     return ParameterInstanceDAO.getBySolverConfig(sc);
   } catch (Exception e) {
     return null;
   }
 }
  /** Creates new form EDACCExperimentModeImportSolverConfigs */
  public EDACCExperimentModeImportSolverConfigs(
      java.awt.Frame parent, boolean modal, ExperimentController expController) {
    super(parent, modal);

    ArrayList<SolverConfiguration> scs = null;
    ArrayList<Solver> solvers = new ArrayList<Solver>();
    try {
      scs = SolverConfigurationDAO.getAll();
      ParameterInstanceDAO.cacheParameterInstances(scs);
      LinkedList<Solver> tmp = SolverDAO.getAll();
      solvers.addAll(tmp);
    } catch (SQLException ex) {
    }

    cancelled = true;
    selectedSolverConfigs = new ArrayList<SolverConfiguration>();
    experimentTableModel = new ExperimentTableModel(true);
    solverConfigTableModelByExperiments = new SolverConfigurationTableModel();
    solverConfigTableModelBySolvers = new SolverConfigurationTableModel();
    experimentTableModel.setExperiments(expController.getExperiments());

    initComponents();

    tblExperiments.setDefaultRenderer(
        char.class,
        new DefaultTableCellRenderer() {

          @Override
          public Component getTableCellRendererComponent(
              JTable table,
              Object value,
              boolean isSelected,
              boolean hasFocus,
              int row,
              int column) {
            JLabel lbl =
                (JLabel)
                    super.getTableCellRendererComponent(
                        table, value, isSelected, hasFocus, row, column);
            lbl.setHorizontalAlignment(JLabel.CENTER);
            return lbl;
          }
        });

    tblExperiments
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              @Override
              public void valueChanged(ListSelectionEvent e) {
                solverConfigurationTableRowFilterByExperiments.clearIncludedExperiments();
                for (int row : tblExperiments.getSelectedRows()) {
                  Experiment exp =
                      experimentTableModel.getExperimentAt(
                          tblExperiments.convertRowIndexToModel(row));
                  solverConfigurationTableRowFilterByExperiments.includeExperiment(exp.getId());
                }
                solverConfigTableModelByExperiments.fireTableDataChanged();
              }
            });

    TableRowSorter tableSolverConfigurationsRowSorterByExperiments =
        new TableRowSorter<SolverConfigurationTableModel>(solverConfigTableModelByExperiments);
    solverConfigurationTableRowFilterByExperiments = new SolverConfigurationTableRowFilter();
    tableSolverConfigurationsRowSorterByExperiments.setRowFilter(
        solverConfigurationTableRowFilterByExperiments);
    tblSolverConfigsByExperiments.setRowSorter(tableSolverConfigurationsRowSorterByExperiments);
    tblSolverConfigsByExperiments.setModel(solverConfigTableModelByExperiments);
    Util.addSpaceSelection(tblSolverConfigsByExperiments, SolverConfigurationTableModel.COL_SEL);
    solverConfigTableModelByExperiments.setSolverConfigurations(scs);

    solTableModel = new SolverTableModel();
    tableSolvers.setModel(solTableModel);
    tableSolvers.removeColumn(
        tableSolvers.getColumnModel().getColumn(SolverTableModel.COL_SELECTED));
    solTableModel.setSolvers(solvers);
    TableRowSorter tableSolverConfigurationsRowSorterBySolvers =
        new TableRowSorter<SolverConfigurationTableModel>(solverConfigTableModelBySolvers);
    solverConfigurationTableRowFilterBySolvers = new SolverConfigurationTableRowFilter();
    tableSolverConfigurationsRowSorterBySolvers.setRowFilter(
        solverConfigurationTableRowFilterBySolvers);
    tblSolverConfigsBySolvers.setRowSorter(tableSolverConfigurationsRowSorterBySolvers);
    tblSolverConfigsBySolvers.setModel(solverConfigTableModelBySolvers);
    Util.addSpaceSelection(tblSolverConfigsBySolvers, SolverConfigurationTableModel.COL_SEL);
    solverConfigTableModelBySolvers.setSolverConfigurations(scs);

    tableSolvers
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {

              @Override
              public void valueChanged(ListSelectionEvent e) {
                solverConfigurationTableRowFilterBySolvers.clearSolverBinaryIds();
                for (int rowView : tableSolvers.getSelectedRows()) {
                  int rowModel = tableSolvers.convertRowIndexToModel(rowView);
                  for (SolverBinaries sb : solTableModel.getSolver(rowModel).getSolverBinaries()) {
                    solverConfigurationTableRowFilterBySolvers.addSolverBinaryId(sb.getId());
                  }
                }
                solverConfigTableModelBySolvers.fireTableDataChanged();
                updateExistingSolverConfigFilterStatus();
              }
            });

    SwingUtilities.invokeLater(
        new Runnable() {

          @Override
          public void run() {
            existingSolverConfigFilter =
                new EDACCFilter(
                    EDACCApp.getApplication().getMainFrame(),
                    true,
                    tblSolverConfigsBySolvers,
                    true);
            solverFilter =
                new EDACCFilter(EDACCApp.getApplication().getMainFrame(), true, tableSolvers, true);
          }
        });
  }