Search in sources :

Example 1 with FDSimBioModelInfo

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;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) ActionListener(java.awt.event.ActionListener) DataIdentifier(cbit.vcell.simdata.DataIdentifier) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JButton(javax.swing.JButton) UserCancelException(org.vcell.util.UserCancelException) RequestManager(cbit.vcell.client.RequestManager) ClientRequestManager(cbit.vcell.client.ClientRequestManager) Version(org.vcell.util.document.Version) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) FDSimMathModelInfo(cbit.vcell.client.TopLevelWindowManager.FDSimMathModelInfo) OpenModelInfoHolder(cbit.vcell.client.TopLevelWindowManager.OpenModelInfoHolder) ActionEvent(java.awt.event.ActionEvent) DataFormatException(java.util.zip.DataFormatException) UserCancelException(org.vcell.util.UserCancelException) Geometry(cbit.vcell.geometry.Geometry) TreePath(javax.swing.tree.TreePath) FDSimBioModelInfo(cbit.vcell.client.TopLevelWindowManager.FDSimBioModelInfo)

Aggregations

ClientRequestManager (cbit.vcell.client.ClientRequestManager)1 RequestManager (cbit.vcell.client.RequestManager)1 FDSimBioModelInfo (cbit.vcell.client.TopLevelWindowManager.FDSimBioModelInfo)1 FDSimMathModelInfo (cbit.vcell.client.TopLevelWindowManager.FDSimMathModelInfo)1 OpenModelInfoHolder (cbit.vcell.client.TopLevelWindowManager.OpenModelInfoHolder)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 Geometry (cbit.vcell.geometry.Geometry)1 DataIdentifier (cbit.vcell.simdata.DataIdentifier)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 Hashtable (java.util.Hashtable)1 DataFormatException (java.util.zip.DataFormatException)1 JButton (javax.swing.JButton)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1 UserCancelException (org.vcell.util.UserCancelException)1 ExternalDataIdentifier (org.vcell.util.document.ExternalDataIdentifier)1 VCDocument (org.vcell.util.document.VCDocument)1 Version (org.vcell.util.document.Version)1