]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/ExternalSetValue.java
New implementation NearestOwnerFinder of CommonDBUtils.getNearestOwner
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / ExternalSetValue.java
1 package org.simantics.db.layer0.variable;
2
3 import org.simantics.databoard.binding.Binding;
4 import org.simantics.databoard.binding.error.BindingException;
5 import org.simantics.db.common.utils.Logger;
6 import org.simantics.db.service.ExternalOperation;
7 import org.simantics.simulator.variable.NodeManager;
8 import org.simantics.simulator.variable.exceptions.NodeManagerException;
9
10 public class ExternalSetValue implements ExternalOperation {
11
12     @SuppressWarnings("rawtypes")
13         final private NodeManager manager;
14     final private Object node;
15     final private Object oldValue;
16     final private Object newValue;
17     final private Binding binding;
18     
19     public ExternalSetValue(@SuppressWarnings("rawtypes") NodeManager manager, Object node, Object oldValue, Object newValue, Binding binding) {
20         this.manager = manager;
21         this.node = node;
22         this.oldValue = oldValue;
23         this.newValue = newValue;
24         this.binding = binding;
25     }
26     
27     @SuppressWarnings("unchecked")
28         @Override
29     public void undo() {
30         try {
31             manager.setValue(node, oldValue, binding);
32         } catch (NodeManagerException | BindingException e) {
33             Logger.defaultLogError(e);
34         }
35     }
36
37     @SuppressWarnings("unchecked")
38         @Override
39     public void redo() {
40         try {
41             manager.setValue(node, newValue, binding);
42         } catch (NodeManagerException | BindingException e) {
43             Logger.defaultLogError(e);
44         }
45     }
46
47     @Override
48     public boolean isDisposed() {
49         return false;
50     }
51
52 }