1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.diagram.query;
\r
14 import org.eclipse.core.runtime.IProgressMonitor;
\r
15 import org.simantics.db.ReadGraph;
\r
16 import org.simantics.db.Resource;
\r
17 import org.simantics.db.common.ResourceArray;
\r
18 import org.simantics.db.common.request.ResourceRead;
\r
19 import org.simantics.db.exception.DatabaseException;
\r
20 import org.simantics.diagram.adapter.IDiagramLoader;
\r
21 import org.simantics.g2d.diagram.IDiagram;
\r
22 import org.simantics.utils.datastructures.hints.IHintObservable;
\r
25 * @author Tuukka Lehtonen
\r
27 public class DiagramLoadQuery extends ResourceRead<IDiagram> {
\r
31 IProgressMonitor monitor;
\r
32 ResourceArray structuralPath;
\r
33 IDiagramLoader loader;
\r
34 IHintObservable initialHints;
\r
36 public DiagramLoadQuery(IProgressMonitor monitor, Resource model, Resource resource, Resource runtime, ResourceArray structuralPath, IDiagramLoader loader, IHintObservable initialHints) {
\r
39 // if (runtime == null)
\r
40 // throw new IllegalArgumentException("null runtime diagram resource");
\r
43 this.runtime = runtime;
\r
44 this.monitor = monitor;
\r
45 this.structuralPath = structuralPath != null ? structuralPath : ResourceArray.EMPTY;
\r
46 this.loader = loader;
\r
47 this.initialHints = initialHints;
\r
51 public IDiagram perform(ReadGraph graph) throws DatabaseException {
\r
52 return loader.loadDiagram(monitor, graph, graph.getPossibleURI(model), resource, runtime, structuralPath, initialHints);
\r
56 public boolean equals(Object other) {
\r
57 // Make sure that we always receive a new result
\r
58 return this == other;
\r
62 public int hashCode() {
\r
63 return super.hashCode() + 31 * getClass().hashCode();
\r