]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/RuntimeDirectProfileEntries.java
Better support for ontological profiles
[simantics/platform.git] / bundles / org.simantics.diagram.profile / src / org / simantics / diagram / profile / view / RuntimeDirectProfileEntries.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.profile.view;
13
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
17
18 import org.simantics.browsing.ui.model.children.ChildRule;
19 import org.simantics.db.ReadGraph;
20 import org.simantics.db.Resource;
21 import org.simantics.db.exception.DatabaseException;
22 import org.simantics.diagram.stubs.DiagramResource;
23
24 public class RuntimeDirectProfileEntries implements ChildRule {
25
26         @Override
27         public boolean isCompatible(Class<?> contentType) {
28                 return contentType.equals(Resource.class);
29         }
30
31         @Override
32         public Collection<?> getChildren(ReadGraph graph, Object parent)
33                         throws DatabaseException {
34         
35                 Resource runtimeDiagram = (Resource)parent;
36         DiagramResource dr = DiagramResource.getInstance(graph);
37         Resource runtimeProfile = graph.getPossibleObject(runtimeDiagram, dr.RuntimeDiagram_HasRuntimeProfile);
38         if(runtimeProfile == null) return Collections.emptyList();
39         return graph.syncRequest(new DirectProfileEntries(new ProfileTuple(runtimeProfile, runtimeProfile, runtimeDiagram)));
40         
41     }
42
43         @Override
44         public Collection<?> getParents(ReadGraph graph, Object child)
45                         throws DatabaseException {
46                 return new ArrayList<Resource>();
47         }
48
49 }