Commit 48faa763 authored by Robert Smith's avatar Robert Smith
Browse files

Fixed MeshElementTreeView bug



Fixed a bug where selecting anything in the MeshElementTreeView would
cause the view to deselect anything selected and close all nodes in its
trees. 
Signed-off-by: Robert Smith's avatarRobert Smith <SmithRW@ornl.gov>
parent d7239495
......@@ -484,15 +484,11 @@ public class ICEMeshPage extends ICEFormPage
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);
};
});
}
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
editor.setDirty(true);
};
});
}
}
......@@ -14,8 +14,8 @@ package org.eclipse.ice.client.widgets;
import java.util.ArrayList;
import org.eclipse.eavp.viz.modeling.base.BasicController;
import org.eclipse.eavp.viz.modeling.FaceController;
import org.eclipse.eavp.viz.modeling.base.BasicController;
import org.eclipse.eavp.viz.modeling.base.IController;
import org.eclipse.eavp.viz.modeling.properties.MeshCategory;
import org.eclipse.eavp.viz.modeling.properties.MeshProperty;
......@@ -348,28 +348,34 @@ public class MeshElementTreeView extends ViewPart
@Override
public void update(IUpdateable component) {
logger.info("ICEMeshPage Message: " + "Mesh changed!");
// If the update came from the mesh component, redraw the mesh
if (component == meshComponent) {
logger.info("ICEMeshPage Message: " + "Mesh changed!");
// Sync with the display
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() { // Just do a blanket update - no need to
// check
// the component
if (elementTreeViewer != null) {
logger.info("MeshElementTreeView Message: "
+ "Updating element view.");
// Set the tree content
if (meshComponent != null) {
elementTreeViewer
.setInput(meshComponent.getPolygons());
}
// Sync with the display
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() { // Just do a blanket update - no need to check
// the component
if (elementTreeViewer != null) {
logger.info("MeshElementTreeView Message: "
+ "Updating element view.");
// Set the tree content
if (meshComponent != null) {
elementTreeViewer.setInput(meshComponent.getPolygons());
// Refresh the view
elementTreeViewer.refresh();
elementTreeViewer.getTree().redraw();
}
// Refresh the view
elementTreeViewer.refresh();
elementTreeViewer.getTree().redraw();
}
}
});
});
}
return;
}
......
......@@ -32,6 +32,7 @@ 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.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.componentVisitor.IComponentVisitor;
/**
......@@ -386,6 +387,36 @@ public class MeshComponent extends ICEObject
return;
}
/**
* Notify all listeners that a change has occurred, providing them with the
* given component as the source.
*
* @param component
* The object to serve as the source of the update.
*/
private void notifyListeners(IUpdateable component) {
// Only process the update if there are listeners
if (listeners != null && !listeners.isEmpty()) {
// Create a thread on which to notify the listeners.
Thread notifierThread = new Thread() {
@Override
public void run() {
// Loop over all listeners and update them
for (int i = 0; i < listeners.size(); i++) {
listeners.get(i).update(component);
}
return;
}
};
// Launch the thread and do the notifications
notifierThread.start();
}
return;
}
/*
* (non-Javadoc)
*
......@@ -398,8 +429,22 @@ public class MeshComponent extends ICEObject
@Override
public void update(IManagedUpdateable component, SubscriptionType[] types) {
// Notify own listeners of the change
notifyListeners();
// If something other than a property changed, then notify the listeners
// as normal
if (types.length != 1 || !SubscriptionType.PROPERTY.equals(types[0])) {
// Notify own listeners of the change
notifyListeners();
}
// If only a property changed, send a new ICEObject as a special signal
// that the MeshComponent should not necessarily be considered as
// updated, leaving it to the listener to check if the meshcomponent is
// equal to the source in case sepcial behavior is required.
else {
notifyListeners(new ICEObject());
}
}
/*
......
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