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;
16 import org.simantics.browsing.ui.BuiltinKeys;
17 import org.simantics.browsing.ui.NodeContext;
18 import org.simantics.browsing.ui.PrimitiveQueryUpdater;
19 import org.simantics.browsing.ui.BuiltinKeys.LabelerKey;
20 import org.simantics.browsing.ui.GraphExplorer.ModificationContext;
21 import org.simantics.browsing.ui.content.Labeler;
22 import org.simantics.browsing.ui.content.LabelerFactory;
23 import org.simantics.browsing.ui.content.Labeler.Modifier;
24 import org.simantics.db.ReadGraph;
25 import org.simantics.db.Resource;
26 import org.simantics.db.exception.DatabaseException;
28 public abstract class GraphLabelerFactory implements LabelerFactory {
31 public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) {
33 assert(updater != null);
34 assert(context != null);
36 return new LazyGraphLabeler(updater, context, key) {
38 public Map<String, String> labels(ReadGraph graph) throws DatabaseException {
39 return GraphLabelerFactory.this.labels(graph, (Resource) context.getConstant(BuiltinKeys.INPUT));
43 public int category(ReadGraph graph) throws DatabaseException {
44 return GraphLabelerFactory.this.category(graph, (Resource) context.getConstant(BuiltinKeys.INPUT));
48 public String toString() {
49 return GraphLabelerFactory.this.toString();
53 public Modifier getModifier(ModificationContext modificationContext, String key) {
54 return GraphLabelerFactory.this.getModifier(key);
60 abstract protected Map<String, String> labels(ReadGraph graph, Resource resource) throws DatabaseException;
62 protected int category(ReadGraph graph, Resource resource) throws DatabaseException {
66 protected Modifier getModifier(String key) {