X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fquery%2FElementClassQuery.java;h=aca97cc7bc5fc34c2ada2ad4a130d8edc896a3cc;hb=96a52e35c714a09715e1ac17c53910cd31ced9c7;hp=009f6d50b544295cfe632f4e1054043092bd77db;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ElementClassQuery.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ElementClassQuery.java index 009f6d50b..aca97cc7b 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ElementClassQuery.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/query/ElementClassQuery.java @@ -1,65 +1,65 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.diagram.query; - -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ResourceAsyncRead; -import org.simantics.db.procedure.AsyncProcedure; -import org.simantics.diagram.adapter.ElementFactory; -import org.simantics.g2d.canvas.impl.DisposedCanvasContext; -import org.simantics.g2d.diagram.IDiagram; -import org.simantics.g2d.element.ElementClass; -import org.simantics.utils.datastructures.hints.IHintObservable; - -public class ElementClassQuery extends ResourceAsyncRead { - - /** - * External hints for loading an element class. - */ - IHintObservable hints; - - public ElementClassQuery(Resource resource, IHintObservable hints) { - super(resource); - this.hints = hints; - } - - @Override - public void perform(AsyncReadGraph graph, AsyncProcedure procedure) { - graph.forAdapted(resource , ElementFactory.class, createElementClass(procedure)); - } - - private AsyncProcedure createElementClass(final AsyncProcedure parent) { - return new AsyncProcedure() { - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - parent.exception(graph, throwable); - } - - @Override - public void execute(AsyncReadGraph graph, ElementFactory factory) { - // TODO: remove (IDiagram) cast - factory.create(graph, DisposedCanvasContext.INSTANCE, (IDiagram) hints, resource, new AsyncProcedure() { - @Override - public void execute(AsyncReadGraph graph, ElementClass result) { - parent.execute(graph, result); - } - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - parent.exception(graph, throwable); - } - }); - } - }; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.diagram.query; + +import org.simantics.db.AsyncReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ResourceAsyncRead; +import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.diagram.adapter.ElementFactory; +import org.simantics.g2d.canvas.impl.DisposedCanvasContext; +import org.simantics.g2d.diagram.IDiagram; +import org.simantics.g2d.element.ElementClass; +import org.simantics.utils.datastructures.hints.IHintObservable; + +public class ElementClassQuery extends ResourceAsyncRead { + + /** + * External hints for loading an element class. + */ + IHintObservable hints; + + public ElementClassQuery(Resource resource, IHintObservable hints) { + super(resource); + this.hints = hints; + } + + @Override + public void perform(AsyncReadGraph graph, AsyncProcedure procedure) { + graph.forAdapted(resource , ElementFactory.class, createElementClass(procedure)); + } + + private AsyncProcedure createElementClass(final AsyncProcedure parent) { + return new AsyncProcedure() { + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + parent.exception(graph, throwable); + } + + @Override + public void execute(AsyncReadGraph graph, ElementFactory factory) { + // TODO: remove (IDiagram) cast + factory.create(graph, DisposedCanvasContext.INSTANCE, (IDiagram) hints, resource, new AsyncProcedure() { + @Override + public void execute(AsyncReadGraph graph, ElementClass result) { + parent.execute(graph, result); + } + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + parent.exception(graph, throwable); + } + }); + } + }; + } + +}