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 java.util.Collection;
15 import java.util.Collections;
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;
29 public class ConnectionUp implements INode {
31 Resource sourceRelation;
33 Resource targetRelation;
36 public ConnectionUp(Resource connection,
37 Resource sourceRelation, Resource target, Resource targetRelation) {
38 this.connection = connection;
39 this.sourceRelation = sourceRelation;
41 this.targetRelation = targetRelation;
45 public Collection<?> getChildren(ReadGraph g) {
46 return Collections.EMPTY_LIST;
50 public ImageDescriptor getImage(ReadGraph g) {
51 return Activator.ARROW_RIGHT_ICON;
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)
61 String relationName = g.getPossibleRelatedValue(targetRelation, b.HasName);
62 if(relationName == null)
65 return targetName + "." + relationName;
69 public int getCategory(ReadGraph graph) {
74 public void handleDrop(Session session, ISelection selection) {
78 public void handleDelete(WriteGraph graph) throws DatabaseException {
82 public boolean hasChildren(ReadGraph g) {
87 public Object getAdapter(Class adapter) {
88 if(adapter.isAssignableFrom(Resource.class))
94 public Modifier getModifier(Session session, String columnId) {