1 package org.simantics.interop.browsing;
\r
3 import java.util.ArrayList;
\r
4 import java.util.Collection;
\r
5 import java.util.List;
\r
7 import org.eclipse.jface.resource.ImageDescriptor;
\r
8 import org.eclipse.jface.viewers.ISelection;
\r
9 import org.simantics.browsing.ui.content.Labeler.Modifier;
\r
10 import org.simantics.db.ReadGraph;
\r
11 import org.simantics.db.Resource;
\r
12 import org.simantics.db.Session;
\r
13 import org.simantics.db.WriteGraph;
\r
14 import org.simantics.db.exception.DatabaseException;
\r
15 import org.simantics.interop.Activator;
\r
16 import org.simantics.interop.stubs.InteropResource;
\r
18 public class ImportNode2 implements INode {
\r
20 private Resource project;
\r
22 public ImportNode2(Resource project) {
\r
23 this.project = project;
\r
26 @SuppressWarnings("rawtypes")
\r
28 public Object getAdapter(Class adapter) {
\r
33 public int getCategory(ReadGraph graph) throws DatabaseException {
\r
39 public ImageDescriptor getImage(ReadGraph graph) throws DatabaseException {
\r
40 return Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/database_connect.png");
\r
44 public String getLabel(ReadGraph graph) throws DatabaseException {
\r
49 public Modifier getModifier(Session session, String columnId) {
\r
50 // TODO Auto-generated method stub
\r
55 public void handleDelete(WriteGraph graph) throws DatabaseException {
\r
56 // TODO Auto-generated method stub
\r
61 public void handleDrop(Session session, ISelection selection) {
\r
62 // TODO Auto-generated method stub
\r
67 public boolean hasChildren(ReadGraph graph) throws DatabaseException {
\r
68 return getChildren(graph).size() > 0;
\r
72 public Collection<?> getChildren(ReadGraph graph) throws DatabaseException {
\r
73 List<INode> nodes = new ArrayList<INode>();
\r
74 InteropResource i = InteropResource.getInstance(graph);
\r
76 Collection<Resource> objs = graph.getObjects(project, i.HasImportData);
\r
77 for (Resource o : objs) {
\r
78 if (graph.isInstanceOf(o, i.ImportLibrary)) {
\r
79 INode node = graph.adapt(o, INode.class);
\r