X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fadapter%2FBranchPointClassFactory.java;h=ab21638657bd2c101b5f6541ac783a728523f4f4;hb=617b9475710b80a125597f222f9777224972ce72;hp=50e88c09ec43480babbf45d1cf0ae04fc83245b4;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BranchPointClassFactory.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BranchPointClassFactory.java index 50e88c09e..ab2163865 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BranchPointClassFactory.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/adapter/BranchPointClassFactory.java @@ -1,84 +1,84 @@ -/******************************************************************************* - * 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.adapter; - - -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter; -import org.simantics.db.common.procedure.guarded.GuardedAsyncProcedureWrapper; -import org.simantics.db.procedure.AsyncProcedure; -import org.simantics.diagram.stubs.DiagramResource; -import org.simantics.diagram.synchronization.SynchronizationHints; -import org.simantics.diagram.synchronization.graph.TransformSynchronizer; -import org.simantics.g2d.canvas.ICanvasContext; -import org.simantics.g2d.diagram.IDiagram; -import org.simantics.g2d.element.ElementClass; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.impl.StaticObjectAdapter; -import org.simantics.g2d.elementclass.BranchPoint; -import org.simantics.g2d.elementclass.BranchPoint.Direction; -import org.simantics.g2d.elementclass.BranchPointClass; - -/** - * @author Tuukka Lehtonen - */ -public class BranchPointClassFactory extends ElementFactoryAdapter { - - public static ElementClass create(Resource elementClass) { - return BranchPointClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementClass)); - } - - @Override - public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, AsyncProcedure procedure) { - procedure.execute(graph, BranchPointClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementType))); - } - - @Override - public void load(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, final Resource element, final IElement e, final AsyncProcedure procedure) { - e.setHint(SynchronizationHints.HINT_SYNCHRONIZER, TransformSynchronizer.INSTANCE); - - final AsyncProcedure guard = new GuardedAsyncProcedureWrapper(procedure, 2); - - final BranchPoint bp = e.getElementClass().getAtMostOneItemOfClass(BranchPoint.class); - if (bp != null) { - final DiagramResource dr = graph.getService(DiagramResource.class); - graph.forHasStatement(element, dr.Horizontal, element, new AsyncProcedureAdapter() { - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - guard.exception(graph, throwable); - } - @Override - public void execute(AsyncReadGraph graph, final Boolean horizontal) { - graph.forHasStatement(element, dr.Vertical, element, new AsyncProcedure() { - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - guard.exception(graph, throwable); - } - @Override - public void execute(AsyncReadGraph graph, Boolean vertical) { - Direction direction = Direction.Any; - if (horizontal ^ vertical) - direction = horizontal ? Direction.Horizontal : Direction.Vertical; - bp.setDirectionPreference(e, direction); - - guard.execute(graph, e); - } - }); - } - }); - } - - ElementFactoryUtil.readTransform(graph, element, e, guard); - } - +/******************************************************************************* + * 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.adapter; + + +import org.simantics.db.AsyncReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter; +import org.simantics.db.common.procedure.guarded.GuardedAsyncProcedureWrapper; +import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.diagram.stubs.DiagramResource; +import org.simantics.diagram.synchronization.SynchronizationHints; +import org.simantics.diagram.synchronization.graph.TransformSynchronizer; +import org.simantics.g2d.canvas.ICanvasContext; +import org.simantics.g2d.diagram.IDiagram; +import org.simantics.g2d.element.ElementClass; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.impl.StaticObjectAdapter; +import org.simantics.g2d.elementclass.BranchPoint; +import org.simantics.g2d.elementclass.BranchPoint.Direction; +import org.simantics.g2d.elementclass.BranchPointClass; + +/** + * @author Tuukka Lehtonen + */ +public class BranchPointClassFactory extends ElementFactoryAdapter { + + public static ElementClass create(Resource elementClass) { + return BranchPointClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementClass)); + } + + @Override + public void create(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, Resource elementType, AsyncProcedure procedure) { + procedure.execute(graph, BranchPointClass.CLASS.newClassWith(false, new StaticObjectAdapter(elementType))); + } + + @Override + public void load(AsyncReadGraph graph, ICanvasContext canvas, IDiagram diagram, final Resource element, final IElement e, final AsyncProcedure procedure) { + e.setHint(SynchronizationHints.HINT_SYNCHRONIZER, TransformSynchronizer.INSTANCE); + + final AsyncProcedure guard = new GuardedAsyncProcedureWrapper(procedure, 2); + + final BranchPoint bp = e.getElementClass().getAtMostOneItemOfClass(BranchPoint.class); + if (bp != null) { + final DiagramResource dr = graph.getService(DiagramResource.class); + graph.forHasStatement(element, dr.Horizontal, element, new AsyncProcedureAdapter() { + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + guard.exception(graph, throwable); + } + @Override + public void execute(AsyncReadGraph graph, final Boolean horizontal) { + graph.forHasStatement(element, dr.Vertical, element, new AsyncProcedure() { + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + guard.exception(graph, throwable); + } + @Override + public void execute(AsyncReadGraph graph, Boolean vertical) { + Direction direction = Direction.Any; + if (horizontal ^ vertical) + direction = horizontal ? Direction.Horizontal : Direction.Vertical; + bp.setDirectionPreference(e, direction); + + guard.execute(graph, e); + } + }); + } + }); + } + + ElementFactoryUtil.readTransform(graph, element, e, guard); + } + } \ No newline at end of file