Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerCell.java')
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerCell.java115
1 files changed, 57 insertions, 58 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerCell.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerCell.java
index f2d4a0291e1..f734e7f71b8 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerCell.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerCell.java
@@ -24,16 +24,17 @@ import org.eclipse.swt.widgets.Widget;
/**
* The ViewerCell is the JFace representation of a cell entry in a ViewerRow.
- *
+ * @param <E> Type of an element of the model
+ *
* @since 3.3
- *
+ *
*/
-public class ViewerCell {
+public class ViewerCell<E> {
private int columnIndex;
- private ViewerRow row;
+ private ViewerRow<E> row;
- private Object element;
+ private E element;
/**
* Constant denoting the cell above current one (value is 1).
@@ -57,11 +58,11 @@ public class ViewerCell {
/**
* Create a new instance of the receiver on the row.
- *
+ *
* @param row
* @param columnIndex
*/
- ViewerCell(ViewerRow row, int columnIndex, Object element) {
+ ViewerCell(ViewerRow<E> row, int columnIndex, E element) {
this.row = row;
this.columnIndex = columnIndex;
this.element = element;
@@ -69,7 +70,7 @@ public class ViewerCell {
/**
* Get the index of the cell.
- *
+ *
* @return the index
*/
public int getColumnIndex() {
@@ -78,7 +79,7 @@ public class ViewerCell {
/**
* Get the bounds of the cell.
- *
+ *
* @return {@link Rectangle}
*/
public Rectangle getBounds() {
@@ -87,10 +88,10 @@ public class ViewerCell {
/**
* Get the element this row represents.
- *
+ *
* @return {@link Object}
*/
- public Object getElement() {
+ public E getElement() {
if (element != null) {
return element;
}
@@ -104,7 +105,7 @@ public class ViewerCell {
/**
* Return the text for the cell.
- *
+ *
* @return {@link String}
*/
public String getText() {
@@ -113,7 +114,7 @@ public class ViewerCell {
/**
* Return the Image for the cell.
- *
+ *
* @return {@link Image} or <code>null</code>
*/
public Image getImage() {
@@ -122,7 +123,7 @@ public class ViewerCell {
/**
* Set the background color of the cell.
- *
+ *
* @param background
*/
public void setBackground(Color background) {
@@ -132,7 +133,7 @@ public class ViewerCell {
/**
* Set the foreground color of the cell.
- *
+ *
* @param foreground
*/
public void setForeground(Color foreground) {
@@ -142,7 +143,7 @@ public class ViewerCell {
/**
* Set the font of the cell.
- *
+ *
* @param font
*/
public void setFont(Font font) {
@@ -152,7 +153,7 @@ public class ViewerCell {
/**
* Set the text for the cell.
- *
+ *
* @param text
*/
public void setText(String text) {
@@ -162,7 +163,7 @@ public class ViewerCell {
/**
* Set the Image for the cell.
- *
+ *
* @param image
*/
public void setImage(Image image) {
@@ -173,10 +174,10 @@ public class ViewerCell {
/**
* Set the style ranges to be applied on the text label Note: Requires
* {@link StyledCellLabelProvider} with owner draw enabled.
- *
+ *
* @param styleRanges
* the styled ranges
- *
+ *
* @since 3.4
*/
public void setStyleRanges(StyleRange[] styleRanges) {
@@ -186,9 +187,9 @@ public class ViewerCell {
/**
* Returns the style ranges to be applied on the text label or
* <code>null</code> if no style ranges have been set.
- *
+ *
* @return styleRanges the styled ranges
- *
+ *
* @since 3.4
*/
public StyleRange[] getStyleRanges() {
@@ -197,7 +198,7 @@ public class ViewerCell {
/**
* Set the columnIndex.
- *
+ *
* @param column
*/
void setColumn(int column) {
@@ -207,11 +208,11 @@ public class ViewerCell {
/**
* Set the row to rowItem and the columnIndex to column.
- *
+ *
* @param rowItem
* @param column
*/
- void update(ViewerRow rowItem, int column, Object element) {
+ void update(ViewerRow<E> rowItem, int column, E element) {
row = rowItem;
columnIndex = column;
this.element = element;
@@ -219,7 +220,7 @@ public class ViewerCell {
/**
* Return the item for the receiver.
- *
+ *
* @return {@link Item}
*/
public Widget getItem() {
@@ -228,7 +229,7 @@ public class ViewerCell {
/**
* Get the control for this cell.
- *
+ *
* @return {@link Control}
*/
public Control getControl() {
@@ -238,7 +239,7 @@ public class ViewerCell {
/**
* Get the current index. This can be different from the original index when
* columns are reordered
- *
+ *
* @return the current index (as shown in the UI)
* @since 3.4
*/
@@ -253,7 +254,7 @@ public class ViewerCell {
* the upper-left of the current cell by passing {@link #ABOVE} |
* {@link #LEFT}. If <code>sameLevel</code> is <code>true</code>, only cells
* in sibling rows (under the same parent) will be considered.
- *
+ *
* @param directionMask
* the direction mask used to identify the requested neighbor
* cell
@@ -261,8 +262,8 @@ public class ViewerCell {
* if <code>true</code>, only consider cells from sibling rows
* @return the requested neighbor cell, or <code>null</code> if not found
*/
- public ViewerCell getNeighbor(int directionMask, boolean sameLevel) {
- ViewerRow row;
+ public ViewerCell<E> getNeighbor(int directionMask, boolean sameLevel) {
+ ViewerRow<E> row;
if ((directionMask & ABOVE) == ABOVE) {
row = this.row.getNeighbor(ViewerRow.ABOVE, sameLevel);
@@ -287,20 +288,17 @@ public class ViewerCell {
columnIndex += modifier;
if (columnIndex >= 0 && columnIndex < row.getColumnCount()) {
- ViewerCell cell = row.getCellAtVisualIndex(columnIndex);
- if (cell != null) {
- while (cell != null
- && columnIndex < row.getColumnCount() - 1
- && columnIndex > 0) {
- if (cell.isVisible()) {
- break;
- }
-
- columnIndex += modifier;
- cell = row.getCellAtVisualIndex(columnIndex);
- if (cell == null) {
- break;
- }
+ ViewerCell<E> cell = row.getCellAtVisualIndex(columnIndex);
+ while (cell != null && columnIndex < row.getColumnCount() - 1
+ && columnIndex > 0) {
+ if (cell.isVisible()) {
+ break;
+ }
+
+ columnIndex += modifier;
+ cell = row.getCellAtVisualIndex(columnIndex);
+ if (cell == null) {
+ break;
}
}
@@ -314,14 +312,14 @@ public class ViewerCell {
/**
* @return the row
*/
- public ViewerRow getViewerRow() {
+ public ViewerRow<E> getViewerRow() {
return row;
}
/**
* The location and bounds of the area where the text is drawn depends on
* various things (image displayed, control with SWT.CHECK)
- *
+ *
* @return The bounds of the of the text area. May return <code>null</code>
* if the underlying widget implementation doesn't provide this
* information
@@ -333,7 +331,7 @@ public class ViewerCell {
/**
* Returns the location and bounds of the area where the image is drawn
- *
+ *
* @return The bounds of the of the image area. May return <code>null</code>
* if the underlying widget implementation doesn't provide this
* information
@@ -345,10 +343,10 @@ public class ViewerCell {
/**
* Gets the foreground color of the cell.
- *
+ *
* @return the foreground of the cell or <code>null</code> for the default
* foreground
- *
+ *
* @since 3.4
*/
public Color getForeground() {
@@ -357,10 +355,10 @@ public class ViewerCell {
/**
* Gets the background color of the cell.
- *
+ *
* @return the background of the cell or <code>null</code> for the default
* background
- *
+ *
* @since 3.4
*/
public Color getBackground() {
@@ -369,9 +367,9 @@ public class ViewerCell {
/**
* Gets the font of the cell.
- *
+ *
* @return the font of the cell or <code>null</code> for the default font
- *
+ *
* @since 3.4
*/
public Font getFont() {
@@ -380,7 +378,7 @@ public class ViewerCell {
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#hashCode()
*/
@Override
@@ -394,7 +392,7 @@ public class ViewerCell {
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -405,7 +403,8 @@ public class ViewerCell {
return false;
if (getClass() != obj.getClass())
return false;
- final ViewerCell other = (ViewerCell) obj;
+ @SuppressWarnings("unchecked")
+ final ViewerCell<E> other = (ViewerCell<E>) obj;
if (columnIndex != other.columnIndex)
return false;
if (row == null) {
@@ -422,7 +421,7 @@ public class ViewerCell {
/**
* Scroll the cell into view
- *
+ *
* @return true if the cell was scrolled into view
* @since 3.5
*/

Back to the top