]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/proxy/ProxyHandler.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/proxy/ProxyHandler.java
new file mode 100644 (file)
index 0000000..109ed1a
--- /dev/null
@@ -0,0 +1,88 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.element.handler.impl.proxy;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.handler.AdditionalColor;\r
+import org.simantics.g2d.element.handler.BendsHandler;\r
+import org.simantics.g2d.element.handler.BorderColor;\r
+import org.simantics.g2d.element.handler.Clickable;\r
+import org.simantics.g2d.element.handler.EdgeVisuals;\r
+import org.simantics.g2d.element.handler.ElementAdapter;\r
+import org.simantics.g2d.element.handler.ElementHandler;\r
+import org.simantics.g2d.element.handler.FillColor;\r
+import org.simantics.g2d.element.handler.HandleMouseEvent;\r
+import org.simantics.g2d.element.handler.Heartbeat;\r
+import org.simantics.g2d.element.handler.InternalSize;\r
+import org.simantics.g2d.element.handler.LifeCycle;\r
+import org.simantics.g2d.element.handler.Move;\r
+import org.simantics.g2d.element.handler.Outline;\r
+import org.simantics.g2d.element.handler.Pick;\r
+import org.simantics.g2d.element.handler.Resize;\r
+import org.simantics.g2d.element.handler.Rotate;\r
+import org.simantics.g2d.element.handler.Scale;\r
+import org.simantics.g2d.element.handler.Stateful;\r
+import org.simantics.g2d.element.handler.TerminalLayout;\r
+import org.simantics.g2d.element.handler.TerminalTopology;\r
+import org.simantics.g2d.element.handler.Text;\r
+import org.simantics.g2d.element.handler.TextColor;\r
+import org.simantics.g2d.element.handler.Transform;\r
+import org.simantics.g2d.element.handler.Validator;\r
+\r
+/**\r
+ * @author Toni Kalajainen\r
+ */\r
+public class ProxyHandler {\r
+\r
+    public static ElementClass getProxyClass(ElementClass clazz, IProxyProvider prov)\r
+    {\r
+        List<ElementHandler> result = new ArrayList<ElementHandler>();\r
+        for (ElementHandler eh : clazz.getAll())\r
+        {\r
+            addProxyElementHandlers(eh, prov, result);\r
+            result.add(eh);\r
+        }\r
+        return ElementClass.compile(result);\r
+    }\r
+\r
+    public static void addProxyElementHandlers(ElementHandler eh, IProxyProvider prov, List<ElementHandler> result)\r
+    {\r
+        if (eh instanceof Move) result.add(new ProxyMove(prov, (Move)eh));\r
+        if (eh instanceof Stateful) result.add(new ProxyEnabled(prov, (Stateful)eh));\r
+        if (eh instanceof Clickable) result.add(new ProxyClickable(prov, (Clickable)eh));\r
+        if (eh instanceof InternalSize) result.add( new ProxyBounds(prov, (InternalSize)eh) );\r
+        if (eh instanceof Resize) result.add( new ProxyResize(prov, (Resize)eh) );\r
+        if (eh instanceof Outline) result.add( new ProxyElementShape(prov, (Outline)eh) );\r
+        if (eh instanceof FillColor) result.add(new ProxyFillColor(prov, (FillColor)eh));\r
+        if (eh instanceof BorderColor) result.add(new ProxyBorderColor(prov, (BorderColor)eh));\r
+        if (eh instanceof TextColor) result.add(new ProxyTextColor(prov, (TextColor)eh));\r
+        if (eh instanceof AdditionalColor) result.add(new ProxyAdditionalColor(prov, (AdditionalColor)eh));\r
+        if (eh instanceof BendsHandler) result.add(new ProxyEdgeBends(prov, (BendsHandler)eh));\r
+        if (eh instanceof EdgeVisuals) result.add(new ProxyEdgeVisuals(prov, (EdgeVisuals)eh));\r
+        if (eh instanceof ElementAdapter) result.add(new ProxyElementAdapter(prov, (ElementAdapter)eh));\r
+        if (eh instanceof HandleMouseEvent) result.add(new ProxyHandleMouseEvent(prov, (HandleMouseEvent)eh));\r
+        if (eh instanceof LifeCycle) result.add(new ProxyLifeCycle(prov, (LifeCycle)eh));\r
+        if (eh instanceof TerminalTopology) result.add(new ProxyNode(prov, (TerminalTopology)eh));\r
+        if (eh instanceof Pick) result.add(new ProxyPick(prov, (Pick)eh));\r
+        if (eh instanceof Rotate) result.add(new ProxyRotate(prov, (Rotate)eh));\r
+        if (eh instanceof Scale) result.add(new ProxyScale(prov, (Scale)eh));\r
+        if (eh instanceof TerminalLayout) result.add(new ProxyTerminalHandler(prov, (TerminalLayout)eh));\r
+        if (eh instanceof Text) result.add(new ProxyText(prov, (Text)eh));\r
+        if (eh instanceof Transform) result.add(new ProxyTransform(prov, (Transform)eh));\r
+        if (eh instanceof Validator) result.add(new ProxyValidator(prov, (Validator)eh));\r
+        if (eh instanceof Heartbeat) result.add(new ProxyHeartbeat(prov, (Heartbeat)eh));\r
+    }\r
+\r
+}\r