1 package org.simantics.document.linking.ge;
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;
13 public class ReplaceWithLatestAction implements ActionFactory{
17 public Runnable create(Object target) {
18 if (!(target instanceof Variable))
20 final Variable v = (Variable)target;
23 return new Runnable() {
27 SimanticsUI.getSession().asyncRequest(new WriteRequest() {
30 public void perform(WriteGraph graph) throws DatabaseException {
31 graph.markUndoPoint();
32 Resource t = v.getPossibleRepresents(graph);
33 SourceLinkUtil.updateToLatest(graph, t);