Commit fb5fe8cf authored by Robert Smith's avatar Robert Smith
Browse files

ICEMeshPage is now saveable



The ICEMeshPage now has the capability to mark itself as dirty and
persist to an .xml file when the save button is used.
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent 888b54b7
......@@ -18,12 +18,13 @@ import java.util.List;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.eavp.viz.service.IVizService;
import org.eclipse.eavp.viz.service.IVizServiceFactory;
import org.eclipse.eavp.viz.service.geometry.widgets.TransformationView;
import org.eclipse.eavp.viz.service.mesh.datastructures.IMeshVizCanvas;
import org.eclipse.ice.client.common.ActionTree;
import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.ICEObject.IUpdateableListener;
import org.eclipse.ice.datastructures.form.MeshComponent;
import org.eclipse.eavp.viz.service.geometry.widgets.TransformationView;
import org.eclipse.eavp.viz.service.geometry.widgets.TransformationView;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.ToolBarManager;
......@@ -42,6 +43,7 @@ import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.widgets.ScrolledForm;
......@@ -55,8 +57,9 @@ import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
*
* @author Taylor Patterson, Jordan H. Deyton
*/
public class ICEMeshPage extends ICEFormPage implements ISelectionListener,
ISelectionProvider, ITabbedPropertySheetPageContributor {
public class ICEMeshPage extends ICEFormPage
implements ISelectionListener, ISelectionProvider,
ITabbedPropertySheetPageContributor, IUpdateableListener {
/**
* Eclipse view ID
......@@ -165,8 +168,15 @@ public class ICEMeshPage extends ICEFormPage implements ISelectionListener,
// Make sure the ResourceComponent exists
if (component != null) {
// Unregister from the previous component
if (meshComp != null) {
meshComp.unregister(this);
}
// Set the component reference
meshComp = component;
meshComp.register(this);
}
return;
......@@ -222,8 +232,7 @@ public class ICEMeshPage extends ICEFormPage implements ISelectionListener,
// Get JME3 Geometry service from factory
IVizServiceFactory factory = editor.getVizServiceFactory();
IVizService service = factory.get("ICE JavaFX Mesh Editor");
// Composite editorComposite = new Composite(parent, SWT.NONE);
meshComp.setService(service);
// Create and draw geometry canvas
try {
......@@ -393,8 +402,8 @@ public class ICEMeshPage extends ICEFormPage implements ISelectionListener,
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// Get the selection made in the MeshElementTreeView.
if (part.getSite().getId().equals(MeshElementTreeView.ID) && canvas !=
null) {
if (part.getSite().getId().equals(MeshElementTreeView.ID)
&& canvas != null) {
// Get the array of all selections in the Mesh Elements view
Object[] treeSelections = ((ITreeSelection) selection).toArray();
......@@ -464,4 +473,26 @@ public class ICEMeshPage extends ICEFormPage implements ISelectionListener,
}
// ----------------------------------------------------------- //
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ice.datastructures.ICEObject.IUpdateableListener#update(org.
* eclipse.ice.datastructures.ICEObject.IUpdateable)
*/
@Override
public void update(IUpdateable component) {
// If the mesh was updated, the editor is now dirty
if (component == meshComp) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
editor.setDirty(true);
};
});
}
}
}
......@@ -24,6 +24,8 @@ Import-Package: ca.odell.glazedlists,
org.eclipse.eavp.viz.modeling,
org.eclipse.eavp.viz.modeling.base,
org.eclipse.eavp.viz.modeling.properties,
org.eclipse.eavp.viz.service,
org.eclipse.eavp.viz.service.mesh.datastructures,
org.eclipse.emf.common,
org.eclipse.emf.common.util,
org.eclipse.emf.ecore,
......
......@@ -17,16 +17,19 @@ import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateable;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateableListener;
import org.eclipse.eavp.viz.datastructures.VizObject.SubscriptionType;
import org.eclipse.eavp.viz.modeling.FaceController;
import org.eclipse.eavp.viz.modeling.base.BasicController;
import org.eclipse.eavp.viz.modeling.base.BasicMesh;
import org.eclipse.eavp.viz.modeling.base.BasicView;
import org.eclipse.eavp.viz.modeling.FaceController;
import org.eclipse.eavp.viz.modeling.base.IController;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateable;
import org.eclipse.eavp.viz.datastructures.VizObject.IManagedUpdateableListener;
import org.eclipse.eavp.viz.datastructures.VizObject.SubscriptionType;
import org.eclipse.eavp.viz.service.IVizService;
import org.eclipse.eavp.viz.service.mesh.datastructures.MeshDescription;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.ICEObject.ICEObject;
import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
......@@ -42,10 +45,15 @@ import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
* @author Robert Smith
*/
@XmlRootElement(name = "MeshComponent")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorType(XmlAccessType.NONE)
public class MeshComponent extends ICEObject
implements Component, IManagedUpdateableListener {
/**
* A compressed description of the mesh, used for persistence
*/
private MeshDescription compressedMesh;
/**
* The wrapped VizMeshComponent.
*/
......@@ -66,6 +74,11 @@ public class MeshComponent extends ICEObject
*/
private int nextVertexID = 1;
/**
* The service which will be rendering this component.
*/
private IVizService service;
/**
* <p>
* The default constructor for a MeshComponent. Initializes the list of
......@@ -75,8 +88,12 @@ public class MeshComponent extends ICEObject
*/
public MeshComponent() {
super();
// Initialize the data members
mesh = new BasicController(new BasicMesh(), new BasicView());
mesh.register(this);
compressedMesh = null;
service = null;
return;
}
......@@ -97,6 +114,7 @@ public class MeshComponent extends ICEObject
*/
public void setMesh(BasicController newMesh) {
mesh = newMesh;
mesh.register(this);
}
/**
......@@ -131,6 +149,19 @@ public class MeshComponent extends ICEObject
notifyListeners();
}
/**
* Returns the component's mesh, compressed into a MeshDescription for easy
* use in persistence for JAXB.
*
* This function exists for use by JAXB and is not intended to be called.
*
* @return
*/
@XmlElement
private MeshDescription getCompressedMesh() {
return new MeshDescription(mesh);
}
/**
* <p>
* Gets a list of all polygons stored in the MeshComponent ordered by their
......@@ -138,7 +169,7 @@ public class MeshComponent extends ICEObject
* </p>
*
* @return
* <p>
* <p>
* A list of polygons contained in this MeshComponent.
* </p>
*/
......@@ -152,7 +183,7 @@ public class MeshComponent extends ICEObject
* </p>
*
* @return
* <p>
* <p>
* The greatest polygon ID (or zero) plus one.
* </p>
*/
......@@ -170,7 +201,7 @@ public class MeshComponent extends ICEObject
* </p>
*
* @return
* <p>
* <p>
* The greatest vertex ID (or zero) plus one.
* </p>
*/
......@@ -188,7 +219,7 @@ public class MeshComponent extends ICEObject
* </p>
*
* @return
* <p>
* <p>
* The greatest edge ID (or zero) plus one.
* </p>
*/
......@@ -200,13 +231,50 @@ public class MeshComponent extends ICEObject
return temp;
}
/**
* Sets the component's contents based on the compressed form of a
* MeshDescription.
*
* This function is intended for use by JAXB for persistence and is not
* intended for use.
*
* @param description
* The compressed description the component's new data.
*/
private void setCompressedMesh(MeshDescription description) {
compressedMesh = description;
}
/**
* Setter method for the service being used to render this component.
*
* @param service
* The service providing the rendering support used to view this
* component's contents.
*/
public void setService(IVizService service) {
this.service = service;
// If a persisted mesh has been loaded into the component, we can now
// unpack it
if (compressedMesh != null) {
mesh = (BasicController) compressedMesh
.unpack(service.getFactory());
mesh.register(this);
// The full mesh is now in memory, so delete the compressed version
compressedMesh = null;
}
}
/**
* <p>
* This operation returns the hash value of the MeshComponent.
* </p>
*
* @return
* <p>
* <p>
* The hashcode of the ICEObject.
* </p>
*/
......@@ -227,7 +295,7 @@ public class MeshComponent extends ICEObject
* The other ICEObject that should be compared with this one.
* </p>
* @return
* <p>
* <p>
* True if the ICEObjects are equal, false otherwise.
* </p>
*/
......@@ -287,7 +355,7 @@ public class MeshComponent extends ICEObject
* </p>
*
* @return
* <p>
* <p>
* The new clone
* </p>
*/
......@@ -330,14 +398,8 @@ public class MeshComponent extends ICEObject
@Override
public void update(IManagedUpdateable component, SubscriptionType[] types) {
// Only pass on updates for the root part's list of children changing,
// in order to refresh the tree view of components.
for (SubscriptionType type : types) {
if (type == SubscriptionType.CHILD) {
notifyListeners();
}
}
// Notify own listeners of the change
notifyListeners();
}
/*
......@@ -351,9 +413,12 @@ public class MeshComponent extends ICEObject
public ArrayList<SubscriptionType> getSubscriptions(
IManagedUpdateable source) {
// Register for all event types
// Register to listen when a part is added/removed/moved or when a
// property is changed
ArrayList<SubscriptionType> types = new ArrayList<SubscriptionType>();
types.add(SubscriptionType.ALL);
types.add(SubscriptionType.CHILD);
types.add(SubscriptionType.PROPERTY);
types.add(SubscriptionType.TRANSFORMATION);
return types;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment