]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/StatementPredicateNode.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / modelBrowser / model / StatementPredicateNode.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.modeling.ui.modelBrowser.model;
13
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;
22
23 @Deprecated
24 public abstract class StatementPredicateNode implements INode {
25
26     protected Statement statement;
27
28     public StatementPredicateNode(Statement resource) {
29         assert resource != null;
30         this.statement = resource;
31     }
32
33     @Override
34     public String getLabel(ReadGraph g) throws DatabaseException {
35         return LabelerUtil.safeStringRepresentation(g, statement.getPredicate());
36     }
37
38     @Override
39     public int getCategory(ReadGraph graph) throws DatabaseException {
40         return 0;
41     }
42
43     @Override
44     public Modifier getModifier(Session session, String columnId) {
45         return null;
46     }
47
48     @Override
49     public boolean hasChildren(ReadGraph g) throws DatabaseException {
50         return !getChildren(g).isEmpty();
51     }
52
53     @Override
54     public Object getAdapter(Class adapter) {
55         if (adapter == Resource.class)
56             return statement.getPredicate();
57         if (adapter == Statement.class)
58             return statement;
59         return null;
60     }
61
62     @Override
63     public boolean equals(Object obj) {
64         if(this == obj)
65             return true;
66         if(obj == null)
67             return false;
68         return getClass().equals(obj.getClass()) && statement.equals(((StatementPredicateNode)obj).statement);
69     }
70
71     @Override
72     public int hashCode() {
73         return getClass().hashCode()*31 + statement.hashCode();
74     }
75
76     @Override
77     public void handleDrop(Session session, ISelection data) {
78     }
79
80 }