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