use of cbit.vcell.client.server.SimStatusEvent in project vcell by virtualcell.
the class DisplayTimeSeriesOp method displayImageTimeSeries.
public void displayImageTimeSeries(final ImageTimeSeries<? extends Image> imageTimeSeries, final String title, final WindowListener windowListener) throws ImageException, IOException {
try {
System.out.println("starting to prepare data for time series viewing");
final PDEDataViewer pdeDataViewer = new PDEDataViewer();
DataSetControllerProvider dataSetControllerProvider;
try {
dataSetControllerProvider = getDataSetControllerProvider(imageTimeSeries, pdeDataViewer);
} catch (ImageException | IOException e1) {
e1.printStackTrace();
throw new RuntimeException(e1.getMessage(), e1);
}
VCDataManager vcDataManager = new VCDataManager(dataSetControllerProvider);
OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]);
final VCDataIdentifier vcDataIdentifier = new VCDataIdentifier() {
public User getOwner() {
return new User("nouser", null);
}
public KeyValue getDataKey() {
return null;
}
public String getID() {
return "mydata";
}
};
PDEDataManager pdeDataManager = new PDEDataManager(outputContext, vcDataManager, vcDataIdentifier);
final ClientPDEDataContext myPdeDataContext = new ClientPDEDataContext(pdeDataManager);
final RequestManager requestManager = new RequestManagerAdapter() {
};
final DataViewerManager dataViewerManager = new DataViewerManager() {
public void dataJobMessage(DataJobEvent event) {
}
public void exportMessage(ExportEvent event) {
}
public void addDataListener(DataListener newListener) {
}
public UserPreferences getUserPreferences() {
// getRequestManager().getUserPreferences();
return null;
}
public void removeDataListener(DataListener newListener) {
}
public void startExport(Component requester, OutputContext outputContext, ExportSpecs exportSpecs) {
// getLocalRequestManager().startExport(outputContext, FieldDataWindowManager.this, exportSpecs);
}
public void simStatusChanged(SimStatusEvent simStatusEvent) {
}
public User getUser() {
return new User("dummy", new KeyValue("123"));
// return getRequestManager().getDocumentManager().getUser();
}
public RequestManager getRequestManager() {
return requestManager;
}
};
System.out.println("ready to display time series");
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame jframe = new TopLevelFrame();
jframe.setTitle(title);
jframe.getContentPane().add(pdeDataViewer);
jframe.setSize(1000, 600);
jframe.setVisible(true);
if (windowListener != null) {
jframe.addWindowListener(windowListener);
}
try {
pdeDataViewer.setDataViewerManager(dataViewerManager);
} catch (PropertyVetoException e) {
e.printStackTrace();
}
pdeDataViewer.setPdeDataContext(myPdeDataContext);
}
});
} catch (InvocationTargetException | InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of cbit.vcell.client.server.SimStatusEvent 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