X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scenegraph.ui%2Fsrc%2Forg%2Fsimantics%2Fscenegraph%2Fui%2FNodeProxy.java;h=a9307c6e2f9868a9316dbc3d2b3ed8fcf1de8eac;hb=refs%2Fchanges%2F63%2F1963%2F9;hp=2b811c94d1f84a25b7a507d889732986e1987803;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scenegraph.ui/src/org/simantics/scenegraph/ui/NodeProxy.java b/bundles/org.simantics.scenegraph.ui/src/org/simantics/scenegraph/ui/NodeProxy.java index 2b811c94d..a9307c6e2 100644 --- a/bundles/org.simantics.scenegraph.ui/src/org/simantics/scenegraph/ui/NodeProxy.java +++ b/bundles/org.simantics.scenegraph.ui/src/org/simantics/scenegraph/ui/NodeProxy.java @@ -1,106 +1,106 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.scenegraph.ui; - -import java.lang.ref.WeakReference; - -import org.simantics.scenegraph.INode; - -/** - * @author Tuukka Lehtonen - */ -class NodeProxy { - - WeakReference ref; - String id; - - NodeProxy(INode n) { - this(n, null); - } - - NodeProxy(INode n, String id) { - this.ref = new WeakReference(n); - this.id = id; - } - - INode getNode() { - return ref.get(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - INode n = getNode(); - if (id != null) { - sb.append("["); - sb.append(id); - sb.append("] "); - } - if (n == null) { - sb.append("(collected)"); - } else { - sb.append(n.getSimpleClassName()); - } - return sb.toString(); - } - - public String getTypeName() { - INode n = getNode(); - return n == null ? "-" : n.getSimpleClassName(); - } - - public String getInternalId() { - INode n = getNode(); - if (n == null) - return "-"; - return n.getId().toString(); - } - - public String getId() { - return id; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - INode node = getNode(); - result = prime * result + ((node == null) ? 0 : node.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NodeProxy other = (NodeProxy) obj; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - - INode node = getNode(); - INode otherNode = other.getNode(); - if (node == null || otherNode == null) - // Collected nodes are never equal to any other node - return false; - - return node.equals(otherNode); - } - +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.scenegraph.ui; + +import java.lang.ref.WeakReference; + +import org.simantics.scenegraph.INode; + +/** + * @author Tuukka Lehtonen + */ +class NodeProxy { + + WeakReference ref; + String id; + + NodeProxy(INode n) { + this(n, null); + } + + NodeProxy(INode n, String id) { + this.ref = new WeakReference(n); + this.id = id; + } + + INode getNode() { + return ref.get(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + INode n = getNode(); + if (id != null) { + sb.append("["); + sb.append(id); + sb.append("] "); + } + if (n == null) { + sb.append("(collected)"); + } else { + sb.append(n.getSimpleClassName()); + } + return sb.toString(); + } + + public String getTypeName() { + INode n = getNode(); + return n == null ? "-" : n.getSimpleClassName(); + } + + public String getInternalId() { + INode n = getNode(); + if (n == null) + return "-"; + return Long.toString(n.getId()); + } + + public String getId() { + return id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + INode node = getNode(); + result = prime * result + ((node == null) ? 0 : node.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NodeProxy other = (NodeProxy) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + + INode node = getNode(); + INode otherNode = other.getNode(); + if (node == null || otherNode == null) + // Collected nodes are never equal to any other node + return false; + + return node.equals(otherNode); + } + } \ No newline at end of file