1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.scenegraph.ui;
14 import java.lang.ref.WeakReference;
16 import org.simantics.scenegraph.INode;
19 * @author Tuukka Lehtonen
23 WeakReference<INode> ref;
30 NodeProxy(INode n, String id) {
31 this.ref = new WeakReference<INode>(n);
40 public String toString() {
41 StringBuilder sb = new StringBuilder();
49 sb.append("(collected)");
51 sb.append(n.getSimpleClassName());
56 public String getTypeName() {
58 return n == null ? "-" : n.getSimpleClassName();
61 public String getInternalId() {
65 return Long.toString(n.getId());
68 public String getId() {
73 public int hashCode() {
76 result = prime * result + ((id == null) ? 0 : id.hashCode());
77 INode node = getNode();
78 result = prime * result + ((node == null) ? 0 : node.hashCode());
83 public boolean equals(Object obj) {
88 if (getClass() != obj.getClass())
90 NodeProxy other = (NodeProxy) obj;
94 } else if (!id.equals(other.id))
97 INode node = getNode();
98 INode otherNode = other.getNode();
99 if (node == null || otherNode == null)
100 // Collected nodes are never equal to any other node
103 return node.equals(otherNode);