]> gerrit.simantics Code Review - simantics/sysdyn.git/blob
e562ff3587bedb8d954c854f75b08d0443c420f6
[simantics/sysdyn.git] /
1 /*******************************************************************************\r
2  * Copyright (c) 2010 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.sysdyn.ui.elements;\r
13 \r
14 import org.simantics.db.AsyncReadGraph;\r
15 import org.simantics.db.Resource;\r
16 import org.simantics.db.common.adaption.ResourceAdapter;\r
17 import org.simantics.db.procedure.AsyncProcedure;\r
18 import org.simantics.diagram.adapter.DiagramClassAdapter;\r
19 import org.simantics.g2d.diagram.DiagramClass;\r
20 import org.simantics.g2d.diagram.DiagramHints;\r
21 import org.simantics.g2d.diagram.IDiagram;\r
22 import org.simantics.g2d.diagram.handler.LifeCycle;\r
23 import org.simantics.g2d.routing.RouterFactory;\r
24 \r
25 /**\r
26  * @author Tuukka Lehtonen\r
27  */\r
28 public class ConfigurationDiagramClassAdapter implements ResourceAdapter<DiagramClass> {\r
29 \r
30     @Override\r
31     public void adapt(AsyncReadGraph g, Resource source, Resource r, AsyncProcedure<DiagramClass> procedure) {\r
32         procedure.execute(g, DiagramClassAdapter.INSTANCE.newClassWith(\r
33                 Initializer.INSTANCE\r
34         ));\r
35     }\r
36 \r
37     static class Initializer extends LifeCycle.Stub {\r
38         public static final Initializer INSTANCE = new Initializer();\r
39 \r
40         @Override\r
41         public void onDiagramCreated(IDiagram diagram) {\r
42             diagram.setHint(DiagramHints.ROUTE_ALGORITHM, RouterFactory.create(false, false));\r
43         }\r
44     }\r
45 \r
46 }\r