]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/GroupProxySymbolItem.java
fb3666e0b275fbc8f982ef9a92be347646249064
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / symbolcontribution / GroupProxySymbolItem.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.diagram.symbolcontribution;
13
14 import org.simantics.diagram.symbollibrary.ISymbolGroup;
15 import org.simantics.diagram.symbollibrary.ISymbolItem;
16 import org.simantics.g2d.element.ElementClass;
17 import org.simantics.utils.datastructures.cache.ProvisionException;
18 import org.simantics.utils.datastructures.hints.IHintObservable;
19
20 /**
21  * An ISymbolItem proxy version that allows changing the ISymbolGroup returned
22  * by {@link #getGroup()}.
23  * 
24  * @author Tuukka Lehtonen
25  */
26 public class GroupProxySymbolItem implements ISymbolItem {
27
28     private final ISymbolItem proxy;
29     private final ISymbolGroup group;
30
31     public GroupProxySymbolItem(ISymbolItem item, ISymbolGroup group) {
32         if (item == null)
33             throw new NullPointerException("null item");
34         if (group == null)
35             throw new NullPointerException("null group");
36         this.proxy = item;
37         this.group = group;
38     }
39
40     @Override
41     public String getName() {
42         return proxy.getName();
43     }
44
45     @Override
46     public String getDescription() {
47         return proxy.getDescription();
48     }
49
50     @Override
51     public Object getAdapter(Class adapter) {
52         return proxy.getAdapter(adapter);
53     }
54
55     @Override
56     public ElementClass getElementClass(IHintObservable hints) throws ProvisionException {
57         return proxy.getElementClass(hints);
58     }
59
60     @Override
61     public ISymbolGroup getGroup() {
62         return group;
63     }
64
65     @Override
66     public int hashCode() {
67         return proxy.hashCode();
68     }
69
70     @Override
71     public boolean equals(Object obj) {
72         return proxy.equals(obj);
73     }
74
75 }