]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/TreeItemReference.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / TreeItemReference.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2012 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.browsing.ui.swt;
13
14 import org.eclipse.swt.widgets.TreeItem;
15 import org.simantics.browsing.ui.common.internal.UIElementReference;
16
17 /**
18  * @author Tuukka Lehtonen
19  */
20 public class TreeItemReference implements UIElementReference {
21
22     private final TreeItem item;
23
24     public static TreeItemReference create(TreeItem item) {
25         return new TreeItemReference(item);
26     }
27
28     private TreeItemReference(TreeItem item) {
29         this.item = item;
30     }
31
32     public TreeItem getItem() {
33         return item;
34     }
35
36     @Override
37     public boolean hasReference() {
38         return item != null;
39     }
40
41     @Override
42     public boolean isDisposed() {
43         if (item == null)
44             return true;
45         return item.isDisposed();
46     }
47
48     @Override
49     public String toString() {
50         if (item == null)
51             return "(" + String.valueOf(System.identityHashCode(this)) + ":no item)";
52         return "(" + String.valueOf(System.identityHashCode(this)) + ":TreeItem@" + System.identityHashCode(item) + ")";
53     }
54
55 }