aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-03-28 13:07:14 (EDT)
committerKevin Sawicki2011-03-28 13:07:14 (EDT)
commit753e3403b262df1a16090836c737a544b42e417c (patch)
tree7e27982b99a7641c89973b0417afd738c427d15e
parent7c973bddb37d43ca7c92b0c6987772531a35ed13 (diff)
downloadegit-753e3403b262df1a16090836c737a544b42e417c.zip
egit-753e3403b262df1a16090836c737a544b42e417c.tar.gz
egit-753e3403b262df1a16090836c737a544b42e417c.tar.bz2
[historyView] Use action decorators on top of content-type iconsrefs/changes/27/2927/2
Use the add and delete decorators on top of the content-type icons for files displayed in the History view. Previously 16 x 16 '+' and 'X' icons were used which hid the type of file being added or deleted from the user. Bug: 340988 Change-Id: Iad75d0c4913c90adb980cb97978533c10669d884 Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffLabelProvider.java47
1 files changed, 26 insertions, 21 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffLabelProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffLabelProvider.java
index 07e484c..6ad8499 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffLabelProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiffLabelProvider.java
@@ -15,6 +15,8 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.LocalResourceManager;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.DecorationOverlayIcon;
+import org.eclipse.jface.viewers.IDecoration;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
@@ -22,13 +24,6 @@ import org.eclipse.ui.PlatformUI;
class FileDiffLabelProvider extends BaseLabelProvider implements
ITableLabelProvider {
- private Image ADD = UIIcons.ELCL16_ADD.createImage();
-
- private Image COPY = PlatformUI.getWorkbench().getSharedImages().getImage(
- ISharedImages.IMG_TOOL_COPY);
-
- private Image DELETE = PlatformUI.getWorkbench().getSharedImages()
- .getImage(ISharedImages.IMG_ETOOL_DELETE);
private Image DEFAULT = PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_OBJ_FILE);
@@ -44,27 +39,39 @@ class FileDiffLabelProvider extends BaseLabelProvider implements
return null;
}
+ private Image getEditorImage(FileDiff diff) {
+ Image image = DEFAULT;
+ String name = new Path(diff.getPath()).lastSegment();
+ if (name != null) {
+ ImageDescriptor descriptor = PlatformUI.getWorkbench()
+ .getEditorRegistry().getImageDescriptor(name);
+ image = (Image) this.resourceManager.get(descriptor);
+ }
+ return image;
+ }
+
+ private Image getDecoratedImage(Image base, ImageDescriptor decorator) {
+ DecorationOverlayIcon decorated = new DecorationOverlayIcon(base,
+ decorator, IDecoration.BOTTOM_RIGHT);
+ return (Image) this.resourceManager.get(decorated);
+ }
+
public Image getColumnImage(final Object element, final int columnIndex) {
if (columnIndex == 0) {
final FileDiff c = (FileDiff) element;
switch (c.getChange()) {
case ADD:
- return ADD;
- case COPY:
- return COPY;
+ return getDecoratedImage(getEditorImage(c),
+ UIIcons.OVR_STAGED_ADD);
case DELETE:
- return DELETE;
+ return getDecoratedImage(getEditorImage(c),
+ UIIcons.OVR_STAGED_REMOVE);
+ case COPY:
+ // fall through
case RENAME:
// fall through
case MODIFY:
- Image image = DEFAULT;
- String name = new Path(c.getPath()).lastSegment();
- if (name != null) {
- ImageDescriptor descriptor = PlatformUI.getWorkbench()
- .getEditorRegistry().getImageDescriptor(name);
- image = (Image) this.resourceManager.get(descriptor);
- }
- return image;
+ return getEditorImage(c);
}
}
return null;
@@ -73,8 +80,6 @@ class FileDiffLabelProvider extends BaseLabelProvider implements
@Override
public void dispose() {
this.resourceManager.dispose();
- ADD.dispose();
- // DELETE is shared, don't dispose
super.dispose();
}