1 package org.simantics.document.server.request;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.exception.DatabaseException;
5 import org.simantics.db.layer0.variable.Variable;
6 import org.simantics.db.layer0.variable.Variables;
7 import org.simantics.db.request.Read;
8 import org.simantics.document.server.handler.AbstractEventHandler;
9 import org.simantics.document.server.io.CommandContext;
10 import org.simantics.structural.stubs.StructuralResource2;
12 public class HandleEventRequest implements Read<AbstractEventHandler> {
16 public HandleEventRequest(String id) {
21 public AbstractEventHandler perform(ReadGraph graph) throws DatabaseException {
23 StructuralResource2.getInstance(graph);
25 Variable variable = Variables.getPossibleVariable(graph, id);
26 if(variable == null) return null;
28 // System.err.println("EVENT " + variable.getURI(graph));
29 Object handler = variable.getValue(graph);
30 if(handler instanceof AbstractEventHandler)
31 return (AbstractEventHandler) handler;
33 throw new DatabaseException("Handler for " + id + " is not instance of AbstractEventHandler (it is instance of " + (handler != null ? handler.getClass() : null) + ")");