]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/GetElementClassRequest.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / adapter / GetElementClassRequest.java
1 /*******************************************************************************
2  * Copyright (c) 2012 Association for Decentralized Information Management in
3  * Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.diagram.adapter;
13
14 import org.simantics.db.AsyncReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.db.common.request.BinaryAsyncRead;
17 import org.simantics.db.procedure.AsyncProcedure;
18 import org.simantics.g2d.canvas.ICanvasContext;
19 import org.simantics.g2d.diagram.IDiagram;
20 import org.simantics.g2d.element.ElementClass;
21
22 /**
23  * @author Tuukka Lehtonen
24  * 
25  * @see CreateElementClassRequest
26  * @see NodeRequest
27  * @see ConnectionRequest
28  */
29 class GetElementClassRequest extends BinaryAsyncRead<Resource, ICanvasContext, ElementClass> {
30
31     private final ElementFactory elementFactory;
32     private final IDiagram       diagram;
33
34     public GetElementClassRequest(ElementFactory elementFactory, Resource element, ICanvasContext canvas, IDiagram diagram) {
35         super(element, canvas);
36         if (elementFactory == null)
37             throw new IllegalArgumentException("elementFactory == null for " + element + " in diagram " + diagram + " with context " + canvas);
38         this.elementFactory = elementFactory; 
39         this.diagram = diagram;
40     }
41
42     @Override
43     public void perform(AsyncReadGraph graph, AsyncProcedure<ElementClass> procedure) {
44         elementFactory.getClass(graph, parameter2, diagram, parameter, procedure);
45     }
46
47 }