1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.modeling.ui.chart.property;
14 import java.util.Collections;
16 import java.util.TreeMap;
18 import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;
19 import org.simantics.charts.ontology.ChartResource;
20 import org.simantics.db.ReadGraph;
21 import org.simantics.db.Resource;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.db.layer0.adapter.Instances;
24 import org.simantics.db.layer0.request.PossibleModel;
25 import org.simantics.layer0.Layer0;
28 * @author Tuukka Lehtonen
30 public class AvailableTemplateFactory extends ReadFactoryImpl<Resource, Map<String, Object>> {
33 public Map<String, Object> perform(ReadGraph graph, Resource input) throws DatabaseException {
34 Layer0 L0 = Layer0.getInstance(graph);
35 ChartResource CHART = ChartResource.getInstance(graph);
36 Instances query = graph.adapt(CHART.ChartTemplate, Instances.class);
37 Resource model = graph.syncRequest(new PossibleModel(input));
39 return Collections.emptyMap();
40 Map<String, Object> result = new TreeMap<String, Object>();
41 for (Resource template : query.find(graph, model)) {
42 if (!graph.isInstanceOf(template, CHART.ChartTemplate))
44 String label = graph.getPossibleRelatedAdapter(template, L0.HasLabel, String.class);
46 result.put(label, template);