1 package org.simantics.browsing.ui.swt;
\r
3 import org.eclipse.jface.viewers.ViewerCell;
\r
4 import org.simantics.browsing.ui.common.internal.UIElementReference;
\r
7 * "Reference" to a viewer cell.
\r
9 * ViewerCell is an object, which is not immutable, and has a very short lifespan. Hence we store its element and columnIndex.
\r
12 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
\r
15 public class ViewerCellReference implements UIElementReference{
\r
17 private final Object element;
\r
18 private final int column;
\r
20 public static ViewerCellReference create(ViewerCell cell) {
\r
21 return new ViewerCellReference(cell);
\r
24 private ViewerCellReference(ViewerCell cell) {
\r
25 this.element = cell.getElement();
\r
26 this.column = cell.getColumnIndex();
\r
30 public boolean hasReference() {
\r
31 return element != null;
\r
35 public boolean isDisposed() {
\r
36 if (element == null)
\r
41 public Object getElement() {
\r
45 public int getColumn() {
\r
50 public int hashCode() {
\r
51 return element.hashCode() + column;
\r
56 public boolean equals(Object obj) {
\r
59 if (obj.getClass() != getClass())
\r
61 ViewerCellReference other = (ViewerCellReference)obj;
\r
62 if (column != other.column)
\r
64 return element.equals(other.element);
\r