1 /*******************************************************************************
2 * Copyright (c) 2012 Association for Decentralized Information Management in
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.adapter;
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;
23 * A request for retrieving an ElementClass based on an {@link ElementFactory},
24 * an element type (Resource), {@link ICanvasContext} and {@link IDiagram}. Only
25 * the canvas context and the element type are considered to identify the
26 * request uniquely. ElementFactory is not a part of the identification since
27 * element factories are originally resolved from element types and the at least
28 * the current implementations do not have proper equals/hashCode
29 * implementations which of destroys the possibility of DB request caching.
31 * @author Tuukka Lehtonen
33 class CreateElementClassRequest extends BinaryAsyncRead<Resource, ICanvasContext, ElementClass> {
35 private final ElementFactory elementFactory;
36 private final IDiagram diagram;
38 public CreateElementClassRequest(ElementFactory elementFactory, Resource elementType, ICanvasContext canvas, IDiagram diagram) {
39 super(elementType, canvas);
40 this.elementFactory = elementFactory;
41 this.diagram = diagram;
45 public void perform(AsyncReadGraph graph, AsyncProcedure<ElementClass> procedure) {
46 elementFactory.create(graph, parameter2, diagram, parameter, procedure);