use of cbit.vcell.solver.SimulationOwner.UnitInfo in project vcell by virtualcell.
the class SimulationEditor method prepareToEdit.
/**
* Comment
* @param simulation not null
* @param parent
* @throws ChomboInvalidGeometryException
* @throws NullPointerException
*/
public void prepareToEdit(Simulation simulation, Component parent) throws ChomboInvalidGeometryException {
Objects.requireNonNull(simulation);
try {
Simulation clonedSimulation = (Simulation) BeanUtils.cloneSerializable(simulation);
clonedSimulation.refreshDependencies();
getMathOverridesPanel1().setMathOverrides(clonedSimulation == null ? null : clonedSimulation.getMathOverrides());
getMeshTabPanel().setSimulation(parent, clonedSimulation);
SolverTaskDescriptionAdvancedPanel stdap = getSolverTaskDescriptionAdvancedPanel1();
{
SimulationOwner so = simulation.getSimulationOwner();
UnitInfo unitInfo = so.getUnitInfo();
stdap.setUnitInfo(unitInfo);
}
stdap.setSolverTaskDescription(clonedSimulation == null ? null : clonedSimulation.getSolverTaskDescription());
boolean shouldMeshBeEnabled = false;
MeshSpecification meshSpec = clonedSimulation.getMeshSpecification();
if (meshSpec != null && meshSpec.getGeometry() != null && meshSpec.getGeometry().getDimension() > 0) {
shouldMeshBeEnabled = true;
}
if (!shouldMeshBeEnabled) {
getJTabbedPane1().remove(getMeshTabPanel());
}
setClonedSimulation(clonedSimulation);
} catch (ChomboInvalidGeometryException exc) {
// if this happens, sim is not allowed to edit
exc.printStackTrace(System.out);
throw exc;
} catch (Throwable exc) {
exc.printStackTrace(System.out);
JOptionPane.showMessageDialog(this, "Could not initialize simulation editor\n" + exc.getMessage(), "Error:", JOptionPane.ERROR_MESSAGE);
}
}
use of cbit.vcell.solver.SimulationOwner.UnitInfo in project vcell by virtualcell.
the class SimulationListPanel method initConnections.
/**
* Initializes connections
* @exception java.lang.Exception The exception description.
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void initConnections() throws java.lang.Exception {
// user code begin {1}
// user code end
getNewButton().addActionListener(ivjEventHandler);
getEditButton().addActionListener(ivjEventHandler);
getDeleteButton().addActionListener(ivjEventHandler);
getRunButton().addActionListener(ivjEventHandler);
// getPythonResultsButton().addActionListener(ivjEventHandler);
getNativeResultsButton().addActionListener(ivjEventHandler);
getMoreActionsButton().addActionListener(ivjEventHandler);
getScrollPaneTable().addPropertyChangeListener(ivjEventHandler);
getOutputFunctionsPanel().addPropertyChangeListener(ivjEventHandler);
getScrollPaneTable().getSelectionModel().addListSelectionListener(ivjEventHandler);
DefaultScrollTableCellRenderer renderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof OutputTimeSpec) {
SimulationWorkspace sw = getSimulationWorkspace();
SimulationOwner so = sw.getSimulationOwner();
UnitInfo unitInfo = so.getUnitInfo();
Objects.requireNonNull(unitInfo);
OutputTimeSpec ots = (OutputTimeSpec) value;
String text = ots.describe(unitInfo);
setText(text);
} else if (value instanceof Double) {
setText(value + "");
}
boolean bFinitVolumeRerun = false;
if (value instanceof SolverDescription) {
SolverDescription solverDescription = (SolverDescription) value;
try {
if (FINITEVOLUME_CUTTOFF != null && solverDescription.equals(SolverDescription.FiniteVolume)) /*Compiled Solver*/
{
SimulationStatus simStatus = getSimulationWorkspace().getSimulationStatus(getSimulationListTableModel1().getValueAt(row));
if (simStatus.getHasData()) {
int statusIndex = 0;
while (simStatus.getJobStatus(statusIndex) != null) {
if (simStatus.getJobStatus(statusIndex).getEndDate().compareTo(FINITEVOLUME_CUTTOFF) > 0) {
bFinitVolumeRerun = true;
break;
}
statusIndex++;
}
}
}
} catch (Exception e) {
// ignore, let table cell render anyway
e.printStackTrace();
}
setText(solverDescription.getShortDisplayLabel());
setToolTipText(solverDescription.getDisplayLabel());
} else {
setToolTipText(getText());
}
if (bFinitVolumeRerun) {
setText(getText() + (bFinitVolumeRerun ? "(*)" : ""));
setToolTipText(getToolTipText() + (bFinitVolumeRerun ? " (data regenerated using FiniteVolumeStandalone)" : ""));
}
return this;
}
};
getScrollPaneTable().setDefaultRenderer(OutputTimeSpec.class, renderer);
getScrollPaneTable().setDefaultRenderer(Double.class, renderer);
getScrollPaneTable().setDefaultRenderer(String.class, renderer);
getScrollPaneTable().setDefaultRenderer(SolverDescription.class, renderer);
getScrollPaneTable().setDefaultEditor(OutputTimeSpec.class, new DefaultCellEditor(new JTextField()));
getScrollPaneTable().setDefaultRenderer(SimulationStatus.class, new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Object obj = getSimulationStatusDisplay(row);
if (obj instanceof JProgressBar) {
return (JProgressBar) obj;
}
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof SimulationStatus) {
setText(obj.toString());
String details = ((SimulationStatus) value).getDetails();
setToolTipText(details);
}
return this;
}
});
}
Aggregations