Search in sources :

Example 6 with UserPreferences

use of cbit.vcell.client.server.UserPreferences in project vcell by virtualcell.

the class SimulationListPanel method createBatchSimulations.

/**
 * Comment
 */
private void createBatchSimulations() {
    int[] selections = getScrollPaneTable().getSelectedRows();
    if (selections == null || selections.length != 1) {
        throw new RuntimeException("Exactly one template Simulation is required for Batch Creation");
    }
    Vector<Simulation> v = new Vector<Simulation>();
    v.add((Simulation) (ivjSimulationListTableModel1.getValueAt(selections[0])));
    Simulation[] toCopy = (Simulation[]) BeanUtils.getArray(v, Simulation.class);
    if (toCopy == null || toCopy.length != 1) {
        throw new RuntimeException("Exactly one template Simulation is required for Batch Creation");
    }
    int index = -1;
    UserPreferences up = getSimulationWorkspace().getClientSimManager().getUserPreferences();
    Map<Integer, Map<String, String>> batchInputDataMap = new LinkedHashMap<>();
    File batchInputFile = parseBatchInputFile(up, batchInputDataMap);
    if (batchInputFile == null || batchInputDataMap.isEmpty()) {
        System.out.println("Failed to read batch input data file or user canceled");
        return;
    }
    try {
        index = getSimulationWorkspace().createBatchSimulations(toCopy, batchInputDataMap, this);
    } catch (Throwable exc) {
        exc.printStackTrace(System.out);
        PopupGenerator.showErrorDialog(this, exc.getMessage(), exc);
    }
    // set selection back to the template simulation
    getScrollPaneTable().getSelectionModel().setSelectionInterval(index, index);
    getScrollPaneTable().scrollRectToVisible(getScrollPaneTable().getCellRect(index, 0, true));
}
Also used : UserPreferences(cbit.vcell.client.server.UserPreferences) LinkedHashMap(java.util.LinkedHashMap) Simulation(cbit.vcell.solver.Simulation) Vector(java.util.Vector) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) File(java.io.File)

Aggregations

UserPreferences (cbit.vcell.client.server.UserPreferences)6 File (java.io.File)5 VCFileChooser (org.vcell.util.gui.VCFileChooser)4 TopLevelWindowManager (cbit.vcell.client.TopLevelWindowManager)3 JFrame (javax.swing.JFrame)3 FileFilter (javax.swing.filechooser.FileFilter)3 UserCancelException (org.vcell.util.UserCancelException)3 Simulation (cbit.vcell.solver.Simulation)2 BioModel (cbit.vcell.biomodel.BioModel)1 ClientServerManager (cbit.vcell.client.server.ClientServerManager)1 Geometry (cbit.vcell.geometry.Geometry)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 MathModel (cbit.vcell.mathmodel.MathModel)1 ExpressionException (cbit.vcell.parser.ExpressionException)1 Component (java.awt.Component)1 Point (java.awt.Point)1 BufferedImage (java.awt.image.BufferedImage)1 PropertyVetoException (java.beans.PropertyVetoException)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1