1 package org.simantics.modeling.ui.diagram.monitor;
3 import java.util.Collections;
5 import java.util.TreeMap;
7 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.Resource;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.db.layer0.adapter.Instances;
12 import org.simantics.db.layer0.request.PossibleModel;
13 import org.simantics.diagram.stubs.DiagramResource;
14 import org.simantics.layer0.Layer0;
15 import org.simantics.utils.strings.AlphanumComparator;
16 import org.simantics.utils.strings.StringUtils;
19 * @author Tuukka Lehtonen
21 public class AvailableTemplateFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {
24 public Map<String, Object> perform(ReadGraph graph, Resource input) throws DatabaseException {
26 Layer0 L0 = Layer0.getInstance(graph);
27 DiagramResource DIA = DiagramResource.getInstance(graph);
28 Instances query = graph.adapt(DIA.MonitorTemplate, Instances.class);
29 Resource model = graph.syncRequest(new PossibleModel(input));
31 return Collections.emptyMap();
32 Map<String, Object> result = new TreeMap<>(AlphanumComparator.CASE_INSENSITIVE_COMPARATOR);
33 for (Resource template : query.find(graph, model)) {
34 String label = graph.getPossibleRelatedAdapter(template, L0.HasLabel, String.class);
35 result.put(StringUtils.safeString(label), template);