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
17 import org.simantics.modeling.ui.modelBrowser.model.INode;
\r
19 @SuppressWarnings("deprecation")
\r
20 public class ImportNode2 implements INode {
\r
22 private Resource project;
\r
24 public ImportNode2(Resource project) {
\r
25 this.project = project;
\r
28 @SuppressWarnings("rawtypes")
\r
30 public Object getAdapter(Class adapter) {
\r
35 public int getCategory(ReadGraph graph) throws DatabaseException {
\r
41 public ImageDescriptor getImage(ReadGraph graph) throws DatabaseException {
\r
42 return Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/silk/database_connect.png");
\r
46 public String getLabel(ReadGraph graph) throws DatabaseException {
\r
51 public Modifier getModifier(Session session, String columnId) {
\r
52 // TODO Auto-generated method stub
\r
57 public void handleDelete(WriteGraph graph) throws DatabaseException {
\r
58 // TODO Auto-generated method stub
\r
63 public void handleDrop(Session session, ISelection selection) {
\r
64 // TODO Auto-generated method stub
\r
69 public boolean hasChildren(ReadGraph graph) throws DatabaseException {
\r
70 return getChildren(graph).size() > 0;
\r
74 public Collection<?> getChildren(ReadGraph graph) throws DatabaseException {
\r
75 List<INode> nodes = new ArrayList<INode>();
\r
76 InteropResource i = InteropResource.getInstance(graph);
\r
78 Collection<Resource> objs = graph.getObjects(project, i.HasImportData);
\r
79 for (Resource o : objs) {
\r
80 if (graph.isInstanceOf(o, i.ImportLibrary)) {
\r
81 INode node = graph.adapt(o, INode.class);
\r