--- /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.io.File;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.eclipse.core.runtime.IPath;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.common.node.IModifiable;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.Session;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ui.Activator;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+\r
+@Deprecated\r
+public class Model extends Node implements IModifiable {\r
+\r
+ final static boolean showFolders = true;\r
+\r
+ Resource configuration;\r
+ Session session;\r
+\r
+ public Model(ReadGraph g, Resource resource) throws DatabaseException {\r
+ super(resource);\r
+ this.configuration = g.getPossibleObject(resource, SimulationResource.getInstance(g).HasConfiguration);\r
+ this.session = g.getSession();\r
+ }\r
+\r
+ public File getModelDir() throws DatabaseException {\r
+ IPath location = Platform.getLocation();\r
+ File f = location.toFile();\r
+\r
+ String modelName =\r
+ (String) session.syncRequest(\r
+ org.simantics.db.common.request.Queries.getRelatedValue(resource, Layer0.URIs.HasName, Bindings.STRING));\r
+\r
+ File modelDir = new File(f, modelName);\r
+ return modelDir;\r
+ }\r
+\r
+ @Override\r
+ public Collection<?> getChildren(ReadGraph g) throws DatabaseException {\r
+ Collection<Object> ret = new ArrayList<Object>(3);\r
+ if(configuration != null) {\r
+ ret.add(new Decorator(g.adapt(configuration, INode.class)) {\r
+ @Override\r
+ public String getLabel(ReadGraph g) {\r
+ return "Configuration";\r
+ }\r
+ });\r
+ }\r
+ ret.add(new Experiments(resource));\r
+ ret.add(new States(resource));\r
+// ret.add(new Queries(g, resource));\r
+ ret.add(new Charts(resource));\r
+ ret.add(new Subscriptions(resource));\r
+ ret.add(new Images(resource));\r
+// ret.add(new Spreadsheets(resource));\r
+ ret.add(new RelationViews(resource));\r
+\r
+ /*if(!showFolders) {\r
+ ArrayList<Object> flatten = new ArrayList<Object>();\r
+ for(INode n : ret)\r
+ flatten.addAll(n.getChildren(g));\r
+ return flatten;\r
+ }*/\r
+ return ret;\r
+ }\r
+\r
+ @Override\r
+ public ImageDescriptor getImage(ReadGraph g) {\r
+ return Activator.MODEL_ICON;\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
+ Model other = (Model)obj;\r
+ if(configuration == null) {\r
+ return resource.equals(other.resource) && other.configuration == null;\r
+ } else {\r
+ return resource.equals(other.resource)\r
+ && configuration.equals(other.configuration);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ if(configuration == null) {\r
+ return getClass().hashCode()*31 + resource.hashCode();\r
+ } else {\r
+ return (getClass().hashCode()*31\r
+ + configuration.hashCode())*31 + resource.hashCode();\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public Modifier getModifier(final Session session, String columnId) {\r
+ return new LabelModifier(session, resource);\r
+ }\r
+}\r