1 /*******************************************************************************
2 * Copyright (c) 2007, 2012 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.browsing.ui.swt;
14 import java.util.Collections;
17 import org.simantics.browsing.ui.NodeContext;
18 import org.simantics.browsing.ui.NodeContext.PrimitiveQueryKey;
19 import org.simantics.browsing.ui.common.node.StandardNodes;
20 import org.simantics.browsing.ui.graph.impl.CommonKeys;
21 import org.simantics.browsing.ui.graph.impl.LazyGraphQueryProcessor;
22 import org.simantics.db.ReadGraph;
23 import org.simantics.db.Resource;
24 import org.simantics.db.exception.DatabaseException;
25 import org.simantics.ui.utils.ResourceAdaptionUtils;
26 import org.simantics.utils.Container;
28 public class StandardContextTypesQueryProcessor extends LazyGraphQueryProcessor<Set<Resource>> {
31 public String toString() {
32 return "Standard Context Types";
36 public Object getIdentifier() {
37 return CommonKeys.STANDARD_CONTEXT_TYPES;
41 protected Set<Resource> initial() {
42 return Collections.emptySet();
46 protected Set<Resource> compute(ReadGraph graph, NodeContext context, PrimitiveQueryKey<Container<Set<Resource>>> key) throws DatabaseException {
47 Object input = context.getConstant(StandardNodes.CONTEXT);
48 Resource resource = ResourceAdaptionUtils.toSingleResource(input);
49 if(resource != null) {
50 return graph.getTypes(resource);
52 return Collections.emptySet();