]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/GroupProxySymbolItem.java
Fixed multiple issues causing dangling references to discarded queries
[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     public ISymbolItem getSubject() {
41         return proxy;
42     }
43
44     @Override
45     public String getName() {
46         return proxy.getName();
47     }
48
49     @Override
50     public String getDescription() {
51         return proxy.getDescription();
52     }
53
54     @Override
55     public Object getAdapter(Class adapter) {
56         return proxy.getAdapter(adapter);
57     }
58
59     @Override
60     public ElementClass getElementClass(IHintObservable hints) throws ProvisionException {
61         return proxy.getElementClass(hints);
62     }
63
64     @Override
65     public ISymbolGroup getGroup() {
66         return group;
67     }
68
69     @Override
70     public int hashCode() {
71         return proxy.hashCode();
72     }
73
74     @Override
75     public boolean equals(Object obj) {
76         return proxy.equals(obj);
77     }
78
79 }