]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/modelBrowser/model/ConnectionUp.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / modelBrowser / model / ConnectionUp.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 java.util.Collection;
15 import java.util.Collections;
16
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.jface.viewers.ISelection;
19 import org.simantics.browsing.ui.content.Labeler.Modifier;
20 import org.simantics.db.ReadGraph;
21 import org.simantics.db.Resource;
22 import org.simantics.db.Session;
23 import org.simantics.db.WriteGraph;
24 import org.simantics.db.exception.DatabaseException;
25 import org.simantics.layer0.Layer0;
26 import org.simantics.modeling.ui.Activator;
27
28 @Deprecated
29 public class ConnectionUp implements INode {
30
31     Resource sourceRelation;
32     Resource target;
33     Resource targetRelation;
34     Resource connection;
35
36     public ConnectionUp(Resource connection,
37             Resource sourceRelation, Resource target, Resource targetRelation) {
38         this.connection = connection;
39         this.sourceRelation = sourceRelation;
40         this.target = target;
41         this.targetRelation = targetRelation;
42     }
43
44     @Override
45     public Collection<?> getChildren(ReadGraph g) {
46         return Collections.EMPTY_LIST;
47     }
48
49     @Override
50     public ImageDescriptor getImage(ReadGraph g) {
51         return Activator.ARROW_RIGHT_ICON;
52     }
53
54     @Override
55     public String getLabel(ReadGraph g) throws DatabaseException {
56         Layer0 b = Layer0.getInstance(g);
57         String targetName = g.getPossibleRelatedValue(target, b.HasName);
58         if(targetName == null)
59             targetName = "";
60
61         String relationName = g.getPossibleRelatedValue(targetRelation, b.HasName);
62         if(relationName == null)
63             relationName = "";
64
65         return targetName + "." + relationName;
66     }
67
68     @Override
69     public int getCategory(ReadGraph graph) {
70         return 0;
71     }
72
73     @Override
74     public void handleDrop(Session session, ISelection selection) {
75     }
76
77     @Override
78     public void handleDelete(WriteGraph graph) throws DatabaseException {
79     }
80
81     @Override
82     public boolean hasChildren(ReadGraph g) {
83         return false;
84     }
85
86     @Override
87     public Object getAdapter(Class adapter) {
88         if(adapter.isAssignableFrom(Resource.class))
89             return connection;
90         return null;
91     }
92
93     @Override
94     public Modifier getModifier(Session session, String columnId) {
95         return null;
96     }
97
98 }