]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/TreeItemReference.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / TreeItemReference.java
diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/TreeItemReference.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/TreeItemReference.java
new file mode 100644 (file)
index 0000000..c9c8af0
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.browsing.ui.swt;\r
+\r
+import org.eclipse.swt.widgets.TreeItem;\r
+import org.simantics.browsing.ui.common.internal.UIElementReference;\r
+\r
+/**\r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class TreeItemReference implements UIElementReference {\r
+\r
+    private final TreeItem item;\r
+\r
+    public static TreeItemReference create(TreeItem item) {\r
+        return new TreeItemReference(item);\r
+    }\r
+\r
+    private TreeItemReference(TreeItem item) {\r
+        this.item = item;\r
+    }\r
+\r
+    public TreeItem getItem() {\r
+        return item;\r
+    }\r
+\r
+    @Override\r
+    public boolean hasReference() {\r
+        return item != null;\r
+    }\r
+\r
+    @Override\r
+    public boolean isDisposed() {\r
+        if (item == null)\r
+            return true;\r
+        return item.isDisposed();\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        if (item == null)\r
+            return "(" + String.valueOf(System.identityHashCode(this)) + ":no item)";\r
+        return "(" + String.valueOf(System.identityHashCode(this)) + ":TreeItem@" + System.identityHashCode(item) + ")";\r
+    }\r
+\r
+}\r