Search in sources :

Example 1 with InteractiveContextDefaultProvider

use of cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider 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;
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCDocument(org.vcell.util.document.VCDocument) Hashtable(java.util.Hashtable) InteractiveContextDefaultProvider(cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider) ClientServerManager(cbit.vcell.client.server.ClientServerManager)

Example 2 with InteractiveContextDefaultProvider

use of cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider 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;
}
Also used : InteractiveContextDefaultProvider(cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider) ClientServerManager(cbit.vcell.client.server.ClientServerManager) InteractiveContext(cbit.vcell.client.server.ClientServerManager.InteractiveContext) ClientServerInfo(cbit.vcell.client.server.ClientServerInfo) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword)

Example 3 with InteractiveContextDefaultProvider

use of cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider 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;
}
Also used : InteractiveContextDefaultProvider(cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider) ClientServerManager(cbit.vcell.client.server.ClientServerManager) ClientServerInfo(cbit.vcell.client.server.ClientServerInfo) DigestedPassword(org.vcell.util.document.UserLoginInfo.DigestedPassword)

Aggregations

ClientServerManager (cbit.vcell.client.server.ClientServerManager)3 InteractiveContextDefaultProvider (cbit.vcell.client.server.ClientServerManager.InteractiveContextDefaultProvider)3 ClientServerInfo (cbit.vcell.client.server.ClientServerInfo)2 DigestedPassword (org.vcell.util.document.UserLoginInfo.DigestedPassword)2 InteractiveContext (cbit.vcell.client.server.ClientServerManager.InteractiveContext)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 Hashtable (java.util.Hashtable)1 VCDocument (org.vcell.util.document.VCDocument)1