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.browsing.ui.graph.impl.contributor.viewpoint;
14 import java.util.Collection;
15 import java.util.function.Consumer;
17 import org.simantics.browsing.ui.BuiltinKeys.ViewpointContributionKey;
18 import org.simantics.browsing.ui.NodeContext;
19 import org.simantics.browsing.ui.PrimitiveQueryUpdater;
20 import org.simantics.browsing.ui.Tester;
21 import org.simantics.browsing.ui.content.Contributor;
22 import org.simantics.browsing.ui.content.ViewpointContribution;
23 import org.simantics.browsing.ui.content.ViewpointContributionFactory;
24 import org.simantics.browsing.ui.graph.impl.contribution.CallbackViewpointContributionImpl;
25 import org.simantics.db.ReadGraph;
26 import org.simantics.db.exception.DatabaseException;
28 abstract public class ContextInputCallbackViewpointContributorImpl implements Contributor<ViewpointContributionFactory> {
30 abstract public void getContribution(ReadGraph graph, NodeContext context, Consumer<Collection<?>> callback) throws DatabaseException;
32 abstract public String getViewpointId();
34 final private Class<?> clazz;
37 public Tester getNodeContextTester() {
41 public ContextInputCallbackViewpointContributorImpl() {
45 public ContextInputCallbackViewpointContributorImpl(Class<?> clazz) {
50 public ViewpointContributionFactory getFactory() {
52 return new ViewpointContributionFactory() {
55 public String getViewpointId() {
56 return ContextInputCallbackViewpointContributorImpl.this.getViewpointId();
60 public ViewpointContribution create(final PrimitiveQueryUpdater updater, NodeContext context, final ViewpointContributionKey key) {
62 return new CallbackViewpointContributionImpl(updater, context, key) {
65 public void children(ReadGraph graph, NodeContext context, Consumer<Collection<?>> callback) throws DatabaseException {
67 ContextInputCallbackViewpointContributorImpl.this.getContribution(graph, context, callback);
72 public Tester getNodeContextTester() {
73 return ContextInputCallbackViewpointContributorImpl.this.getNodeContextTester();
77 public Class<?> getInputClass() {
78 return ContextInputCallbackViewpointContributorImpl.this.getInputClass();
90 public Class<?> getInputClass() {