--- /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.diagram.query;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.ResourceArray;\r
+import org.simantics.db.common.request.ResourceRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.diagram.adapter.IDiagramLoader;\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.utils.datastructures.hints.IHintObservable;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class DiagramLoadQuery extends ResourceRead<IDiagram> {\r
+\r
+ Resource model;\r
+ Resource runtime;\r
+ IProgressMonitor monitor;\r
+ ResourceArray structuralPath;\r
+ IDiagramLoader loader;\r
+ IHintObservable initialHints;\r
+\r
+ public DiagramLoadQuery(IProgressMonitor monitor, Resource model, Resource resource, Resource runtime, ResourceArray structuralPath, IDiagramLoader loader, IHintObservable initialHints) {\r
+ super(resource);\r
+\r
+// if (runtime == null)\r
+// throw new IllegalArgumentException("null runtime diagram resource");\r
+\r
+ this.model = model;\r
+ this.runtime = runtime;\r
+ this.monitor = monitor;\r
+ this.structuralPath = structuralPath != null ? structuralPath : ResourceArray.EMPTY;\r
+ this.loader = loader;\r
+ this.initialHints = initialHints;\r
+ }\r
+\r
+ @Override\r
+ public IDiagram perform(ReadGraph graph) throws DatabaseException {\r
+ return loader.loadDiagram(monitor, graph, graph.getPossibleURI(model), resource, runtime, structuralPath, initialHints);\r
+ }\r
+\r
+ @Override\r
+ public boolean equals(Object other) {\r
+ // Make sure that we always receive a new result\r
+ return this == other;\r
+ }\r
+\r
+ @Override\r
+ public int hashCode() {\r
+ return super.hashCode() + 31 * getClass().hashCode();\r
+ }\r
+\r
+}\r