This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a ParaViewConnectionAdapter to cleanly interface the
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
Showing
2 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...aview/src/org/eclipse/ice/viz/service/connections/paraview/ParaViewConnectionAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |