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;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 public abstract class GraphLabelerFactory implements LabelerFactory {
33 public Labeler create(PrimitiveQueryUpdater updater, final NodeContext context, LabelerKey key) {
35 assert(updater != null);
36 assert(context != null);
38 return new LazyGraphLabeler(updater, context, key) {
40 public Map<String, String> labels(ReadGraph graph) throws DatabaseException {
41 return GraphLabelerFactory.this.labels(graph, (Resource) context.getConstant(BuiltinKeys.INPUT));
45 public int category(ReadGraph graph) throws DatabaseException {
46 return GraphLabelerFactory.this.category(graph, (Resource) context.getConstant(BuiltinKeys.INPUT));
50 public String toString() {
51 return GraphLabelerFactory.this.toString();
55 public Modifier getModifier(ModificationContext modificationContext, String key) {
56 return GraphLabelerFactory.this.getModifier(key);
60 public Logger getLogger() {
61 return LoggerFactory.getLogger(GraphLabelerFactory.class);
67 abstract protected Map<String, String> labels(ReadGraph graph, Resource resource) throws DatabaseException;
69 protected int category(ReadGraph graph, Resource resource) throws DatabaseException {
73 protected Modifier getModifier(String key) {