aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Still2013-09-16 18:05:46 (EDT)
committerHendrik Still2013-09-18 06:05:20 (EDT)
commit6c753cd28a9731192fa36b4b8a1d3e0a3b874e86 (patch)
treef52373f87af2b495f4c9f04cfded1e14dbc9631c
parent65af4d1068503632de6a26721755209e734e0d09 (diff)
downloadeclipse.platform.ui-6c753cd28a9731192fa36b4b8a1d3e0a3b874e86.zip
eclipse.platform.ui-6c753cd28a9731192fa36b4b8a1d3e0a3b874e86.tar.gz
eclipse.platform.ui-6c753cd28a9731192fa36b4b8a1d3e0a3b874e86.tar.bz2
Updated several classes as cleanup refs/changes/88/16488/2
Also - generified Decorators like IFontDecorator - generified IIndexableLazyContentProvider Change-Id: Ie5ace2dd5b451459e69907f83b6f73d5ea7f54db Signed-off-by: Hendrik Still <hendrik.still@gammas.de>
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/BaseLabelProvider.java9
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java2
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellNavigationStrategy.java22
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java32
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java8
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingLabelProvider.java105
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingStyledCellLabelProvider.java68
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecorationContext.java4
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java51
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IBaseLabelProvider.java4
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IColorDecorator.java7
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IDelayedLabelDecorator.java5
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IFontDecorator.java5
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IIndexableLazyContentProvider.java6
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelDecorator.java7
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelProviderListener.java5
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILazyContentProvider.java3
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILightweightLabelDecorator.java5
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelDecorator.java9
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelProviderChangedEvent.java15
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/NamedHandleObjectLabelProvider.java5
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/OwnerDrawLabelProvider.java53
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java2
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewerInternals.java5
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java34
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledString.java16
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableLayout.java10
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java3
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java4
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeNode.java2
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerRow.java12
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerColumn.java6
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java6
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/deferred/IntHashMap.java8
34 files changed, 298 insertions, 240 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/BaseLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/BaseLabelProvider.java
index d377ee1..27bf3e2 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/BaseLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/BaseLabelProvider.java
@@ -28,7 +28,7 @@ public class BaseLabelProvider<E> extends EventManager implements IBaseLabelProv
/* (non-Javadoc)
* Method declared on IBaseLabelProvider.
*/
- public void addListener(ILabelProviderListener listener) {
+ public void addListener(ILabelProviderListener<E> listener) {
addListenerObject(listener);
}
@@ -54,7 +54,7 @@ public class BaseLabelProvider<E> extends EventManager implements IBaseLabelProv
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
- public void removeListener(ILabelProviderListener listener) {
+ public void removeListener(ILabelProviderListener<E> listener) {
removeListenerObject(listener);
}
@@ -67,10 +67,11 @@ public class BaseLabelProvider<E> extends EventManager implements IBaseLabelProv
*
* @see ILabelProviderListener#labelProviderChanged
*/
- protected void fireLabelProviderChanged(final LabelProviderChangedEvent event) {
+ protected void fireLabelProviderChanged(final LabelProviderChangedEvent<E> event) {
Object[] listeners = getListeners();
for (int i = 0; i < listeners.length; ++i) {
- final ILabelProviderListener l = (ILabelProviderListener) listeners[i];
+ @SuppressWarnings("unchecked")
+ final ILabelProviderListener<E> l = (ILabelProviderListener<E>) listeners[i];
SafeRunnable.run(new SafeRunnable() {
public void run() {
l.labelProviderChanged(event);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
index 6c5c6aa..d7fa4e5 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellLabelProvider.java
@@ -80,7 +80,7 @@ public abstract class CellLabelProvider<E,I> extends BaseLabelProvider<E> {
* @return {@link Image} or <code>null</code> if there is not image.
*/
- public Image getToolTipImage(Object object) {
+ public Image getToolTipImage(E object) {
return null;
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellNavigationStrategy.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellNavigationStrategy.java
index b1d562f..0480096 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellNavigationStrategy.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/CellNavigationStrategy.java
@@ -21,11 +21,13 @@ import org.eclipse.swt.widgets.Event;
* <p>
* <b>Subclasses can implement their custom navigation algorithms</b>
* </p>
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*
*/
-public class CellNavigationStrategy {
+public class CellNavigationStrategy<E,I> {
/**
* is the given event an event which moves the selection to another cell
*
@@ -35,7 +37,7 @@ public class CellNavigationStrategy {
* the key event
* @return <code>true</code> if a new cell is searched
*/
- public boolean isNavigationEvent(ColumnViewer viewer, Event event) {
+ public boolean isNavigationEvent(ColumnViewer<E,I> viewer, Event event) {
switch (event.keyCode) {
case SWT.ARROW_UP:
case SWT.ARROW_DOWN:
@@ -60,8 +62,8 @@ public class CellNavigationStrategy {
* the key event
* @return <code>true</code> if this event triggers collapsing of a node
*/
- public boolean isCollapseEvent(ColumnViewer viewer,
- ViewerCell cellToCollapse, Event event) {
+ public boolean isCollapseEvent(ColumnViewer<E,I> viewer,
+ ViewerCell<E> cellToCollapse, Event event) {
return false;
}
@@ -74,7 +76,7 @@ public class CellNavigationStrategy {
* the key event
* @return <code>true</code> if this event triggers expanding of a node
*/
- public boolean isExpandEvent(ColumnViewer viewer, ViewerCell cellToExpand,
+ public boolean isExpandEvent(ColumnViewer<E,I> viewer, ViewerCell<E> cellToExpand,
Event event) {
return false;
}
@@ -87,7 +89,7 @@ public class CellNavigationStrategy {
* @param event
* the event triggering the expansion
*/
- public void expand(ColumnViewer viewer, ViewerCell cellToExpand, Event event) {
+ public void expand(ColumnViewer<E,I> viewer, ViewerCell<E> cellToExpand, Event event) {
}
@@ -99,7 +101,7 @@ public class CellNavigationStrategy {
* @param event
* the event triggering the expansion
*/
- public void collapse(ColumnViewer viewer, ViewerCell cellToCollapse,
+ public void collapse(ColumnViewer<E,I> viewer, ViewerCell<E> cellToCollapse,
Event event) {
}
@@ -115,8 +117,8 @@ public class CellNavigationStrategy {
* default implementation is taken. E.g. it's fairly impossible to
* react on PAGE_DOWN requests
*/
- public ViewerCell findSelectedCell(ColumnViewer viewer,
- ViewerCell currentSelectedCell, Event event) {
+ public ViewerCell<E> findSelectedCell(ColumnViewer<E,I> viewer,
+ ViewerCell<E> currentSelectedCell, Event event) {
switch (event.keyCode) {
case SWT.ARROW_UP:
@@ -154,7 +156,7 @@ public class CellNavigationStrategy {
* the event
* @return <code>true</code> if the event has to be canceled
*/
- public boolean shouldCancelEvent(ColumnViewer viewer, Event event) {
+ public boolean shouldCancelEvent(ColumnViewer<E,I> viewer, Event event) {
return event.keyCode == SWT.ARROW_LEFT
|| event.keyCode == SWT.ARROW_RIGHT;
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java
index 48a2d4a..daa0eb4 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ColumnViewerToolTipSupport.java
@@ -26,12 +26,14 @@ import org.eclipse.swt.widgets.Event;
/**
* The ColumnViewerTooltipSupport is the class that provides tool tips for
* ColumnViewers.
+ * @param <E> Type of an single element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*
*/
-public class ColumnViewerToolTipSupport extends DefaultToolTip {
- private ColumnViewer viewer;
+public class ColumnViewerToolTipSupport<E,I> extends DefaultToolTip {
+ private ColumnViewer<E,I> viewer;
private static final String VIEWER_CELL_KEY = Policy.JFACE
+ "_VIEWER_CELL_KEY"; //$NON-NLS-1$
@@ -54,7 +56,7 @@ public class ColumnViewerToolTipSupport extends DefaultToolTip {
* <code>true</code> if the activation is done manually using
* {@link #show(Point)}
*/
- protected ColumnViewerToolTipSupport(ColumnViewer viewer, int style,
+ protected ColumnViewerToolTipSupport(ColumnViewer<E,I> viewer, int style,
boolean manualActivation) {
super(viewer.getControl(), style, manualActivation);
this.viewer = viewer;
@@ -68,8 +70,8 @@ public class ColumnViewerToolTipSupport extends DefaultToolTip {
* @param viewer
* the viewer the support is attached to
*/
- public static void enableFor(ColumnViewer viewer) {
- new ColumnViewerToolTipSupport(viewer, ToolTip.NO_RECREATE, false);
+ public static <E,I> void enableFor(ColumnViewer<E,I> viewer) {
+ new ColumnViewerToolTipSupport<E,I>(viewer, ToolTip.NO_RECREATE, false);
}
/**
@@ -85,8 +87,8 @@ public class ColumnViewerToolTipSupport extends DefaultToolTip {
* @see ToolTip#RECREATE
* @see ToolTip#NO_RECREATE
*/
- public static void enableFor(ColumnViewer viewer, int style) {
- new ColumnViewerToolTipSupport(viewer, style, false);
+ public static <E,I> void enableFor(ColumnViewer<E,I> viewer, int style) {
+ new ColumnViewerToolTipSupport<E,I>(viewer, style, false);
}
@Override
@@ -100,7 +102,8 @@ public class ColumnViewerToolTipSupport extends DefaultToolTip {
*/
@Override
protected Composite createToolTipContentArea(Event event, Composite parent) {
- ViewerCell cell = (ViewerCell) getData(VIEWER_CELL_KEY);
+ @SuppressWarnings("unchecked")
+ ViewerCell<E> cell = (ViewerCell<E>) getData(VIEWER_CELL_KEY);
setData(VIEWER_CELL_KEY, null);
return createViewerToolTipContentArea(event, cell, parent);
@@ -127,7 +130,7 @@ public class ColumnViewerToolTipSupport extends DefaultToolTip {
* @since 3.4
*/
protected Composite createViewerToolTipContentArea(Event event,
- ViewerCell cell, Composite parent) {
+ ViewerCell<E> cell, Composite parent) {
return super.createToolTipContentArea(event, parent);
}
@@ -139,28 +142,29 @@ public class ColumnViewerToolTipSupport extends DefaultToolTip {
boolean rv = false;
- ViewerRow row = viewer.getViewerRow(new Point(event.x, event.y));
+ ViewerRow<E> row = viewer.getViewerRow(new Point(event.x, event.y));
viewer.getControl().setToolTipText(""); //$NON-NLS-1$
Point point = new Point(event.x, event.y);
if (row != null) {
- Object element = row.getItem().getData();
+ @SuppressWarnings("unchecked")
+ E element = (E) row.getItem().getData();
- ViewerCell cell = row.getCell(point);
+ ViewerCell<E> cell = row.getCell(point);
if( cell == null ) {
return false;
}
- ViewerColumn viewPart = viewer.getViewerColumn(cell
+ ViewerColumn<E,I> viewPart = viewer.getViewerColumn(cell
.getColumnIndex());
if (viewPart == null) {
return false;
}
- CellLabelProvider labelProvider = viewPart.getLabelProvider();
+ CellLabelProvider<E,I> labelProvider = viewPart.getLabelProvider();
boolean useNative = labelProvider.useNativeToolTip(element);
String text = labelProvider.getToolTipText(element);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java
index a4ce41f..82e75b6 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java
@@ -76,10 +76,10 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* a label provider avoids having to define public methods
* for internal events.
*/
- private final ILabelProviderListener labelProviderListener = new ILabelProviderListener() {
+ private final ILabelProviderListener<E> labelProviderListener = new ILabelProviderListener<E>() {
private boolean logWhenDisposed = true; // initially true, set to false
-
- public void labelProviderChanged(LabelProviderChangedEvent event) {
+
+ public void labelProviderChanged(LabelProviderChangedEvent<E> event) {
Control control = getControl();
if (control == null || control.isDisposed()) {
if (logWhenDisposed) {
@@ -193,7 +193,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* </p>
* @param event the change event
*/
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
+ protected void handleLabelProviderChanged(LabelProviderChangedEvent<E> event) {
labelProviderChanged();
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingLabelProvider.java
index c859739..3d5831e 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingLabelProvider.java
@@ -21,13 +21,15 @@ import org.eclipse.swt.graphics.Image;
* a nested label provider and an optional decorator.
* The decorator decorates the label text, image, font and colors provided by
* the nested label provider.
+ *
+ * @param <E> Type of an element of the model
*/
-public class DecoratingLabelProvider extends LabelProvider implements
- ILabelProvider, IViewerLabelProvider, IColorProvider, IFontProvider, ITreePathLabelProvider {
+public class DecoratingLabelProvider<E> extends LabelProvider<E> implements
+ IViewerLabelProvider<E>, IColorProvider<E>, IFontProvider<E>, ITreePathLabelProvider<E> {
- private ILabelProvider provider;
+ private ILabelProvider<E> provider;
- private ILabelDecorator decorator;
+ private ILabelDecorator<E> decorator;
// Need to keep our own list of listeners
private ListenerList listeners = new ListenerList();
@@ -41,8 +43,8 @@ public class DecoratingLabelProvider extends LabelProvider implements
* @param provider the nested label provider
* @param decorator the label decorator, or <code>null</code> if no decorator is to be used initially
*/
- public DecoratingLabelProvider(ILabelProvider provider,
- ILabelDecorator decorator) {
+ public DecoratingLabelProvider(ILabelProvider<E> provider,
+ ILabelDecorator<E> decorator) {
Assert.isNotNull(provider);
this.provider = provider;
this.decorator = decorator;
@@ -55,7 +57,7 @@ public class DecoratingLabelProvider extends LabelProvider implements
* @param listener a label provider listener
*/
@Override
- public void addListener(ILabelProviderListener listener) {
+ public void addListener(ILabelProviderListener<E> listener) {
super.addListener(listener);
provider.addListener(listener);
if (decorator != null) {
@@ -84,11 +86,11 @@ public class DecoratingLabelProvider extends LabelProvider implements
* <code>decorateImage</code> method.
*/
@Override
- public Image getImage(Object element) {
+ public Image getImage(E element) {
Image image = provider.getImage(element);
if (decorator != null) {
if (decorator instanceof LabelDecorator) {
- LabelDecorator ld2 = (LabelDecorator) decorator;
+ LabelDecorator<E> ld2 = (LabelDecorator<E>) decorator;
Image decorated = ld2.decorateImage(image, element, getDecorationContext());
if (decorated != null) {
return decorated;
@@ -108,7 +110,7 @@ public class DecoratingLabelProvider extends LabelProvider implements
*
* @return the label decorator, or <code>null</code> if none has been set.
*/
- public ILabelDecorator getLabelDecorator() {
+ public ILabelDecorator<E> getLabelDecorator() {
return decorator;
}
@@ -117,7 +119,7 @@ public class DecoratingLabelProvider extends LabelProvider implements
*
* @return the nested label provider
*/
- public ILabelProvider getLabelProvider() {
+ public ILabelProvider<E> getLabelProvider() {
return provider;
}
@@ -129,11 +131,11 @@ public class DecoratingLabelProvider extends LabelProvider implements
* <code>decorateText</code> method.
*/
@Override
- public String getText(Object element) {
+ public String getText(E element) {
String text = provider.getText(element);
if (decorator != null) {
if (decorator instanceof LabelDecorator) {
- LabelDecorator ld2 = (LabelDecorator) decorator;
+ LabelDecorator<E> ld2 = (LabelDecorator<E>) decorator;
String decorated = ld2.decorateText(text, element, getDecorationContext());
if (decorated != null) {
return decorated;
@@ -155,7 +157,7 @@ public class DecoratingLabelProvider extends LabelProvider implements
* decorator returns <code>true</code>.
*/
@Override
- public boolean isLabelProperty(Object element, String property) {
+ public boolean isLabelProperty(E element, String property) {
if (provider.isLabelProperty(element, property)) {
return true;
}
@@ -172,7 +174,7 @@ public class DecoratingLabelProvider extends LabelProvider implements
* @param listener a label provider listener
*/
@Override
- public void removeListener(ILabelProviderListener listener) {
+ public void removeListener(ILabelProviderListener<E> listener) {
super.removeListener(listener);
provider.removeListener(listener);
if (decorator != null) {
@@ -190,24 +192,28 @@ public class DecoratingLabelProvider extends LabelProvider implements
*
* @param decorator the label decorator, or <code>null</code> if no decorations are to be applied
*/
- public void setLabelDecorator(ILabelDecorator decorator) {
- ILabelDecorator oldDecorator = this.decorator;
+ public void setLabelDecorator(ILabelDecorator<E> decorator) {
+ ILabelDecorator<E> oldDecorator = this.decorator;
if (oldDecorator != decorator) {
Object[] listenerList = this.listeners.getListeners();
if (oldDecorator != null) {
for (int i = 0; i < listenerList.length; ++i) {
+ @SuppressWarnings("unchecked")
+ ILabelProviderListener<E> labelProviderListener = (ILabelProviderListener<E>) listenerList[i];
oldDecorator
- .removeListener((ILabelProviderListener) listenerList[i]);
+ .removeListener(labelProviderListener);
}
}
this.decorator = decorator;
if (decorator != null) {
for (int i = 0; i < listenerList.length; ++i) {
+ @SuppressWarnings("unchecked")
+ ILabelProviderListener<E> labelProviderListener = (ILabelProviderListener<E>) listenerList[i];
decorator
- .addListener((ILabelProviderListener) listenerList[i]);
+ .addListener(labelProviderListener);
}
}
- fireLabelProviderChanged(new LabelProviderChangedEvent(this));
+ fireLabelProviderChanged(new LabelProviderChangedEvent<E>(this));
}
}
@@ -216,13 +222,13 @@ public class DecoratingLabelProvider extends LabelProvider implements
* (non-Javadoc)
* @see org.eclipse.jface.viewers.IViewerLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel, java.lang.Object)
*/
- public void updateLabel(ViewerLabel settings, Object element) {
+ public void updateLabel(ViewerLabel settings, E element) {
- ILabelDecorator currentDecorator = getLabelDecorator();
+ ILabelDecorator<E> currentDecorator = getLabelDecorator();
String oldText = settings.getText();
boolean decorationReady = true;
if (currentDecorator instanceof IDelayedLabelDecorator) {
- IDelayedLabelDecorator delayedDecorator = (IDelayedLabelDecorator) currentDecorator;
+ IDelayedLabelDecorator<E> delayedDecorator = (IDelayedLabelDecorator<E>) currentDecorator;
if (!delayedDecorator.prepareDecoration(element, oldText)) {
// The decoration is not ready but has been queued for processing
decorationReady = false;
@@ -252,16 +258,19 @@ public class DecoratingLabelProvider extends LabelProvider implements
* @param element The Object being decorated.
* @since 3.1
*/
- protected void updateForDecorationReady(ViewerLabel settings, Object element) {
+ protected void updateForDecorationReady(ViewerLabel settings, E element) {
if(decorator instanceof IColorDecorator){
- IColorDecorator colorDecorator = (IColorDecorator) decorator;
+ @SuppressWarnings("unchecked")
+ IColorDecorator<E> colorDecorator = (IColorDecorator<E>) decorator;
settings.setBackground(colorDecorator.decorateBackground(element));
settings.setForeground(colorDecorator.decorateForeground(element));
}
if(decorator instanceof IFontDecorator) {
- settings.setFont(((IFontDecorator) decorator).decorateFont(element));
+ @SuppressWarnings("unchecked")
+ IFontDecorator<E> fontDecorator = (IFontDecorator<E>) decorator;
+ settings.setFont(fontDecorator.decorateFont(element));
}
}
@@ -269,9 +278,11 @@ public class DecoratingLabelProvider extends LabelProvider implements
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
- public Color getBackground(Object element) {
+ public Color getBackground(E element) {
if(provider instanceof IColorProvider) {
- return ((IColorProvider) provider).getBackground(element);
+ @SuppressWarnings("unchecked")
+ IColorProvider<E> colorProvider = (IColorProvider<E>) provider;
+ return colorProvider.getBackground(element);
}
return null;
}
@@ -279,9 +290,11 @@ public class DecoratingLabelProvider extends LabelProvider implements
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
- public Font getFont(Object element) {
+ public Font getFont(E element) {
if(provider instanceof IFontProvider) {
- return ((IFontProvider) provider).getFont(element);
+ @SuppressWarnings("unchecked")
+ IFontProvider<E> fontProvider = (IFontProvider<E>) provider;
+ return fontProvider.getFont(element);
}
return null;
}
@@ -289,9 +302,11 @@ public class DecoratingLabelProvider extends LabelProvider implements
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
- public Color getForeground(Object element) {
+ public Color getForeground(E element) {
if(provider instanceof IColorProvider) {
- return ((IColorProvider) provider).getForeground(element);
+ @SuppressWarnings("unchecked")
+ IColorProvider<E> colorProvider = (IColorProvider<E>) provider;
+ return colorProvider.getForeground(element);
}
return null;
}
@@ -323,19 +338,19 @@ public class DecoratingLabelProvider extends LabelProvider implements
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreePathLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel, org.eclipse.jface.viewers.TreePath)
*/
- public void updateLabel(ViewerLabel settings, TreePath elementPath) {
- ILabelDecorator currentDecorator = getLabelDecorator();
+ public void updateLabel(ViewerLabel settings, TreePath<E> elementPath) {
+ ILabelDecorator<E> currentDecorator = getLabelDecorator();
String oldText = settings.getText();
- Object element = elementPath.getLastSegment();
+ E element = elementPath.getLastSegment();
boolean decorationReady = true;
if (currentDecorator instanceof LabelDecorator) {
- LabelDecorator labelDecorator = (LabelDecorator) currentDecorator;
+ LabelDecorator<E> labelDecorator = (LabelDecorator<E>) currentDecorator;
if (!labelDecorator.prepareDecoration(element, oldText, getDecorationContext())) {
// The decoration is not ready but has been queued for processing
decorationReady = false;
}
} else if (currentDecorator instanceof IDelayedLabelDecorator) {
- IDelayedLabelDecorator delayedDecorator = (IDelayedLabelDecorator) currentDecorator;
+ IDelayedLabelDecorator<E> delayedDecorator = (IDelayedLabelDecorator<E>) currentDecorator;
if (!delayedDecorator.prepareDecoration(element, oldText)) {
// The decoration is not ready but has been queued for processing
decorationReady = false;
@@ -345,7 +360,8 @@ public class DecoratingLabelProvider extends LabelProvider implements
// update icon and label
if (provider instanceof ITreePathLabelProvider) {
- ITreePathLabelProvider pprov = (ITreePathLabelProvider) provider;
+ @SuppressWarnings("unchecked")
+ ITreePathLabelProvider<E> pprov = (ITreePathLabelProvider<E>) provider;
if (decorationReady || oldText == null
|| settings.getText().length() == 0) {
pprov.updateLabel(settings, elementPath);
@@ -374,11 +390,11 @@ public class DecoratingLabelProvider extends LabelProvider implements
* @param settings the settings obtained from the label provider
* @param elementPath the element path being decorated
*/
- private void decorateSettings(ViewerLabel settings, TreePath elementPath) {
- Object element = elementPath.getLastSegment();
+ private void decorateSettings(ViewerLabel settings, TreePath<E> elementPath) {
+ E element = elementPath.getLastSegment();
if (decorator != null) {
if (decorator instanceof LabelDecorator) {
- LabelDecorator labelDecorator = (LabelDecorator) decorator;
+ LabelDecorator<E> labelDecorator = (LabelDecorator<E>) decorator;
String text = labelDecorator.decorateText(settings.getText(), element, getDecorationContext());
if (text != null && text.length() > 0)
settings.setText(text);
@@ -395,7 +411,8 @@ public class DecoratingLabelProvider extends LabelProvider implements
settings.setImage(image);
}
if(decorator instanceof IColorDecorator){
- IColorDecorator colorDecorator = (IColorDecorator) decorator;
+ @SuppressWarnings("unchecked")
+ IColorDecorator<E> colorDecorator = (IColorDecorator<E>) decorator;
Color background = colorDecorator.decorateBackground(element);
if (background != null)
settings.setBackground(background);
@@ -405,7 +422,9 @@ public class DecoratingLabelProvider extends LabelProvider implements
}
if(decorator instanceof IFontDecorator) {
- Font font = ((IFontDecorator) decorator).decorateFont(element);
+ @SuppressWarnings("unchecked")
+ IFontDecorator<E> fontDecorator = (IFontDecorator<E>) decorator;
+ Font font = fontDecorator.decorateFont(element);
if (font != null)
settings.setFont(font);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingStyledCellLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingStyledCellLabelProvider.java
index 2c34903..e20c3f3 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingStyledCellLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecoratingStyledCellLabelProvider.java
@@ -38,15 +38,17 @@ import org.eclipse.swt.graphics.Image;
* and {@link IFontDecorator} to provide foreground and background color and
* font decoration.
* </p>
+ * @param <E> Type of an element of the model
+ * @param <I> Type of the input
*
* @since 3.4
*/
-public class DecoratingStyledCellLabelProvider extends
- DelegatingStyledCellLabelProvider {
+public class DecoratingStyledCellLabelProvider<E,I> extends
+ DelegatingStyledCellLabelProvider<E,I> {
- private ILabelDecorator decorator;
+ private ILabelDecorator<E> decorator;
private IDecorationContext decorationContext= DecorationContext.DEFAULT_CONTEXT;
- private ILabelProviderListener labelProviderListener;
+ private ILabelProviderListener<E> labelProviderListener;
/**
* Creates a {@link DecoratingStyledCellLabelProvider} that delegates the
@@ -64,7 +66,7 @@ public class DecoratingStyledCellLabelProvider extends
* used
*/
public DecoratingStyledCellLabelProvider(
- IStyledLabelProvider labelProvider, ILabelDecorator decorator,
+ IStyledLabelProvider<E> labelProvider, ILabelDecorator<E> decorator,
IDecorationContext decorationContext) {
super(labelProvider);
@@ -72,8 +74,8 @@ public class DecoratingStyledCellLabelProvider extends
this.decorationContext = decorationContext != null ? decorationContext
: DecorationContext.DEFAULT_CONTEXT;
- this.labelProviderListener = new ILabelProviderListener() {
- public void labelProviderChanged(LabelProviderChangedEvent event) {
+ this.labelProviderListener = new ILabelProviderListener<E>() {
+ public void labelProviderChanged(LabelProviderChangedEvent<E> event) {
fireLabelProviderChanged(event);
}
};
@@ -105,19 +107,19 @@ public class DecoratingStyledCellLabelProvider extends
this.decorationContext = decorationContext;
}
- private boolean waitForPendingDecoration(ViewerCell cell) {
+ private boolean waitForPendingDecoration(ViewerCell<E> cell) {
if (this.decorator == null)
return false;
- Object element = cell.getElement();
+ E element = cell.getElement();
String oldText = cell.getText();
boolean isDecorationPending = false;
if (this.decorator instanceof LabelDecorator) {
- isDecorationPending = !((LabelDecorator) this.decorator)
+ isDecorationPending = !((LabelDecorator<E>) this.decorator)
.prepareDecoration(element, oldText, getDecorationContext());
} else if (this.decorator instanceof IDelayedLabelDecorator) {
- isDecorationPending = !((IDelayedLabelDecorator) this.decorator)
+ isDecorationPending = !((IDelayedLabelDecorator<E>) this.decorator)
.prepareDecoration(element, oldText);
}
if (isDecorationPending && oldText.length() == 0) {
@@ -128,7 +130,7 @@ public class DecoratingStyledCellLabelProvider extends
}
@Override
- public void update(ViewerCell cell) {
+ public void update(ViewerCell<E> cell) {
if (waitForPendingDecoration(cell)) {
return; // wait until the decoration is ready
}
@@ -136,10 +138,11 @@ public class DecoratingStyledCellLabelProvider extends
}
@Override
- public Color getForeground(Object element) {
+ public Color getForeground(E element) {
if (this.decorator instanceof IColorDecorator) {
- Color foreground = ((IColorDecorator) this.decorator)
- .decorateForeground(element);
+ @SuppressWarnings("unchecked")
+ IColorDecorator<E> colorDecorator = (IColorDecorator<E>) this.decorator;
+ Color foreground = colorDecorator.decorateForeground(element);
if (foreground != null)
return foreground;
}
@@ -147,10 +150,11 @@ public class DecoratingStyledCellLabelProvider extends
}
@Override
- public Color getBackground(Object element) {
+ public Color getBackground(E element) {
if (this.decorator instanceof IColorDecorator) {
- Color color = ((IColorDecorator) this.decorator)
- .decorateBackground(element);
+ @SuppressWarnings("unchecked")
+ IColorDecorator<E> colorDecorator = (IColorDecorator<E>) this.decorator;
+ Color color = colorDecorator.decorateBackground(element);
if (color != null)
return color;
}
@@ -158,9 +162,11 @@ public class DecoratingStyledCellLabelProvider extends
}
@Override
- public Font getFont(Object element) {
+ public Font getFont(E element) {
if (this.decorator instanceof IFontDecorator) {
- Font font = ((IFontDecorator) this.decorator).decorateFont(element);
+ @SuppressWarnings("unchecked")
+ IFontDecorator<E> fontDecorator = (IFontDecorator<E>) this.decorator;
+ Font font = fontDecorator.decorateFont(element);
if (font != null)
return font;
}
@@ -168,14 +174,14 @@ public class DecoratingStyledCellLabelProvider extends
}
@Override
- public Image getImage(Object element) {
+ public Image getImage(E element) {
Image image = super.getImage(element);
if (this.decorator == null) {
return image;
}
Image decorated = null;
if (this.decorator instanceof LabelDecorator) {
- decorated = ((LabelDecorator) this.decorator).decorateImage(image,
+ decorated = ((LabelDecorator<E>) this.decorator).decorateImage(image,
element, getDecorationContext());
} else {
decorated = this.decorator.decorateImage(image, element);
@@ -194,7 +200,7 @@ public class DecoratingStyledCellLabelProvider extends
* @return the styled text string used to label the element
*/
@Override
- protected StyledString getStyledText(Object element) {
+ protected StyledString getStyledText(E element) {
StyledString styledString = super.getStyledText(element);
if (this.decorator == null) {
return styledString;
@@ -203,7 +209,7 @@ public class DecoratingStyledCellLabelProvider extends
String label = styledString.getString();
String decorated;
if (this.decorator instanceof LabelDecorator) {
- decorated = ((LabelDecorator) this.decorator).decorateText(label,
+ decorated = ((LabelDecorator<E>) this.decorator).decorateText(label,
element, getDecorationContext());
} else {
decorated = this.decorator.decorateText(label, element);
@@ -238,7 +244,7 @@ public class DecoratingStyledCellLabelProvider extends
*
* @return the decorator or <code>null</code> if no decorator is installed
*/
- public ILabelDecorator getLabelDecorator() {
+ public ILabelDecorator<E> getLabelDecorator() {
return this.decorator;
}
@@ -253,8 +259,8 @@ public class DecoratingStyledCellLabelProvider extends
* the label decorator, or <code>null</code> if no decorations
* are to be applied
*/
- public void setLabelDecorator(ILabelDecorator newDecorator) {
- ILabelDecorator oldDecorator = this.decorator;
+ public void setLabelDecorator(ILabelDecorator<E> newDecorator) {
+ ILabelDecorator<E> oldDecorator = this.decorator;
if (oldDecorator != newDecorator) {
if (oldDecorator != null)
oldDecorator.removeListener(this.labelProviderListener);
@@ -263,11 +269,11 @@ public class DecoratingStyledCellLabelProvider extends
newDecorator.addListener(this.labelProviderListener);
}
}
- fireLabelProviderChanged(new LabelProviderChangedEvent(this));
+ fireLabelProviderChanged(new LabelProviderChangedEvent<E>(this));
}
@Override
- public void addListener(ILabelProviderListener listener) {
+ public void addListener(ILabelProviderListener<E> listener) {
super.addListener(listener);
if (this.decorator != null) {
this.decorator.addListener(this.labelProviderListener);
@@ -275,7 +281,7 @@ public class DecoratingStyledCellLabelProvider extends
}
@Override
- public void removeListener(ILabelProviderListener listener) {
+ public void removeListener(ILabelProviderListener<E> listener) {
super.removeListener(listener);
if (this.decorator != null && !isListenerAttached()) {
this.decorator.removeListener(this.labelProviderListener);
@@ -283,7 +289,7 @@ public class DecoratingStyledCellLabelProvider extends
}
@Override
- public boolean isLabelProperty(Object element, String property) {
+ public boolean isLabelProperty(E element, String property) {
if (super.isLabelProperty(element, property)) {
return true;
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecorationContext.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecorationContext.java
index 3cd5aa1..cb16068 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecorationContext.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DecorationContext.java
@@ -29,7 +29,7 @@ public class DecorationContext implements IDecorationContext {
*/
public static final IDecorationContext DEFAULT_CONTEXT = new DecorationContext();
- private Map properties = new HashMap();
+ private Map<String,Object> properties = new HashMap<String,Object>();
/**
* Create a decoration context.
@@ -49,7 +49,7 @@ public class DecorationContext implements IDecorationContext {
* @see org.eclipse.jface.viewers.IDecorationContext#getProperties()
*/
public String[] getProperties() {
- return (String[]) properties.keySet().toArray(new String[properties.size()]);
+ return properties.keySet().toArray(new String[properties.size()]);
}
/**
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java
index 1ce122b..0889336 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/DelegatingStyledCellLabelProvider.java
@@ -34,10 +34,12 @@ import org.eclipse.swt.graphics.Image;
* optionally implement {@link IColorProvider} and {@link IFontProvider} to
* provide foreground and background color and a default font.
* </p>
+ * @param <E> Type of an element of the model
+ * @param <I> Type of the input
*
* @since 3.4
*/
-public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
+public class DelegatingStyledCellLabelProvider<E,I> extends StyledCellLabelProvider<E,I> {
/**
* Interface marking a label provider that provides styled text labels and
@@ -47,8 +49,9 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* optionally implement {@link IColorProvider} and {@link IFontProvider} to
* provide foreground and background color and a default font.
* </p>
+ * @param <E> Type of an element of the model
*/
- public static interface IStyledLabelProvider extends IBaseLabelProvider {
+ public static interface IStyledLabelProvider<E> extends IBaseLabelProvider<E> {
/**
* Returns the styled text label for the given element
@@ -58,7 +61,7 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
*
* @return the styled string.
*/
- public StyledString getStyledText(Object element);
+ public StyledString getStyledText(E element);
/**
* Returns the image for the label of the given element. The image is
@@ -70,10 +73,10 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* @return the image used to label the element, or <code>null</code>
* if there is no image for the given object
*/
- public Image getImage(Object element);
+ public Image getImage(E element);
}
- private IStyledLabelProvider styledLabelProvider;
+ private IStyledLabelProvider<E> styledLabelProvider;
/**
* Creates a {@link DelegatingStyledCellLabelProvider} that delegates the
@@ -84,7 +87,7 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* the label provider that provides the styled labels and the
* images
*/
- public DelegatingStyledCellLabelProvider(IStyledLabelProvider labelProvider) {
+ public DelegatingStyledCellLabelProvider(IStyledLabelProvider<E> labelProvider) {
if (labelProvider == null)
throw new IllegalArgumentException(
"Label provider must not be null"); //$NON-NLS-1$
@@ -98,8 +101,8 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
*/
@Override
- public void update(ViewerCell cell) {
- Object element = cell.getElement();
+ public void update(ViewerCell<E> cell) {
+ E element = cell.getElement();
StyledString styledString = getStyledText(element);
String newText= styledString.toString();
@@ -132,10 +135,11 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* @return the foreground color for the element, or <code>null</code> to
* use the default foreground color
*/
- public Color getForeground(Object element) {
+ public Color getForeground(E element) {
if (this.styledLabelProvider instanceof IColorProvider) {
- return ((IColorProvider) this.styledLabelProvider)
- .getForeground(element);
+ @SuppressWarnings("unchecked")
+ IColorProvider<E> colorProvider = (IColorProvider<E>) this.styledLabelProvider;
+ return colorProvider.getForeground(element);
}
return null;
}
@@ -148,10 +152,11 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* @return the background color for the element, or <code>null</code> to
* use the default background color
*/
- public Color getBackground(Object element) {
+ public Color getBackground(E element) {
if (this.styledLabelProvider instanceof IColorProvider) {
- return ((IColorProvider) this.styledLabelProvider)
- .getBackground(element);
+ @SuppressWarnings("unchecked")
+ IColorProvider<E> colorProvider = (IColorProvider<E>) this.styledLabelProvider;
+ return colorProvider.getBackground(element);
}
return null;
}
@@ -164,9 +169,11 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* @return the font for the element, or <code>null</code> to use the
* default font
*/
- public Font getFont(Object element) {
+ public Font getFont(E element) {
if (this.styledLabelProvider instanceof IFontProvider) {
- return ((IFontProvider) this.styledLabelProvider).getFont(element);
+ @SuppressWarnings("unchecked")
+ IFontProvider<E> fontProvider = (IFontProvider<E>) this.styledLabelProvider;
+ return fontProvider.getFont(element);
}
return null;
}
@@ -181,7 +188,7 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* @return the image used to label the element, or <code>null</code> if
* there is no image for the given object
*/
- public Image getImage(Object element) {
+ public Image getImage(E element) {
return this.styledLabelProvider.getImage(element);
}
@@ -192,7 +199,7 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
* the element for which to provide the styled label text
* @return the styled text string used to label the element
*/
- protected StyledString getStyledText(Object element) {
+ protected StyledString getStyledText(E element) {
return this.styledLabelProvider.getStyledText(element);
}
@@ -201,24 +208,24 @@ public class DelegatingStyledCellLabelProvider extends StyledCellLabelProvider {
*
* @return the wrapped label provider
*/
- public IStyledLabelProvider getStyledStringProvider() {
+ public IStyledLabelProvider<E> getStyledStringProvider() {
return this.styledLabelProvider;
}
@Override
- public void addListener(ILabelProviderListener listener) {
+ public void addListener(ILabelProviderListener<E> listener) {
super.addListener(listener);
this.styledLabelProvider.addListener(listener);
}
@Override
- public void removeListener(ILabelProviderListener listener) {
+ public void removeListener(ILabelProviderListener<E> listener) {
super.removeListener(listener);
this.styledLabelProvider.removeListener(listener);
}
@Override
- public boolean isLabelProperty(Object element, String property) {
+ public boolean isLabelProperty(E element, String property) {
return this.styledLabelProvider.isLabelProperty(element, property);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IBaseLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IBaseLabelProvider.java
index 401a281..caa3edf 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IBaseLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IBaseLabelProvider.java
@@ -51,7 +51,7 @@ public interface IBaseLabelProvider<E> {
*
* @param listener a label provider listener
*/
- public void addListener(ILabelProviderListener listener);
+ public void addListener(ILabelProviderListener<E> listener);
/**
* Disposes of this label provider. When a label provider is
@@ -83,5 +83,5 @@ public interface IBaseLabelProvider<E> {
*
* @param listener a label provider listener
*/
- public void removeListener(ILabelProviderListener listener);
+ public void removeListener(ILabelProviderListener<E> listener);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IColorDecorator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IColorDecorator.java
index d8294e0..599026c 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IColorDecorator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IColorDecorator.java
@@ -19,11 +19,12 @@ import org.eclipse.swt.graphics.Color;
*
* If an IColorDecorator decorates a foreground or background in an object
* that also has an IColorProvider the IColorDecorator will take precedence.
+ * @param <E> Type of an element of the model
* @see IColorProvider
*
* @since 3.1
*/
-public interface IColorDecorator {
+public interface IColorDecorator<E> {
/**
* Return the foreground Color for element or <code>null</code> if there
@@ -31,7 +32,7 @@ public interface IColorDecorator {
* @param element
* @return Color or <code>null</code>
*/
- public Color decorateForeground(Object element);
+ public Color decorateForeground(E element);
/**
* Return the background Color for element or <code>null</code> if there
@@ -39,6 +40,6 @@ public interface IColorDecorator {
* @param element
* @return Color or <code>null</code>
*/
- public Color decorateBackground(Object element);
+ public Color decorateBackground(E element);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IDelayedLabelDecorator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IDelayedLabelDecorator.java
index ea7f91e..51cc3a7 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IDelayedLabelDecorator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IDelayedLabelDecorator.java
@@ -17,9 +17,10 @@ package org.eclipse.jface.viewers;
* if the decorator is ready. Interested parties should register an
* ILabelProviderListener with a delayed label decorator in order to be informed
* when the decoration is ready.
+ * @param <E> Type of an element of the model
* @since 3.0
*/
-public interface IDelayedLabelDecorator extends ILabelDecorator {
+public interface IDelayedLabelDecorator<E> extends ILabelDecorator<E> {
/**
* Prepare the element for decoration. If it is already decorated and ready for update
@@ -29,6 +30,6 @@ public interface IDelayedLabelDecorator extends ILabelDecorator {
* @return boolean <code>true</code> if the decoration is ready for this element
*/
- public boolean prepareDecoration(Object element, String originalText);
+ public boolean prepareDecoration(E element, String originalText);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IFontDecorator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IFontDecorator.java
index ea69c37..67f8b07 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IFontDecorator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IFontDecorator.java
@@ -18,11 +18,12 @@ import org.eclipse.swt.graphics.Font;
*
* If an IFontDecorator decorates a font in an object that also has
* an IFontProvider the IFontDecorator will take precedence.
+ * @param <E> Type of an element of the model
* @see IFontProvider
*
* @since 3.1
*/
-public interface IFontDecorator {
+public interface IFontDecorator<E> {
/**
* Return the font for element or <code>null</code> if there
@@ -31,6 +32,6 @@ public interface IFontDecorator {
* @param element
* @return Font or <code>null</code>
*/
- public Font decorateFont(Object element);
+ public Font decorateFont(E element);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IIndexableLazyContentProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IIndexableLazyContentProvider.java
index 0d561ed..c19c940 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IIndexableLazyContentProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IIndexableLazyContentProvider.java
@@ -12,10 +12,12 @@ package org.eclipse.jface.viewers;
/**
* Adds efficient element indexing support to ILazyContentProvider.
+ * @param <E> Type of an element of the model
+ * @param <I> Type of the input
*
* @since 3.5
*/
-public interface IIndexableLazyContentProvider extends ILazyContentProvider {
+public interface IIndexableLazyContentProvider<E,I> extends ILazyContentProvider<I> {
/**
* Find the row index of the parameter element in the set of contents provided
* by this object. Under normal usage, this method will only be used to
@@ -25,5 +27,5 @@ public interface IIndexableLazyContentProvider extends ILazyContentProvider {
* @param element the element to find within the contents served here
* @return the zero-based index of the element, or -1 if the element is not found
*/
- public int findElement(Object element);
+ public int findElement(E element);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelDecorator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelDecorator.java
index 16fc861..5da4a8a 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelDecorator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelDecorator.java
@@ -18,8 +18,9 @@ import org.eclipse.swt.graphics.Image;
* for example by a label provider.
*
* @see ILabelProvider
+ * @param <E> Type of an element of the model
*/
-public interface ILabelDecorator extends IBaseLabelProvider {
+public interface ILabelDecorator<E> extends IBaseLabelProvider<E> {
/**
* Returns an image that is based on the given image,
* but decorated with additional information relating to the state
@@ -38,7 +39,7 @@ public interface ILabelDecorator extends IBaseLabelProvider {
*
* @see org.eclipse.jface.resource.CompositeImageDescriptor
*/
- public Image decorateImage(Image image, Object element);
+ public Image decorateImage(Image image, E element);
/**
* Returns a text label that is based on the given text label,
@@ -56,5 +57,5 @@ public interface ILabelDecorator extends IBaseLabelProvider {
* @param element the element whose image is being decorated
* @return the decorated text label, or <code>null</code> if no decoration is to be applied
*/
- public String decorateText(String text, Object element);
+ public String decorateText(String text, E element);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelProviderListener.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelProviderListener.java
index 8f9d095..2bf2bfc 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelProviderListener.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILabelProviderListener.java
@@ -12,11 +12,12 @@ package org.eclipse.jface.viewers;
/**
* A listener which is notified when a label provider's state changes.
+ * @param <E> Type of an element of the model
*
* @see IBaseLabelProvider#addListener
* @see IBaseLabelProvider#removeListener
*/
-public interface ILabelProviderListener {
+public interface ILabelProviderListener<E> {
/**
* Notifies this listener that the state of the label provider
* has changed in a way that affects the labels it computes.
@@ -27,5 +28,5 @@ public interface ILabelProviderListener {
*
* @param event the label provider change event
*/
- public void labelProviderChanged(LabelProviderChangedEvent event);
+ public void labelProviderChanged(LabelProviderChangedEvent<E> event);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILazyContentProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILazyContentProvider.java
index 7ae961a..b978005 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILazyContentProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILazyContentProvider.java
@@ -26,10 +26,7 @@ package org.eclipse.jface.viewers;
* require a call to <code>#setItemCount</code> on the
* viewer that uses it.
* @param <I> Type of the input for the view
-<<<<<<< HEAD
-=======
*
->>>>>>> 6d6b20c... Bug 413973 - [Viewers] Add generics to the TreeViewer
*/
public interface ILazyContentProvider<I> extends IContentProvider<I> {
/**
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILightweightLabelDecorator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILightweightLabelDecorator.java
index 5fdecab..7635e2a 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILightweightLabelDecorator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ILightweightLabelDecorator.java
@@ -14,8 +14,9 @@ package org.eclipse.jface.viewers;
* The <code>ILightweightLabelDecorator</code> is a decorator that decorates
* using a prefix, suffix and overlay image rather than doing all
* of the image and text management itself like an <code>ILabelDecorator</code>.
+ * @param <E> Type of an element of the model
*/
-public interface ILightweightLabelDecorator extends IBaseLabelProvider {
+public interface ILightweightLabelDecorator<E> extends IBaseLabelProvider<E> {
/**
* Calculates decorations based on element.
@@ -23,6 +24,6 @@ public interface ILightweightLabelDecorator extends IBaseLabelProvider {
* @param element the element to decorate
* @param decoration the decoration to set
*/
- public void decorate(Object element, IDecoration decoration);
+ public void decorate(E element, IDecoration decoration);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelDecorator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelDecorator.java
index 46991ba..a10775e 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelDecorator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelDecorator.java
@@ -16,11 +16,12 @@ import org.eclipse.swt.graphics.Image;
/**
* The LabelDecorator is an abstract superclass of ILabelDecorators
* that support IDecorationContext.
+ * @param <E> Type of an element of the model
* @see IDecorationContext
* @since 3.2
*
*/
-public abstract class LabelDecorator implements ILabelDecorator {
+public abstract class LabelDecorator<E> implements ILabelDecorator<E> {
/**
* Returns an image that is based on the given image,
@@ -41,7 +42,7 @@ public abstract class LabelDecorator implements ILabelDecorator {
*
* @see org.eclipse.jface.resource.CompositeImageDescriptor
*/
- public abstract Image decorateImage(Image image, Object element, IDecorationContext context);
+ public abstract Image decorateImage(Image image, E element, IDecorationContext context);
/**
* Returns a text label that is based on the given text label,
@@ -60,7 +61,7 @@ public abstract class LabelDecorator implements ILabelDecorator {
* @param context additional context information about the element being decorated
* @return the decorated text label, or <code>null</code> if no decoration is to be applied
*/
- public abstract String decorateText(String text, Object element, IDecorationContext context);
+ public abstract String decorateText(String text, E element, IDecorationContext context);
/**
* Prepare the element for decoration. If it is already decorated and ready for update
@@ -70,5 +71,5 @@ public abstract class LabelDecorator implements ILabelDecorator {
* @param context The decoration context
* @return boolean <code>true</code> if the decoration is ready for this element
*/
- public abstract boolean prepareDecoration(Object element, String originalText, IDecorationContext context);
+ public abstract boolean prepareDecoration(E element, String originalText, IDecorationContext context);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelProviderChangedEvent.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelProviderChangedEvent.java
index a49686b..5c10dc6 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelProviderChangedEvent.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelProviderChangedEvent.java
@@ -14,10 +14,11 @@ import java.util.EventObject;
/**
* Event object describing a label provider state change.
+ * @param <E> Type of an element of the model
*
* @see ILabelProviderListener
*/
-public class LabelProviderChangedEvent extends EventObject {
+public class LabelProviderChangedEvent<E> extends EventObject {
/**
* Generated serial version UID for this class.
@@ -36,7 +37,7 @@ public class LabelProviderChangedEvent extends EventObject {
*
* @param source the label provider
*/
- public LabelProviderChangedEvent(IBaseLabelProvider source) {
+ public LabelProviderChangedEvent(IBaseLabelProvider<E> source) {
super(source);
}
@@ -47,7 +48,7 @@ public class LabelProviderChangedEvent extends EventObject {
* @param source the label provider
* @param elements the element whose labels have changed
*/
- public LabelProviderChangedEvent(IBaseLabelProvider source,
+ public LabelProviderChangedEvent(IBaseLabelProvider<E> source,
Object[] elements) {
super(source);
this.elements = elements;
@@ -60,7 +61,7 @@ public class LabelProviderChangedEvent extends EventObject {
* @param source the label provider
* @param element the element whose label needs to be updated
*/
- public LabelProviderChangedEvent(IBaseLabelProvider source, Object element) {
+ public LabelProviderChangedEvent(IBaseLabelProvider<E> source, Object element) {
super(source);
this.elements = new Object[1];
this.elements[0] = element;
@@ -75,9 +76,8 @@ public class LabelProviderChangedEvent extends EventObject {
public Object getElement() {
if (this.elements == null || this.elements.length == 0) {
return null;
- } else {
- return this.elements[0];
}
+ return this.elements[0];
}
/**
@@ -89,8 +89,7 @@ public class LabelProviderChangedEvent extends EventObject {
public Object[] getElements() {
if (this.elements == null) {
return null;
- } else {
- return this.elements;
}
+ return this.elements;
}
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/NamedHandleObjectLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/NamedHandleObjectLabelProvider.java
index 157b095..2d96736 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/NamedHandleObjectLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/NamedHandleObjectLabelProvider.java
@@ -17,10 +17,11 @@ import org.eclipse.core.commands.common.NotDefinedException;
/**
* A label provider for instances of <code>NamedHandlerObject</code>, which
* exposes the name as the label.
+ * @param <E> Type of an element of the model
*
* @since 3.2
*/
-public final class NamedHandleObjectLabelProvider extends LabelProvider {
+public final class NamedHandleObjectLabelProvider<E> extends LabelProvider<E> {
/**
* The text of the element is simply the name of the element if its a
@@ -34,7 +35,7 @@ public final class NamedHandleObjectLabelProvider extends LabelProvider {
* name or if the element is not a named handle object.
*/
@Override
- public final String getText(final Object element) {
+ public final String getText(final E element) {
if (element instanceof NamedHandleObject) {
try {
return ((NamedHandleObject) element).getName();
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/OwnerDrawLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/OwnerDrawLabelProvider.java
index 7c8cacb..28d4f3e 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/OwnerDrawLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/OwnerDrawLabelProvider.java
@@ -28,28 +28,31 @@ import org.eclipse.swt.widgets.Listener;
* <p>
* <b>This class is intended to be subclassed by implementors.</b>
* </p>
+ * @param <E> Type of an element of the model
+ * @param <I> Type of the input
*
* @since 3.3
*
*/
-public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
+public abstract class OwnerDrawLabelProvider<E,I> extends CellLabelProvider<E,I> {
- static class OwnerDrawListener implements Listener {
- Set enabledColumns = new HashSet();
+ static class OwnerDrawListener<E,I> implements Listener {
+ Set<ViewerColumn<E,I>> enabledColumns = new HashSet<ViewerColumn<E,I>>();
int enabledGlobally = 0;
- private ColumnViewer viewer;
+ private ColumnViewer<E,I> viewer;
- OwnerDrawListener(ColumnViewer viewer) {
+ OwnerDrawListener(ColumnViewer<E,I> viewer) {
this.viewer = viewer;
}
public void handleEvent(Event event) {
- ViewerColumn column = viewer.getViewerColumn(event.index);
+ ViewerColumn<E,I> column = viewer.getViewerColumn(event.index);
if (column != null && (enabledGlobally > 0 || enabledColumns.contains(column))) {
- CellLabelProvider provider = column.getLabelProvider();
+ CellLabelProvider<E,I> provider = column.getLabelProvider();
if (provider instanceof OwnerDrawLabelProvider) {
- Object element = event.item.getData();
- OwnerDrawLabelProvider ownerDrawProvider = (OwnerDrawLabelProvider) provider;
+ @SuppressWarnings("unchecked")
+ E element = (E) event.item.getData();
+ OwnerDrawLabelProvider<E,I> ownerDrawProvider = (OwnerDrawLabelProvider<E,I>) provider;
switch (event.type) {
case SWT.MeasureItem:
ownerDrawProvider.measure(event, element);
@@ -84,13 +87,14 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
getOrCreateOwnerDrawListener(viewer).enabledGlobally++;
}
- private static OwnerDrawListener getOrCreateOwnerDrawListener(
- final ColumnViewer viewer) {
+ private static <E,I> OwnerDrawListener<E,I> getOrCreateOwnerDrawListener(
+ final ColumnViewer<E,I> viewer) {
Control control = viewer.getControl();
- OwnerDrawListener listener = (OwnerDrawListener) control
+ @SuppressWarnings("unchecked")
+ OwnerDrawListener<E,I> listener = (OwnerDrawListener<E,I>) control
.getData(OWNER_DRAW_LABEL_PROVIDER_LISTENER);
if (listener == null) {
- listener = new OwnerDrawListener(viewer);
+ listener = new OwnerDrawListener<E,I>(viewer);
control.setData(OWNER_DRAW_LABEL_PROVIDER_LISTENER, listener);
control.addListener(SWT.MeasureItem, listener);
control.addListener(SWT.EraseItem, listener);
@@ -108,7 +112,7 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
}
@Override
- public void dispose(ColumnViewer viewer, ViewerColumn column) {
+ public void dispose(ColumnViewer<E,I> viewer, ViewerColumn<E,I> column) {
if (!viewer.getControl().isDisposed()) {
setOwnerDrawEnabled(viewer, column, false);
}
@@ -125,7 +129,7 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
* {@link #initialize(ColumnViewer, ViewerColumn, boolean)}.
*/
@Override
- protected void initialize(ColumnViewer viewer, ViewerColumn column) {
+ protected void initialize(ColumnViewer<E,I> viewer, ViewerColumn<E,I> column) {
this.initialize(viewer, column, true);
}
@@ -148,14 +152,14 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
*
* @since 3.4
*/
- final protected void initialize(ColumnViewer viewer, ViewerColumn column,
+ final protected void initialize(ColumnViewer<E,I> viewer, ViewerColumn<E,I> column,
boolean enableOwnerDraw) {
super.initialize(viewer, column);
setOwnerDrawEnabled(viewer, column, enableOwnerDraw);
}
@Override
- public void update(ViewerCell cell) {
+ public void update(ViewerCell<E> cell) {
// Force a redraw
Rectangle cellBounds = cell.getBounds();
cell.getControl().redraw(cellBounds.x, cellBounds.y, cellBounds.width,
@@ -179,7 +183,7 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
* @see SWT#COLOR_LIST_SELECTION
* @see SWT#COLOR_LIST_SELECTION_TEXT
*/
- protected void erase(Event event, Object element) {
+ protected void erase(Event event, E element) {
Rectangle bounds = event.getBounds();
if ((event.detail & SWT.SELECTED) != 0) {
@@ -211,7 +215,7 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
* the model element
* @see SWT#MeasureItem
*/
- protected abstract void measure(Event event, Object element);
+ protected abstract void measure(Event event, E element);
/**
* Handle the paint event.
@@ -222,7 +226,7 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
* the model element
* @see SWT#PaintItem
*/
- protected abstract void paint(Event event, Object element);
+ protected abstract void paint(Event event, E element);
/**
* Enables or disables owner draw for the given viewer and column. This
@@ -243,17 +247,18 @@ public abstract class OwnerDrawLabelProvider extends CellLabelProvider {
*
* @since 3.4
*/
- protected void setOwnerDrawEnabled(ColumnViewer viewer,
- ViewerColumn column, boolean enabled) {
+ protected void setOwnerDrawEnabled(ColumnViewer<E,I> viewer,
+ ViewerColumn<E,I> column, boolean enabled) {
if (enabled) {
- OwnerDrawListener listener = getOrCreateOwnerDrawListener(viewer);
+ OwnerDrawListener<E,I> listener = getOrCreateOwnerDrawListener(viewer);
if (column == null) {
listener.enabledGlobally++;
} else {
listener.enabledColumns.add(column);
}
} else {
- OwnerDrawListener listener = (OwnerDrawListener) viewer
+ @SuppressWarnings("unchecked")
+ OwnerDrawListener<E,I> listener = (OwnerDrawListener<E,I>) viewer
.getControl().getData(OWNER_DRAW_LABEL_PROVIDER_LISTENER);
if (listener != null) {
if (column == null) {
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
index e691182..1fe8954 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
@@ -1214,7 +1214,7 @@ public abstract class StructuredViewer<E,I> extends ContentViewer<E,I> implement
* @param event the event that generated this update
*/
@Override
- protected void handleLabelProviderChanged(LabelProviderChangedEvent event) {
+ protected void handleLabelProviderChanged(LabelProviderChangedEvent<E> event) {
@SuppressWarnings("unchecked")
E[] elements = (E[])event.getElements();
if (elements != null) {
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewerInternals.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewerInternals.java
index 2a1b78d..329d466 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewerInternals.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewerInternals.java
@@ -66,7 +66,7 @@ public class StructuredViewerInternals {
* the {@link AssociateListener}
* @noreference This method is not intended to be referenced by clients.
*/
- protected static void setAssociateListener(StructuredViewer viewer,
+ protected static <E,I> void setAssociateListener(StructuredViewer<E,I> viewer,
AssociateListener listener) {
viewer.setAssociateListener(listener);
}
@@ -79,8 +79,9 @@ public class StructuredViewerInternals {
* @return the Widgets corresponding to the element
*
* @noreference This method is not intended to be referenced by clients.
+ * @since 3.10
*/
- protected static Widget[] getItems(StructuredViewer viewer, Object element) {
+ protected static <E,I> Widget[] getItems(StructuredViewer<E,I> viewer, E element) {
return viewer.findItems(element);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java
index 4ce6a45..9573a21 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledCellLabelProvider.java
@@ -39,10 +39,12 @@ import org.eclipse.swt.widgets.Event;
* {@link ViewerCell#setStyleRanges(StyleRange[])} to set style ranges
* on the label.
* </p>
+ * @param <E> Type of an element of the model
+ * @param <I> Type of the input
*
* @since 3.4
*/
-public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
+public abstract class StyledCellLabelProvider<E,I> extends OwnerDrawLabelProvider<E,I> {
/**
* Style constant for indicating that the styled colors are to be applied
@@ -67,8 +69,8 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
// reused text layout
private TextLayout cachedTextLayout;
- private ColumnViewer viewer;
- private ViewerColumn column;
+ private ColumnViewer<E,I> viewer;
+ private ViewerColumn<E,I> column;
private int deltaOfLastMeasure;
@@ -138,7 +140,7 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* @return the viewer on which this label provider is installed on or <code>null</code> if the
* label provider is not installed.
*/
- protected final ColumnViewer getViewer() {
+ protected final ColumnViewer<E,I> getViewer() {
return this.viewer;
}
@@ -149,7 +151,7 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* @return the column on which this label provider is installed on or <code>null</code> if the
* label provider is not installed.
*/
- protected final ViewerColumn getColumn() {
+ protected final ViewerColumn<E,I> getColumn() {
return this.column;
}
@@ -157,7 +159,7 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* @see org.eclipse.jface.viewers.OwnerDrawLabelProvider#initialize(org.eclipse.jface.viewers.ColumnViewer, org.eclipse.jface.viewers.ViewerColumn)
*/
@Override
- public void initialize(ColumnViewer viewer, ViewerColumn column) {
+ public void initialize(ColumnViewer<E,I> viewer, ViewerColumn<E,I> column) {
Assert.isTrue(this.viewer == null && this.column == null, "Label provider instance already in use"); //$NON-NLS-1$
this.viewer= viewer;
@@ -189,7 +191,7 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* @see org.eclipse.jface.viewers.OwnerDrawLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
*/
@Override
- public void update(ViewerCell cell) {
+ public void update(ViewerCell<E> cell) {
// clients must override and configure the cell and call super
super.update(cell); // calls 'repaint' to trigger the paint listener
}
@@ -239,9 +241,9 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
return styleRange;
}
- private ViewerCell getViewerCell(Event event, Object element) {
- ViewerRow row= viewer.getViewerRowFromItem(event.item);
- return new ViewerCell(row, event.index, element);
+ private ViewerCell<E> getViewerCell(Event event, E element) {
+ ViewerRow<E> row= viewer.getViewerRowFromItem(event.item);
+ return new ViewerCell<E>(row, event.index, element);
}
/**
@@ -255,7 +257,7 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* @see SWT#EraseItem
*/
@Override
- protected void erase(Event event, Object element) {
+ protected void erase(Event event, E element) {
// use native erase
if (isOwnerDrawEnabled()) {
// info has been set by 'update': announce that we paint ourselves
@@ -270,11 +272,11 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* java.lang.Object)
*/
@Override
- protected void measure(Event event, Object element) {
+ protected void measure(Event event, E element) {
if (!isOwnerDrawEnabled())
return;
- ViewerCell cell= getViewerCell(event, element);
+ ViewerCell<E> cell= getViewerCell(event, element);
boolean applyColors = useColors(event);
TextLayout layout = getSharedTextLayout(event.display);
@@ -290,7 +292,7 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* @param applyColors
* @return the text width delta (0 if the text layout contains no other font)
*/
- private int updateTextLayout(TextLayout layout, ViewerCell cell,
+ private int updateTextLayout(TextLayout layout, ViewerCell<E> cell,
boolean applyColors) {
layout.setStyle(null, 0, Integer.MAX_VALUE); // clear old styles
@@ -324,11 +326,11 @@ public abstract class StyledCellLabelProvider extends OwnerDrawLabelProvider {
* java.lang.Object)
*/
@Override
- protected void paint(Event event, Object element) {
+ protected void paint(Event event, E element) {
if (!isOwnerDrawEnabled())
return;
- ViewerCell cell= getViewerCell(event, element);
+ ViewerCell<E> cell= getViewerCell(event, element);
boolean applyColors= useColors(event);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledString.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledString.java
index 1a6b33c..c83e2ab 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledString.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StyledString.java
@@ -214,10 +214,10 @@ public class StyledString {
int offset = fBuffer.length();
fBuffer.append(string.toString());
- List otherRuns = string.fStyleRuns;
+ List<StyleRun> otherRuns = string.fStyleRuns;
if (otherRuns != null && !otherRuns.isEmpty()) {
for (int i = 0; i < otherRuns.size(); i++) {
- StyleRun curr = (StyleRun) otherRuns.get(i);
+ StyleRun curr = otherRuns.get(i);
if (i == 0 && curr.offset != 0) {
appendStyleRun(null, offset); // appended string will
// start with the default
@@ -410,13 +410,13 @@ public class StyledString {
*/
public StyleRange[] getStyleRanges() {
if (hasRuns()) {
- ArrayList res = new ArrayList();
+ ArrayList<StyleRange> res = new ArrayList<StyleRange>();
- List styleRuns = getStyleRuns();
+ List<StyleRun> styleRuns = getStyleRuns();
int offset = 0;
Styler style = null;
for (int i = 0; i < styleRuns.size(); i++) {
- StyleRun curr = (StyleRun) styleRuns.get(i);
+ StyleRun curr = styleRuns.get(i);
if (isDifferentStyle(curr.style, style)) {
if (curr.offset > offset && style != null) {
res.add(createStyleRange(offset, curr.offset, style));
@@ -428,7 +428,7 @@ public class StyledString {
if (fBuffer.length() > offset && style != null) {
res.add(createStyleRange(offset, fBuffer.length(), style));
}
- return (StyleRange[]) res.toArray(new StyleRange[res.size()]);
+ return res.toArray(new StyleRange[res.size()]);
}
return EMPTY;
}
@@ -511,7 +511,7 @@ public class StyledString {
}
}
- private static class StyleRunList extends ArrayList {
+ private static class StyleRunList extends ArrayList<StyleRun> {
private static final long serialVersionUID = 123L;
public StyleRunList() {
@@ -519,7 +519,7 @@ public class StyledString {
}
public StyleRun getRun(int index) {
- return (StyleRun) get(index);
+ return get(index);
}
@Override
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableLayout.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableLayout.java
index f27acf4..1713034 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableLayout.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableLayout.java
@@ -58,7 +58,7 @@ public class TableLayout extends Layout {
* The list of column layout data (element type:
* <code>ColumnLayoutData</code>).
*/
- private List columns = new ArrayList();
+ private List<ColumnLayoutData> columns = new ArrayList<ColumnLayoutData>();
/**
* Indicates whether <code>layout</code> has yet to be called.
@@ -113,7 +113,7 @@ public class TableLayout extends Layout {
int width = 0;
int size = columns.size();
for (int i = 0; i < size; ++i) {
- ColumnLayoutData layoutData = (ColumnLayoutData) columns.get(i);
+ ColumnLayoutData layoutData = columns.get(i);
if (layoutData instanceof ColumnPixelData) {
ColumnPixelData col = (ColumnPixelData) layoutData;
width += col.width;
@@ -167,7 +167,7 @@ public class TableLayout extends Layout {
// First calc space occupied by fixed columns
for (int i = 0; i < size; i++) {
- ColumnLayoutData col = (ColumnLayoutData) columns.get(i);
+ ColumnLayoutData col = columns.get(i);
if (col instanceof ColumnPixelData) {
ColumnPixelData cpd = (ColumnPixelData) col;
int pixels = cpd.width;
@@ -200,7 +200,7 @@ public class TableLayout extends Layout {
int rest = width - fixedWidth;
int totalDistributed = 0;
for (int i = 0; i < size; ++i) {
- ColumnLayoutData col = (ColumnLayoutData) columns.get(i);
+ ColumnLayoutData col = columns.get(i);
if (col instanceof ColumnWeightData) {
ColumnWeightData cw = (ColumnWeightData) col;
// calculate weight as above
@@ -223,7 +223,7 @@ public class TableLayout extends Layout {
if (i == size) {
i = 0;
}
- ColumnLayoutData col = (ColumnLayoutData) columns.get(i);
+ ColumnLayoutData col = columns.get(i);
if (col instanceof ColumnWeightData) {
++widths[i];
--diff;
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 7e43a54..ce3aab9 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
@@ -454,7 +454,8 @@ public class TableViewer<E,I> extends AbstractTableViewer<E,I> {
protected Widget doFindItem(E element) {
IContentProvider<? super I> contentProvider = getContentProvider();
if (contentProvider instanceof IIndexableLazyContentProvider) {
- IIndexableLazyContentProvider indexable = (IIndexableLazyContentProvider) contentProvider;
+ @SuppressWarnings("unchecked")
+ IIndexableLazyContentProvider<E,? super I> indexable = (IIndexableLazyContentProvider<E,? super I>) contentProvider;
int idx = indexable.findElement(element);
if (idx != -1) {
return doGetItem(idx);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java
index e6dfc91..c8a4907 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeColumnViewerLabelProvider.java
@@ -50,7 +50,7 @@ public class TreeColumnViewerLabelProvider<E,I> extends
*
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
- public void addListener(ILabelProviderListener listener) {
+ public void addListener(ILabelProviderListener<E> listener) {
// Do nothing by default
}
@@ -60,7 +60,7 @@ public class TreeColumnViewerLabelProvider<E,I> extends
*
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
- public void removeListener(ILabelProviderListener listener) {
+ public void removeListener(ILabelProviderListener<E> listener) {
// Do nothing by default
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeNode.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeNode.java
index b2ca329..8f2a80c 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeNode.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeNode.java
@@ -98,7 +98,7 @@ public class TreeNode<E> {
*
* @return The value; may be anything.
*/
- public Object getValue() {
+ public E getValue() {
return value;
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerRow.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerRow.java
index b3e6503..7392f02 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerRow.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewerRow.java
@@ -343,17 +343,19 @@ public class TreeViewerRow<E> extends ViewerRow<E> {
}
@Override
- public TreePath getTreePath() {
+ public TreePath<E> getTreePath() {
TreeItem tItem = item;
LinkedList<E> segments = new LinkedList<E>();
while (tItem != null) {
+ @SuppressWarnings("unchecked")
E segment = (E) tItem.getData();
Assert.isNotNull(segment);
segments.addFirst(segment);
tItem = tItem.getParentItem();
}
-
- return new TreePath<E>((E[]) segments.toArray());
+ @SuppressWarnings("unchecked")
+ E[] segmentsArray = (E[]) segments.toArray();
+ return new TreePath<E>(segmentsArray);
}
void setItem(TreeItem item) {
@@ -367,7 +369,9 @@ public class TreeViewerRow<E> extends ViewerRow<E> {
@Override
public E getElement() {
- return (E) item.getData();
+ @SuppressWarnings("unchecked")
+ E element = (E) item.getData();
+ return element;
}
@Override
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 0b790cb..bb9a1a5 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
@@ -39,7 +39,7 @@ public abstract class ViewerColumn<E,I> {
private EditingSupport editingSupport;
- private ILabelProviderListener listener;
+ private ILabelProviderListener<E> listener;
private boolean listenerRegistered = false;
@@ -57,9 +57,9 @@ public abstract class ViewerColumn<E,I> {
protected ViewerColumn(final ColumnViewer<E,I> viewer, Widget columnOwner) {
this.viewer = viewer;
columnOwner.setData(ViewerColumn.COLUMN_VIEWER_KEY, this);
- this.listener = new ILabelProviderListener() {
+ this.listener = new ILabelProviderListener<E>() {
- public void labelProviderChanged(LabelProviderChangedEvent event) {
+ public void labelProviderChanged(LabelProviderChangedEvent<E> event) {
viewer.handleLabelProviderChanged(event);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java
index ab5ba08..5f59b2d 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java
@@ -16,7 +16,6 @@ import java.util.Comparator;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-
import org.eclipse.jface.util.Policy;
/**
@@ -138,8 +137,9 @@ public class ViewerComparator<E,I> {
if (viewer == null || !(viewer instanceof ContentViewer)) {
name1 = e1.toString();
} else {
- IBaseLabelProvider<E> prov = ((ContentViewer<E,I>) viewer)
- .getLabelProvider();
+ @SuppressWarnings("unchecked")
+ ContentViewer<E,I> contentViewer = (ContentViewer<E,I>) viewer;
+ IBaseLabelProvider<E> prov = contentViewer.getLabelProvider();
if (prov instanceof ILabelProvider) {
ILabelProvider<E> lprov = (ILabelProvider<E>) prov;
name1 = lprov.getText(e1);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/deferred/IntHashMap.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/deferred/IntHashMap.java
index 6b6dd86..ad604be 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/deferred/IntHashMap.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/deferred/IntHashMap.java
@@ -21,21 +21,21 @@ import java.util.HashMap;
* @since 3.1
*/
/* package */ class IntHashMap {
- private HashMap map;
+ private HashMap<Object,Integer> map;
/**
* @param size
* @param loadFactor
*/
public IntHashMap(int size, float loadFactor) {
- map = new HashMap(size, loadFactor);
+ map = new HashMap<Object,Integer>(size, loadFactor);
}
/**
*
*/
public IntHashMap() {
- map = new HashMap();
+ map = new HashMap<Object,Integer>();
}
/**
@@ -67,7 +67,7 @@ import java.util.HashMap;
* @return the int value at the given key, or the default value if this map does not contain the given key
*/
public int get(Object key, int defaultValue) {
- Integer result = (Integer)map.get(key);
+ Integer result = map.get(key);
if (result != null) {
return result.intValue();