aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Still2013-09-27 09:52:03 (EDT)
committerHendrik Still2013-09-27 10:43:37 (EDT)
commit2775789112b18310595c7f0777ea6db1f462ef3e (patch)
treefbe57ea08149c9d73da0ca235441269dbb213ad3
parentb40f516713b3ced0750a77719f4ff65541eff144 (diff)
downloadeclipse.platform.ui-2775789112b18310595c7f0777ea6db1f462ef3e.zip
eclipse.platform.ui-2775789112b18310595c7f0777ea6db1f462ef3e.tar.gz
eclipse.platform.ui-2775789112b18310595c7f0777ea6db1f462ef3e.tar.bz2
Bug 414072 - [Viewers] Add generics to Editorsrefs/changes/39/16839/2
Added generics to the EditingSupport, ICellModifier and corresponding classes, to allow a typesafe use of the viewers framework. Includes also updates in the TableViewer, (Abstract)TreeViewer, ColumnViewer Change-Id: I0057e06261d37302984c18c9584bb0d2028ffb5f Signed-off-by: Hendrik Still <hendrik.still@gammas.de>
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java2
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewer.java40
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditor.java92
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationEvent.java22
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationStrategy.java14
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxViewerCellEditor.java18
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DoubleClickEvent.java2
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/EditingSupport.java27
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellHighlighter.java26
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java52
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ICellModifier.java19
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SWTFocusCellManager.java71
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java6
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerEditor.java36
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerFocusCellManager.java26
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java28
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerEditor.java30
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerFocusCellManager.java26
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java6
19 files changed, 287 insertions, 256 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
index d2e0f1b..1b0b5f4 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
@@ -3229,7 +3229,7 @@ public abstract class AbstractTreeViewer<E,I> extends ColumnViewer<E,I> {
* @since 3.3
*/
@Override
- protected ColumnViewerEditor createViewerEditor() {
+ protected ColumnViewerEditor<E,I> createViewerEditor() {
return null;
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewer.java
index 9ec0bfd..225a5f2 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewer.java
@@ -14,6 +14,11 @@
package org.eclipse.jface.viewers;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.internal.InternalPolicy;
+import org.eclipse.jface.util.Policy;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
@@ -22,11 +27,6 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Widget;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.internal.InternalPolicy;
-import org.eclipse.jface.util.Policy;
/**
* The ColumnViewer is the abstract superclass of viewers that have columns
@@ -45,7 +45,7 @@ import org.eclipse.jface.util.Policy;
public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
private CellEditor[] cellEditors;
- private ICellModifier cellModifier;
+ private ICellModifier<E> cellModifier;
private String[] columnProperties;
@@ -54,7 +54,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
*/
private ViewerCell<E> cell = new ViewerCell<E>(null, 0, null);
- private ColumnViewerEditor viewerEditor;
+ private ColumnViewerEditor<E,I> viewerEditor;
private boolean busy;
private boolean logWhenBusy = true; // initially true, set to false
@@ -115,7 +115,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* @return the editor, or <code>null</code> if this viewer does not support
* editing cell contents.
*/
- protected abstract ColumnViewerEditor createViewerEditor();
+ protected abstract ColumnViewerEditor<E,I> createViewerEditor();
/**
* Returns the viewer cell at the given widget-relative coordinates, or
@@ -217,7 +217,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
*/
private void setupEditingSupport(final int columnIndex, ViewerColumn<E,I> viewer) {
if (getCellModifier() != null) {
- viewer.setEditingSupport(new EditingSupport(this) {
+ viewer.setEditingSupport(new EditingSupport<E,I>(this) {
/*
* (non-Javadoc)
@@ -227,7 +227,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* .Object)
*/
@Override
- public boolean canEdit(Object element) {
+ public boolean canEdit(E element) {
Object[] properties = getColumnProperties();
if (columnIndex < properties.length) {
@@ -246,7 +246,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* .lang.Object)
*/
@Override
- public CellEditor getCellEditor(Object element) {
+ public CellEditor getCellEditor(E element) {
CellEditor[] editors = getCellEditors();
if (columnIndex < editors.length) {
return getCellEditors()[columnIndex];
@@ -262,7 +262,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* .Object)
*/
@Override
- public Object getValue(Object element) {
+ public Object getValue(E element) {
Object[] properties = getColumnProperties();
if (columnIndex < properties.length) {
@@ -281,13 +281,11 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* .Object, java.lang.Object)
*/
@Override
- public void setValue(Object element, Object value) {
+ public void setValue(E element, Object value) {
Object[] properties = getColumnProperties();
if (columnIndex < properties.length) {
- @SuppressWarnings("unchecked")
- E castedElement = (E)element;
- getCellModifier().modify(findItem(castedElement),
+ getCellModifier().modify(findItem(element),
(String) getColumnProperties()[columnIndex],
value);
}
@@ -504,7 +502,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* @see ViewerColumn#setEditingSupport(EditingSupport)
* @see EditingSupport
*/
- public ICellModifier getCellModifier() {
+ public ICellModifier<E> getCellModifier() {
return cellModifier;
}
@@ -623,7 +621,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* @see ViewerColumn#setEditingSupport(EditingSupport)
* @see EditingSupport
*/
- public void setCellModifier(ICellModifier modifier) {
+ public void setCellModifier(ICellModifier<E> modifier) {
this.cellModifier = modifier;
}
@@ -723,7 +721,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
* @param columnViewerEditor
* the new column viewer editor
*/
- public void setColumnViewerEditor(ColumnViewerEditor columnViewerEditor) {
+ public void setColumnViewerEditor(ColumnViewerEditor<E,I> columnViewerEditor) {
Assert.isNotNull(columnViewerEditor);
this.viewerEditor = columnViewerEditor;
}
@@ -731,7 +729,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
/**
* @return the currently attached viewer editor
*/
- public ColumnViewerEditor getColumnViewerEditor() {
+ public ColumnViewerEditor<E,I> getColumnViewerEditor() {
return viewerEditor;
}
@@ -757,7 +755,7 @@ public abstract class ColumnViewer<E,I> extends StructuredViewer<E,I> {
ViewerColumn<E,I> column = (ViewerColumn<E,I>) owner
.getData(ViewerColumn.COLUMN_VIEWER_KEY);
if (column != null) {
- EditingSupport e = column.getEditingSupport();
+ EditingSupport<? super E, ? super I> e = column.getEditingSupport();
// Ensure that only EditingSupports are wiped that are
// setup
// for Legacy reasons
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditor.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditor.java
index e72056b..3f18867 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditor.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditor.java
@@ -32,12 +32,14 @@ import org.eclipse.swt.widgets.Item;
/**
* This is the base for all editor implementations of Viewers. ColumnViewer
* implementors have to subclass this class and implement the missing methods
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
* @see TableViewerEditor
* @see TreeViewerEditor
*/
-public abstract class ColumnViewerEditor {
+public abstract class ColumnViewerEditor<E,I> {
private CellEditor cellEditor;
private ICellEditorListener cellEditorListener;
@@ -46,18 +48,18 @@ public abstract class ColumnViewerEditor {
private MouseListener mouseListener;
- private ColumnViewer viewer;
+ private ColumnViewer<E,I> viewer;
private TraverseListener tabeditingListener;
- private ViewerCell cell;
+ private ViewerCell<E> cell;
private ListenerList editorActivationListener;
- private ColumnViewerEditorActivationStrategy editorActivationStrategy;
+ private ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy;
private boolean inEditorDeactivation;
-
+
private DisposeListener disposeListener;
/**
@@ -117,8 +119,8 @@ public abstract class ColumnViewerEditor {
* <li>{@link ColumnViewerEditor#TABBING_VERTICAL}</li>
* </ul>
*/
- protected ColumnViewerEditor(final ColumnViewer viewer,
- ColumnViewerEditorActivationStrategy editorActivationStrategy,
+ protected ColumnViewerEditor(final ColumnViewer<E,I> viewer,
+ ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy,
int feature) {
this.viewer = viewer;
this.editorActivationStrategy = editorActivationStrategy;
@@ -134,7 +136,7 @@ public abstract class ColumnViewerEditor {
cancelEditing();
}
}
-
+
};
initCellEditorListener();
}
@@ -158,8 +160,8 @@ public abstract class ColumnViewerEditor {
private boolean activateCellEditor(final ColumnViewerEditorActivationEvent activationEvent) {
- ViewerColumn part = viewer.getViewerColumn(cell.getColumnIndex());
- Object element = cell.getElement();
+ ViewerColumn<E,I> part = viewer.getViewerColumn(cell.getColumnIndex());
+ E element = cell.getElement();
if (part != null && part.getEditingSupport() != null
&& part.getEditingSupport().canEdit(element)) {
@@ -264,7 +266,7 @@ public abstract class ColumnViewerEditor {
.afterEditorActivated(activationEvent);
}
}
-
+
this.cell.getItem().addDisposeListener(disposeListener);
return true;
@@ -343,7 +345,7 @@ public abstract class ColumnViewerEditor {
.afterEditorDeactivated(tmp);
}
}
-
+
if( ! this.cell.getItem().isDisposed() ) {
this.cell.getItem().removeDisposeListener(disposeListener);
}
@@ -412,11 +414,11 @@ public abstract class ColumnViewerEditor {
.afterEditorDeactivated(tmp);
}
}
-
+
if( ! this.cell.getItem().isDisposed() ) {
this.cell.getItem().addDisposeListener(disposeListener);
}
-
+
this.cellEditor = null;
this.cell = null;
@@ -441,7 +443,9 @@ public abstract class ColumnViewerEditor {
applyEditorValue();
}
- this.cell = (ViewerCell) event.getSource();
+ @SuppressWarnings("unchecked")
+ ViewerCell<E> viewerCell = (ViewerCell<E>) event.getSource();
+ this.cell = viewerCell;
// Only null if we are not in a deactivation process see bug 260892
if( ! activateCellEditor(event) && ! inEditorDeactivation ) {
@@ -452,7 +456,7 @@ public abstract class ColumnViewerEditor {
}
private void saveEditorValue(CellEditor cellEditor) {
- ViewerColumn part = viewer.getViewerColumn(cell.getColumnIndex());
+ ViewerColumn<E,I> part = viewer.getViewerColumn(cell.getColumnIndex());
if (part != null && part.getEditingSupport() != null) {
part.getEditingSupport().saveCellEditorValue(cellEditor, cell);
@@ -527,10 +531,10 @@ public abstract class ColumnViewerEditor {
* @param event
* the traverse event
*/
- protected void processTraverseEvent(int columnIndex, ViewerRow row,
+ protected void processTraverseEvent(int columnIndex, ViewerRow<E> row,
TraverseEvent event) {
- ViewerCell cell2edit = null;
+ ViewerCell<E> cell2edit = null;
if (event.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
event.doit = false;
@@ -565,11 +569,11 @@ public abstract class ColumnViewerEditor {
}
}
- private ViewerCell searchCellAboveBelow(ViewerRow row, ColumnViewer viewer,
+ private ViewerCell<E> searchCellAboveBelow(ViewerRow<E> row, ColumnViewer<E,I> viewer,
int columnIndex, boolean above) {
- ViewerCell rv = null;
+ ViewerCell<E> rv = null;
- ViewerRow newRow = null;
+ ViewerRow<E> newRow = null;
if (above) {
newRow = row.getNeighbor(ViewerRow.ABOVE, false);
@@ -578,12 +582,16 @@ public abstract class ColumnViewerEditor {
}
if (newRow != null) {
- ViewerColumn column = viewer.getViewerColumn(columnIndex);
- if (column != null
- && column.getEditingSupport() != null
- && column.getEditingSupport().canEdit(
- newRow.getItem().getData())) {
- rv = newRow.getCell(columnIndex);
+ ViewerColumn<E,I> column = viewer.getViewerColumn(columnIndex);
+ if (column != null && column.getEditingSupport() != null) {
+ @SuppressWarnings("unchecked")
+ E element = (E) newRow.getItem().getData();
+ if (column.getEditingSupport().canEdit(element)) {
+ rv = newRow.getCell(columnIndex);
+ } else {
+ rv = searchCellAboveBelow(newRow, viewer, columnIndex,
+ above);
+ }
} else {
rv = searchCellAboveBelow(newRow, viewer, columnIndex, above);
}
@@ -592,16 +600,16 @@ public abstract class ColumnViewerEditor {
return rv;
}
- private boolean isCellEditable(ColumnViewer viewer, ViewerCell cell) {
- ViewerColumn column = viewer.getViewerColumn(cell.getColumnIndex());
+ private boolean isCellEditable(ColumnViewer<E,I> viewer, ViewerCell<E> cell) {
+ ViewerColumn<E,I> column = viewer.getViewerColumn(cell.getColumnIndex());
return column != null && column.getEditingSupport() != null
&& column.getEditingSupport().canEdit(cell.getElement());
}
- private ViewerCell searchPreviousCell(ViewerRow row,
- ViewerCell currentCell, ViewerCell originalCell, ColumnViewer viewer) {
- ViewerCell rv = null;
- ViewerCell previousCell;
+ private ViewerCell<E> searchPreviousCell(ViewerRow<E> row,
+ ViewerCell<E> currentCell, ViewerCell<E> originalCell, ColumnViewer<E,I> viewer) {
+ ViewerCell<E> rv = null;
+ ViewerCell<E> previousCell;
if (currentCell != null) {
previousCell = currentCell.getNeighbor(ViewerCell.LEFT, true);
@@ -630,7 +638,7 @@ public abstract class ColumnViewerEditor {
if ((feature & TABBING_CYCLE_IN_ROW) == TABBING_CYCLE_IN_ROW) {
rv = searchPreviousCell(row, null, originalCell, viewer);
} else if ((feature & TABBING_MOVE_TO_ROW_NEIGHBOR) == TABBING_MOVE_TO_ROW_NEIGHBOR) {
- ViewerRow rowAbove = row.getNeighbor(ViewerRow.ABOVE, false);
+ ViewerRow<E> rowAbove = row.getNeighbor(ViewerRow.ABOVE, false);
if (rowAbove != null) {
rv = searchPreviousCell(rowAbove, null, originalCell,
viewer);
@@ -641,11 +649,11 @@ public abstract class ColumnViewerEditor {
return rv;
}
- private ViewerCell searchNextCell(ViewerRow row, ViewerCell currentCell,
- ViewerCell originalCell, ColumnViewer viewer) {
- ViewerCell rv = null;
+ private ViewerCell<E> searchNextCell(ViewerRow<E> row, ViewerCell<E> currentCell,
+ ViewerCell<E> originalCell, ColumnViewer<E,I> viewer) {
+ ViewerCell<E> rv = null;
- ViewerCell nextCell;
+ ViewerCell<E> nextCell;
if (currentCell != null) {
nextCell = currentCell.getNeighbor(ViewerCell.RIGHT, true);
@@ -668,7 +676,7 @@ public abstract class ColumnViewerEditor {
if ((feature & TABBING_CYCLE_IN_ROW) == TABBING_CYCLE_IN_ROW) {
rv = searchNextCell(row, null, originalCell, viewer);
} else if ((feature & TABBING_MOVE_TO_ROW_NEIGHBOR) == TABBING_MOVE_TO_ROW_NEIGHBOR) {
- ViewerRow rowBelow = row.getNeighbor(ViewerRow.BELOW, false);
+ ViewerRow<E> rowBelow = row.getNeighbor(ViewerRow.BELOW, false);
if (rowBelow != null) {
rv = searchNextCell(rowBelow, null, originalCell, viewer);
}
@@ -704,7 +712,7 @@ public abstract class ColumnViewerEditor {
* @param event
* the event requesting to update the focusCell
*/
- protected abstract void updateFocusCell(ViewerCell focusCell,
+ protected abstract void updateFocusCell(ViewerCell<E> focusCell,
ColumnViewerEditorActivationEvent event);
/**
@@ -713,14 +721,14 @@ public abstract class ColumnViewerEditor {
* returned
*
*/
- public ViewerCell getFocusCell() {
+ public ViewerCell<E> getFocusCell() {
return null;
}
/**
* @return the viewer working for
*/
- protected ColumnViewer getViewer() {
+ protected ColumnViewer<E,I> getViewer() {
return viewer;
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationEvent.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationEvent.java
index d951645..63c4618 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationEvent.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationEvent.java
@@ -19,13 +19,13 @@ import org.eclipse.swt.events.TraverseEvent;
/**
* This event is passed on when a cell-editor is going to be activated
- *
+ *
* @since 3.3
- *
+ *
*/
public class ColumnViewerEditorActivationEvent extends EventObject {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
@@ -96,15 +96,15 @@ public class ColumnViewerEditorActivationEvent extends EventObject {
* Cancel the event (=> editor is not activated)
*/
public boolean cancel = false;
-
+
/**
* This constructor can be used when no event exists. The type set is
* {@link #PROGRAMMATIC}
- *
+ *
* @param cell
* the cell
*/
- public ColumnViewerEditorActivationEvent(ViewerCell cell) {
+ public ColumnViewerEditorActivationEvent(ViewerCell<?> cell) {
super(cell);
eventType = PROGRAMMATIC;
}
@@ -113,13 +113,13 @@ public class ColumnViewerEditorActivationEvent extends EventObject {
* This constructor is used for all types of mouse events. Currently the
* type is can be {@link #MOUSE_CLICK_SELECTION} and
* {@link #MOUSE_DOUBLE_CLICK_SELECTION}
- *
+ *
* @param cell
* the cell source of the event
* @param event
* the event
*/
- public ColumnViewerEditorActivationEvent(ViewerCell cell, MouseEvent event) {
+ public ColumnViewerEditorActivationEvent(ViewerCell<?> cell, MouseEvent event) {
super(cell);
if (event.count >= 2) {
@@ -138,7 +138,7 @@ public class ColumnViewerEditorActivationEvent extends EventObject {
* @param event
* the event
*/
- public ColumnViewerEditorActivationEvent(ViewerCell cell, KeyEvent event) {
+ public ColumnViewerEditorActivationEvent(ViewerCell<?> cell, KeyEvent event) {
super(cell);
this.eventType = KEY_PRESSED;
this.sourceEvent = event;
@@ -150,13 +150,13 @@ public class ColumnViewerEditorActivationEvent extends EventObject {
/**
* This constructor is used to mark the activation triggered by a traversal
- *
+ *
* @param cell
* the cell source of the event
* @param event
* the event
*/
- public ColumnViewerEditorActivationEvent(ViewerCell cell, TraverseEvent event) {
+ public ColumnViewerEditorActivationEvent(ViewerCell<?> cell, TraverseEvent event) {
super(cell);
this.eventType = TRAVERSAL;
this.sourceEvent = event;
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationStrategy.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationStrategy.java
index ce432e2..6cef646 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationStrategy.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerEditorActivationStrategy.java
@@ -21,11 +21,13 @@ import org.eclipse.swt.events.MouseEvent;
* This class is responsible to determine if a cell selection event is triggers
* an editor activation. Implementors can extend and overwrite to implement
* custom editing behavior
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*/
-public class ColumnViewerEditorActivationStrategy {
- private ColumnViewer viewer;
+public class ColumnViewerEditorActivationStrategy<E,I> {
+ private ColumnViewer<E,I> viewer;
private KeyListener keyboardActivationListener;
@@ -33,7 +35,7 @@ public class ColumnViewerEditorActivationStrategy {
* @param viewer
* the viewer the editor support is attached to
*/
- public ColumnViewerEditorActivationStrategy(ColumnViewer viewer) {
+ public ColumnViewerEditorActivationStrategy(ColumnViewer<E,I> viewer) {
this.viewer = viewer;
}
@@ -55,14 +57,14 @@ public class ColumnViewerEditorActivationStrategy {
/**
* @return the cell holding the current focus
*/
- private ViewerCell getFocusCell() {
+ private ViewerCell<E> getFocusCell() {
return viewer.getColumnViewerEditor().getFocusCell();
}
/**
* @return the viewer
*/
- public ColumnViewer getViewer() {
+ public ColumnViewer<E,I> getViewer() {
return viewer;
}
@@ -78,7 +80,7 @@ public class ColumnViewerEditorActivationStrategy {
keyboardActivationListener = new KeyListener() {
public void keyPressed(KeyEvent e) {
- ViewerCell cell = getFocusCell();
+ ViewerCell<E> cell = getFocusCell();
if (cell != null) {
viewer
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxViewerCellEditor.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxViewerCellEditor.java
index 555b68a..60ebb52 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxViewerCellEditor.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxViewerCellEditor.java
@@ -35,14 +35,16 @@ import org.eclipse.swt.widgets.Control;
* A cell editor that presents a list of items in a combo box. In contrast to
* {@link ComboBoxCellEditor} it wraps the underlying {@link CCombo} using a
* {@link ComboViewer}
+ * @param <E> Type of an element of the model
+ * @param <I> Type of the input
* @since 3.4
*/
-public class ComboBoxViewerCellEditor extends AbstractComboBoxCellEditor {
+public class ComboBoxViewerCellEditor<E,I> extends AbstractComboBoxCellEditor {
/**
* The custom combo box control.
*/
- ComboViewer viewer;
+ ComboViewer<E,I> viewer;
Object selectedValue;
@@ -82,7 +84,7 @@ public class ComboBoxViewerCellEditor extends AbstractComboBoxCellEditor {
CCombo comboBox = new CCombo(parent, getStyle());
comboBox.setFont(parent.getFont());
- viewer = new ComboViewer(comboBox);
+ viewer = new ComboViewer<E,I>(comboBox);
comboBox.addKeyListener(new KeyAdapter() {
// hook key pressed - see PR 14201
@@ -194,7 +196,7 @@ public class ComboBoxViewerCellEditor extends AbstractComboBoxCellEditor {
* the label provider used
* @see StructuredViewer#setLabelProvider(IBaseLabelProvider)
*/
- public void setLabelProvider(IBaseLabelProvider labelProvider) {
+ public void setLabelProvider(IBaseLabelProvider<E> labelProvider) {
viewer.setLabelProvider(labelProvider);
}
@@ -204,7 +206,7 @@ public class ComboBoxViewerCellEditor extends AbstractComboBoxCellEditor {
* @see StructuredViewer#setContentProvider(IContentProvider)
* @since 3.7
*/
- public void setContentProvider(IStructuredContentProvider provider) {
+ public void setContentProvider(IStructuredContentProvider<E,I> provider) {
viewer.setContentProvider(provider);
}
@@ -216,7 +218,7 @@ public class ComboBoxViewerCellEditor extends AbstractComboBoxCellEditor {
* {@link #setContentProvider(IStructuredContentProvider)}
*/
@Deprecated
- public void setContenProvider(IStructuredContentProvider provider) {
+ public void setContenProvider(IStructuredContentProvider<E,I> provider) {
viewer.setContentProvider(provider);
}
@@ -225,14 +227,14 @@ public class ComboBoxViewerCellEditor extends AbstractComboBoxCellEditor {
* the input used
* @see StructuredViewer#setInput(Object)
*/
- public void setInput(Object input) {
+ public void setInput(I input) {
viewer.setInput(input);
}
/**
* @return get the viewer
*/
- public ComboViewer getViewer() {
+ public ComboViewer<E,I> getViewer() {
return viewer;
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DoubleClickEvent.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DoubleClickEvent.java
index 156f3f4..eb2bdae 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DoubleClickEvent.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DoubleClickEvent.java
@@ -27,7 +27,7 @@ public class DoubleClickEvent extends EventObject {
* @since 3.1
*/
private static final long serialVersionUID = 3258408443605038133L;
-
+
/**
* The selection.
*/
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/EditingSupport.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/EditingSupport.java
index 1a8670e..5478c2f 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/EditingSupport.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/EditingSupport.java
@@ -18,18 +18,21 @@ import org.eclipse.core.runtime.Assert;
/**
* EditingSupport is the abstract superclass of the support for cell editing.
*
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
+ *
* @since 3.3
*
*/
-public abstract class EditingSupport {
+public abstract class EditingSupport<E,I> {
- private ColumnViewer viewer;
+ private ColumnViewer<E, I> viewer;
/**
* @param viewer
* a new viewer
*/
- public EditingSupport(ColumnViewer viewer) {
+ public EditingSupport(ColumnViewer<E,I> viewer) {
Assert.isNotNull(viewer, "Viewer is not allowed to be null"); //$NON-NLS-1$
this.viewer = viewer;
}
@@ -41,7 +44,7 @@ public abstract class EditingSupport {
* the model element
* @return the CellEditor
*/
- protected abstract CellEditor getCellEditor(Object element);
+ protected abstract CellEditor getCellEditor(E element);
/**
* Is the cell editable
@@ -50,7 +53,7 @@ public abstract class EditingSupport {
* the model element
* @return true if editable
*/
- protected abstract boolean canEdit(Object element);
+ protected abstract boolean canEdit(E element);
/**
* Get the value to set to the editor
@@ -59,7 +62,7 @@ public abstract class EditingSupport {
* the model element
* @return the value shown
*/
- protected abstract Object getValue(Object element);
+ protected abstract Object getValue(E element);
/**
* Sets the new value on the given element. Note that implementers need to
@@ -67,22 +70,22 @@ public abstract class EditingSupport {
* methods are called, either directly or through some kind of listener
* mechanism on the implementer's model, to cause the new value to appear in
* the viewer.
- *
+ *
* <p>
* <b>Subclasses should overwrite.</b>
* </p>
- *
+ *
* @param element
* the model element
* @param value
* the new value
*/
- protected abstract void setValue(Object element, Object value);
+ protected abstract void setValue(E element, Object value);
/**
* @return the viewer this editing support works for
*/
- public ColumnViewer getViewer() {
+ public ColumnViewer<E,I> getViewer() {
return viewer;
}
@@ -95,7 +98,7 @@ public abstract class EditingSupport {
* @param cell
* the cell the editor is working for
*/
- protected void initializeCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
+ protected void initializeCellEditorValue(CellEditor cellEditor, ViewerCell<E> cell) {
Object value = getValue(cell.getElement());
cellEditor.setValue(value);
}
@@ -108,7 +111,7 @@ public abstract class EditingSupport {
* @param cell
* the cell the editor is working for
*/
- protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
+ protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell<E> cell) {
Object value = cellEditor.getValue();
setValue(cell.getElement(), value);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellHighlighter.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellHighlighter.java
index 8852508..4b51470 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellHighlighter.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellHighlighter.java
@@ -14,36 +14,38 @@
package org.eclipse.jface.viewers;
/**
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
* @since 3.3
*
*/
-public abstract class FocusCellHighlighter {
- private ColumnViewer viewer;
- private SWTFocusCellManager mgr;
+public abstract class FocusCellHighlighter<E,I> {
+ private ColumnViewer<E,I> viewer;
+ private SWTFocusCellManager<E,I> mgr;
/**
* @param viewer
*/
- public FocusCellHighlighter(ColumnViewer viewer) {
+ public FocusCellHighlighter(ColumnViewer<E,I> viewer) {
this.viewer = viewer;
}
- void setMgr(SWTFocusCellManager mgr) {
+ void setMgr(SWTFocusCellManager<E,I> mgr) {
this.mgr = mgr;
}
-
+
/**
* @return the focus cell
*/
- public ViewerCell getFocusCell() {
+ public ViewerCell<E> getFocusCell() {
// Mgr is normally not null because the highlighter is passed
// to the SWTFocusCellManager instance
if( mgr != null ) {
// Use this method because it ensure that no
- // cell update (which might cause scrolling) happens
- return mgr._getFocusCell();
+ // cell update (which might cause scrolling) happens
+ return mgr._getFocusCell();
}
-
+
return viewer.getColumnViewerEditor().getFocusCell();
}
@@ -56,7 +58,7 @@ public abstract class FocusCellHighlighter {
* @deprecated use {@link #focusCellChanged(ViewerCell, ViewerCell)} instead
*/
@Deprecated
- protected void focusCellChanged(ViewerCell cell) {
+ protected void focusCellChanged(ViewerCell<E> cell) {
}
/**
@@ -75,7 +77,7 @@ public abstract class FocusCellHighlighter {
* focused before
* @since 3.4
*/
- protected void focusCellChanged(ViewerCell newCell, ViewerCell oldCell) {
+ protected void focusCellChanged(ViewerCell<E> newCell, ViewerCell<E> oldCell) {
focusCellChanged(newCell);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java
index 703188f..647567d 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/FocusCellOwnerDrawHighlighter.java
@@ -26,27 +26,29 @@ import org.eclipse.swt.widgets.Listener;
* the control into owner draw mode and highlighting the currently selected
* cell. To make the use this class you should create the control with the
* {@link SWT#FULL_SELECTION} bit set
- *
+ *
* This class can be subclassed to configure how the coloring of the selected
* cell.
- *
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
+ *
* @since 3.3
- *
+ *
*/
-public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
+public class FocusCellOwnerDrawHighlighter<E,I> extends FocusCellHighlighter<E,I> {
/**
* Create a new instance which can be passed to a
* {@link TreeViewerFocusCellManager}
- *
+ *
* @param viewer
* the viewer
*/
- public FocusCellOwnerDrawHighlighter(ColumnViewer viewer) {
+ public FocusCellOwnerDrawHighlighter(ColumnViewer<E,I> viewer) {
super(viewer);
hookListener(viewer);
}
- private void markFocusedCell(Event event, ViewerCell cell) {
+ private void markFocusedCell(Event event, ViewerCell<E> cell) {
Color background = (cell.getControl().isFocusControl()) ? getSelectedCellBackgroundColor(cell)
: getSelectedCellBackgroundColorNoFocus(cell);
Color foreground = (cell.getControl().isFocusControl()) ? getSelectedCellForegroundColor(cell)
@@ -67,7 +69,7 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
gc.setBackground(background);
gc.setForeground(foreground);
-
+
if (onlyTextHighlighting(cell)) {
Rectangle area = event.getBounds();
Rectangle rect = cell.getTextBounds();
@@ -78,12 +80,12 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
} else {
gc.fillRectangle(event.getBounds());
}
-
+
event.detail &= ~SWT.SELECTED;
}
}
- private void removeSelectionInformation(Event event, ViewerCell cell) {
+ private void removeSelectionInformation(Event event, ViewerCell<E> cell) {
GC gc = event.gc;
gc.setBackground(cell.getViewerRow().getBackground(
cell.getColumnIndex()));
@@ -93,20 +95,20 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
event.detail &= ~SWT.SELECTED;
}
- private void hookListener(final ColumnViewer viewer) {
+ private void hookListener(final ColumnViewer<E,I> viewer) {
Listener listener = new Listener() {
public void handleEvent(Event event) {
if ((event.detail & SWT.SELECTED) > 0) {
- ViewerCell focusCell = getFocusCell();
- ViewerRow row = viewer.getViewerRowFromItem(event.item);
+ ViewerCell<E> focusCell = getFocusCell();
+ ViewerRow<E> row = viewer.getViewerRowFromItem(event.item);
Assert
.isNotNull(row,
"Internal structure invalid. Item without associated row is not possible."); //$NON-NLS-1$
- ViewerCell cell = row.getCell(event.index);
+ ViewerCell<E> cell = row.getCell(event.index);
if (focusCell == null || !cell.equals(focusCell)) {
removeSelectionInformation(event, cell);
@@ -123,69 +125,69 @@ public class FocusCellOwnerDrawHighlighter extends FocusCellHighlighter {
/**
* The color to use when rendering the background of the selected cell when
* the control has the input focus
- *
+ *
* @param cell
* the cell which is colored
* @return the color or <code>null</code> to use the default
*/
- protected Color getSelectedCellBackgroundColor(ViewerCell cell) {
+ protected Color getSelectedCellBackgroundColor(ViewerCell<E> cell) {
return null;
}
/**
* The color to use when rendering the foreground (=text) of the selected
* cell when the control has the input focus
- *
+ *
* @param cell
* the cell which is colored
* @return the color or <code>null</code> to use the default
*/
- protected Color getSelectedCellForegroundColor(ViewerCell cell) {
+ protected Color getSelectedCellForegroundColor(ViewerCell<E> cell) {
return null;
}
/**
* The color to use when rendering the foreground (=text) of the selected
* cell when the control has <b>no</b> input focus
- *
+ *
* @param cell
* the cell which is colored
* @return the color or <code>null</code> to use the same used when
* control has focus
* @since 3.4
*/
- protected Color getSelectedCellForegroundColorNoFocus(ViewerCell cell) {
+ protected Color getSelectedCellForegroundColorNoFocus(ViewerCell<E> cell) {
return null;
}
/**
* The color to use when rendering the background of the selected cell when
* the control has <b>no</b> input focus
- *
+ *
* @param cell
* the cell which is colored
* @return the color or <code>null</code> to use the same used when
* control has focus
* @since 3.4
*/
- protected Color getSelectedCellBackgroundColorNoFocus(ViewerCell cell) {
+ protected Color getSelectedCellBackgroundColorNoFocus(ViewerCell<E> cell) {
return null;
}
/**
* Controls whether the whole cell or only the text-area is highlighted
- *
+ *
* @param cell
* the cell which is highlighted
* @return <code>true</code> if only the text area should be highlighted
* @since 3.4
*/
- protected boolean onlyTextHighlighting(ViewerCell cell) {
+ protected boolean onlyTextHighlighting(ViewerCell<E> cell) {
return false;
}
@Override
- protected void focusCellChanged(ViewerCell newCell, ViewerCell oldCell) {
+ protected void focusCellChanged(ViewerCell<E> newCell, ViewerCell<E> oldCell) {
super.focusCellChanged(newCell, oldCell);
// Redraw new area
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ICellModifier.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ICellModifier.java
index 372eae0..6bffd78 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ICellModifier.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ICellModifier.java
@@ -16,17 +16,18 @@ package org.eclipse.jface.viewers;
* <ul>
* <li>to check if a a model element's property can be edited or not</li>
* <li>retrieve a value a model element's property</li>
- * <li>to store a cell editor's value back into the model
+ * <li>to store a cell editor's value back into the model
* element's property</li>
* </ul>
* <p>
* This interface should be implemented by classes that wish to
* act as cell modifiers.
* </p>
+ * @param <E> Type of an single element of the model
*/
-public interface ICellModifier {
+public interface ICellModifier<E> {
/**
- * Checks whether the given property of the given element can be
+ * Checks whether the given property of the given element can be
* modified.
*
* @param element the element
@@ -34,7 +35,7 @@ public interface ICellModifier {
* @return <code>true</code> if the property can be modified,
* and <code>false</code> if it is not modifiable
*/
- public boolean canModify(Object element, String property);
+ public boolean canModify(E element, String property);
/**
* Returns the value for the given property of the given element.
@@ -44,15 +45,15 @@ public interface ICellModifier {
* @param property the property
* @return the property value
*/
- public Object getValue(Object element, String property);
+ public Object getValue(E element, String property);
/**
* Modifies the value for the given property of the given element.
* Has no effect if the element does not have the given property,
* or if the property cannot be modified.
* <p>
- * Note that it is possible for an SWT Item to be passed instead of
- * the model element. To handle this case in a safe way, use:
+ * Note that it is possible for an SWT Item to be passed instead of
+ * the model element. To handle this case in a safe way, use:
* <pre>
* if (element instanceof Item) {
* element = ((Item) element).getData();
@@ -60,11 +61,11 @@ public interface ICellModifier {
* // modify the element's property here
* </pre>
* </p>
- *
+ *
* @param element the model element or SWT Item (see above)
* @param property the property
* @param value the new property value
- *
+ *
* @see org.eclipse.swt.widgets.Item
*/
public void modify(Object element, String property, Object value);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SWTFocusCellManager.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SWTFocusCellManager.java
index 7e847e1..e854340 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SWTFocusCellManager.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/SWTFocusCellManager.java
@@ -13,6 +13,7 @@
package org.eclipse.jface.viewers;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.ACC;
import org.eclipse.swt.accessibility.AccessibleAdapter;
@@ -23,25 +24,25 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
-import org.eclipse.core.runtime.Assert;
-
/**
* This class is responsible to provide cell management base features for the
* SWT-Controls {@link org.eclipse.swt.widgets.Table} and
* {@link org.eclipse.swt.widgets.Tree}.
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*
*/
-abstract class SWTFocusCellManager {
+abstract class SWTFocusCellManager<E,I> {
- private CellNavigationStrategy navigationStrategy;
+ private CellNavigationStrategy<E,I> navigationStrategy;
- private ColumnViewer viewer;
+ private ColumnViewer<E,I> viewer;
- private ViewerCell focusCell;
+ private ViewerCell<E> focusCell;
- private FocusCellHighlighter cellHighlighter;
+ private FocusCellHighlighter<E,I> cellHighlighter;
private DisposeListener itemDeletionListener = new DisposeListener() {
@@ -56,15 +57,15 @@ abstract class SWTFocusCellManager {
* @param focusDrawingDelegate
* @param navigationDelegate
*/
- public SWTFocusCellManager(ColumnViewer viewer,
- FocusCellHighlighter focusDrawingDelegate,
- CellNavigationStrategy navigationDelegate) {
+ public SWTFocusCellManager(ColumnViewer<E,I> viewer,
+ FocusCellHighlighter<E,I> focusDrawingDelegate,
+ CellNavigationStrategy<E,I> navigationDelegate) {
this.viewer = viewer;
this.cellHighlighter = focusDrawingDelegate;
if( this.cellHighlighter != null ) {
this.cellHighlighter.setMgr(this);
}
-
+
this.navigationStrategy = navigationDelegate;
hookListener(viewer);
}
@@ -78,7 +79,7 @@ abstract class SWTFocusCellManager {
}
private void handleMouseDown(Event event) {
- ViewerCell cell = viewer.getCell(new Point(event.x, event.y));
+ ViewerCell<E> cell = viewer.getCell(new Point(event.x, event.y));
if (cell != null) {
if (!cell.equals(focusCell)) {
@@ -88,7 +89,7 @@ abstract class SWTFocusCellManager {
}
private void handleKeyDown(Event event) {
- ViewerCell tmp = null;
+ ViewerCell<E> tmp = null;
if (navigationStrategy.isCollapseEvent(viewer, focusCell, event)) {
navigationStrategy.collapse(viewer, focusCell, event);
@@ -112,11 +113,11 @@ abstract class SWTFocusCellManager {
private void handleSelection(Event event) {
if ((event.detail & SWT.CHECK) == 0 && focusCell != null && focusCell.getItem() != event.item
&& event.item != null && ! event.item.isDisposed() ) {
- ViewerRow row = viewer.getViewerRowFromItem(event.item);
+ ViewerRow<E> row = viewer.getViewerRowFromItem(event.item);
Assert
.isNotNull(row,
"Internal Structure invalid. Row item has no row ViewerRow assigned"); //$NON-NLS-1$
- ViewerCell tmp = row.getCell(focusCell.getColumnIndex());
+ ViewerCell<E> tmp = row.getCell(focusCell.getColumnIndex());
if (!focusCell.equals(tmp)) {
setFocusCell(tmp);
}
@@ -125,7 +126,7 @@ abstract class SWTFocusCellManager {
/**
* Handles the {@link SWT#FocusIn} event.
- *
+ *
* @param event the event
*/
private void handleFocusIn(Event event) {
@@ -134,9 +135,9 @@ abstract class SWTFocusCellManager {
}
}
- abstract ViewerCell getInitialFocusCell();
+ abstract ViewerCell<E> getInitialFocusCell();
- private void hookListener(final ColumnViewer viewer) {
+ private void hookListener(final ColumnViewer<E,I> viewer) {
Listener listener = new Listener() {
public void handleEvent(Event event) {
@@ -174,23 +175,23 @@ abstract class SWTFocusCellManager {
new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent event) {
- ViewerCell cell = getFocusCell();
+ ViewerCell<E> cell = getFocusCell();
if (cell == null)
return;
-
- ViewerRow row = cell.getViewerRow();
+
+ ViewerRow<E> row = cell.getViewerRow();
if (row == null)
return;
-
- ViewerColumn viewPart = viewer.getViewerColumn(cell
+
+ ViewerColumn<E,I> viewPart = viewer.getViewerColumn(cell
.getColumnIndex());
-
+
if (viewPart == null)
return;
-
- CellLabelProvider labelProvider = viewPart
+
+ CellLabelProvider<E,I> labelProvider = viewPart
.getLabelProvider();
-
+
if (labelProvider == null)
return;
labelProvider.update(cell);
@@ -204,16 +205,16 @@ abstract class SWTFocusCellManager {
* @return the cell with the focus
*
*/
- public ViewerCell getFocusCell() {
+ public ViewerCell<E> getFocusCell() {
return focusCell;
}
-
- final ViewerCell _getFocusCell() {
+
+ final ViewerCell<E> _getFocusCell() {
return focusCell;
}
- void setFocusCell(ViewerCell focusCell) {
- ViewerCell oldCell = this.focusCell;
+ void setFocusCell(ViewerCell<E> focusCell) {
+ ViewerCell<E> oldCell = this.focusCell;
if( this.focusCell != null && ! this.focusCell.getItem().isDisposed() ) {
this.focusCell.getItem().removeDisposeListener(itemDeletionListener);
@@ -228,13 +229,13 @@ abstract class SWTFocusCellManager {
if( focusCell != null ) {
focusCell.scrollIntoView();
}
-
+
this.cellHighlighter.focusCellChanged(focusCell,oldCell);
-
+
getViewer().getControl().getAccessible().setFocus(ACC.CHILDID_SELF);
}
- ColumnViewer getViewer() {
+ ColumnViewer<E,I> getViewer() {
return viewer;
}
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java
index ce3aab9..b4c8ad4 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java
@@ -132,9 +132,9 @@ public class TableViewer<E,I> extends AbstractTableViewer<E,I> {
}
@Override
- protected ColumnViewerEditor createViewerEditor() {
- return new TableViewerEditor(this, null,
- new ColumnViewerEditorActivationStrategy(this),
+ protected ColumnViewerEditor<E,I> createViewerEditor() {
+ return new TableViewerEditor<E,I>(this, null,
+ new ColumnViewerEditorActivationStrategy<E,I>(this),
ColumnViewerEditor.DEFAULT);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerEditor.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerEditor.java
index 7ba0a6e..595aa22 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerEditor.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerEditor.java
@@ -25,17 +25,19 @@ import org.eclipse.swt.widgets.TableItem;
/**
* This is an editor-implementation for {@link Table}
- *
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
+ *
* @since 3.3
- *
+ *
*/
-public final class TableViewerEditor extends ColumnViewerEditor {
+public final class TableViewerEditor<E,I> extends ColumnViewerEditor<E,I> {
/**
* This viewer's table editor.
*/
private TableEditor tableEditor;
- private SWTFocusCellManager focusCellManager;
+ private SWTFocusCellManager<E,I> focusCellManager;
/**
* @param viewer
@@ -47,8 +49,8 @@ public final class TableViewerEditor extends ColumnViewerEditor {
* @param feature
* the feature mask
*/
- TableViewerEditor(TableViewer viewer, SWTFocusCellManager focusCellManager,
- ColumnViewerEditorActivationStrategy editorActivationStrategy,
+ TableViewerEditor(TableViewer<E,I> viewer, SWTFocusCellManager<E,I> focusCellManager,
+ ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy,
int feature) {
super(viewer, editorActivationStrategy, feature);
tableEditor = new TableEditor(viewer.getTable());
@@ -57,7 +59,7 @@ public final class TableViewerEditor extends ColumnViewerEditor {
/**
* Create a customized editor with focusable cells
- *
+ *
* @param viewer
* the viewer the editor is created for
* @param focusCellManager
@@ -75,11 +77,11 @@ public final class TableViewerEditor extends ColumnViewerEditor {
* </ul>
* @see #create(TableViewer, ColumnViewerEditorActivationStrategy, int)
*/
- public static void create(TableViewer viewer,
- SWTFocusCellManager focusCellManager,
- ColumnViewerEditorActivationStrategy editorActivationStrategy,
+ public static <E,I> void create(TableViewer<E,I> viewer,
+ SWTFocusCellManager<E,I> focusCellManager,
+ ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy,
int feature) {
- TableViewerEditor editor = new TableViewerEditor(viewer,
+ TableViewerEditor<E,I> editor = new TableViewerEditor<E,I>(viewer,
focusCellManager, editorActivationStrategy, feature);
viewer.setColumnViewerEditor(editor);
if (focusCellManager != null) {
@@ -89,7 +91,7 @@ public final class TableViewerEditor extends ColumnViewerEditor {
/**
* Create a customized editor whose activation process is customized
- *
+ *
* @param viewer
* the viewer the editor is created for
* @param editorActivationStrategy
@@ -104,8 +106,8 @@ public final class TableViewerEditor extends ColumnViewerEditor {
* <li>{@link ColumnViewerEditor#TABBING_VERTICAL}</li>
* </ul>
*/
- public static void create(TableViewer viewer,
- ColumnViewerEditorActivationStrategy editorActivationStrategy,
+ public static <E,I> void create(TableViewer<E,I> viewer,
+ ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy,
int feature) {
create(viewer, null, editorActivationStrategy, feature);
}
@@ -128,7 +130,7 @@ public final class TableViewerEditor extends ColumnViewerEditor {
}
@Override
- public ViewerCell getFocusCell() {
+ public ViewerCell<E> getFocusCell() {
if (focusCellManager != null) {
return focusCellManager.getFocusCell();
}
@@ -137,14 +139,14 @@ public final class TableViewerEditor extends ColumnViewerEditor {
}
@Override
- protected void updateFocusCell(ViewerCell focusCell,
+ protected void updateFocusCell(ViewerCell<E> focusCell,
ColumnViewerEditorActivationEvent event) {
// Update the focus cell when we activated the editor with these 2
// events
if (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
|| event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL) {
- List l = getViewer().getSelectionFromWidget();
+ List<E> l = getViewer().getSelectionFromWidget();
if (!l.contains(focusCell.getElement())) {
getViewer().setSelection(
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerFocusCellManager.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerFocusCellManager.java
index 5153e73..8c86eb9 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerFocusCellManager.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewerFocusCellManager.java
@@ -20,11 +20,14 @@ import org.eclipse.swt.widgets.Table;
* This class is responsible to provide the concept of cells for {@link Table}.
* This concept is needed to provide features like editor activation with the
* keyboard
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*
*/
-public class TableViewerFocusCellManager extends SWTFocusCellManager {
+public class TableViewerFocusCellManager<E,I> extends SWTFocusCellManager<E,I> {
+ @SuppressWarnings("rawtypes")
private static final CellNavigationStrategy TABLE_NAVIGATE = new CellNavigationStrategy();
/**
@@ -43,8 +46,9 @@ public class TableViewerFocusCellManager extends SWTFocusCellManager {
* @param focusDrawingDelegate
* the delegate responsible to highlight selected cell
*/
- public TableViewerFocusCellManager(TableViewer viewer,
- FocusCellHighlighter focusDrawingDelegate) {
+ @SuppressWarnings("unchecked")
+ public TableViewerFocusCellManager(TableViewer<E,I> viewer,
+ FocusCellHighlighter<E,I> focusDrawingDelegate) {
this(viewer, focusDrawingDelegate, TABLE_NAVIGATE);
}
@@ -59,19 +63,19 @@ public class TableViewerFocusCellManager extends SWTFocusCellManager {
* the strategy used to navigate the cells
* @since 3.4
*/
- public TableViewerFocusCellManager(TableViewer viewer,
- FocusCellHighlighter focusDrawingDelegate,
- CellNavigationStrategy navigationStrategy) {
+ public TableViewerFocusCellManager(TableViewer<E,I> viewer,
+ FocusCellHighlighter<E,I> focusDrawingDelegate,
+ CellNavigationStrategy<E,I> navigationStrategy) {
super(viewer, focusDrawingDelegate, navigationStrategy);
}
@Override
- ViewerCell getInitialFocusCell() {
+ ViewerCell<E> getInitialFocusCell() {
Table table = (Table) getViewer().getControl();
if (!table.isDisposed() && table.getItemCount() > 0
&& !table.getItem(table.getTopIndex()).isDisposed()) {
- final ViewerRow aViewerRow = getViewer().getViewerRowFromItem(
+ final ViewerRow<E> aViewerRow = getViewer().getViewerRowFromItem(
table.getItem(table.getTopIndex()));
if (table.getColumnCount() == 0) {
return aViewerRow.getCell(0);
@@ -87,13 +91,13 @@ public class TableViewerFocusCellManager extends SWTFocusCellManager {
return null;
}
- private boolean columnInVisibleArea(Rectangle clientArea, ViewerRow row, int colIndex) {
+ private boolean columnInVisibleArea(Rectangle clientArea, ViewerRow<E> row, int colIndex) {
return row.getBounds(colIndex).x >= clientArea.x;
}
@Override
- public ViewerCell getFocusCell() {
- ViewerCell cell = super.getFocusCell();
+ public ViewerCell<E> getFocusCell() {
+ ViewerCell<E> cell = super.getFocusCell();
Table t = (Table) getViewer().getControl();
// It is possible that the selection has changed under the hood
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
index 30036bd..d4e10bb 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
@@ -315,8 +315,8 @@ public class TreeViewer<E,I> extends AbstractTreeViewer<E, I> {
}
@Override
- protected ColumnViewerEditor createViewerEditor() {
- return new TreeViewerEditor(this,null,new ColumnViewerEditorActivationStrategy(this),ColumnViewerEditor.DEFAULT);
+ protected ColumnViewerEditor<E,I> createViewerEditor() {
+ return new TreeViewerEditor<E,I>(this,null,new ColumnViewerEditorActivationStrategy<E,I>(this),ColumnViewerEditor.DEFAULT);
}
/*
@@ -590,11 +590,11 @@ public class TreeViewer<E,I> extends AbstractTreeViewer<E, I> {
// The current item was selected, but its data is null.
// The data will be replaced by the given element, so to keep
// it selected, we have to add it to the selection.
- @SuppressWarnings({ "unchecked", "cast" })
- TreePath<E>[] originalPaths = (TreePath<E>[]) selection.getPaths();
+ @SuppressWarnings({ "unchecked" })
+ TreePath<E>[] originalPaths = selection.getPaths();
int length = originalPaths.length;
- @SuppressWarnings({ "unchecked", "cast" })
- TreePath<E>[] paths = (TreePath<E>[]) new TreePath[length + 1];
+ @SuppressWarnings({ "unchecked" })
+ TreePath<E>[] paths = new TreePath[length + 1];
System.arraycopy(originalPaths, 0, paths, 0, length);
// set the element temporarily so that we can call getTreePathFromItem
item.setData(element);
@@ -957,16 +957,16 @@ public class TreeViewer<E,I> extends AbstractTreeViewer<E, I> {
for (@SuppressWarnings("rawtypes")
Iterator<TreePath> it = oldSelection.iterator(); it
.hasNext();) {
- @SuppressWarnings({ "unchecked", "cast" })
- TreePath<E> path = (TreePath<E>) it.next();
+ @SuppressWarnings({ "unchecked" })
+ TreePath<E> path = it.next();
if (path.startsWith(removedPath, getComparer())) {
it.remove();
removed = true;
}
}
if (removed) {
- @SuppressWarnings({ "unchecked", "cast" })
- TreePath<E>[] oldTreePathSelection = (TreePath<E>[]) oldSelection
+ @SuppressWarnings({ "unchecked" })
+ TreePath<E>[] oldTreePathSelection = oldSelection
.toArray(new TreePath[oldSelection.size()]);
setSelection(new TreeSelection(oldTreePathSelection,
@@ -1100,8 +1100,8 @@ public class TreeViewer<E,I> extends AbstractTreeViewer<E, I> {
}
treePath = getTreePathFromItem((Item) widget);
} else {
- @SuppressWarnings({ "unchecked", "cast" })
- TreePath<E> emptyTreePath = (TreePath<E>) TreePath.EMPTY;
+ @SuppressWarnings({ "unchecked" })
+ TreePath<E> emptyTreePath = TreePath.EMPTY;
treePath = emptyTreePath;
}
lazyTreePathContentProvider.updateElement(treePath, index);
@@ -1133,8 +1133,8 @@ public class TreeViewer<E,I> extends AbstractTreeViewer<E, I> {
if (widget instanceof Item) {
treePath = getTreePathFromItem((Item) widget);
} else {
- @SuppressWarnings({ "unchecked", "cast" })
- TreePath<E> emptyTreePath = (TreePath<E>) TreePath.EMPTY;
+ @SuppressWarnings({ "unchecked" })
+ TreePath<E> emptyTreePath = TreePath.EMPTY;
treePath = emptyTreePath;
}
lazyTreePathContentProvider.updateChildCount(treePath, currentChildCount);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerEditor.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerEditor.java
index a21276f..99ed7e9 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerEditor.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerEditor.java
@@ -25,16 +25,18 @@ import org.eclipse.swt.widgets.TreeItem;
/**
* This is an editor implementation for {@link Tree}
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*/
-public class TreeViewerEditor extends ColumnViewerEditor {
+public class TreeViewerEditor<E,I> extends ColumnViewerEditor<E,I> {
/**
* This viewer's tree editor.
*/
private TreeEditor treeEditor;
- private SWTFocusCellManager focusCellManager;
+ private SWTFocusCellManager<E,I> focusCellManager;
/**
* @param viewer
@@ -46,8 +48,8 @@ public class TreeViewerEditor extends ColumnViewerEditor {
* @param feature
* the feature mask
*/
- TreeViewerEditor(TreeViewer viewer, SWTFocusCellManager focusCellManager,
- ColumnViewerEditorActivationStrategy editorActivationStrategy,
+ TreeViewerEditor(TreeViewer<E,I> viewer, SWTFocusCellManager<E,I> focusCellManager,
+ ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy,
int feature) {
super(viewer, editorActivationStrategy, feature);
treeEditor = new TreeEditor(viewer.getTree());
@@ -74,11 +76,11 @@ public class TreeViewerEditor extends ColumnViewerEditor {
* </ul>
* @see #create(TreeViewer, ColumnViewerEditorActivationStrategy, int)
*/
- public static void create(TreeViewer viewer,
- SWTFocusCellManager focusCellManager,
- ColumnViewerEditorActivationStrategy editorActivationStrategy,
+ public static <E,I> void create(TreeViewer<E,I> viewer,
+ SWTFocusCellManager<E,I> focusCellManager,
+ ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy,
int feature) {
- TreeViewerEditor editor = new TreeViewerEditor(viewer,
+ TreeViewerEditor<E,I> editor = new TreeViewerEditor<E,I>(viewer,
focusCellManager, editorActivationStrategy, feature);
viewer.setColumnViewerEditor(editor);
if (focusCellManager != null) {
@@ -103,8 +105,8 @@ public class TreeViewerEditor extends ColumnViewerEditor {
* <li>{@link ColumnViewerEditor#TABBING_VERTICAL}</li>
* </ul>
*/
- public static void create(TreeViewer viewer,
- ColumnViewerEditorActivationStrategy editorActivationStrategy,
+ public static <E,I> void create(TreeViewer<E,I> viewer,
+ ColumnViewerEditorActivationStrategy<E,I> editorActivationStrategy,
int feature) {
create(viewer, null, editorActivationStrategy, feature);
}
@@ -126,7 +128,7 @@ public class TreeViewerEditor extends ColumnViewerEditor {
}
@Override
- public ViewerCell getFocusCell() {
+ public ViewerCell<E> getFocusCell() {
if (focusCellManager != null) {
return focusCellManager.getFocusCell();
}
@@ -135,21 +137,21 @@ public class TreeViewerEditor extends ColumnViewerEditor {
}
@Override
- protected void updateFocusCell(ViewerCell focusCell,
+ protected void updateFocusCell(ViewerCell<E> focusCell,
ColumnViewerEditorActivationEvent event) {
// Update the focus cell when we activated the editor with these 2
// events
if (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
|| event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL) {
- List l = getViewer().getSelectionFromWidget();
+ List<E> l = getViewer().getSelectionFromWidget();
if (!l.contains(focusCell.getElement())) {
getViewer().setSelection(
new TreeSelection(focusCell.getViewerRow()
.getTreePath()),true);
}
-
+
// Set the focus cell after the selection is updated because else
// the cell is not scrolled into view
if (focusCellManager != null) {
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerFocusCellManager.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerFocusCellManager.java
index ed09bdc..c1c2c45 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerFocusCellManager.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerFocusCellManager.java
@@ -24,11 +24,14 @@ import org.eclipse.swt.widgets.TreeItem;
* This class is responsible to provide the concept of cells for {@link Tree}.
* This concept is needed to provide features like editor activation with the
* keyboard
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*
*/
-public class TreeViewerFocusCellManager extends SWTFocusCellManager {
+public class TreeViewerFocusCellManager<E,I> extends SWTFocusCellManager<E,I> {
+ @SuppressWarnings("rawtypes")
private static final CellNavigationStrategy TREE_NAVIGATE = new CellNavigationStrategy() {
@Override
public void collapse(ColumnViewer viewer, ViewerCell cellToCollapse,
@@ -98,8 +101,9 @@ public class TreeViewerFocusCellManager extends SWTFocusCellManager {
* @param focusDrawingDelegate
* the delegate responsible to highlight selected cell
*/
- public TreeViewerFocusCellManager(TreeViewer viewer,
- FocusCellHighlighter focusDrawingDelegate) {
+ @SuppressWarnings("unchecked")
+ public TreeViewerFocusCellManager(TreeViewer<E,I> viewer,
+ FocusCellHighlighter<E,I> focusDrawingDelegate) {
this(viewer, focusDrawingDelegate, TREE_NAVIGATE);
}
@@ -114,18 +118,18 @@ public class TreeViewerFocusCellManager extends SWTFocusCellManager {
* the strategy used to navigate the cells
* @since 3.4
*/
- public TreeViewerFocusCellManager(TreeViewer viewer,
- FocusCellHighlighter focusDrawingDelegate,
- CellNavigationStrategy navigationStrategy) {
+ public TreeViewerFocusCellManager(TreeViewer<E,I> viewer,
+ FocusCellHighlighter<E,I> focusDrawingDelegate,
+ CellNavigationStrategy<E,I> navigationStrategy) {
super(viewer, focusDrawingDelegate, navigationStrategy);
}
@Override
- ViewerCell getInitialFocusCell() {
+ ViewerCell<E> getInitialFocusCell() {
Tree tree = (Tree) getViewer().getControl();
if (! tree.isDisposed() && tree.getItemCount() > 0 && ! tree.getTopItem().isDisposed()) {
- ViewerRow aViewerRow = getViewer().getViewerRowFromItem(tree.getTopItem());
+ ViewerRow<E> aViewerRow = getViewer().getViewerRowFromItem(tree.getTopItem());
if (tree.getColumnCount() == 0) {
return aViewerRow.getCell(0);
}
@@ -140,13 +144,13 @@ public class TreeViewerFocusCellManager extends SWTFocusCellManager {
return null;
}
- private boolean columnInVisibleArea(Rectangle clientArea, ViewerRow row, int colIndex) {
+ private boolean columnInVisibleArea(Rectangle clientArea, ViewerRow<E> row, int colIndex) {
return row.getBounds(colIndex).x >= clientArea.x;
}
@Override
- public ViewerCell getFocusCell() {
- ViewerCell cell = super.getFocusCell();
+ public ViewerCell<E> getFocusCell() {
+ ViewerCell<E> cell = super.getFocusCell();
Tree t = (Tree) getViewer().getControl();
// It is possible that the selection has changed under the hood
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java
index bb9a1a5..316e18a 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java
@@ -37,7 +37,7 @@ public abstract class ViewerColumn<E,I> {
static String COLUMN_VIEWER_KEY = Policy.JFACE + ".columnViewer";//$NON-NLS-1$
- private EditingSupport editingSupport;
+ private EditingSupport<E,I> editingSupport;
private ILabelProviderListener<E> listener;
@@ -119,7 +119,7 @@ public abstract class ViewerColumn<E,I> {
*
* @return {@link EditingSupport}
*/
- /* package */EditingSupport getEditingSupport() {
+ /* package */EditingSupport<E, I> getEditingSupport() {
return editingSupport;
}
@@ -133,7 +133,7 @@ public abstract class ViewerColumn<E,I> {
* @param editingSupport
* The {@link EditingSupport} to set.
*/
- public void setEditingSupport(EditingSupport editingSupport) {
+ public void setEditingSupport(EditingSupport<E,I> editingSupport) {
this.editingSupport = editingSupport;
}