Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Added a ParaViewConnectionAdapter to cleanly interface the
Browse files Browse the repository at this point in the history
ParaViewVizService with the VtkWebClient.

Signed-off-by: Jordan Deyton <deytonjh@ornl.gov>
  • Loading branch information
Jordan Deyton committed Mar 3, 2015
1 parent 860c621 commit 7f4936f
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
Expand Up @@ -4,8 +4,10 @@ Bundle-Name: ParaView Visualization Service Plugin
Bundle-SymbolicName: org.eclipse.ice.viz.service.paraview;singleton:=true
Bundle-Version: 2.0.0
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.eclipse.core.runtime.preferences;version="3.3.0",
Import-Package: com.kitware.vtk.web,
org.eclipse.core.runtime.preferences;version="3.3.0",
org.eclipse.ice.client.widgets.viz.service,
org.eclipse.ice.datastructures.ICEObject,
org.eclipse.ice.datastructures.form,
org.eclipse.ice.viz.service,
org.eclipse.ice.viz.service.connections,
Expand Down
@@ -0,0 +1,64 @@
package org.eclipse.ice.viz.service.connections.paraview;

import java.util.List;
import java.util.concurrent.ExecutionException;

import org.eclipse.ice.datastructures.form.Entry;
import org.eclipse.ice.viz.service.connections.ConnectionAdapter;

import com.kitware.vtk.web.VtkWebClient;
import com.kitware.vtk.web.VtkWebClientHttpImpl;

public class ParaViewConnectionAdapter extends ConnectionAdapter<VtkWebClient> {

@Override
protected VtkWebClient openConnection() {

boolean connected = false;
VtkWebClient client = null;

try {
client = new VtkWebClientHttpImpl();
String host = getConnectionProperty("host");
String port = getConnectionProperty("port");
String url = "http://" + host + ":" + port + "/rpc-http/";
connected = client.connect(url).get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}

if (!connected) {
client = null;
}

return client;
}

@Override
protected boolean closeConnection(VtkWebClient connection) {
connection.close();
return true;
}

@Override
public boolean setConnectionProperties(List<Entry> row) {
// We need to get the following information:
// host
// port

// TODO Update this when we can launch the server.

boolean changed = false;

if (row != null && row.size() >= 3) {
objectName = row.get(0).getValue();
changed |= setConnectionProperty("host", row.get(1).getValue());
changed |= setConnectionProperty("port", row.get(2).getValue());
}

return changed;
}

}

0 comments on commit 7f4936f

Please sign in to comment.