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.labeler;
16 import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;
17 import org.simantics.browsing.ui.NodeContext;
18 import org.simantics.browsing.ui.PrimitiveQueryUpdater;
19 import org.simantics.browsing.ui.Tester;
20 import org.simantics.browsing.ui.content.Contributor;
21 import org.simantics.browsing.ui.content.Labeler;
22 import org.simantics.browsing.ui.content.Labeler.Modifier;
23 import org.simantics.browsing.ui.content.LabelerFactory;
24 import org.simantics.browsing.ui.graph.impl.contribution.FinalLabelerContributionImpl;
25 import org.simantics.db.ReadGraph;
26 import org.simantics.db.UndoContext;
27 import org.simantics.db.exception.DatabaseException;
29 abstract public class ContextColumnFinalLabelerContributorImpl implements Contributor<LabelerFactory> {
31 abstract public Map<String, String> getLabel(ReadGraph graph, NodeContext input) throws DatabaseException;
33 public int getCategory(ReadGraph graph, NodeContext input) throws DatabaseException {
37 public Modifier getModifier(ReadGraph graph, NodeContext input, String columnKey) throws DatabaseException {
41 final private Class<?> clazz;
44 public Tester getNodeContextTester() {
48 public ContextColumnFinalLabelerContributorImpl() {
52 public ContextColumnFinalLabelerContributorImpl(Class<?> clazz) {
57 public LabelerFactory getFactory() {
59 return new LabelerFactory() {
62 public Labeler create(final PrimitiveQueryUpdater updater, NodeContext context, final LabelerKey key) {
64 return new FinalLabelerContributionImpl(updater, context, key) {
67 public Map<String, String> labels(ReadGraph graph, NodeContext context) throws DatabaseException {
69 return ContextColumnFinalLabelerContributorImpl.this.getLabel(graph, context);
75 public Modifier getModifier(ReadGraph graph, UndoContext undoContext, NodeContext context, String columnKey) throws DatabaseException {
77 return ContextColumnFinalLabelerContributorImpl.this.getModifier(graph, context, columnKey);
82 public int category(ReadGraph graph, NodeContext context) throws DatabaseException {
84 return ContextColumnFinalLabelerContributorImpl.this.getCategory(graph, context);
89 public String toString() {
90 return ContextColumnFinalLabelerContributorImpl.this.toString();
102 public Class<?> getInputClass() {