use of cbit.vcell.client.RequestManager in project vcell by virtualcell.
the class NetworkFreePanel method createModel.
private void createModel() {
DocumentWindow dw = (DocumentWindow) BeanUtils.findTypeParentOfComponent(this, DocumentWindow.class);
BioModelWindowManager bmwm = (BioModelWindowManager) (dw.getTopLevelWindowManager());
RequestManager rm = dw.getTopLevelWindowManager().getRequestManager();
rm.createBioModelFromApplication(bmwm, "Test", fieldSimulationContext);
}
use of cbit.vcell.client.RequestManager in project vcell by virtualcell.
the class FieldDataGUIPanel method jButtonFDDelete_ActionPerformed.
private void jButtonFDDelete_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
final RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
TreePath selPath = getJTree1().getSelectionPath();
final DefaultMutableTreeNode mainNode = (DefaultMutableTreeNode) selPath.getLastPathComponent();
final FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
if (!fieldDataMainList.externalDataIdentifier.getOwner().equals(clientRequestManager.getDocumentManager().getUser())) {
DialogUtils.showErrorDialog(this, "Delete failed: User " + clientRequestManager.getDocumentManager().getUser().getName() + "does not own FieldData '" + fieldDataMainList.externalDataIdentifier.getName() + "'");
}
if (PopupGenerator.showComponentOKCancelDialog(this, new JLabel("Delete " + fieldDataMainList.externalDataIdentifier.getName() + "?"), "Confirm Delete") != JOptionPane.OK_OPTION) {
return;
}
AsynchClientTask CheckRemoveFromDBTask = new AsynchClientTask("Check Field Data references in DB", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
if (fieldDataWindowManager.findReferencingModels(fieldDataMainList.externalDataIdentifier, false)) {
throw new Exception("Cannot delete Field Data '" + fieldDataMainList.externalDataIdentifier.getName() + "' because it is referenced in a Model(s) or Function(s) file.");
}
}
};
AsynchClientTask RemoveNodeTreeTask = new AsynchClientTask("Remove FieldData tree node", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
((DefaultTreeModel) getJTree1().getModel()).removeNodeFromParent(mainNode);
if (((DefaultMutableTreeNode) getJTree1().getModel().getRoot()).getChildCount() == 0) {
updateJTree(clientRequestManager);
}
}
};
AsynchClientTask RemoveFromDiskAndDBTask = new AsynchClientTask("Remove Field Data from Disk and DB", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
// Remove from Disk
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
FieldDataFileOperationSpec fdos = FieldDataFileOperationSpec.createDeleteFieldDataFileOperationSpec(fieldDataMainList.externalDataIdentifier);
clientRequestManager.getDocumentManager().fieldDataFileOperation(fdos);
// Remove from DB
fieldDataWindowManager.deleteExternalDataIdentifier(fieldDataMainList.externalDataIdentifier);
}
};
//
// Execute Field Data Info - JTree tasks
//
AsynchClientTask[] tasks = new AsynchClientTask[] { CheckRemoveFromDBTask, RemoveFromDiskAndDBTask, RemoveNodeTreeTask };
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, tasks, false);
}
use of cbit.vcell.client.RequestManager in project vcell by virtualcell.
the class FieldDataGUIPanel method getJButtonCreateGeom.
/**
* This method initializes jButtonCopyInfo
*
* @return javax.swing.JButton
*/
private JButton getJButtonCreateGeom() {
if (jButtonCreateGeom == null) {
jButtonCreateGeom = new JButton();
jButtonCreateGeom.setEnabled(false);
jButtonCreateGeom.setText("Create Geom");
jButtonCreateGeom.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
javax.swing.tree.TreePath selPath = getJTree1().getSelectionPath();
javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode) selPath.getLastPathComponent();
if (lastPathComponent.getUserObject() instanceof FieldDataVarList) {
DataIdentifier dataIdentifier = ((FieldDataVarList) lastPathComponent.getUserObject()).dataIdentifier;
TreePath ppPath = selPath.getParentPath().getParentPath();
javax.swing.tree.DefaultMutableTreeNode ppLastPathComp = (javax.swing.tree.DefaultMutableTreeNode) ppPath.getLastPathComponent();
if (ppLastPathComp.getUserObject() instanceof FieldDataMainList) {
ExternalDataIdentifier extDataID = ((FieldDataMainList) ppLastPathComp.getUserObject()).externalDataIdentifier;
final OpenModelInfoHolder openModelInfoHolder = FieldDataWindowManager.selectOpenModelsFromDesktop(FieldDataGUIPanel.this, fieldDataWindowManager.getRequestManager(), false, "Select BioModel or MathModel to receive new geometry", false);
if (openModelInfoHolder == null) {
DialogUtils.showErrorDialog(FieldDataGUIPanel.this, "Before proceeding, please open a Biomodel application or Mathmodel you wish to apply a new Field Data Geometry to");
return;
}
AsynchClientTask applyGeomTask = new AsynchClientTask("apply geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
final String OK_OPTION = "Ok";
if (openModelInfoHolder instanceof FDSimMathModelInfo) {
Version version = ((FDSimMathModelInfo) openModelInfoHolder).getMathModelVersion();
String modelName = (version == null ? "NoName" : version.getName());
if (newGeom.getName() == null) {
newGeom.setName(modelName + "_" + BeanUtils.generateDateTimeString());
}
String message = "Confirm Setting new FieldData derived geometry on MathModel '" + modelName + "'";
if (DialogUtils.showWarningDialog(FieldDataGUIPanel.this, message, new String[] { OK_OPTION, "Cancel" }, OK_OPTION).equals(OK_OPTION)) {
((FDSimMathModelInfo) openModelInfoHolder).getMathDescription().setGeometry(newGeom);
}
} else if (openModelInfoHolder instanceof FDSimBioModelInfo) {
Version version = ((FDSimBioModelInfo) openModelInfoHolder).getBioModelVersion();
String modelName = (version == null ? "NoName" : version.getName());
String simContextName = ((FDSimBioModelInfo) openModelInfoHolder).getSimulationContext().getName();
if (newGeom.getName() == null) {
newGeom.setName(modelName + "_" + simContextName + "_" + BeanUtils.generateDateTimeString());
}
String message = "Confirm Setting new FieldData derived geometry on BioModel '" + modelName + "' , Application '" + simContextName + "'";
if (DialogUtils.showWarningDialog(FieldDataGUIPanel.this, message, new String[] { OK_OPTION, "Cancel" }, OK_OPTION).equals(OK_OPTION)) {
((FDSimBioModelInfo) openModelInfoHolder).getSimulationContext().setGeometry(newGeom);
}
}
}
};
VCDocument.GeomFromFieldDataCreationInfo geomFromFieldDataCreationInfo = new VCDocument.GeomFromFieldDataCreationInfo(extDataID, dataIdentifier.getName());
AsynchClientTask[] createGeomTask = clientRequestManager.createNewGeometryTasks(fieldDataWindowManager, geomFromFieldDataCreationInfo, new AsynchClientTask[] { applyGeomTask }, "Apply Geometry");
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(ClientRequestManager.GUI_PARENT, fieldDataWindowManager.getComponent());
ClientTaskDispatcher.dispatch(FieldDataGUIPanel.this, hash, createGeomTask, false, false, null, true);
}
}
} catch (UserCancelException e1) {
// ignore
} catch (Exception e1) {
e1.printStackTrace();
DialogUtils.showErrorDialog(FieldDataGUIPanel.this, e1.getMessage());
}
// jButtonFDCopyRef_ActionPerformed(e);
// fieldDataWindowManager.newDocument(VCDocument.GEOMETRY_DOC, option);
// copyMethod(COPY_CRNL);
// // javax.swing.tree.TreePath selPath = getJTree1().getSelectionPath();
// // if(selPath != null){
// // javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode)selPath.getLastPathComponent();
// // copyMethod(lastPathComponent, copyMode);
// // }
// // String copyString = "";
// // javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode)selPath.getLastPathComponent();
// // if(lastPathComponent.equals(getJTree1().getModel().getRoot())){
// // int childCount = lastPathComponent.getChildCount();
// // for(int i=0;i<childCount;i+= 1){
// // if(i != 0){
// // copyString+="\n";
// // }
// // copyString+=
// // ((FieldDataMainList)((DefaultMutableTreeNode)lastPathComponent.getChildAt(i)).getUserObject()).externalDataIdentifier.getName();
// // }
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataOriginList){
// // Origin origin = ((FieldDataOriginList)lastPathComponent.getUserObject()).origin;
// // copyString = origin.getX()+","+origin.getY()+","+origin.getZ();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataExtentList){
// // Extent extent = ((FieldDataExtentList)lastPathComponent.getUserObject()).extent;
// // copyString = extent.getX()+","+extent.getY()+","+extent.getZ();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataISizeList){
// // ISize isize = ((FieldDataISizeList)lastPathComponent.getUserObject()).isize;
// // copyString = isize.getX()+","+isize.getY()+","+isize.getZ();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataTimeList){
// // double[] times = ((FieldDataTimeList)lastPathComponent.getUserObject()).times;
// // for(int i=0;i<times.length;i+= 1){
// // if(i != 0){
// // copyString+="\n";
// // }
// // copyString+= times[i]+"";
// // }
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataMainList){
// // ExternalDataIdentifier extDataID =
// // ((FieldDataMainList)lastPathComponent.getUserObject()).externalDataIdentifier;
// // copyString = extDataID.getName();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataVarList){
// // DataIdentifier dataIdentifier =
// // ((FieldDataVarList)lastPathComponent.getUserObject()).dataIdentifier;
// // copyString = dataIdentifier.getName();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataVarMainList){
// // int childCount = lastPathComponent.getChildCount();
// // for(int i=0;i<childCount;i+= 1){
// // if(i != 0){
// // copyString+="\n";
// // }
// // copyString+=
// // ((FieldDataVarList)((DefaultMutableTreeNode)lastPathComponent.getChildAt(i)).getUserObject()).dataIdentifier.getName();
// // }
// // }
// // if(copyString.length() > 0 ){
// // VCellTransferable.sendToClipboard(copyString);
// // }
// // }
}
});
}
return jButtonCreateGeom;
}
use of cbit.vcell.client.RequestManager in project vcell by virtualcell.
the class FieldDataGUIPanel method jButtonFDFromSim_ActionPerformed.
private void jButtonFDFromSim_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
try {
final RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
final FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = FieldDataWindowManager.selectOpenModelsFromDesktop(this, fieldDataWindowManager.getRequestManager(), true, "Select Simulation for Field Data", true);
if (simInfoHolder == null) {
PopupGenerator.showErrorDialog(this, "Please open a Bio or Math model containing the spatial (non-compartmental) simulation you wish to use to create a new Field Data");
return;
}
// Check that the sim is in a state that can be copied
final SimulationInfo simInfo = simInfoHolder.getSimInfo();
if (simInfo == null) {
throw new Exception("Selected sim '" + simInfoHolder.getSimName() + "' has no simInfo (save your model and retry).");
}
SimulationStatus simStatus = clientRequestManager.getServerSimulationStatus(simInfo);
if (simStatus != null && (simStatus.isRunning() || simStatus.isStartRequested())) {
throw new Exception("Can't copy 'running' simulation data from sim '" + simInfo.getName() + "'");
}
final FieldDataFileOperationSpec fdos = FieldDataFileOperationSpec.createCopySimFieldDataFileOperationSpec(null, (simInfo.getParentSimulationReference() != null ? simInfo.getParentSimulationReference() : simInfo.getSimulationVersion().getVersionKey()), simInfo.getOwner(), simInfoHolder.getJobIndex(), clientRequestManager.getDocumentManager().getUser());
AsynchClientTask[] addTasks = addNewExternalData(this, this, true);
AsynchClientTask[] taskArray = new AsynchClientTask[1 + addTasks.length];
// add to the end
System.arraycopy(addTasks, 0, taskArray, 1, addTasks.length);
taskArray[0] = new AsynchClientTask("Create Field Data from Simulation", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
FieldDataFileOperationResults fdor = clientRequestManager.getDocumentManager().fieldDataFileOperation(FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec((simInfo.getParentSimulationReference() != null ? simInfo.getParentSimulationReference() : simInfo.getSimulationVersion().getVersionKey()), simInfo.getOwner(), simInfoHolder.getJobIndex()));
// Create (non-editable) info for display
fdos.origin = fdor.origin;
fdos.extent = fdor.extent;
fdos.isize = fdor.iSize;
fdos.times = fdor.times;
fdos.varNames = new String[fdor.dataIdentifierArr.length];
for (int i = 0; i < fdor.dataIdentifierArr.length; i += 1) {
fdos.varNames[i] = (fdor.dataIdentifierArr[i].getVariableType().equals(VariableType.VOLUME) ? "(vol) " : "") + (fdor.dataIdentifierArr[i].getVariableType().equals(VariableType.MEMBRANE) ? "(mbr) " : "") + fdor.dataIdentifierArr[i].getName();
}
hashTable.put("fdos", fdos);
hashTable.put("initFDName", simInfo.getName());
// addNewExternalData(clientRequestManager, fdos, simInfoHolder.simInfo.getName(), true);
}
};
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, taskArray, false);
} catch (UserCancelException e) {
return;
} catch (Exception e) {
PopupGenerator.showErrorDialog(this, "Error creating Field Data from simulation\n" + e.getMessage(), e);
}
}
use of cbit.vcell.client.RequestManager in project vcell by virtualcell.
the class FieldDataGUIPanel method refreshMainNode.
private void refreshMainNode(final DefaultMutableTreeNode mainNode) {
final boolean isMainExpanded = getJTree1().isExpanded(new TreePath(mainNode.getPath()));
final boolean isVarExpanded = getJTree1().isExpanded(new TreePath(((DefaultMutableTreeNode) mainNode.getLastChild()).getPath()));
// Remove all children from Main node in a Tree safe way
DefaultMutableTreeNode root = (DefaultMutableTreeNode) getJTree1().getModel().getRoot();
int mainNodeIndex = ((DefaultTreeModel) getJTree1().getModel()).getIndexOfChild(root, mainNode);
((DefaultTreeModel) getJTree1().getModel()).removeNodeFromParent(mainNode);
mainNode.removeAllChildren();
final DefaultMutableTreeNode varNode = new DefaultMutableTreeNode(new FieldDataVarMainList());
mainNode.add(varNode);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(mainNode, root, mainNodeIndex);
//
// Create thread-safe tasks to get Field Data Info and update JTree
//
final String FDOR_INFO = "FDOR_INFO";
final RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
AsynchClientTask FieldDataInfoTask = new AsynchClientTask("Gather Field Data info", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
final FieldDataFileOperationResults fieldDataFileOperationResults = clientRequestManager.getDocumentManager().fieldDataFileOperation(FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(fieldDataMainList.externalDataIdentifier.getKey(), clientRequestManager.getDocumentManager().getUser(), FieldDataFileOperationSpec.JOBINDEX_DEFAULT));
hash.put(FDOR_INFO, fieldDataFileOperationResults);
}
};
AsynchClientTask FieldDataInfoTreeUpdate = new AsynchClientTask("Update Field Data GUI", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) {
try {
FieldDataFileOperationResults fieldDataFileOperationResults = (FieldDataFileOperationResults) hash.get(FDOR_INFO);
Arrays.sort(fieldDataFileOperationResults.dataIdentifierArr, new Comparator<DataIdentifier>() {
public int compare(DataIdentifier o1, DataIdentifier o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
final DefaultMutableTreeNode isizeNode = new DefaultMutableTreeNode(new FieldDataISizeList(fieldDataFileOperationResults.iSize));
final DefaultMutableTreeNode originNode = new DefaultMutableTreeNode(new FieldDataOriginList(fieldDataFileOperationResults.origin));
final DefaultMutableTreeNode extentNode = new DefaultMutableTreeNode(new FieldDataExtentList(fieldDataFileOperationResults.extent));
final DefaultMutableTreeNode timeNode = new DefaultMutableTreeNode(new FieldDataTimeList(fieldDataFileOperationResults.times));
final DefaultMutableTreeNode idNode = new DefaultMutableTreeNode(new FieldDataIDList(fieldDataMainList.externalDataIdentifier.getKey()));
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(isizeNode, mainNode, 0);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(originNode, mainNode, 1);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(extentNode, mainNode, 2);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(timeNode, mainNode, 3);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(idNode, mainNode, 4);
for (int i = 0; i < fieldDataFileOperationResults.dataIdentifierArr.length; i += 1) {
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(new DefaultMutableTreeNode(new FieldDataVarList(fieldDataFileOperationResults.dataIdentifierArr[i])), varNode, varNode.getChildCount());
}
if (isMainExpanded) {
getJTree1().expandPath(new TreePath(mainNode.getPath()));
}
if (isVarExpanded) {
getJTree1().expandPath(new TreePath(varNode.getPath()));
}
} catch (Throwable e) {
hash.put(ClientTaskDispatcher.TASK_ABORTED_BY_ERROR, e);
}
}
};
//
// Execute Field Data Info - JTree tasks
//
AsynchClientTask[] tasks = new AsynchClientTask[] { FieldDataInfoTask, FieldDataInfoTreeUpdate };
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, tasks, false);
}
Aggregations