1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\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.modeling.ui.modelBrowser.model;
\r
14 import org.eclipse.jface.viewers.ISelection;
\r
15 import org.simantics.browsing.ui.content.Labeler.Modifier;
\r
16 import org.simantics.browsing.ui.graph.impl.LabelerUtil;
\r
17 import org.simantics.db.ReadGraph;
\r
18 import org.simantics.db.Resource;
\r
19 import org.simantics.db.Session;
\r
20 import org.simantics.db.Statement;
\r
21 import org.simantics.db.exception.DatabaseException;
\r
24 public abstract class StatementPredicateNode implements INode {
\r
26 protected Statement statement;
\r
28 public StatementPredicateNode(Statement resource) {
\r
29 assert resource != null;
\r
30 this.statement = resource;
\r
34 public String getLabel(ReadGraph g) throws DatabaseException {
\r
35 return LabelerUtil.safeStringRepresentation(g, statement.getPredicate());
\r
39 public int getCategory(ReadGraph graph) throws DatabaseException {
\r
44 public Modifier getModifier(Session session, String columnId) {
\r
49 public boolean hasChildren(ReadGraph g) throws DatabaseException {
\r
50 return !getChildren(g).isEmpty();
\r
54 public Object getAdapter(Class adapter) {
\r
55 if (adapter == Resource.class)
\r
56 return statement.getPredicate();
\r
57 if (adapter == Statement.class)
\r
63 public boolean equals(Object obj) {
\r
68 return getClass().equals(obj.getClass()) && statement.equals(((StatementPredicateNode)obj).statement);
\r
72 public int hashCode() {
\r
73 return getClass().hashCode()*31 + statement.hashCode();
\r
77 public void handleDrop(Session session, ISelection data) {
\r