use of java.util.EventObject in project vcell by virtualcell.
the class ClientSimManager method runSmoldynParticleView.
public void runSmoldynParticleView(final Simulation originalSimulation) {
SimulationOwner simulationOwner = simWorkspace.getSimulationOwner();
Collection<AsynchClientTask> tasks;
if (simulationOwner instanceof SimulationContext) {
tasks = ClientRequestManager.updateMath(documentWindowManager.getComponent(), (SimulationContext) simulationOwner, false, NetworkGenerationRequirements.ComputeFullStandardTimeout);
} else {
tasks = new ArrayList<>();
}
AsynchClientTask pv = new AsynchClientTask("starting particle view", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
File[] exes = SolverUtilities.getExes(SolverDescription.Smoldyn);
assert exes.length == 1 : "one and only one smoldyn solver expected";
File smoldynExe = exes[0];
Simulation simulation = new TempSimulation(originalSimulation, false);
SimulationTask simTask = new SimulationTask(new SimulationJob(simulation, 0, null), 0);
File inputFile = new File(ResourceUtil.getLocalSimDir(User.tempUser.getName()), simTask.getSimulationJobID() + SimDataConstants.SMOLDYN_INPUT_FILE_EXTENSION);
inputFile.deleteOnExit();
PrintWriter pw = new PrintWriter(inputFile);
SmoldynFileWriter smf = new SmoldynFileWriter(pw, true, null, simTask, false);
smf.write();
pw.close();
String[] cmd = new String[] { smoldynExe.getAbsolutePath(), inputFile.getAbsolutePath() };
StringBuilder commandLine = new StringBuilder();
for (int i = 0; i < cmd.length; i++) {
if (i > 0) {
commandLine.append(" ");
}
commandLine.append(TokenMangler.getEscapedPathName(cmd[i]));
}
System.out.println(commandLine);
char[] charArrayOut = new char[10000];
char[] charArrayErr = new char[10000];
ProcessBuilder processBuilder = new ProcessBuilder(cmd);
final Process process = processBuilder.start();
getClientTaskStatusSupport().addProgressDialogListener(new ProgressDialogListener() {
public void cancelButton_actionPerformed(EventObject newEvent) {
process.destroy();
}
});
InputStream errorStream = process.getErrorStream();
InputStreamReader errisr = new InputStreamReader(errorStream);
InputStream outputStream = process.getInputStream();
InputStreamReader outisr = new InputStreamReader(outputStream);
StringBuilder sb = new StringBuilder();
boolean running = true;
while (running) {
try {
process.exitValue();
running = false;
} catch (IllegalThreadStateException e) {
// process didn't exit yet, do nothing
}
if (outputStream.available() > 0) {
outisr.read(charArrayOut, 0, charArrayOut.length);
}
if (errorStream.available() > 0) {
errisr.read(charArrayErr, 0, charArrayErr.length);
sb.append(new String(charArrayErr));
}
}
if (sb.length() > 0) {
throw new RuntimeException(sb.toString());
}
}
};
tasks.add(pv);
ClientTaskDispatcher.dispatchColl(documentWindowManager.getComponent(), new Hashtable<String, Object>(), tasks, false, true, null);
}
use of java.util.EventObject in project vcell by virtualcell.
the class VCDocumentDbTreePanel method search.
public void search(final boolean bShowAll) {
final Object[] status = new Object[] { null };
class SearchCancel implements ProgressDialogListener {
public void cancelButton_actionPerformed(EventObject newEvent) {
status[0] = UserCancelException.CANCEL_GENERIC;
}
}
final SearchCancel searchCancel = new SearchCancel();
final ArrayList<SearchCriterion> searchCriterionListFinal = new ArrayList<DatabaseSearchPanel.SearchCriterion>();
AsynchClientTask searchCriteriaTask = new AsynchClientTask("Creating search criteria...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, true) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (bShowAll) {
return;
}
new Thread(new Runnable() {
public void run() {
try {
ArrayList<SearchCriterion> searchCriterionList = getDatabaseSearchPanel().getSearchCriterionList(getDocumentManager());
if (status[0] == null) {
// update status only if no one else has
if (searchCriterionList != null && searchCriterionList.size() > 0) {
searchCriterionListFinal.addAll(searchCriterionList);
}
status[0] = "OK";
return;
} else {
return;
}
} catch (Exception e) {
status[0] = e;
}
}
}).start();
long startTime = System.currentTimeMillis();
while ((System.currentTimeMillis() - startTime) < 60000) {
if (status[0] != null) {
if (status[0] instanceof Exception) {
// User cancelled or there was an exception in search criteria thread
throw (Exception) status[0];
}
// search criteria thread completed with 'OK'
return;
}
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
// ignore
}
}
throw new Exception("getSearchCriterionList timed out");
}
};
AsynchClientTask refreshTask = new AsynchClientTask("Refreshing tree...", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (searchCriterionListFinal.size() > 0) {
// show with search criteria
refresh(searchCriterionListFinal);
} else {
// show all
refresh(null);
}
}
};
Hashtable<String, Object> hashTable = new Hashtable<String, Object>();
if (!bShowAll && getDatabaseSearchPanel().hasRemoteDatabaseSearchDefined()) {
ClientTaskDispatcher.dispatch(this, hashTable, new AsynchClientTask[] { searchCriteriaTask, refreshTask }, true, false, true, searchCancel, true);
} else {
try {
searchCriteriaTask.run(hashTable);
refreshTask.run(hashTable);
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, e.getMessage());
}
}
}
use of java.util.EventObject in project vcell by virtualcell.
the class BNGWindowManager method runBioNetGen.
/**
* Gets the bngOutputPanel property (cbit.vcell.client.bionetgen.BNGOutputPanel) value.
* @return The bngOutputPanel property value.
*/
public void runBioNetGen(BNGInput bngInput) {
// Create a hash and put in the details required to run the ClientTaskDispatcher
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(BNG_OUTPUT_PANEL, getBngOutputPanel());
final BNGExecutorService bngService = BNGExecutorService.getInstance(bngInput, NetworkGenerationRequirements.NoTimeoutMS);
// Create the AsynchClientTasks : in this case, running the BioNetGen (non-swing) and then displaying the output (swing) tasks.
AsynchClientTask[] tasksArray = new AsynchClientTask[2];
tasksArray[0] = new RunBioNetGen(bngService);
tasksArray[1] = new DisplayBNGOutput();
// Dispatch the tasks using the ClientTaskDispatcher.
ClientTaskDispatcher.dispatch(getBngOutputPanel(), hash, tasksArray, false, true, new ProgressDialogListener() {
public void cancelButton_actionPerformed(EventObject newEvent) {
try {
bngService.stopBNG();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
use of java.util.EventObject in project vcell by virtualcell.
the class DocumentWindow method startVCellVisIt.
private void startVCellVisIt() {
AsynchClientTask findVisitTask = new AsynchClientTask("Searching for VisIt...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
try {
VisitSupport.launchVisTool(VCellConfiguration.getFileProperty(PropertyLoader.visitExe));
} catch (Exception e) {
e.printStackTrace();
OperatingSystemInfo osi = OperatingSystemInfo.getInstance();
String executableName = ResourceUtil.getExecutableName(VisitSupport.VISIT_EXEC_NAME, false, osi);
File executableLocation = new ExecutableFinderDialog(DocumentWindow.this, "If VisIt is installed (from " + "https://wci.llnl.gov/codes/visit/" + ") but not in the system path, then press press '" + ExecutableFinderDialog.FIND + "' and navigate to '" + executableName + "'.\nElse please install VisIt, restart VCell, and try again").find(executableName);
VisitSupport.launchVisTool(executableLocation);
}
}
};
ProgressDialogListener progressDialogListener = new ProgressDialogListener() {
@Override
public void cancelButton_actionPerformed(EventObject newEvent) {
System.out.println(newEvent);
}
};
// ClientTaskDispatcher.dispatch(requester, hash, tasks, customDialog, bShowProgressPopup, bKnowProgress, cancelable, progressDialogListener, bInputBlocking);
ClientTaskDispatcher.dispatch(DocumentWindow.this, new Hashtable<>(), new AsynchClientTask[] { findVisitTask }, null, true, false, true, progressDialogListener, false);
}
use of java.util.EventObject in project Payara by payara.
the class CheckMgr method fireTestFinishedEvent.
// call once per test, when r is complete
protected void fireTestFinishedEvent(Result r) {
Object[] listeners;
synchronized (listenerList) {
listeners = listenerList.toArray();
}
if (listeners == null)
return;
// those that are interested in this event
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] instanceof VerifierEventsListener) {
// create the event:
EventObject event = new EventObject(r);
((VerifierEventsListener) listeners[i]).testFinished(event);
}
}
}
Aggregations