From 35c2198e062615a08b32f1cd6bf2de2365783dd6 Mon Sep 17 00:00:00 2001 From: Jordan Deyton Date: Wed, 4 Mar 2015 17:27:16 -0500 Subject: [PATCH] Added a basic implementation of ParaViewVizService and skeleton code for ParaViewPlot. Signed-off-by: Jordan Deyton --- .../viz/service/paraview/ParaViewPlot.java | 17 ++- .../service/paraview/ParaViewVizService.java | 118 +++++++++++++++--- 2 files changed, 120 insertions(+), 15 deletions(-) diff --git a/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewPlot.java b/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewPlot.java index 8342d210e..b0ddb8b66 100644 --- a/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewPlot.java +++ b/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewPlot.java @@ -15,8 +15,12 @@ import java.util.Map; import org.eclipse.ice.client.widgets.viz.service.IPlot; +import org.eclipse.ice.datastructures.ICEObject.IUpdateable; +import org.eclipse.ice.viz.service.connections.ConnectionClient; import org.eclipse.swt.widgets.Composite; +import com.kitware.vtk.web.VtkWebClient; + /** * This class is responsible for embedding ParaView-supported graphics inside * client {@link Composite}s. @@ -30,8 +34,12 @@ * @author Jordan Deyton * */ -public class ParaViewPlot implements IPlot { +public class ParaViewPlot extends ConnectionClient implements IPlot { + public ParaViewPlot(ParaViewVizService vizService, URI file) { + + } + /* * (non-Javadoc) * @@ -124,4 +132,11 @@ public boolean isSourceRemote() { return false; } + + @Override + public void update(IUpdateable component) { + // TODO Auto-generated method stub + + } + } diff --git a/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewVizService.java b/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewVizService.java index dbda27723..3bcb335c9 100644 --- a/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewVizService.java +++ b/src/org.eclipse.ice.viz.service.paraview/src/org/eclipse/ice/viz/service/paraview/ParaViewVizService.java @@ -13,9 +13,17 @@ import java.net.URI; import java.util.Map; +import java.util.Set; import org.eclipse.ice.client.widgets.viz.service.IPlot; -import org.eclipse.ice.client.widgets.viz.service.IVizService; +import org.eclipse.ice.viz.service.AbstractVizService; +import org.eclipse.ice.viz.service.connections.ConnectionManager; +import org.eclipse.ice.viz.service.connections.ConnectionTable; +import org.eclipse.ice.viz.service.connections.IConnectionAdapter; +import org.eclipse.ice.viz.service.connections.paraview.ParaViewConnectionAdapter; +import org.eclipse.ice.viz.service.preferences.CustomScopedPreferenceStore; + +import com.kitware.vtk.web.VtkWebClient; /** * This class is responsible for providing a service to connect to (or launch) @@ -29,7 +37,74 @@ * @author Jordan Deyton * */ -public class ParaViewVizService implements IVizService { +public class ParaViewVizService extends AbstractVizService { + + /** + * The current instance of the viz service. This instance was created when + * the OSGi viz service was instantiated. + */ + private static ParaViewVizService instance; + + /** + * The manager for all of the ParaView connections. + */ + private final ConnectionManager connections; + + /** + * The default constructor. + *

+ * Note: Only OSGi should call this method! + *

+ */ + public ParaViewVizService() { + // Update the instance to point to this viz service (there should be + // only one). + instance = this; + + // Set up the connection manager. + connections = new ConnectionManager() { + @Override + protected CustomScopedPreferenceStore getPreferenceStore() { + return (CustomScopedPreferenceStore) ParaViewVizService.this + .getPreferenceStore(); + } + + @Override + protected ConnectionTable createConnectionTable() { + return new ConnectionTable(); + } + + @Override + protected IConnectionAdapter createConnectionAdapter() { + return new ParaViewConnectionAdapter(); + } + }; + + return; + } + + /** + * Gets the current instance of the viz service. This instance was created + * by OSGi. + *

+ * Note: This method is only intended to be used by the preference + * page to notify the service when the preferences have changed. + *

+ * + * @return The current instance of the viz service. + */ + protected static ParaViewVizService getInstance() { + return instance; + } + + /** + * This method notifies the service that the preferences have changed. Any + * connections that have changed should be reset. + */ + protected void preferencesChanged(Map changedKeys, + Set addedKeys, Set removedKeys) { + connections.preferencesChanged(changedKeys, addedKeys, removedKeys); + } /* * (non-Javadoc) @@ -48,8 +123,7 @@ public String getName() { */ @Override public String getVersion() { - // TODO Update this value. - return ""; + return "0.0"; } /* @@ -60,7 +134,7 @@ public String getVersion() { */ @Override public boolean hasConnectionProperties() { - // TODO Auto-generated method stub + // Do nothing yet. return false; } @@ -72,7 +146,7 @@ public boolean hasConnectionProperties() { */ @Override public Map getConnectionProperties() { - // TODO Auto-generated method stub + // Do nothing yet. return null; } @@ -84,8 +158,7 @@ public Map getConnectionProperties() { */ @Override public void setConnectionProperties(Map props) { - // TODO Auto-generated method stub - + // Do nothing yet. } /* @@ -95,8 +168,7 @@ public void setConnectionProperties(Map props) { */ @Override public boolean connect() { - // TODO Auto-generated method stub - return false; + return connections.connect(); } /* @@ -106,8 +178,7 @@ public boolean connect() { */ @Override public boolean disconnect() { - // TODO Auto-generated method stub - return false; + return connections.disconnect(); } /* @@ -119,8 +190,27 @@ public boolean disconnect() { */ @Override public IPlot createPlot(URI file) throws Exception { - // TODO Auto-generated method stub - return null; + ParaViewPlot plot = null; + if (canOpenFile(file)) { + plot = new ParaViewPlot(this, file); + connections.addClient(plot); + } + return plot; + } + + /** + * Determines whether or not the file can be opened in ParaView. + * + * @param file + * The file to test. May be {@code null}. + * @return True if the file can be opened in VisIt, false otherwise. + */ + private boolean canOpenFile(URI file) { + boolean canOpen = false; + if (file != null) { + // TODO + } + return canOpen; } }