use of cbit.vcell.client.server.ClientServerManager in project vcell by virtualcell.
the class MathTestingReportGenerator method main.
public static void main(String[] args) {
ClientServerManager clientServerManager = null;
try {
if (args.length != 3) {
System.out.println("usage: MathTestingReportGenerator apihost apiport password");
System.exit(1);
}
String userid = "vcelltestaccount";
String apihost = args[0];
Integer apiport = Integer.parseInt(args[1]);
String password = args[2];
clientServerManager = ClientFactory.createRemoteClientServerManager(apihost, apiport, userid, password);
DocumentManager documentManager = clientServerManager.getDocumentManager();
TestSuiteInfoNew[] testSuiteInfos = documentManager.getTestSuiteInfos();
for (TestSuiteInfoNew testSuiteInfo : testSuiteInfos) {
System.out.println(testSuiteInfo.toShortString());
}
//
// sorted by TSKey
//
Arrays.sort(testSuiteInfos, new Comparator<TestSuiteInfoNew>() {
@Override
public int compare(TestSuiteInfoNew o1, TestSuiteInfoNew o2) {
return o1.getTSKey().compareTo(o2.getTSKey());
}
});
//
// print out details of the last one.
//
TestSuiteNew testSuite = documentManager.getTestSuite(testSuiteInfos[testSuiteInfos.length - 1].getTSKey());
for (TestCaseNew testCase : testSuite.getTestCases()) {
System.out.println("TEST CASE: " + testCase.getAnnotation());
TestCriteriaNew[] testCriterias = testCase.getTestCriterias();
for (TestCriteriaNew testCriteria : testCriterias) {
System.out.println(" CRITERIA: " + testCriteria.getReportStatusMessage());
for (VariableComparisonSummary summary : testCriteria.getVarComparisonSummaries()) {
System.out.println(" SUMMARY: " + summary.toShortString());
}
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
} finally {
if (clientServerManager != null) {
clientServerManager.cleanup();
}
}
}
use of cbit.vcell.client.server.ClientServerManager in project vcell by virtualcell.
the class VCellClient method startClient.
/**
* Insert the method's description here.
* Creation date: (5/5/2004 3:51:06 PM)
* @param bioModel cbit.vcell.biomodel.BioModel
*/
public static VCellClient startClient(final VCDocument startupDoc, final ClientServerInfo clientServerInfo) {
/* Set Look and Feel */
VCellLookAndFeel.setVCellLookAndFeel();
// instantiate app
final VCellClient vcellClient = new VCellClient();
Hashtable<String, Object> hash = new Hashtable<String, Object>();
AsynchClientTask task1 = new AsynchClientTask("Starting Virtual Cell", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// start management layer
InteractiveContextDefaultProvider defaultRequester = new VCellGuiInteractiveContextDefaultProvider();
vcellClient.setClientServerManager(new ClientServerManager(clientServerInfo, defaultRequester));
vcellClient.setRequestManager(new ClientRequestManager(vcellClient));
vcellClient.setMdiManager(new ClientMDIManager(vcellClient.getRequestManager()));
// start auxilliary stuff
vcellClient.startStatusThreads();
// make sure we have at least a blank document to start with
if (startupDoc != null) {
hashTable.put("startupDoc", startupDoc);
} else {
VCDocument newStartupDoc = ((ClientRequestManager) vcellClient.getRequestManager()).createDefaultDocument(VCDocumentType.BIOMODEL_DOC);
hashTable.put("startupDoc", newStartupDoc);
}
DocumentWindowAboutBox.parseVCellVersion();
}
};
AsynchClientTask task2 = new AsynchClientTask("Creating GUI", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// fire up the GUI
VCDocument startupDoc = (VCDocument) hashTable.get("startupDoc");
// needs to be set first, else throw away dirty/needs paint information stored in previous instance.
RepaintManager.setCurrentManager(new VCellClient.CheckThreadViolationRepaintManager());
DocumentWindowManager currWindowManager = vcellClient.createAndShowGUI(startupDoc);
if (currWindowManager != null) {
hashTable.put("currWindowManager", currWindowManager);
}
if (clientServerInfo.getUsername() == null) {
// we were not supplied login credentials; pop-up dialog
VCellClient.login(vcellClient.getRequestManager(), clientServerInfo, currWindowManager);
}
}
};
AsynchClientTask task3 = new AsynchClientTask("Connecting to Server", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// try server connection
if (clientServerInfo.getUsername() != null) {
DocumentWindowManager currWindowManager = (DocumentWindowManager) hashTable.get("currWindowManager");
// we were not supplied login credentials; pop-up dialog
vcellClient.getRequestManager().connectToServer(currWindowManager, clientServerInfo);
}
}
};
AsynchClientTask[] taskArray = new AsynchClientTask[] { task1, task2, task3 };
ClientTaskDispatcher.dispatch(null, hash, taskArray);
return vcellClient;
}
use of cbit.vcell.client.server.ClientServerManager in project vcell by virtualcell.
the class ReactionCartoonTool method showSaveReactionImageDialog.
// TO DO: allow user preferences for directory selection.
public void showSaveReactionImageDialog() throws Exception {
// set file filter
String result = DialogUtils.showInputDialog0(getDialogOwner(getGraphPane()), "Enter pixel width of saved rxdiagram image (height will be proportional)", "800");
int width = Integer.parseInt(result);
SimpleFilenameFilter jpgFilter = new SimpleFilenameFilter("jpg");
final java.io.File defaultFile = new java.io.File(getModel().getName() + ".jpg");
ClientServerManager csm = (ClientServerManager) getDocumentManager().getSessionManager();
UserPreferences userPref = csm.getUserPreferences();
File defaultPath = userPref.getCurrentDialogPath();
VCFileChooser fileChooser = new VCFileChooser(defaultPath);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.addChoosableFileFilter(jpgFilter);
fileChooser.setSelectedFile(defaultFile);
fileChooser.setDialogTitle("Save Image As...");
// name once the user changes the directory.
class FileChooserFix implements java.beans.PropertyChangeListener {
public void propertyChange(java.beans.PropertyChangeEvent ev) {
JFileChooser chooser = (JFileChooser) ev.getSource();
if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
chooser.setSelectedFile(defaultFile);
}
}
}
fileChooser.addPropertyChangeListener(new FileChooserFix());
// process user input
if (fileChooser.showSaveDialog(getDialogOwner(getGraphPane())) == JFileChooser.APPROVE_OPTION) {
java.io.File selectedFile = fileChooser.getSelectedFile();
if (selectedFile != null) {
if (selectedFile.exists()) {
int question = javax.swing.JOptionPane.showConfirmDialog(getDialogOwner(getGraphPane()), "Overwrite file: " + selectedFile.getPath() + "?");
if (question == javax.swing.JOptionPane.NO_OPTION || question == javax.swing.JOptionPane.CANCEL_OPTION) {
return;
}
}
BufferedImage bufferedImage = ITextWriter.generateDocReactionsImage(this.getModel(), width);
FileOutputStream reactionImageOutputStream = null;
try {
reactionImageOutputStream = new FileOutputStream(selectedFile);
reactionImageOutputStream.write(ITextWriter.encodeJPEG(bufferedImage).toByteArray());
} finally {
try {
if (reactionImageOutputStream != null) {
reactionImageOutputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
// reset the user preference for the default path, if needed.
File newPath = selectedFile.getParentFile();
if (!newPath.equals(defaultPath)) {
userPref.setCurrentDialogPath(newPath);
}
}
}
}
use of cbit.vcell.client.server.ClientServerManager in project vcell by virtualcell.
the class ClientFactory method createRemoteClientServerManager.
public static ClientServerManager createRemoteClientServerManager(String apihost, Integer apiport, String username, String password) {
DigestedPassword digestedPassword = new DigestedPassword(password);
ClientServerInfo csInfo = ClientServerInfo.createRemoteServerInfo(apihost, apiport, username, digestedPassword);
InteractiveContextDefaultProvider defaultInteractiveContextProvider = new VCellGuiInteractiveContextDefaultProvider();
ClientServerManager clientServerManager = new ClientServerManager(csInfo, defaultInteractiveContextProvider);
RequestManagerAdapter requestManager = new RequestManagerAdapter();
TopLevelWindowManager windowManager = new TopLevelWindowManager(requestManager) {
@Override
public Component getComponent() {
return null;
}
@Override
public String getManagerID() {
return null;
}
@Override
public boolean isRecyclable() {
return false;
}
};
InteractiveContext requester = new VCellGuiInteractiveContext(windowManager);
clientServerManager.connect(requester);
return clientServerManager;
}
use of cbit.vcell.client.server.ClientServerManager in project vcell by virtualcell.
the class ClientFactory method createLocalClientServerManager.
public static ClientServerManager createLocalClientServerManager(String userid, String password) {
DigestedPassword digestedPassword = new DigestedPassword(password);
ClientServerInfo csInfo = ClientServerInfo.createLocalServerInfo(userid, digestedPassword);
InteractiveContextDefaultProvider defaultInteractiveContextProvider = new VCellGuiInteractiveContextDefaultProvider();
ClientServerManager clientServerManager = new ClientServerManager(csInfo, defaultInteractiveContextProvider);
clientServerManager.connect(null);
return clientServerManager;
}
Aggregations