use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class SimResultsViewerController method propertyChange.
public void propertyChange(PropertyChangeEvent evt) {
// update functions
if (simResultsViewer != null && evt.getPropertyName().equals("outputFunctions")) {
try {
ArrayList<AnnotatedFunction> outputFunctionsList = (ArrayList<AnnotatedFunction>) evt.getNewValue();
dataManager.setOutputContext(new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()])));
simResultsViewer.refreshFunctions();
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(simResultsViewer, "Failed to update viewer after function change: " + e.getMessage(), e);
}
}
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class TestingFrameworkWindowManager method compare.
/**
* Insert the method's description here.
* Creation date: (1/20/2003 11:52:18 AM)
* @return boolean
* @param mathDesc cbit.vcell.math.MathDescription
*/
public void compare(final TestCriteriaNew testCriteria, final SimulationInfo userDefinedRegrSimInfo) {
final String KEY_MERGEDDATAINFO = "KEY_MERGEDDATAINFO";
final String KEY_MERGEDDATASETVIEWERCNTRLR = "KEY_MERGEDDATASETVIEWERCNTRLR";
AsynchClientTask gatherDataTask = new AsynchClientTask("Gathering compare Dta...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// create the merged data for the simulationInfo in testCriteria and the regression simInfo
SimulationInfo simInfo = testCriteria.getSimInfo();
SimulationInfo regrSimInfo = null;
if (userDefinedRegrSimInfo != null) {
regrSimInfo = userDefinedRegrSimInfo;
} else {
regrSimInfo = testCriteria.getRegressionSimInfo();
}
if (regrSimInfo == null) {
return;
}
VCDataIdentifier vcSimId1 = new VCSimulationDataIdentifier(simInfo.getAuthoritativeVCSimulationIdentifier(), 0);
VCDataIdentifier vcSimId2 = new VCSimulationDataIdentifier(regrSimInfo.getAuthoritativeVCSimulationIdentifier(), 0);
User user = simInfo.getOwner();
VCDataIdentifier[] vcIdentifierArray = new VCDataIdentifier[] { vcSimId2, vcSimId1 };
MergedDataInfo mergedDataInfo = new MergedDataInfo(user, vcIdentifierArray, MergedDataInfo.createDefaultPrefixNames(vcIdentifierArray.length));
hashTable.put(KEY_MERGEDDATAINFO, mergedDataInfo);
// get the data manager and wire it up
//
// get all "Data1.XXX" data identifiers ... and remove those which are functions
// add functions of the form DIFF_XXX = (Data1.XXX - Data2.XXX) for convenience in comparing results.
//
Simulation sim1 = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(simInfo);
Simulation sim2 = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(regrSimInfo);
boolean isSpatial = sim1.isSpatial();
if (sim2.isSpatial() != isSpatial) {
throw new RuntimeException("Cannot compare spatial and non-spatial data sets : " + simInfo + "& " + regrSimInfo);
}
DataManager mergedDataManager = getRequestManager().getDataManager(null, mergedDataInfo, isSpatial);
DataManager data1Manager = getRequestManager().getDataManager(null, vcSimId1, isSpatial);
DataManager data2Manager = getRequestManager().getDataManager(null, vcSimId2, isSpatial);
Vector<AnnotatedFunction> functionList = new Vector<AnnotatedFunction>();
AnnotatedFunction[] data1Functions = data1Manager.getFunctions();
AnnotatedFunction[] existingFunctions = mergedDataManager.getFunctions();
DataIdentifier[] data1Identifiers = data1Manager.getDataIdentifiers();
DataIdentifier[] data2Identifiers = data2Manager.getDataIdentifiers();
for (int i = 0; i < data1Identifiers.length; i++) {
//
// make sure dataIdentifier is not already a function
//
boolean bIsFunction = false;
for (int j = 0; j < data1Functions.length; j++) {
if (data1Identifiers[i].getName().equals(data1Functions[j].getName())) {
bIsFunction = true;
}
}
if (bIsFunction) {
continue;
}
//
// make sure corresponding identifier exists in "Data2"
//
boolean bIsInData2 = false;
for (int j = 0; j < data2Identifiers.length; j++) {
if (data2Identifiers[j].getName().equals(data1Identifiers[i].getName())) {
bIsInData2 = true;
}
}
if (!bIsInData2) {
continue;
}
//
// create "Diff" function
//
String data1Name = "Data1." + data1Identifiers[i].getName();
String data2Name = "Data2." + data1Identifiers[i].getName();
String functionName = "DIFF_" + data1Identifiers[i].getName();
VariableType varType = data1Identifiers[i].getVariableType();
Expression exp = new Expression(data1Name + "-" + data2Name);
AnnotatedFunction newFunction = new AnnotatedFunction(functionName, exp, data1Identifiers[i].getDomain(), "", varType, FunctionCategory.OUTPUTFUNCTION);
//
// make sure new "Diff" function isn't already in existing function list.
//
boolean bDiffFunctionAlreadyHere = false;
for (int j = 0; j < existingFunctions.length; j++) {
if (newFunction.getName().equals(existingFunctions[j].getName())) {
bDiffFunctionAlreadyHere = true;
}
}
if (bDiffFunctionAlreadyHere) {
continue;
}
functionList.add(newFunction);
}
OutputContext outputContext = null;
if (functionList.size() > 0) {
AnnotatedFunction[] newDiffFunctions = (AnnotatedFunction[]) BeanUtils.getArray(functionList, AnnotatedFunction.class);
outputContext = new OutputContext(newDiffFunctions);
}
MergedDatasetViewerController mergedDatasetViewerCtr = getRequestManager().getMergedDatasetViewerController(outputContext, mergedDataInfo, !isSpatial);
hashTable.put(KEY_MERGEDDATASETVIEWERCNTRLR, mergedDatasetViewerCtr);
}
};
AsynchClientTask showResultsTask = new AsynchClientTask("Showing Compare Results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
// make the viewer
MergedDatasetViewerController mergedDatasetViewerCtr = (MergedDatasetViewerController) hashTable.get(KEY_MERGEDDATASETVIEWERCNTRLR);
addDataListener(mergedDatasetViewerCtr);
DataViewer viewer = mergedDatasetViewerCtr.createViewer();
viewer.setDataViewerManager(TestingFrameworkWindowManager.this);
addExportListener(viewer);
VCDataIdentifier vcDataIdentifier = (MergedDataInfo) hashTable.get(KEY_MERGEDDATAINFO);
ChildWindowManager childWindowManager = TFWFinder.findChildWindowManager(getComponent());
ChildWindow childWindow = childWindowManager.addChildWindow(viewer, vcDataIdentifier, "Comparing ... " + vcDataIdentifier.getID());
childWindow.pack();
// childWindow.setSize(450, 450);
childWindow.setIsCenteredOnParent();
childWindow.show();
}
};
ClientTaskDispatcher.dispatch(getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { gatherDataTask, showResultsTask }, false);
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class PDEDataViewer method createMultiTimePlotHelper.
// private static class MultiTimePointPropChangeListener implements PropertyChangeListener {
// @Override
// public void propertyChange(PropertyChangeEvent evt) {
// }
// }
private MultiTimePlotHelper createMultiTimePlotHelper(final ClientPDEDataContext copyThisPDEDatacontext, final User user, DataSymbolMetadataResolver argDataSymbolMetadataResolver) throws Exception {
final ClientPDEDataContext[] copyHolder = new ClientPDEDataContext[1];
if (PDEDataViewer.this.isPostProcess()) {
copyHolder[0] = PDEDataViewerPostProcess.createPostProcessPDEDataContext(copyThisPDEDatacontext);
} else {
copyHolder[0] = (ClientPDEDataContext) ((PDEDataManager) copyThisPDEDatacontext.getDataManager()).createNewPDEDataManager(copyThisPDEDatacontext.getVCDataIdentifier(), null).getPDEDataContext();
}
copyHolder[0].setVariableAndTime(copyThisPDEDatacontext.getDataIdentifier(), copyThisPDEDatacontext.getTimePoint());
return new PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper() {
private DataSymbolMetadataResolver dataSymbolMetadataResolver = argDataSymbolMetadataResolver;
private ArrayList<PropertyChangeListener> myPropertyChangeHolder = new ArrayList<>();
private ClientPDEDataContext myPdeDataContext = copyHolder[0];
private VariableType myVariableType = copyThisPDEDatacontext.getDataIdentifier().getVariableType();
// catch events from 'this' PDEDataViewer and pass with new source
private PropertyChangeListener myPropertyChangeListener;
private User myUser = user;
// List<AnnotatedFunction> myAnnots;
// access to anonymous outer class
private PdeTimePlotMultipleVariablesPanel.MultiTimePlotHelper multiTimePlotHelperThis = this;
private PDEPlotControlPanel.IdentifierListCellRenderer myListCellRenderer;
private AnnotatedFunction[] lastAnnotatedFunctions;
private PDEPlotControlPanel.FunctionListProvider functionListProvider = new PDEPlotControlPanel.FunctionListProvider() {
@Override
public List<AnnotatedFunction> getAnnotatedFunctions() {
if (myPdeDataContext.getDataManager().getOutputContext() != null && myPdeDataContext.getDataManager().getOutputContext().getOutputFunctions() != null && myPdeDataContext.getDataManager().getOutputContext().getOutputFunctions().length > 0) {
return new ArrayList<>(Arrays.asList(myPdeDataContext.getDataManager().getOutputContext().getOutputFunctions()));
}
return new ArrayList<>();
}
};
private Comparator<AnnotatedFunction> nameComparator = new Comparator<AnnotatedFunction>() {
@Override
public int compare(AnnotatedFunction o1, AnnotatedFunction o2) {
return o2.getName().compareToIgnoreCase(o1.getName());
}
};
@Override
public void removeDataJobListener(DataJobListener dataJobListener) {
PDEDataViewer.this.removeDataJobListener(dataJobListener);
}
@Override
public void addDataJobListener(DataJobListener dataJobListener) {
PDEDataViewer.this.addDataJobListener(dataJobListener);
}
@Override
public User getUser() {
return myUser;
}
@Override
public PDEDataContext getPdeDatacontext() {
return myPdeDataContext;
}
@Override
public DataIdentifier[] getCopyOfDisplayedDataIdentifiers() {
DataIdentifier[] newData = PDEDataViewer.this.getPDEPlotControlPanel1().getDataIdentifierFilter().accept(DefaultDataIdentifierFilter.ALL, functionListProvider.getAnnotatedFunctions(), myPdeDataContext.getDataIdentifiers()).toArray(new DataIdentifier[0]);
return DataIdentifier.collectSortedSimilarDataTypes(this.getVariableType(), newData);
}
@Override
public PDEPlotControlPanel.IdentifierListCellRenderer getListCellRenderer() {
if (myListCellRenderer == null) {
myListCellRenderer = new PDEPlotControlPanel.IdentifierListCellRenderer(functionListProvider);
}
return myListCellRenderer;
}
@Override
public Simulation getsimulation() {
return PDEDataViewer.this.getSimulation();
}
private List<AnnotatedFunction> efficiencyFilter(List<AnnotatedFunction> funcs) {
ArrayList<AnnotatedFunction> outputfunctions = new ArrayList<>();
Iterator<AnnotatedFunction> iter = funcs.iterator();
while (iter.hasNext()) {
AnnotatedFunction theFunc = iter.next();
if ((isPostProcess() && theFunc.getFunctionType().equals(VariableType.POSTPROCESSING)) || (!isPostProcess() && !theFunc.getFunctionType().equals(VariableType.POSTPROCESSING))) {
outputfunctions.add(theFunc);
}
}
return outputfunctions;
}
@Override
public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener) {
myPropertyChangeHolder.add(propertyChangeListener);
if (myPropertyChangeListener == null) {
myPropertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == PDEDataViewer.this && evt.getPropertyName().equals(PDEDataContext.PROP_PDE_DATA_CONTEXT)) {
// List<AnnotatedFunction> currentOutputFunctions = functionListProvider.getAnnotatedFunctions();
// currentOutputFunctions = efficiencyFilter(currentOutputFunctions);
// currentOutputFunctions.sort(nameComparator);
List<AnnotatedFunction> newOutputFunctions0 = Arrays.asList(((ClientPDEDataContext) PDEDataViewer.this.getPdeDataContext()).getDataManager().getOutputContext().getOutputFunctions());
List<AnnotatedFunction> newOutputFunctions = efficiencyFilter(newOutputFunctions0);
newOutputFunctions.sort(nameComparator);
if (lastAnnotatedFunctions != null && Compare.isEqualOrNullStrict(lastAnnotatedFunctions, newOutputFunctions.toArray(new AnnotatedFunction[0]))) {
return;
}
lastAnnotatedFunctions = new AnnotatedFunction[newOutputFunctions.size()];
for (int i = 0; i < newOutputFunctions.size(); i++) {
lastAnnotatedFunctions[i] = new AnnotatedFunction(newOutputFunctions.get(i));
}
// lastAnnotatedFunctions = newOutputFunctions0.toArray(new AnnotatedFunction[0]);
myPdeDataContext.getDataManager().setOutputContext(new OutputContext(newOutputFunctions0.toArray(new AnnotatedFunction[0])));
myPdeDataContext.refreshIdentifiers();
for (int i = 0; i < myPropertyChangeHolder.size(); i++) {
myPropertyChangeHolder.get(i).propertyChange(new PropertyChangeEvent(multiTimePlotHelperThis, SimDataConstants.PROPERTY_NAME_DATAIDENTIFIERS, null, null));
}
}
}
};
PDEDataViewer.this.addPropertyChangeListener(myPropertyChangeListener);
}
}
@Override
public void removeallPropertyChangeListeners() {
myPropertyChangeHolder.clear();
if (myPropertyChangeListener != null) {
PDEDataViewer.this.removePropertyChangeListener(myPropertyChangeListener);
}
}
@Override
public VariableType getVariableType() {
return myVariableType;
}
// @Override
// public void addExtraTasks(AsynchClientTask[] moreTasks) {
// PDEDataViewer.this.addExtraTasks(moreTasks);
// }
@Override
public DataSymbolMetadataResolver getDataSymbolMetadataResolver() {
return dataSymbolMetadataResolver;
}
};
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class PDEExportDataPanel method startExport.
/**
* Comment
*/
private void startExport() {
if (getExportSettings1().getSelectedFormat() == ExportFormat.QUICKTIME && getJSlider1().getValue() == getJSlider2().getValue()) {
DialogUtils.showWarningDialog(this, "User selected 'begin' and 'end' export times are the same. 'Movie' export format 'begin' and 'end' times must be different");
return;
}
DisplayPreferences[] displayPreferences = null;
@SuppressWarnings("deprecation") Object[] variableSelections = getJListVariables().getSelectedValues();
boolean selectionHasVolumeVariables = false;
boolean selectionHasMembraneVariables = false;
switch(getExportSettings1().getSelectedFormat()) {
case PLY:
case QUICKTIME:
case GIF:
case FORMAT_JPEG:
case ANIMATED_GIF:
{
displayPreferences = new DisplayPreferences[variableSelections.length];
StringBuffer noScaleInfoNames = new StringBuffer();
for (int i = 0; i < displayPreferences.length; i++) {
BitSet domainValid = null;
try {
if (dataInfoProvider != null) {
DataIdentifier varSelectionDataIdnetDataIdentifier = null;
for (int j = 0; j < dataInfoProvider.getPDEDataContext().getDataIdentifiers().length; j++) {
if (dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j].getName().equals(variableSelections[i])) {
varSelectionDataIdnetDataIdentifier = dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j];
}
}
if (varSelectionDataIdnetDataIdentifier != null) {
selectionHasVolumeVariables = selectionHasVolumeVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.POSTPROCESSING) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME_REGION);
selectionHasMembraneVariables = selectionHasMembraneVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE_REGION);
CartesianMesh cartesianMesh = dataInfoProvider.getPDEDataContext().getCartesianMesh();
int dataLength = cartesianMesh.getDataLength(varSelectionDataIdnetDataIdentifier.getVariableType());
domainValid = new BitSet(dataLength);
domainValid.clear();
for (int j = 0; j < dataLength; j++) {
if (dataInfoProvider.isDefined(varSelectionDataIdnetDataIdentifier, j)) {
domainValid.set(j);
}
}
} else {
throw new Exception("No DataIdentifer found for variable name '" + variableSelections[i] + "'");
}
}
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "Error during domain evaluation:\n" + e.getMessage());
return;
}
displayPreferences[i] = new DisplayPreferences(getDisplayAdapterService().getDisplayPreferences((String) variableSelections[i]), domainValid);
if (!getDisplayAdapterService().hasStateID((String) variableSelections[i])) {
noScaleInfoNames.append("--- " + (String) variableSelections[i] + "\n");
}
}
break;
}
case CSV:
{
// check for membrane variables... warn for 3D geometry...
// one gets the whole nine yards by index, not generally useful... except for a few people like Boris :)
boolean mbVars = false;
DataIdentifier[] dataIDs = getPdeDataContext().getDataIdentifiers();
for (int i = 0; i < variableSelections.length; i++) {
String varName = (String) variableSelections[i];
for (int j = 0; j < dataIDs.length; j++) {
if (dataIDs[j].getName().equals(varName) && dataIDs[j].getVariableType().equals(VariableType.MEMBRANE)) {
mbVars = true;
break;
}
}
}
if (mbVars && getPdeDataContext().getCartesianMesh().getGeometryDimension() == 3 && getJRadioButtonSlice().isSelected()) {
String choice = PopupGenerator.showWarningDialog(this, getDataViewerManager().getUserPreferences(), UserMessage.warn_exportMembraneData3D, null);
if (choice.equals(UserMessage.OPTION_CANCEL)) {
// user canceled
return;
}
}
getExportSettings1().setSimulationSelector(createSimulationSelector());
getExportSettings1().setIsCSVExport(true);
break;
}
case NRRD:
case IMAGEJ:
case UCD:
case VTK_IMAGE:
case VTK_UNSTRUCT:
break;
default:
break;
}
;
if (getJRadioButtonROI().isSelected() && getROISelections().getSelectedIndex() == -1) {
PopupGenerator.showErrorDialog(this, "To export selections, you must select at least one item from the ROI selection list");
}
getExportSettings1().setTimeSpecs(new TimeSpecs(getJSlider1().getValue(), getJSlider2().getValue(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE));
getExportSettings1().setDisplayPreferences(displayPreferences, Arrays.asList(variableSelections).toArray(new String[0]), viewZoom);
getExportSettings1().setSliceCount(FormatSpecificSpecs.getSliceCount(getJRadioButtonFull().isSelected(), getNormalAxis(), getPdeDataContext().getCartesianMesh()));
getExportSettings1().setImageSizeCalculationInfo(getPdeDataContext().getCartesianMesh(), getNormalAxis());
getExportSettings1().setIsSmoldyn(isSmoldyn);
ExportFormat format = getSelectedFormat();
if (format.equals(ExportFormat.PLY)) {
getExportSettings1().setFormatSpecificSpecs(new PLYSpecs(true, displayPreferences));
}
if (format.requiresFollowOn()) {
Frame theFrame = JOptionPane.getFrameForComponent(this);
boolean okToExport = getExportSettings1().showFormatSpecificDialog(theFrame, selectionHasVolumeVariables, selectionHasMembraneVariables);
if (!okToExport) {
return;
}
}
if (format.equals(ExportFormat.IMAGEJ)) {
// export nrrd for imagej direct, the we'll send to imagej from vcell client
getExportSettings1().setFormatSpecificSpecs(new RasterSpecs(ExportConstants.NRRD_SINGLE, false));
}
// determine of sim result is from local (quick) run or on server.
final OutputContext outputContext = ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext();
final ExportSpecs exportSpecs = getExportSpecs();
boolean isLocalSimResult = false;
VCDataIdentifier vcId = exportSpecs.getVCDataIdentifier();
if (vcId instanceof LocalVCDataIdentifier) {
isLocalSimResult = true;
}
// find out if smoldyn export choice is 'particle' - not available at this time
boolean isParticle = false;
if (getExportSettings1().getFormatSpecificSpecs() instanceof ImageSpecs) {
isParticle = ((ImageSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
} else if (getExportSettings1().getFormatSpecificSpecs() instanceof MovieSpecs) {
isParticle = ((MovieSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
}
if (isLocalSimResult && isParticle) {
DialogUtils.showErrorDialog(this, "Particle export for Smoldyn particles unavailable in local data at this time.");
return;
}
// pass the export request down the line; non-blocking call
if (!isLocalSimResult) {
// for sims that ran on server, do as before.
getDataViewerManager().startExport(this, outputContext, exportSpecs);
} else {
final String SOURCE_FILE_KEY = "SOURCE_FILE_KEY";
final String DESTINATION_FILE_KEY = "DEESTINATION_FILE_KEY";
AsynchClientTask localExportTast = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
try {
File primaryDir = ResourceUtil.getLocalRootDir();
User usr = User.tempUser;
File usrDir = new File(primaryDir.getAbsolutePath(), usr.getName());
System.setProperty(PropertyLoader.exportBaseDirInternalProperty, usrDir.getAbsolutePath() + File.separator);
System.setProperty(PropertyLoader.exportBaseURLProperty, usrDir.toURI().toURL().toString());
DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, localExportServiceImpl);
ExportEvent localExportEvent = dataServerImpl.makeRemoteFile(outputContext, usr, exportSpecs);
File sourceFile = new File(usrDir, new File((new URL(localExportEvent.getLocation()).getPath())).getName());
hashTable.put(SOURCE_FILE_KEY, sourceFile);
} catch (Exception e) {
throw new Exception("Unable to export local sim results data : " + e.getMessage(), e);
}
}
};
AsynchClientTask localSaveTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setSelectedFile(new File(sourceFile.getName()));
if (jFileChooser.showSaveDialog(PDEExportDataPanel.this) == JFileChooser.APPROVE_OPTION) {
File destinationFile = jFileChooser.getSelectedFile();
if (destinationFile.exists()) {
final String OVERWRITE = "Overwrite";
final String CANCEL = "Cancel";
String response = DialogUtils.showWarningDialog(PDEExportDataPanel.this, "OK to Overwrite " + destinationFile.getAbsolutePath() + "?", new String[] { OVERWRITE, CANCEL }, OVERWRITE);
if (response == null || !response.equals(OVERWRITE)) {
return;
}
}
hashTable.put(DESTINATION_FILE_KEY, destinationFile);
}
}
};
AsynchClientTask localDeleteTempTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, false, false) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
File destinationFile = (File) hashTable.get(DESTINATION_FILE_KEY);
if (sourceFile != null && sourceFile.exists()) {
try {
if (destinationFile != null) {
copyFile(sourceFile, destinationFile);
}
} finally {
sourceFile.delete();
}
}
}
};
ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { localExportTast, localSaveTask, localDeleteTempTask }, false, true, null);
}
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class VCellClientDataServiceImpl method displayPostProcessingDataInVCell.
@Override
public void displayPostProcessingDataInVCell(SimulationDataSetRef simulationDataSetRef) throws NumberFormatException, DataAccessException {
User vcUser = vcellClient.getRequestManager().getDocumentManager().getUser();
VCSimulationIdentifier vcSimId = new VCSimulationIdentifier(new KeyValue(simulationDataSetRef.getSimId()), vcUser);
ClientDocumentManager clientDocumentManager = (ClientDocumentManager) vcellClient.getClientServerManager().getDocumentManager();
SimulationOwner simulationOwner = null;
if (simulationDataSetRef.isMathModel) {
simulationOwner = clientDocumentManager.getMathModel(new KeyValue(simulationDataSetRef.getModelId()));
} else {
BioModel bioModel = clientDocumentManager.getBioModel(new KeyValue(simulationDataSetRef.getModelId()));
simulationOwner = bioModel.getSimulationContext(simulationDataSetRef.getSimulationContextName());
}
ArrayList<AnnotatedFunction> outputFunctionsList = simulationOwner.getOutputFunctionContext().getOutputFunctionsList();
OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
VCSimulationDataIdentifier vcSimDataId = new VCSimulationDataIdentifier(vcSimId, simulationDataSetRef.getJobIndex());
PDEDataManager pdeDataManager = (PDEDataManager) vcellClient.getRequestManager().getDataManager(outputContext, vcSimDataId, true);
final ClientPDEDataContext newClientPDEDataContext = pdeDataManager.getPDEDataContext();
// this was the code before the windows refactoring; appears to just always get the first window???
// Enumeration<TopLevelWindowManager> windowManagers = vcellClient.getMdiManager().getWindowManagers();
// final Window window = FindWindow.getWindow(windowManagers.nextElement().getComponent());
Optional<TopLevelWindowManager> first = vcellClient.getMdiManager().getWindowManagers().stream().findFirst();
VCAssert.assertTrue(first.isPresent(), "window manager not present?");
final Window window = getWindow(first.get().getComponent());
AsynchClientTask task = new AsynchClientTask("Display Post Processing Statistics", AsynchClientTask.TASKTYPE_SWING_NONBLOCKING, false, false) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
DataProcessingResultsPanel dataProcessingResultsPanel = new DataProcessingResultsPanel();
dataProcessingResultsPanel.update(newClientPDEDataContext);
DialogUtils.showComponentOKCancelDialog(window, dataProcessingResultsPanel, "Post Processing Statistics");
}
};
Hashtable<String, Object> hash = new Hashtable<String, Object>();
Vector<AsynchClientTask> tasksV = new Vector<AsynchClientTask>();
tasksV.add(task);
AsynchClientTask[] tasks = new AsynchClientTask[tasksV.size()];
tasksV.copyInto(tasks);
ClientTaskDispatcher.dispatch(window, hash, tasks, true);
}
Aggregations