use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class BioModelEditorApplicationPanel method setSimulationContext.
public void setSimulationContext(SimulationContext newValue) {
if (simulationContext == newValue) {
return;
}
final boolean respondingToSelectionManager = selectionManager.isBusy();
final Object[] selectedObj = selectionManager.getSelectedObjects();
SimulationContext oldValue = simulationContext;
if (oldValue != null) {
oldValue.removePropertyChangeListener(eventHandler);
}
if (newValue != null) {
newValue.addPropertyChangeListener(eventHandler);
}
simulationContext = newValue;
AsynchClientTask task1 = new AsynchClientTask("loading application", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
simulationContext.getGeometry().precomputeAll(new GeometryThumbnailImageFactoryAWT());
}
};
AsynchClientTask task2 = new AsynchClientTask("showing application", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
applicationGeometryPanel.setSimulationContext(simulationContext);
applicationSpecificationsPanel.setSimulationContext(simulationContext);
applicationProtocolsPanel.setSimulationContext(simulationContext);
applicationSimulationsPanel.setSimulationContext(simulationContext);
parameterEstimationPanel.setSelectionManager(null);
showOrHideFittingPanel();
parameterEstimationPanel.setSelectionManager(selectionManager);
// showOrHideProtocolsPanel();
if (respondingToSelectionManager) {
selectionManager.setSelectedObjects(new Object[0]);
selectionManager.setSelectedObjects(selectedObj);
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class BioModelEditorApplicationsPanel method getJMenuAppCopyAs.
/**
* Return the JMenuItemCopy property value.
* @return javax.swing.JMenuItem
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private javax.swing.JMenu getJMenuAppCopyAs() {
if (menuAppCopyAs == null) {
try {
menuAppCopyAs = new javax.swing.JMenu(GuiConstants.MENU_TEXT_APP_COPYAS);
menuItemAppNonSpatialCopyStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
menuItemAppNonSpatialCopyStochastic.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_STOCHASTIC_APPLICATION);
menuItemAppNonSpatialCopyStochastic.addActionListener(eventHandler);
menuItemNonSpatialCopyDeterministic = new javax.swing.JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
menuItemNonSpatialCopyDeterministic.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_DETERMINISTIC_APPLICATION);
menuItemNonSpatialCopyDeterministic.addActionListener(eventHandler);
menuItemAppNonSpatialCopyRulebased = new javax.swing.JMenuItem(GuiConstants.MENU_TEXT_RULEBASED_APPLICATION);
menuItemAppNonSpatialCopyRulebased.setActionCommand(GuiConstants.ACTIONCMD_NON_SPATIAL_COPY_TO_RULEBASED_APPLICATION);
menuItemAppNonSpatialCopyRulebased.addActionListener(eventHandler);
menuAppSpatialCopyAsNonSpatial = new JMenu(GuiConstants.MENU_TEXT_NON_SPATIAL_APPLICATION);
menuItemAppSpatialCopyAsNonSpatialDeterministic = new JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
menuItemAppSpatialCopyAsNonSpatialDeterministic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_NON_SPATIAL_DETERMINISTIC_APPLICATION);
menuItemAppSpatialCopyAsNonSpatialDeterministic.addActionListener(eventHandler);
menuItemAppSpatialCopyAsNonSpatialStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
menuItemAppSpatialCopyAsNonSpatialStochastic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_NON_SPATIAL_STOCHASTIC_APPLICATION);
menuItemAppSpatialCopyAsNonSpatialStochastic.addActionListener(eventHandler);
menuAppSpatialCopyAsNonSpatial.add(menuItemAppSpatialCopyAsNonSpatialDeterministic);
menuAppSpatialCopyAsNonSpatial.add(menuItemAppSpatialCopyAsNonSpatialStochastic);
menuAppSpatialCopyAsSpatial = new JMenu(GuiConstants.MENU_TEXT_SPATIAL_APPLICATION);
menuItemAppSpatialCopyAsSpatialDeterministic = new JMenuItem(GuiConstants.MENU_TEXT_DETERMINISTIC_APPLICATION);
menuItemAppSpatialCopyAsSpatialDeterministic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_SPATIAL_DETERMINISTIC_APPLICATION);
menuItemAppSpatialCopyAsSpatialDeterministic.addActionListener(eventHandler);
menuItemAppSpatialCopyAsSpatialStochastic = new JMenuItem(GuiConstants.MENU_TEXT_STOCHASTIC_APPLICATION);
menuItemAppSpatialCopyAsSpatialStochastic.setActionCommand(GuiConstants.ACTIONCMD_SPATIAL_COPY_TO_SPATIAL_STOCHASTIC_APPLICATION);
menuItemAppSpatialCopyAsSpatialStochastic.addActionListener(eventHandler);
menuAppSpatialCopyAsSpatial.add(menuItemAppSpatialCopyAsSpatialDeterministic);
menuAppSpatialCopyAsSpatial.add(menuItemAppSpatialCopyAsSpatialStochastic);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
menuAppCopyAs.removeAll();
SimulationContext selectedSimContext = getSelectedSimulationContext();
if (selectedSimContext != null) {
if (selectedSimContext.getGeometry().getDimension() == 0) {
menuAppCopyAs.add(menuItemNonSpatialCopyDeterministic);
menuAppCopyAs.add(menuItemAppNonSpatialCopyStochastic);
menuAppCopyAs.add(menuItemAppNonSpatialCopyRulebased);
} else {
menuAppCopyAs.add(menuAppSpatialCopyAsNonSpatial);
menuAppCopyAs.add(menuAppSpatialCopyAsSpatial);
}
}
return menuAppCopyAs;
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class BioModelEditorApplicationsPanel method deleteButtonPressed.
protected void deleteButtonPressed() {
int[] rows = table.getSelectedRows();
if (rows == null || rows.length == 0) {
return;
}
String confirm = PopupGenerator.showOKCancelWarningDialog(this, "Deleting application(s)", "Are you sure you want to delete selected application(s)?");
if (confirm.equals(UserMessage.OPTION_CANCEL)) {
return;
}
ArrayList<SimulationContext> deleteList = new ArrayList<SimulationContext>();
for (int r : rows) {
SimulationContext simContext = tableModel.getValueAt(r);
if (simContext != null) {
deleteList.add(simContext);
}
}
try {
for (SimulationContext sc : deleteList) {
deleteApplication(sc);
}
} catch (PropertyVetoException ex) {
ex.printStackTrace();
DialogUtils.showErrorDialog(BioModelEditorApplicationsPanel.this, ex.getMessage());
}
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class BioModelEditorApplicationsPanel method compareButtonPressed.
private void compareButtonPressed() {
int[] rows = table.getSelectedRows();
if (rows == null || rows.length != 2) {
return;
}
try {
SimulationContext simContext1 = tableModel.getValueAt(rows[0]);
SimulationContext simContext2 = tableModel.getValueAt(rows[1]);
BioModel bioModel = simContext1.getBioModel();
MathMappingCallback callback = new MathMappingCallback() {
@Override
public void setProgressFraction(float fractionDone) {
Thread.dumpStack();
System.out.println("---> stdout mathMapping: progress = " + (fractionDone * 100.0) + "% done");
}
@Override
public void setMessage(String message) {
Thread.dumpStack();
System.out.println("---> stdout mathMapping: message = " + message);
}
@Override
public boolean isInterrupted() {
return false;
}
};
simContext1.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
simContext2.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
Xmlproducer xmlProducer = new Xmlproducer(false);
String simContext1XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext1, bioModel));
String simContext2XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext2, bioModel));
DiffConfiguration comparisonSetting = DiffConfiguration.COMPARE_DOCS_OTHER;
XmlTreeDiff diffTree = XmlHelper.compareMerge(simContext1XML, simContext2XML, comparisonSetting, true);
String baselineDesc = "application " + simContext1.getName();
String modifiedDesc = "application " + simContext2.getName();
TMLPanel comparePanel = new TMLPanel();
comparePanel.setXmlTreeDiff(diffTree);
comparePanel.setBaselineVersionDescription(baselineDesc);
comparePanel.setModifiedVersionDescription(modifiedDesc);
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
String title = "comparing application " + simContext1.getName() + " and " + simContext2.getName();
ChildWindow childWindow = childWindowManager.addChildWindow(comparePanel, diffTree, title, true);
childWindow.setSize(new Dimension(600, 600));
childWindow.show();
} catch (XmlParseException e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "failed to compare applications: \n\n" + e.getMessage());
}
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class BioModelEditorApplicationsTableModel method bioModelChange.
@Override
protected void bioModelChange(PropertyChangeEvent evt) {
super.bioModelChange(evt);
BioModel oldValue = (BioModel) evt.getOldValue();
if (oldValue != null) {
for (SimulationContext simulationContext : oldValue.getSimulationContexts()) {
simulationContext.removePropertyChangeListener(this);
}
}
BioModel newValue = (BioModel) evt.getNewValue();
if (newValue != null) {
for (SimulationContext simulationContext : newValue.getSimulationContexts()) {
simulationContext.addPropertyChangeListener(this);
}
}
}
Aggregations