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