1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.scenegraph.ui;
\r
14 import java.lang.ref.WeakReference;
\r
16 import org.simantics.scenegraph.INode;
\r
19 * @author Tuukka Lehtonen
\r
23 WeakReference<INode> ref;
\r
26 NodeProxy(INode n) {
\r
30 NodeProxy(INode n, String id) {
\r
31 this.ref = new WeakReference<INode>(n);
\r
40 public String toString() {
\r
41 StringBuilder sb = new StringBuilder();
\r
42 INode n = getNode();
\r
49 sb.append("(collected)");
\r
51 sb.append(n.getSimpleClassName());
\r
53 return sb.toString();
\r
56 public String getTypeName() {
\r
57 INode n = getNode();
\r
58 return n == null ? "-" : n.getSimpleClassName();
\r
61 public String getInternalId() {
\r
62 INode n = getNode();
\r
65 return n.getId().toString();
\r
68 public String getId() {
\r
73 public int hashCode() {
\r
74 final int prime = 31;
\r
76 result = prime * result + ((id == null) ? 0 : id.hashCode());
\r
77 INode node = getNode();
\r
78 result = prime * result + ((node == null) ? 0 : node.hashCode());
\r
83 public boolean equals(Object obj) {
\r
88 if (getClass() != obj.getClass())
\r
90 NodeProxy other = (NodeProxy) obj;
\r
92 if (other.id != null)
\r
94 } else if (!id.equals(other.id))
\r
97 INode node = getNode();
\r
98 INode otherNode = other.getNode();
\r
99 if (node == null || otherNode == null)
\r
100 // Collected nodes are never equal to any other node
\r
103 return node.equals(otherNode);
\r