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