]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/proxy/ProxyHandler.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / proxy / ProxyHandler.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in 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.g2d.element.handler.impl.proxy;\r
13 \r
14 import java.util.ArrayList;\r
15 import java.util.List;\r
16 \r
17 import org.simantics.g2d.element.ElementClass;\r
18 import org.simantics.g2d.element.handler.AdditionalColor;\r
19 import org.simantics.g2d.element.handler.BendsHandler;\r
20 import org.simantics.g2d.element.handler.BorderColor;\r
21 import org.simantics.g2d.element.handler.Clickable;\r
22 import org.simantics.g2d.element.handler.EdgeVisuals;\r
23 import org.simantics.g2d.element.handler.ElementAdapter;\r
24 import org.simantics.g2d.element.handler.ElementHandler;\r
25 import org.simantics.g2d.element.handler.FillColor;\r
26 import org.simantics.g2d.element.handler.HandleMouseEvent;\r
27 import org.simantics.g2d.element.handler.Heartbeat;\r
28 import org.simantics.g2d.element.handler.InternalSize;\r
29 import org.simantics.g2d.element.handler.LifeCycle;\r
30 import org.simantics.g2d.element.handler.Move;\r
31 import org.simantics.g2d.element.handler.Outline;\r
32 import org.simantics.g2d.element.handler.Pick;\r
33 import org.simantics.g2d.element.handler.Resize;\r
34 import org.simantics.g2d.element.handler.Rotate;\r
35 import org.simantics.g2d.element.handler.Scale;\r
36 import org.simantics.g2d.element.handler.Stateful;\r
37 import org.simantics.g2d.element.handler.TerminalLayout;\r
38 import org.simantics.g2d.element.handler.TerminalTopology;\r
39 import org.simantics.g2d.element.handler.Text;\r
40 import org.simantics.g2d.element.handler.TextColor;\r
41 import org.simantics.g2d.element.handler.Transform;\r
42 import org.simantics.g2d.element.handler.Validator;\r
43 \r
44 /**\r
45  * @author Toni Kalajainen\r
46  */\r
47 public class ProxyHandler {\r
48 \r
49     public static ElementClass getProxyClass(ElementClass clazz, IProxyProvider prov)\r
50     {\r
51         List<ElementHandler> result = new ArrayList<ElementHandler>();\r
52         for (ElementHandler eh : clazz.getAll())\r
53         {\r
54             addProxyElementHandlers(eh, prov, result);\r
55             result.add(eh);\r
56         }\r
57         return ElementClass.compile(result);\r
58     }\r
59 \r
60     public static void addProxyElementHandlers(ElementHandler eh, IProxyProvider prov, List<ElementHandler> result)\r
61     {\r
62         if (eh instanceof Move) result.add(new ProxyMove(prov, (Move)eh));\r
63         if (eh instanceof Stateful) result.add(new ProxyEnabled(prov, (Stateful)eh));\r
64         if (eh instanceof Clickable) result.add(new ProxyClickable(prov, (Clickable)eh));\r
65         if (eh instanceof InternalSize) result.add( new ProxyBounds(prov, (InternalSize)eh) );\r
66         if (eh instanceof Resize) result.add( new ProxyResize(prov, (Resize)eh) );\r
67         if (eh instanceof Outline) result.add( new ProxyElementShape(prov, (Outline)eh) );\r
68         if (eh instanceof FillColor) result.add(new ProxyFillColor(prov, (FillColor)eh));\r
69         if (eh instanceof BorderColor) result.add(new ProxyBorderColor(prov, (BorderColor)eh));\r
70         if (eh instanceof TextColor) result.add(new ProxyTextColor(prov, (TextColor)eh));\r
71         if (eh instanceof AdditionalColor) result.add(new ProxyAdditionalColor(prov, (AdditionalColor)eh));\r
72         if (eh instanceof BendsHandler) result.add(new ProxyEdgeBends(prov, (BendsHandler)eh));\r
73         if (eh instanceof EdgeVisuals) result.add(new ProxyEdgeVisuals(prov, (EdgeVisuals)eh));\r
74         if (eh instanceof ElementAdapter) result.add(new ProxyElementAdapter(prov, (ElementAdapter)eh));\r
75         if (eh instanceof HandleMouseEvent) result.add(new ProxyHandleMouseEvent(prov, (HandleMouseEvent)eh));\r
76         if (eh instanceof LifeCycle) result.add(new ProxyLifeCycle(prov, (LifeCycle)eh));\r
77         if (eh instanceof TerminalTopology) result.add(new ProxyNode(prov, (TerminalTopology)eh));\r
78         if (eh instanceof Pick) result.add(new ProxyPick(prov, (Pick)eh));\r
79         if (eh instanceof Rotate) result.add(new ProxyRotate(prov, (Rotate)eh));\r
80         if (eh instanceof Scale) result.add(new ProxyScale(prov, (Scale)eh));\r
81         if (eh instanceof TerminalLayout) result.add(new ProxyTerminalHandler(prov, (TerminalLayout)eh));\r
82         if (eh instanceof Text) result.add(new ProxyText(prov, (Text)eh));\r
83         if (eh instanceof Transform) result.add(new ProxyTransform(prov, (Transform)eh));\r
84         if (eh instanceof Validator) result.add(new ProxyValidator(prov, (Validator)eh));\r
85         if (eh instanceof Heartbeat) result.add(new ProxyHeartbeat(prov, (Heartbeat)eh));\r
86     }\r
87 \r
88 }\r