1 /*******************************************************************************
\r
2 * Copyright (c) 2010, 2011 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.browsing.ui.model.nodetypes;
\r
14 import java.util.Collection;
\r
16 import org.simantics.browsing.ui.BuiltinKeys;
\r
17 import org.simantics.browsing.ui.NodeContext;
\r
18 import org.simantics.browsing.ui.NodeContext.ConstantKey;
\r
19 import org.simantics.db.ReadGraph;
\r
20 import org.simantics.db.exception.DatabaseException;
\r
21 import org.simantics.ui.selection.WorkbenchSelectionElement;
\r
24 * Node type specifies the content type and role of the node in
\r
25 * the model browser.
\r
26 * @author Hannu Niemistö
\r
28 public interface NodeType {
\r
30 public static class TypeKey implements ConstantKey<NodeType> {
\r
31 private TypeKey() {}
\r
33 public String toString() {
\r
37 public static final ConstantKey<NodeType> TYPE = new TypeKey();
\r
39 public static final ConstantKey<?>[] KEY_SEQUENCE = new ConstantKey<?>[] {
\r
44 public static final ConstantKey<?>[] KEY_SEQUENCE_EXT = new ConstantKey<?>[] {
\r
47 BuiltinKeys.UI_CONTEXT,
\r
48 BuiltinKeys.BROWSE_CONTEXT,
\r
49 BuiltinKeys.ACTION_BROWSE_CONTEXT
\r
53 * Creates a node context from the content. If the content is not
\r
54 * suitable for this node type, returns null. This method cannot
\r
55 * assume anything about the Java type of the content given as
\r
56 * a parameter, but if it returns a node its content must be
\r
57 * an instance of the Java class given by getContentType.
\r
59 NodeContext createNodeContext(ReadGraph graph, Object content) throws DatabaseException;
\r
62 * Returns the expected Java type of the content.
\r
64 Class<?> getContentType();
\r
67 * Tests if this node type inherits (or is equal to) given node type.
\r
69 boolean inherits(ReadGraph graph, NodeType superType) throws DatabaseException;
\r
71 Collection<NodeType> getSuper(ReadGraph g) throws DatabaseException;
\r
73 String toString(ReadGraph graph) throws DatabaseException;
\r
75 WorkbenchSelectionElement getWorkbenchSelectionElement(NodeContext context);
\r