X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FTreeItemReference.java;fp=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FTreeItemReference.java;h=c9c8af0f2637f2f1b4a7143dfe6255a6aa5619a4;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 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 index 000000000..c9c8af0f2 --- /dev/null +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/TreeItemReference.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2007, 2012 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.browsing.ui.swt; + +import org.eclipse.swt.widgets.TreeItem; +import org.simantics.browsing.ui.common.internal.UIElementReference; + +/** + * @author Tuukka Lehtonen + */ +public class TreeItemReference implements UIElementReference { + + private final TreeItem item; + + public static TreeItemReference create(TreeItem item) { + return new TreeItemReference(item); + } + + private TreeItemReference(TreeItem item) { + this.item = item; + } + + public TreeItem getItem() { + return item; + } + + @Override + public boolean hasReference() { + return item != null; + } + + @Override + public boolean isDisposed() { + if (item == null) + return true; + return item.isDisposed(); + } + + @Override + public String toString() { + if (item == null) + return "(" + String.valueOf(System.identityHashCode(this)) + ":no item)"; + return "(" + String.valueOf(System.identityHashCode(this)) + ":TreeItem@" + System.identityHashCode(item) + ")"; + } + +}