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