1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Association for Decentralized Information Management in
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.model.nodetypes;
14 import java.util.Collection;
16 import org.simantics.browsing.ui.BuiltinKeys;
17 import org.simantics.browsing.ui.NodeContext;
18 import org.simantics.browsing.ui.NodeContext.ConstantKey;
19 import org.simantics.db.ReadGraph;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.ui.selection.WorkbenchSelectionElement;
24 * Node type specifies the content type and role of the node in
26 * @author Hannu Niemistö
28 public interface NodeType {
30 public static class TypeKey implements ConstantKey<NodeType> {
33 public String toString() {
37 public static final ConstantKey<NodeType> TYPE = new TypeKey();
39 public static final ConstantKey<?>[] KEY_SEQUENCE = new ConstantKey<?>[] {
44 public static final ConstantKey<?>[] KEY_SEQUENCE_EXT = new ConstantKey<?>[] {
47 BuiltinKeys.UI_CONTEXT,
48 BuiltinKeys.BROWSE_CONTEXT,
49 BuiltinKeys.ACTION_BROWSE_CONTEXT
53 * Creates a node context from the content. If the content is not
54 * suitable for this node type, returns null. This method cannot
55 * assume anything about the Java type of the content given as
56 * a parameter, but if it returns a node its content must be
57 * an instance of the Java class given by getContentType.
59 NodeContext createNodeContext(ReadGraph graph, Object content) throws DatabaseException;
62 * Returns the expected Java type of the content.
64 Class<?> getContentType();
67 * Tests if this node type inherits (or is equal to) given node type.
69 boolean inherits(ReadGraph graph, NodeType superType) throws DatabaseException;
71 Collection<NodeType> getSuper(ReadGraph g) throws DatabaseException;
73 String toString(ReadGraph graph) throws DatabaseException;
75 WorkbenchSelectionElement getWorkbenchSelectionElement(NodeContext context);