1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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.diagram.profile.view;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
18 import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;
19 import org.simantics.db.ReadGraph;
20 import org.simantics.db.Resource;
21 import org.simantics.db.common.request.ObjectsWithType;
22 import org.simantics.db.exception.DatabaseException;
23 import org.simantics.db.layer0.adapter.Instances;
24 import org.simantics.diagram.stubs.DiagramResource;
26 public class AvailableStyles extends ViewpointContributor<Resource> {
29 public Collection<?> getContribution(ReadGraph graph, Resource runtimeDiagram) throws DatabaseException {
31 DiagramResource dr = DiagramResource.getInstance(graph);
32 String modelURI = graph.getPossibleRelatedValue((Resource)runtimeDiagram, dr.RuntimeDiagram_HasModelURI);
34 return Collections.emptyList();
36 Resource model = graph.getPossibleResource(modelURI);
38 return Collections.emptyList();
40 Instances query = graph.adapt(dr.Style, Instances.class);
42 ArrayList<Resource> result = new ArrayList<Resource>();
43 result.addAll(query.find(graph, model));
44 result.addAll(graph.syncRequest(new ObjectsWithType(model, L0.ConsistsOf, dr.Style)));