]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/VariableRepresentation.java
Index tokenized lowercase versions of name and types for UI searches
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / VariableRepresentation.java
1 package org.simantics.db.layer0.util;
2
3 import java.util.Map;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.RequestProcessor;
7 import org.simantics.db.common.request.UniqueRead;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.layer0.util.SimanticsClipboard.Representation;
10 import org.simantics.db.layer0.variable.Variable;
11 import org.simantics.db.layer0.variable.Variables;
12 import org.simantics.utils.datastructures.hints.IHintContext.Key;
13
14 class VariableRepresentation implements Representation {
15
16         private String URI;
17         
18         public VariableRepresentation(String URI) {
19                 this.URI = URI;
20         }
21
22         @Override
23         public Key getKey() {
24                 return SimanticsKeys.KEY_VARIABLE;
25         }
26         
27         @SuppressWarnings("unchecked")
28         @Override
29         public <T> T getValue(RequestProcessor processor, Map<String,Object> hints) throws DatabaseException {
30                 return (T)processor.syncRequest(new UniqueRead<Variable>() {
31                         @Override
32                         public Variable perform(ReadGraph graph) throws DatabaseException {
33                                 return Variables.getVariable(graph, URI);
34                         }
35                 });
36         }
37         
38 }