]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/proxy/ProxyHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / proxy / ProxyHandler.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.g2d.element.handler.impl.proxy;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.simantics.g2d.element.ElementClass;
18 import org.simantics.g2d.element.handler.AdditionalColor;
19 import org.simantics.g2d.element.handler.BendsHandler;
20 import org.simantics.g2d.element.handler.BorderColor;
21 import org.simantics.g2d.element.handler.Clickable;
22 import org.simantics.g2d.element.handler.EdgeVisuals;
23 import org.simantics.g2d.element.handler.ElementAdapter;
24 import org.simantics.g2d.element.handler.ElementHandler;
25 import org.simantics.g2d.element.handler.FillColor;
26 import org.simantics.g2d.element.handler.HandleMouseEvent;
27 import org.simantics.g2d.element.handler.Heartbeat;
28 import org.simantics.g2d.element.handler.InternalSize;
29 import org.simantics.g2d.element.handler.LifeCycle;
30 import org.simantics.g2d.element.handler.Move;
31 import org.simantics.g2d.element.handler.Outline;
32 import org.simantics.g2d.element.handler.Pick;
33 import org.simantics.g2d.element.handler.Resize;
34 import org.simantics.g2d.element.handler.Rotate;
35 import org.simantics.g2d.element.handler.Scale;
36 import org.simantics.g2d.element.handler.Stateful;
37 import org.simantics.g2d.element.handler.TerminalLayout;
38 import org.simantics.g2d.element.handler.TerminalTopology;
39 import org.simantics.g2d.element.handler.Text;
40 import org.simantics.g2d.element.handler.TextColor;
41 import org.simantics.g2d.element.handler.Transform;
42 import org.simantics.g2d.element.handler.Validator;
43
44 /**
45  * @author Toni Kalajainen
46  */
47 public class ProxyHandler {
48
49     public static ElementClass getProxyClass(ElementClass clazz, IProxyProvider prov)
50     {
51         List<ElementHandler> result = new ArrayList<ElementHandler>();
52         for (ElementHandler eh : clazz.getAll())
53         {
54             addProxyElementHandlers(eh, prov, result);
55             result.add(eh);
56         }
57         return ElementClass.compile(result);
58     }
59
60     public static void addProxyElementHandlers(ElementHandler eh, IProxyProvider prov, List<ElementHandler> result)
61     {
62         if (eh instanceof Move) result.add(new ProxyMove(prov, (Move)eh));
63         if (eh instanceof Stateful) result.add(new ProxyEnabled(prov, (Stateful)eh));
64         if (eh instanceof Clickable) result.add(new ProxyClickable(prov, (Clickable)eh));
65         if (eh instanceof InternalSize) result.add( new ProxyBounds(prov, (InternalSize)eh) );
66         if (eh instanceof Resize) result.add( new ProxyResize(prov, (Resize)eh) );
67         if (eh instanceof Outline) result.add( new ProxyElementShape(prov, (Outline)eh) );
68         if (eh instanceof FillColor) result.add(new ProxyFillColor(prov, (FillColor)eh));
69         if (eh instanceof BorderColor) result.add(new ProxyBorderColor(prov, (BorderColor)eh));
70         if (eh instanceof TextColor) result.add(new ProxyTextColor(prov, (TextColor)eh));
71         if (eh instanceof AdditionalColor) result.add(new ProxyAdditionalColor(prov, (AdditionalColor)eh));
72         if (eh instanceof BendsHandler) result.add(new ProxyEdgeBends(prov, (BendsHandler)eh));
73         if (eh instanceof EdgeVisuals) result.add(new ProxyEdgeVisuals(prov, (EdgeVisuals)eh));
74         if (eh instanceof ElementAdapter) result.add(new ProxyElementAdapter(prov, (ElementAdapter)eh));
75         if (eh instanceof HandleMouseEvent) result.add(new ProxyHandleMouseEvent(prov, (HandleMouseEvent)eh));
76         if (eh instanceof LifeCycle) result.add(new ProxyLifeCycle(prov, (LifeCycle)eh));
77         if (eh instanceof TerminalTopology) result.add(new ProxyNode(prov, (TerminalTopology)eh));
78         if (eh instanceof Pick) result.add(new ProxyPick(prov, (Pick)eh));
79         if (eh instanceof Rotate) result.add(new ProxyRotate(prov, (Rotate)eh));
80         if (eh instanceof Scale) result.add(new ProxyScale(prov, (Scale)eh));
81         if (eh instanceof TerminalLayout) result.add(new ProxyTerminalHandler(prov, (TerminalLayout)eh));
82         if (eh instanceof Text) result.add(new ProxyText(prov, (Text)eh));
83         if (eh instanceof Transform) result.add(new ProxyTransform(prov, (Transform)eh));
84         if (eh instanceof Validator) result.add(new ProxyValidator(prov, (Validator)eh));
85         if (eh instanceof Heartbeat) result.add(new ProxyHeartbeat(prov, (Heartbeat)eh));
86     }
87
88 }