use of cbit.vcell.client.TopLevelWindowManager.FDSimBioModelInfo 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;
}
Aggregations