]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/GroupProxySymbolItem.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / symbolcontribution / GroupProxySymbolItem.java
diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/GroupProxySymbolItem.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/GroupProxySymbolItem.java
new file mode 100644 (file)
index 0000000..5b30fb6
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************\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.diagram.symbolcontribution;\r
+\r
+import org.simantics.diagram.symbollibrary.ISymbolGroup;\r
+import org.simantics.diagram.symbollibrary.ISymbolItem;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.utils.datastructures.cache.ProvisionException;\r
+import org.simantics.utils.datastructures.hints.IHintObservable;\r
+\r
+/**\r
+ * An ISymbolItem proxy version that allows changing the ISymbolGroup returned\r
+ * by {@link #getGroup()}.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class GroupProxySymbolItem implements ISymbolItem {\r
+\r
+    private final ISymbolItem proxy;\r
+    private final ISymbolGroup group;\r
+\r
+    public GroupProxySymbolItem(ISymbolItem item, ISymbolGroup group) {\r
+        if (item == null)\r
+            throw new NullPointerException("null item");\r
+        if (group == null)\r
+            throw new NullPointerException("null group");\r
+        this.proxy = item;\r
+        this.group = group;\r
+    }\r
+\r
+    @Override\r
+    public String getName() {\r
+        return proxy.getName();\r
+    }\r
+\r
+    @Override\r
+    public String getDescription() {\r
+        return proxy.getDescription();\r
+    }\r
+\r
+    @Override\r
+    public Object getAdapter(Class adapter) {\r
+        return proxy.getAdapter(adapter);\r
+    }\r
+\r
+    @Override\r
+    public ElementClass getElementClass(IHintObservable hints) throws ProvisionException {\r
+        return proxy.getElementClass(hints);\r
+    }\r
+\r
+    @Override\r
+    public ISymbolGroup getGroup() {\r
+        return group;\r
+    }\r
+\r
+    @Override\r
+    public int hashCode() {\r
+        return proxy.hashCode();\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        return proxy.equals(obj);\r
+    }\r
+\r
+}
\ No newline at end of file