]> gerrit.simantics Code Review - simantics/platform.git/blob
98f1cbd277d71f9d17bac882eae8800d56950e5d
[simantics/platform.git] /
1 package org.simantics.document.linking.ge;
2
3 import org.simantics.db.Resource;
4 import org.simantics.db.WriteGraph;
5 import org.simantics.db.common.request.WriteRequest;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.db.layer0.adapter.ActionFactory;
8 import org.simantics.db.layer0.variable.Variable;
9 import org.simantics.document.linking.utils.SourceLinkUtil;
10 import org.simantics.ui.SimanticsUI;
11
12
13 public class ReplaceWithLatestAction implements ActionFactory{
14         
15         
16         @Override
17         public Runnable create(Object target) {
18                 if (!(target instanceof Variable))
19                         return null;
20                 final Variable v = (Variable)target;
21                 
22
23                 return new Runnable() {
24                         
25                         @Override
26                         public void run() {
27                                 SimanticsUI.getSession().asyncRequest(new WriteRequest() {
28                                         
29                                         @Override
30                                         public void perform(WriteGraph graph) throws DatabaseException {
31                                             graph.markUndoPoint();
32                                                 Resource t = v.getPossibleRepresents(graph);
33                                                 SourceLinkUtil.updateToLatest(graph, t);
34                                                 
35                                         }
36                                 });
37                                 
38                         }
39                 };
40
41                 
42         }
43
44 }