X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fchart%2Fproperty%2FAvailableTemplateFactory.java;h=0bec91105b4e25e3d8a1999b697e8bb70ea0fd5e;hp=0f9eb00893e19dd566966cbba8ebedd1b7e90994;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/AvailableTemplateFactory.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/AvailableTemplateFactory.java index 0f9eb0089..0bec91105 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/AvailableTemplateFactory.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/AvailableTemplateFactory.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in - * Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.modeling.ui.chart.property; - -import java.util.Collections; -import java.util.Map; -import java.util.TreeMap; - -import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; -import org.simantics.charts.ontology.ChartResource; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.adapter.Instances; -import org.simantics.db.layer0.request.PossibleModel; -import org.simantics.layer0.Layer0; - -/** - * @author Tuukka Lehtonen - */ -public class AvailableTemplateFactory extends ReadFactoryImpl> { - - @Override - public Map perform(ReadGraph graph, Resource input) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - ChartResource CHART = ChartResource.getInstance(graph); - Instances query = graph.adapt(CHART.ChartTemplate, Instances.class); - Resource model = graph.syncRequest(new PossibleModel(input)); - if (model == null) - return Collections.emptyMap(); - Map result = new TreeMap(); - for (Resource template : query.find(graph, model)) { - if (!graph.isInstanceOf(template, CHART.ChartTemplate)) - continue; - String label = graph.getPossibleRelatedAdapter(template, L0.HasLabel, String.class); - if (label != null) - result.put(label, template); - } - return result; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.modeling.ui.chart.property; + +import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; + +import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl; +import org.simantics.charts.ontology.ChartResource; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.adapter.Instances; +import org.simantics.db.layer0.request.PossibleModel; +import org.simantics.layer0.Layer0; + +/** + * @author Tuukka Lehtonen + */ +public class AvailableTemplateFactory extends ReadFactoryImpl> { + + @Override + public Map perform(ReadGraph graph, Resource input) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + ChartResource CHART = ChartResource.getInstance(graph); + Instances query = graph.adapt(CHART.ChartTemplate, Instances.class); + Resource model = graph.syncRequest(new PossibleModel(input)); + if (model == null) + return Collections.emptyMap(); + Map result = new TreeMap(); + for (Resource template : query.find(graph, model)) { + if (!graph.isInstanceOf(template, CHART.ChartTemplate)) + continue; + String label = graph.getPossibleRelatedAdapter(template, L0.HasLabel, String.class); + if (label != null) + result.put(label, template); + } + return result; + } + +}