1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.diagram.profile.view;
\r
14 import java.util.ArrayList;
\r
15 import java.util.Collection;
\r
16 import java.util.Collections;
\r
18 import org.simantics.browsing.ui.model.children.ChildRule;
\r
19 import org.simantics.db.ReadGraph;
\r
20 import org.simantics.db.Resource;
\r
21 import org.simantics.db.common.utils.ListUtils;
\r
22 import org.simantics.db.exception.DatabaseException;
\r
23 import org.simantics.diagram.stubs.DiagramResource;
\r
24 import org.simantics.scenegraph.profile.ProfileUtils;
\r
26 public class ProfileEntryChildren implements ChildRule {
\r
29 public boolean isCompatible(Class<?> contentType) {
\r
30 return contentType.equals(ResourcePair.class);
\r
34 public Collection<?> getChildren(ReadGraph graph, Object parent)
\r
35 throws DatabaseException {
\r
37 ResourcePair entry = (ResourcePair)parent;
\r
38 ArrayList<ResourcePair> entries = new ArrayList<ResourcePair>();
\r
39 DiagramResource DIA = DiagramResource.getInstance(graph);
\r
40 Resource children = graph.getPossibleObject(entry.getSecond(), DIA.HasEntries);
\r
41 if(children == null) return Collections.emptyList();
\r
43 for(Resource entry2 : ProfileUtils.getProfileChildrenFromEntries(graph, children)) entries.add(new ResourcePair(entry.getFirst(), entry2));
\r
49 public Collection<?> getParents(ReadGraph graph, Object child)
\r
50 throws DatabaseException {
\r
51 return new ArrayList<Resource>();
\r