use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class NagiosVCellMonitor method checkVCell.
private CheckResults checkVCell(VCELL_CHECK_LEVEL checkLevel, String rmiHostName, int rmiPort, String rmiBootstrapStubName, String vcellNagiosPassword, int criticalTimeout, int monitorPort) throws Exception {
SimulationStatusPersistent lastSimStatus = null;
String vcellVersion = null;
TreeMap<VCELL_CHECK_LEVEL, Long> levelTimesMillisec = new TreeMap<NagiosVCellMonitor.VCELL_CHECK_LEVEL, Long>();
long startTime = System.currentTimeMillis();
VCellConnection vcellConnection = null;
try {
if (rmiHostName == null || rmiPort == -1) {
throw new UnexpectedTestStateException("Host name/ip and rmiPort required for testing, rmihostname=" + rmiHostName + " rmiport=" + rmiPort);
}
String rmiUrl = "//" + rmiHostName + ":" + rmiPort + "/" + rmiBootstrapStubName;
VCellBootstrap vcellBootstrap = null;
try {
vcellBootstrap = (VCellBootstrap) Naming.lookup(rmiUrl);
} catch (Exception e) {
throw new UnexpectedTestStateException("Error during bootstrap lookup, " + e.getClass().getSimpleName() + " " + e.getMessage());
}
vcellVersion = vcellBootstrap.getVCellSoftwareVersion();
levelTimesMillisec.put(VCELL_CHECK_LEVEL.RMI_ONLY_0, System.currentTimeMillis() - startTime);
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.CONNECT_1.ordinal()) {
if (vcellNagiosPassword == null) {
throw new UnexpectedTestStateException("vcellNagios Password required for " + VCELL_CHECK_LEVEL.CONNECT_1.toString() + " and above");
}
UserLoginInfo userLoginInfo = new UserLoginInfo(VCELL_NAGIOS_USER, new DigestedPassword(vcellNagiosPassword));
vcellConnection = vcellBootstrap.getVCellConnection(userLoginInfo);
levelTimesMillisec.put(VCELL_CHECK_LEVEL.CONNECT_1, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.RMI_ONLY_0));
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.INFOS_2.ordinal()) {
VCInfoContainer vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
levelTimesMillisec.put(VCELL_CHECK_LEVEL.INFOS_2, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.CONNECT_1));
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.LOAD_3.ordinal()) {
KeyValue bioModelKey = null;
final String testModelName = "Solver Suite 5.1 (BETA only ode)";
for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
if (userLoginInfo.getUserName().equals(bioModelInfo.getVersion().getOwner().getName()) && bioModelInfo.getVersion().getName().equals(testModelName)) {
bioModelKey = bioModelInfo.getVersion().getVersionKey();
break;
}
}
BigString bioModelXML = vcellConnection.getUserMetaDbServer().getBioModelXML(bioModelKey);
BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
bioModel.refreshDependencies();
levelTimesMillisec.put(VCELL_CHECK_LEVEL.LOAD_3, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.INFOS_2));
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.DATA_4.ordinal()) {
final String testSimContextName = "non-spatial ODE";
SimulationContext simulationContext = bioModel.getSimulationContext(testSimContextName);
final String testSimName = "Copy of combined ida/cvode";
Simulation simulation = simulationContext.getSimulation(testSimName);
if (simulation == null) {
throw new UnexpectedTestStateException("Couldn't find sim '" + testSimName + "' for " + checkLevel.toString());
}
VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
ArrayList<AnnotatedFunction> outputFunctionsList = simulationContext.getOutputFunctionContext().getOutputFunctionsList();
OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
double[] times = vcellConnection.getDataSetController().getDataSetTimes(vcSimulationDataIdentifier);
ODESimData odeSimData = vcellConnection.getDataSetController().getODEData(vcSimulationDataIdentifier);
levelTimesMillisec.put(VCELL_CHECK_LEVEL.DATA_4, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.LOAD_3));
if (checkLevel.ordinal() >= VCELL_CHECK_LEVEL.RUN_5.ordinal()) {
KeyValue copy1Key = null;
KeyValue copy2Key = null;
VCSimulationIdentifier testRunSimID = null;
try {
if (simulationContext.getSimulations().length != 1) {
throw new UnexpectedTestStateException("Expecting only 1 sim to be copied for " + checkLevel.toString());
}
SimulationStatusPersistent simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(simulation.getVersion().getVersionKey());
if (!simulationStatus.isCompleted()) {
throw new UnexpectedTestStateException("Expecting completed sim to copy for " + checkLevel.toString());
}
String copyModelName = testModelName + "_" + rmiHostName + "_rmi" + rmiPort + "_siteprt" + monitorPort;
boolean bForceCleanup = true;
while (true) {
boolean bMessy = false;
for (BioModelInfo bioModelInfo : vcInfoContainer.getBioModelInfos()) {
if (userLoginInfo.getUserName().equals(bioModelInfo.getVersion().getOwner().getName()) && bioModelInfo.getVersion().getName().equals(copyModelName)) {
bMessy = true;
if (bForceCleanup) {
try {
vcellConnection.getUserMetaDbServer().deleteBioModel(bioModelInfo.getVersion().getVersionKey());
} catch (Exception e) {
e.printStackTrace();
}
} else {
throw new MessyTestEnvironmentException("Messy test environment, not expecting " + copyModelName + " and couldn't cleanup");
}
}
}
if (!bMessy) {
break;
}
// get new vcInfoContainer without cleaned-up model
vcInfoContainer = vcellConnection.getUserMetaDbServer().getVCInfoContainer();
bForceCleanup = false;
}
BigString copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModelAs(bioModelXML, copyModelName, null);
BioModel copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
copy1Key = copyBioModel.getVersion().getVersionKey();
copyBioModel.refreshDependencies();
Simulation copySim = copyBioModel.getSimulationContext(testSimContextName).copySimulation(copyBioModel.getSimulationContext(testSimContextName).getSimulation(testSimName));
final String copyTestSimName = "test";
copySim.setName(copyTestSimName);
copyBioModel.refreshDependencies();
copyBioModelXMLStr = new BigString(XmlHelper.bioModelToXML(copyBioModel));
copyBioModelXMLStr = vcellConnection.getUserMetaDbServer().saveBioModel(copyBioModelXMLStr, null);
copyBioModel = XmlHelper.XMLToBioModel(new XMLSource(copyBioModelXMLStr.toString()));
copy2Key = copyBioModel.getVersion().getVersionKey();
copyBioModel.refreshDependencies();
Simulation newSimulation = copyBioModel.getSimulationContext(testSimContextName).getSimulation(copyTestSimName);
simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
if (simulationStatus != null && !simulationStatus.isNeverRan()) {
throw new UnexpectedTestStateException("Expecting new sim to have 'never ran' status for " + checkLevel.toString());
}
testRunSimID = new VCSimulationIdentifier(newSimulation.getVersion().getVersionKey(), copyBioModel.getVersion().getOwner());
vcellConnection.getSimulationController().startSimulation(testRunSimID, 1);
lastSimStatus = simulationStatus;
MessageEvent[] messageEvents = null;
while (simulationStatus == null || (!simulationStatus.isStopped() && !simulationStatus.isCompleted() && !simulationStatus.isFailed())) {
Thread.sleep(200);
if (((System.currentTimeMillis() - startTime) / 1000) > criticalTimeout) {
vcellConnection.getSimulationController().stopSimulation(testRunSimID);
vcellConnection.getMessageEvents();
break;
}
simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(newSimulation.getVersion().getVersionKey());
if (simulationStatus != null && !simulationStatus.toString().equals((lastSimStatus == null ? null : lastSimStatus.toString()))) {
lastSimStatus = simulationStatus;
}
if (simulationStatus != null && simulationStatus.isFailed()) {
throw new Exception("time " + ((System.currentTimeMillis() - startTime) / 1000) + ", Sim execution failed key:" + testRunSimID.getSimulationKey() + " sim " + newSimulation.getName() + " model " + copyBioModel.getVersion().getName() + " messg " + simulationStatus.getFailedMessage());
}
messageEvents = vcellConnection.getMessageEvents();
}
} finally {
try {
if (copy1Key != null) {
vcellConnection.getUserMetaDbServer().deleteBioModel(copy1Key);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (copy2Key != null) {
vcellConnection.getUserMetaDbServer().deleteBioModel(copy2Key);
}
} catch (Exception e) {
e.printStackTrace();
}
if (testRunSimID != null) {
deleteSimData(testRunSimID);
}
}
levelTimesMillisec.put(VCELL_CHECK_LEVEL.RUN_5, System.currentTimeMillis() - startTime - levelTimesMillisec.get(VCELL_CHECK_LEVEL.DATA_4));
}
}
}
}
}
return new CheckResults(vcellVersion, levelTimesMillisec, lastSimStatus, System.currentTimeMillis() - startTime, null);
} catch (Exception e) {
return new CheckResults(vcellVersion, levelTimesMillisec, lastSimStatus, System.currentTimeMillis() - startTime, e);
} finally {
vcellConnection = null;
}
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class SimulationWorkspace method showSimulationResults.
/**
* Comment
*/
void showSimulationResults(Simulation[] sims, ViewerType viewerType) {
ArrayList<AnnotatedFunction> outputFunctionsList = getSimulationOwner().getOutputFunctionContext().getOutputFunctionsList();
OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
getClientSimManager().showSimulationResults(outputContext, sims, viewerType);
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class FRAPStudyPanel method refreshPDEDisplay.
protected void refreshPDEDisplay(DisplayChoice choice) throws Exception {
Simulation sim = null;
FRAPStudy fStudy = getFrapWorkspace().getWorkingFrapStudy();
if (fStudy == null || fStudy.getBioModel() == null || fStudy.getBioModel().getSimulations() == null || fStudy.getBioModel().getSimulations().length < 1) {
return;
}
sim = fStudy.getBioModel().getSimulations()[0];
FieldFunctionArguments[] fieldFunctionArgs = FieldUtilities.getFieldFunctionArguments(sim.getMathDescription());
FieldDataIdentifierSpec[] fieldDataIdentifierSpecs = new FieldDataIdentifierSpec[fieldFunctionArgs.length];
for (int i = 0; i < fieldDataIdentifierSpecs.length; i++) {
fieldDataIdentifierSpecs[i] = new FieldDataIdentifierSpec(fieldFunctionArgs[i], fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier());
}
PDEDataViewer flourViewer = getFlourDataViewer();
PDEDataManager dataManager = null;
if (choice == DisplayChoice.EXTTIMEDATA) {
flourViewer.setSimulation(null);
flourViewer.setPdeDataContext(null);
flourViewer.setDataIdentifierFilter(new DataIdentifierFilter() {
private String ALL_DATAIDENTIFIERS = "All";
private String EXP_NORM_FLUOR = "Exp. Norm. Fluor";
private String SIM_NORM_FLUOR = "Sim. Norm. Fluor";
private String DEFAULT_VIEW = "Default View (more...)";
private String[] filterSetNames = new String[] { ALL_DATAIDENTIFIERS, EXP_NORM_FLUOR, SIM_NORM_FLUOR, DEFAULT_VIEW };
public boolean accept(String filterSetName, List<AnnotatedFunction> myFunctionList, DataIdentifier dataidentifier) {
if (filterSetName.equals(ALL_DATAIDENTIFIERS)) {
return true;
} else if (filterSetName.equals(EXP_NORM_FLUOR)) {
return dataidentifier.getName().indexOf(NORM_FLUOR_VAR) != -1;
} else if (filterSetName.equals(SIM_NORM_FLUOR)) {
boolean a = (dataidentifier.getName().indexOf(REACTION_RATE_PREFIX) == -1) && ((dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_COMBINED) != -1) || (dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_IMMOBILE) != -1) || (dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_MOBILE) != -1) || (dataidentifier.getName().indexOf(FRAPStudy.SPECIES_NAME_PREFIX_SLOW_MOBILE) != -1));
return a;
} else if (filterSetName.equals(DEFAULT_VIEW)) {
boolean a = (dataidentifier.getName().indexOf(REACTION_RATE_PREFIX) == -1) && ((dataidentifier.getName().indexOf(NORM_FLUOR_VAR) != -1) || (dataidentifier.getName().indexOf(NORM_SIM_VAR) != -1));
return a;
}
throw new IllegalArgumentException("DataIdentifierFilter: Unknown filterSetName " + filterSetName);
}
public String getDefaultFilterName() {
return DEFAULT_VIEW;
}
public String[] getFilterSetNames() {
return filterSetNames;
}
public boolean isAcceptAll(String filterSetName) {
return filterSetName.equals(ALL_DATAIDENTIFIERS);
}
@Override
public void setPostProcessingMode(boolean bPostProcessingMode) {
// TODO Auto-generated method stub
}
@Override
public boolean isPostProcessingMode() {
// TODO Auto-generated method stub
return false;
}
@Override
public ArrayList<DataIdentifier> accept(String filterSetName, List<AnnotatedFunction> myFunctionList, DataIdentifier[] dataidentifiers) {
if (filterSetName.equals(DEFAULT_VIEW)) {
ArrayList<DataIdentifier> dataIds = new ArrayList<>();
if (dataidentifiers != null) {
for (int i = 0; i < dataidentifiers.length; i++) {
dataIds.add(dataidentifiers[i]);
}
}
return dataIds;
}
throw new RuntimeException("Not Implemented for FRAP");
}
});
ExternalDataIdentifier timeSeriesExtDataID = fStudy.getFrapDataExternalDataInfo().getExternalDataIdentifier();
ExternalDataIdentifier maskExtDataID = fStudy.getRoiExternalDataInfo().getExternalDataIdentifier();
// add sim
int jobIndex = 0;
SimulationJob simJob = new SimulationJob(sim, jobIndex, fieldDataIdentifierSpecs);
// add function to display normalized fluorence data
Norm_Exp_Fluor = new Expression(Norm_Exp_Fluor_Str);
SimulationSymbolTable simSymbolTable = simJob.getSimulationSymbolTable();
if (// one diffusing component
simSymbolTable.getVariable(FRAPStudy.SPECIES_NAME_PREFIX_SLOW_MOBILE) == null) {
Norm_Sim = new Expression(Norm_Sim_One_Diff_Str);
} else // two diffusing components
{
Norm_Sim = new Expression(Norm_Sim_Two_Diff_Str);
}
AnnotatedFunction[] func = { new AnnotatedFunction(NORM_FLUOR_VAR, Norm_Exp_Fluor, null, null, VariableType.VOLUME, FunctionCategory.OLDUSERDEFINED), new AnnotatedFunction(NORM_SIM_VAR, Norm_Sim, null, null, VariableType.VOLUME, FunctionCategory.OLDUSERDEFINED) };
VCDataIdentifier[] dataIDs = new VCDataIdentifier[] { timeSeriesExtDataID, maskExtDataID, simJob.getVCDataIdentifier() };
VCDataIdentifier vcDataId = new MergedDataInfo(LocalWorkspace.getDefaultOwner(), dataIDs, FRAPStudy.VFRAP_DS_PREFIX);
outputContext = new OutputContext(func);
dataManager = new PDEDataManager(outputContext, getLocalWorkspace().getVCDataManager(), vcDataId);
ClientPDEDataContext pdeDataContext = new ClientPDEDataContext(dataManager);
pdeDataContext.refreshIdentifiers();
flourViewer.setSimulation(sim);
flourViewer.setPdeDataContext(pdeDataContext);
SimulationModelInfo simModelInfo = new SimulationWorkspaceModelInfo(fStudy.getBioModel().getSimulationContext(sim), sim.getName());
flourViewer.setSimulationModelInfo(simModelInfo);
getLocalWorkspace().getDataSetControllerImpl().addDataJobListener(flourViewer);
((VirtualFrapWindowManager) flourViewer.getDataViewerManager()).setLocalWorkSpace(getLocalWorkspace());
// do now show post data processing for VFRAP
flourViewer.setPostProcessingPanelVisible(false);
flourViewer.repaint();
}
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class ClientSimManager method runQuickSimulation.
public void runQuickSimulation(final Simulation originalSimulation, ViewerType viewerType) {
Collection<AsynchClientTask> taskList = new ArrayList<AsynchClientTask>();
final SimulationOwner simulationOwner = simWorkspace.getSimulationOwner();
// ----------- update math if it is from biomodel (simulationContext)
if (simulationOwner instanceof SimulationContext) {
Collection<AsynchClientTask> ut = ClientRequestManager.updateMath(documentWindowManager.getComponent(), ((SimulationContext) simulationOwner), false, NetworkGenerationRequirements.ComputeFullStandardTimeout);
taskList.addAll(ut);
}
// ----------- run simulation(s)
final File localSimDataDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
AsynchClientTask runSimTask = new AsynchClientTask("running simulation", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Simulation simulation = new TempSimulation(originalSimulation, false);
SimulationTask simTask = new SimulationTask(new SimulationJob(simulation, 0, null), 0);
Solver solver = createQuickRunSolver(localSimDataDir, simTask);
if (solver == null) {
throw new RuntimeException("null solver");
}
// check if spatial stochastic simulation (smoldyn solver) has data processing instructions with field data - need to access server for field data, so cannot do local simulation run.
if (solver instanceof SmoldynSolver) {
DataProcessingInstructions dpi = simulation.getDataProcessingInstructions();
if (dpi != null) {
FieldDataIdentifierSpec fdis = dpi.getSampleImageFieldData(simulation.getVersion().getOwner());
if (fdis != null) {
throw new RuntimeException("Spatial Stochastic simulation '" + simulation.getName() + "' (Smoldyn solver) with field data (in data processing instructions) cannot be run locally at this time since field data needs to be retrieved from the VCell server.");
}
}
}
solver.addSolverListener(new SolverListener() {
public void solverStopped(SolverEvent event) {
getClientTaskStatusSupport().setMessage(event.getSimulationMessage().getDisplayMessage());
}
public void solverStarting(SolverEvent event) {
String displayMessage = event.getSimulationMessage().getDisplayMessage();
System.out.println(displayMessage);
getClientTaskStatusSupport().setMessage(displayMessage);
if (displayMessage.equals(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT.getDisplayMessage())) {
getClientTaskStatusSupport().setProgress(75);
} else if (displayMessage.equals(SimulationMessage.MESSAGE_SOLVER_RUNNING_INPUT_FILE.getDisplayMessage())) {
getClientTaskStatusSupport().setProgress(90);
}
}
public void solverProgress(SolverEvent event) {
getClientTaskStatusSupport().setMessage("Running...");
int progress = (int) (event.getProgress() * 100);
getClientTaskStatusSupport().setProgress(progress);
}
public void solverPrinted(SolverEvent event) {
getClientTaskStatusSupport().setMessage("Running...");
}
public void solverFinished(SolverEvent event) {
getClientTaskStatusSupport().setMessage(event.getSimulationMessage().getDisplayMessage());
}
public void solverAborted(SolverEvent event) {
getClientTaskStatusSupport().setMessage(event.getSimulationMessage().getDisplayMessage());
}
});
solver.startSolver();
while (true) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
if (getClientTaskStatusSupport().isInterrupted()) {
solver.stopSolver();
throw UserCancelException.CANCEL_GENERIC;
}
SolverStatus solverStatus = solver.getSolverStatus();
if (solverStatus != null) {
if (solverStatus.getStatus() == SolverStatus.SOLVER_ABORTED) {
throw new RuntimeException(solverStatus.getSimulationMessage().getDisplayMessage());
}
if (solverStatus.getStatus() != SolverStatus.SOLVER_STARTING && solverStatus.getStatus() != SolverStatus.SOLVER_READY && solverStatus.getStatus() != SolverStatus.SOLVER_RUNNING) {
break;
}
}
}
ArrayList<AnnotatedFunction> outputFunctionsList = getSimWorkspace().getSimulationOwner().getOutputFunctionContext().getOutputFunctionsList();
OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
Simulation[] simsArray = new Simulation[] { simulation };
hashTable.put("outputContext", outputContext);
hashTable.put("simsArray", simsArray);
}
};
taskList.add(runSimTask);
// --------- add tasks from showSimResults : retrieve data, display results
AsynchClientTask[] showResultsTask = showSimulationResults0(true, viewerType);
for (AsynchClientTask task : showResultsTask) {
taskList.add(task);
}
// ------- dispatch
AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()];
taskList.toArray(taskArray);
ClientTaskDispatcher.dispatch(documentWindowManager.getComponent(), new Hashtable<String, Object>(), taskArray, true, true, null);
}
use of cbit.vcell.simdata.OutputContext in project vcell by virtualcell.
the class FieldDataWindowManager method viewData.
public void viewData(final ExternalDataIdentifier eDI) {
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
if (eDI != null && eDI.equals(currentlyViewedEDI) && childWindowManager != null && childWindowManager.getChildWindowFromContext(eDI) != null) {
childWindowManager.getChildWindowFromContext(eDI).show();
} else {
if (currentlyViewedOutputFunctionViewer != null) {
if (getLocalRequestManager() != null && getLocalRequestManager().getAsynchMessageManager() != null) {
getLocalRequestManager().getAsynchMessageManager().removeDataJobListener(currentlyViewedOutputFunctionViewer.getPDEDataViewer());
}
if (currentlyViewedOutputFunctionViewer != null) {
currentlyViewedOutputFunctionViewer.getPDEDataViewer().getPdeDataContext().removePropertyChangeListener(this);
}
}
if (currentlyViewedOutputFunctionViewer != null) {
ChildWindow childWindow = childWindowManager.getChildWindowFromContext(eDI);
if (childWindow != null) {
childWindow.close();
}
}
currentlyViewedEDI = null;
currentlyViewedOutputFunctionViewer = null;
if (eDI == null) {
return;
}
AsynchClientTask task1 = new AsynchClientTask("retrieve data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
ClientPDEDataContext newPDEDataContext = getPDEDataContext(eDI, new OutputContext(new AnnotatedFunction[0]));
hashTable.put("newPDEDataContext", newPDEDataContext);
}
};
AsynchClientTask task2 = new AsynchClientTask("show data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
try {
PDEDataViewer currentlyViewedPDEDV = new PDEDataViewer();
ClientPDEDataContext newPDEDataContext = (ClientPDEDataContext) hashTable.get("newPDEDataContext");
currentlyViewedPDEDV.setPdeDataContext(newPDEDataContext);
newPDEDataContext.addPropertyChangeListener(FieldDataWindowManager.this);
getLocalRequestManager().getAsynchMessageManager().addDataJobListener(currentlyViewedPDEDV);
currentlyViewedOutputFunctionViewer = new OutputFunctionViewer(currentlyViewedPDEDV, FieldDataWindowManager.this, eDI);
DataViewerManager dvm = new DataViewerManager() {
public void dataJobMessage(DataJobEvent event) {
}
public void exportMessage(ExportEvent event) {
}
public void addDataListener(DataListener newListener) {
}
public UserPreferences getUserPreferences() {
return getRequestManager().getUserPreferences();
}
public void removeDataListener(DataListener newListener) {
}
public void startExport(Component requester, OutputContext outputContext, ExportSpecs exportSpecs) {
getLocalRequestManager().startExport(outputContext, requester, exportSpecs);
}
public void simStatusChanged(SimStatusEvent simStatusEvent) {
}
public User getUser() {
return getRequestManager().getDocumentManager().getUser();
}
public RequestManager getRequestManager() {
return FieldDataWindowManager.this.getRequestManager();
}
};
try {
currentlyViewedPDEDV.setDataViewerManager(dvm);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getComponent());
currentlyViewedEDI = eDI;
ChildWindow childWindow = childWindowManager.addChildWindow(currentlyViewedOutputFunctionViewer, currentlyViewedEDI, "Field Data Viewer (" + eDI.getName() + ")");
childWindow.setSize(600, 500);
childWindow.setIsCenteredOnParent();
childWindow.show();
} catch (Exception e) {
if (currentlyViewedOutputFunctionViewer != null) {
if (getLocalRequestManager() != null && getLocalRequestManager().getAsynchMessageManager() != null) {
getLocalRequestManager().getAsynchMessageManager().removeDataJobListener(currentlyViewedOutputFunctionViewer.getPDEDataViewer());
}
if (currentlyViewedOutputFunctionViewer != null) {
currentlyViewedOutputFunctionViewer.getPDEDataViewer().getPdeDataContext().removePropertyChangeListener(FieldDataWindowManager.this);
}
}
throw e;
}
}
};
ClientTaskDispatcher.dispatch(this.getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 }, false);
}
}
Aggregations