-
-
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void updateRenderObjectsFor(INode node) {
- List<vtkProp> toDelete = new ArrayList<vtkProp>();
- view.lock();
- for (vtkProp prop : nodeToActor.getValues((E)node)) {
- if (prop.GetVTKId() != 0) {
- view.getRenderer().RemoveActor(prop);
- //prop.Delete();
- toDelete.add(prop);
- }
- actorToNode.remove(prop);
- }
- view.unlock();
- nodeToActor.remove((E)node);
- Collection<vtkProp> coll = getActors((E)node);
- if (coll == null)
- return;
- for (vtkProp prop : coll) {
- nodeToActor.add((E)node,prop);
- actorToNode.put(prop, (E)node);
- toDelete.remove(prop);
- }
- for (vtkProp p : toDelete)
- p.Delete();
- }
-
- protected abstract Collection<vtkProp> getActors(E node);
-
- @SuppressWarnings("unchecked")
- private void receiveAdd(E node, String id, boolean db) {
- if (DEBUG) System.out.println("receiveAdd " + debugString(node) + " " + id + " " + db);
- synchronized (syncMutex) {
- for (Pair<E, String> n : added) {
- if (n.first.equals(node))
- return;
- }
- if (changeTracking) {
- mapping.rangeModified((E)node.getParent());
- }
- added.add(new Pair<E, String>(node, id));
- rangeModified = true;
- }
- view.refresh();
- }
-
- @SuppressWarnings("unchecked")
- private void receiveRemove(E node, String id, boolean db) {
- if (DEBUG) System.out.println("receiveRemove " + debugString(node) + " " + id + " " + db);
- synchronized (syncMutex) {
- for (Pair<E, String> n : removed) {
- if (n.first.equals(node))
- return;
- }
- if (changeTracking && !db)
- mapping.rangeModified((E)node.getParent());
- removed.add(new Pair<E, String>(node, id));
- rangeModified = true;
- }
- view.refresh();
- }
-
- @SuppressWarnings("unchecked")
- private void receiveUpdate(E node, String id, boolean db) {
- if (DEBUG) System.out.println("receiveUpdate " + debugString(node) + " " + id + " " + db);
- synchronized (syncMutex) {
-// for (Pair<E, String> n : updated) {
-// if (n.first.equals(node))
-// return;
-// }
- if (changeTracking && !db)
- mapping.rangeModified(node);
- //updated.add(new Pair<E, String>(node, id));
- updated.add(node, id);
- rangeModified = true;
- }
- view.refresh();
- }
-
- private boolean graphUpdates = false;
- private Set<E> graphModified = new HashSet<E>();
-
- private boolean requestCommit = false;
- private String commitMessage = null;
-
- @Override
- public void commit(String message) {
- requestCommit = true;
- commitMessage = message;
- }
-
- protected void doCommit() {
- session.asyncRequest(new WriteRequest() {
-
- @Override
- public void perform(WriteGraph graph) throws DatabaseException {
- if (DEBUG) System.out.println("Commit " + commitMessage);
- if (commitMessage != null) {
- Layer0Utils.addCommentMetadata(graph, commitMessage);
- graph.markUndoPoint();
- commitMessage = null;
- }
- commit(graph);
- }
-
- }, new Callback<DatabaseException>() {
-
- @Override
- public void run(DatabaseException parameter) {
- if (parameter != null)
- ExceptionUtils.logAndShowError("Cannot commit editor changes", parameter);
- }
- });
- }
-
- protected void commit(WriteGraph graph) throws DatabaseException {
- synchronized(syncMutex) {
- if (DEBUG) System.out.println("Commit");
- graphUpdates = true;
- mapping.updateDomain(graph);
- graphUpdates = false;
- clearDeletes();
- if (DEBUG) System.out.println("Commit done");
- }
- }
-
-
-
- @Override
- public void domainModified() {
- if (graphUpdates)
- return;
- if (DEBUG)System.out.println("domainModified");
- session.asyncRequest(new ReadRequest() {
-
- @SuppressWarnings("unchecked")
- @Override
- public void run(ReadGraph graph) throws DatabaseException {
- update(graph);
- }
- });
-
- }
-
- protected void reset(ReadGraph graph) throws MappingException {
- if (DEBUG) System.out.println("Reset");
+
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void updateRenderObjectsFor(E node) {
+ List<vtkProp> toDelete = new ArrayList<vtkProp>();
+ view.lock();
+ for (vtkProp prop : nodeToActor.getValues((E)node)) {
+ if (prop.GetVTKId() != 0) {
+ view.getRenderer().RemoveActor(prop);
+ //prop.Delete();
+ toDelete.add(prop);
+ }
+ actorToNode.remove(prop);
+ }
+ view.unlock();
+ nodeToActor.remove((E)node);
+ Collection<vtkProp> coll = getActors((E)node);
+ if (coll != null) {
+ for (vtkProp prop : coll) {
+ nodeToActor.add((E)node,prop);
+ actorToNode.put(prop, (E)node);
+ toDelete.remove(prop);
+ }
+ }
+ for (vtkProp p : toDelete)
+ p.Delete();
+ }
+
+ protected abstract Collection<vtkProp> getActors(E node);
+
+ @SuppressWarnings("unchecked")
+ private void receiveAdd(E node, String id, boolean db) {
+ if (DEBUG) System.out.println("receiveAdd " + debugString(node) + " " + id + " " + db);
+ synchronized (syncMutex) {
+ for (Pair<E, String> n : added) {
+ if (n.first.equals(node))
+ return;
+ }
+ if (changeTracking) {
+ mapping.rangeModified((E)node.getParent());
+ }
+ added.add(new Pair<E, String>(node, id));
+ rangeModified = true;
+ }
+ view.refresh();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void receiveRemove(E node, String id, boolean db) {
+ if (DEBUG) System.out.println("receiveRemove " + debugString(node) + " " + id + " " + db);
+ synchronized (syncMutex) {
+ for (Pair<E, String> n : removed) {
+ if (n.first.equals(node))
+ return;
+ }
+ if (changeTracking && !db)
+ mapping.rangeModified((E)node.getParent());
+ removed.add(new Pair<E, String>(node, id));
+ rangeModified = true;
+ }
+ repaint();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void receiveUpdate(E node, String id, boolean db) {
+ if (DEBUG) System.out.println("receiveUpdate " + debugString(node) + " " + id + " " + db);
+ synchronized (syncMutex) {
+// for (Pair<E, String> n : updated) {
+// if (n.first.equals(node))
+// return;
+// }
+ if (changeTracking && !db)
+ mapping.rangeModified(node);
+ //updated.add(new Pair<E, String>(node, id));
+ updated.add(node, id);
+ rangeModified = true;
+ }
+ repaint();
+ }
+
+ private boolean graphUpdates = false;
+ private Set<E> graphModified = new HashSet<E>();
+
+ private boolean requestCommit = false;
+ private String commitMessage = null;
+
+ @Override
+ public void commit(String message) {
+ requestCommit = true;
+ commitMessage = message;
+ }
+
+ protected void doCommit() {
+ session.asyncRequest(new WriteRequest() {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ if (DEBUG) System.out.println("Commit " + commitMessage);
+ if (commitMessage != null) {
+ Layer0Utils.addCommentMetadata(graph, commitMessage);
+ graph.markUndoPoint();
+ commitMessage = null;
+ }
+ commit(graph);
+ }
+
+ }, new Callback<DatabaseException>() {
+
+ @Override
+ public void run(DatabaseException parameter) {
+ if (parameter != null)
+ ExceptionUtils.logAndShowError("Cannot commit editor changes", parameter);
+ }
+ });
+ }
+
+ protected void commit(WriteGraph graph) throws DatabaseException {
+ synchronized(syncMutex) {
+ if (DEBUG) System.out.println("Commit");
+ graphUpdates = true;
+ mapping.updateDomain(graph);
+ graphUpdates = false;
+ clearDeletes();
+ if (DEBUG) System.out.println("Commit done");
+ }
+ }
+
+
+
+ @Override
+ public void domainModified() {
+ if (graphUpdates)
+ return;
+ if (DEBUG)System.out.println("domainModified");
+ session.asyncRequest(new ReadRequest() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run(ReadGraph graph) throws DatabaseException {
+ update(graph);
+ }
+ });
+
+ }
+
+ protected void reset(ReadGraph graph) throws MappingException {
+ if (DEBUG) System.out.println("Reset");