--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modeling.ui.modelBrowser.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.modeling.ui.Activator;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
+import org.simantics.structural2.utils.StructuralUtils;\r
+\r
+@Deprecated\r
+public class Interface extends Node {\r
+ \r
+ Resource instance; // may be null\r
+ boolean isLeaf;\r
+ \r
+ public Interface(Resource resource, Resource instance, boolean isLeaf) {\r
+ super(resource);\r
+ this.instance = instance;\r
+ this.isLeaf = isLeaf;\r
+ }\r
+\r
+ @Override\r
+ public Collection<?> getChildren(ReadGraph g) throws DatabaseException {\r
+ Collection<Resource> resources = \r
+ StructuralUtils.getPropertyRelations(g, resource);\r
+ Collection<INode> nodes = new ArrayList<INode>(resources.size());\r
+ StructuralResource2 sr = StructuralResource2.getInstance(g);\r
+ for(Resource r : resources) {\r
+ if (g.hasStatement(resource, sr.Binds))\r
+ nodes.add(new Parameter(g, r, instance, isLeaf));\r
+ }\r
+ return nodes;\r
+ }\r
+\r
+ @Override\r
+ public ImageDescriptor getImage(ReadGraph g) {\r
+ return Activator.INTERFACE_ICON;\r
+ }\r
+ \r
+ @Override\r
+ public String getLabel(ReadGraph g) throws DatabaseException {\r
+ return "Interface [" + getChildren(g).size() + "]";\r
+ }\r
+ \r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if(this == obj)\r
+ return true;\r
+ if(obj == null)\r
+ return false;\r
+ if(!getClass().equals(obj.getClass()))\r
+ return false;\r
+ Interface other = (Interface)obj;\r
+ return resource.equals(other.resource)\r
+ && (instance == null ? other.instance==null : instance.equals(other.instance))\r
+ && isLeaf == other.isLeaf;\r
+ }\r
+ \r
+ @Override\r
+ public int hashCode() {\r
+ return (getClass().hashCode()*31 + (instance == null ? 0 : instance.hashCode()))*31 + resource.hashCode();\r
+ }\r
+\r
+}\r