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