diff options
author | Michael Valenta | 2006-12-18 16:16:09 +0000 |
---|---|---|
committer | Michael Valenta | 2006-12-18 16:16:09 +0000 |
commit | d7057776415ed6ee067b96c97bb539b46d531fa6 (patch) | |
tree | 2b732e0eed4ed4161288ec6415f035d29feb3cd4 | |
parent | e75b49417c3cf07cca5dfc0426606c0beb0d96ce (diff) | |
download | eclipse.platform.team-d7057776415ed6ee067b96c97bb539b46d531fa6.tar.gz eclipse.platform.team-d7057776415ed6ee067b96c97bb539b46d531fa6.tar.xz eclipse.platform.team-d7057776415ed6ee067b96c97bb539b46d531fa6.zip |
Bug 167722 Switch to using OverlayIcon from JFace
4 files changed, 32 insertions, 165 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java index 6f3798b57..dddc7b5ae 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecoratorPreferencesPage.java @@ -11,13 +11,7 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Observable; -import java.util.Observer; +import java.util.*; import org.eclipse.compare.internal.TabFolderLayout; import org.eclipse.core.resources.IResource; @@ -38,7 +32,6 @@ import org.eclipse.swt.widgets.*; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.client.Command; import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; -import org.eclipse.team.internal.ui.OverlayIcon; import org.eclipse.team.internal.ui.SWTUtils; import org.eclipse.ui.*; import org.eclipse.ui.dialogs.ListSelectionDialog; @@ -501,7 +494,7 @@ public class CVSDecoratorPreferencesPage extends PreferencePage implements IWork if (overlay == null) return baseImage; try { - return fImageCache.createImage(new OverlayIcon(baseImage, new ImageDescriptor[] {overlay}, new int[] {OverlayIcon.BOTTOM_RIGHT}, new Point(baseImage.getBounds().width, baseImage.getBounds().height))); + return fImageCache.createImage(new DecorationOverlayIcon(baseImage, new ImageDescriptor[] {null, null, null, overlay, null}, new Point(baseImage.getBounds().width, baseImage.getBounds().height))); } catch (DeviceResourceException e) { CVSUIPlugin.log(new Status(IStatus.ERROR, CVSUIPlugin.ID, 0, "Error creating decorator image", e)); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java deleted file mode 100644 index 03fd677dd..000000000 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/OverlayIcon.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.team.internal.ui; - -import java.util.Arrays; - -import org.eclipse.jface.resource.CompositeImageDescriptor; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.graphics.*; - -/** - * An OverlayIcon consists of a main icon and several adornments. - */ -public class OverlayIcon extends CompositeImageDescriptor { - // the base image - private Image base; - // the base as a descriptor - private ImageDescriptor descriptorBase; - // the overlay images - private ImageDescriptor[] overlays; - // the size - private Point size; - // the locations - private int[] locations; - - public static final int TOP_LEFT = 0; - public static final int TOP_RIGHT = 1; - public static final int BOTTOM_LEFT = 2; - public static final int BOTTOM_RIGHT = 3; - - public static final int DEFAULT_WIDTH= 22; - public static final int DEFAULT_HEIGHT= 16; - - /** - * OverlayIcon constructor. - * - * @param base the base image - * @param overlays the overlay images - * @param locations the location of each image - * @param size the size - */ - public OverlayIcon(Image base, ImageDescriptor[] overlays, int[] locations, Point size) { - this.base = base; - this.descriptorBase = null; - this.overlays = overlays; - this.locations = locations; - this.size = size; - } - - protected void drawOverlays(ImageDescriptor[] overlays, int[] locations) { - Point size = getSize(); - for (int i = 0; i < overlays.length; i++) { - ImageDescriptor overlay = overlays[i]; - ImageData overlayData = overlay.getImageData(); - switch (locations[i]) { - case TOP_LEFT: - drawImage(overlayData, 0, 0); - break; - case TOP_RIGHT: - drawImage(overlayData, size.x - overlayData.width, 0); - break; - case BOTTOM_LEFT: - drawImage(overlayData, 0, size.y - overlayData.height); - break; - case BOTTOM_RIGHT: - drawImage(overlayData, size.x - overlayData.width, size.y - overlayData.height); - break; - } - } - } - - public boolean equals(Object o) { - if (! (o instanceof OverlayIcon)) return false; - OverlayIcon other = (OverlayIcon) o; - return base.equals(other.base) && Arrays.equals(overlays, other.overlays); - } - - public int hashCode() { - int code = base.hashCode(); - for (int i = 0; i < overlays.length; i++) { - code ^= overlays[i].hashCode(); - } - return code; - } - - - protected void drawCompositeImage(int width, int height) { - if(descriptorBase != null) { - ImageData bg; - if (descriptorBase == null || (bg= descriptorBase.getImageData()) == null) - bg= DEFAULT_IMAGE_DATA; - drawImage(bg, 0, 0); - } else { - drawImage(base.getImageData(), 0, 0); - } - drawOverlays(overlays, locations); - } - - protected Point getSize() { - return size; - } -} diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java index 907b3ed6b..ce9369259 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SynchronizeModelElementLabelProvider.java @@ -10,11 +10,7 @@ *******************************************************************************/ package org.eclipse.team.internal.ui.synchronize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.structuremergeviewer.DiffNode; @@ -145,38 +141,34 @@ public class SynchronizeModelElementLabelProvider extends LabelProvider implemen } private Image propagateConflicts(Image base, ISynchronizeModelElement element) { - // if the folder is already conflicting then don't bother propagating - // the conflict - List overlays = new ArrayList(); - List locations = new ArrayList(); + + ImageDescriptor[] overlayImages = new ImageDescriptor[4]; + boolean hasOverlay = false; // Decorate with the busy indicator if (element.getProperty(ISynchronizeModelElement.BUSY_PROPERTY)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_HOURGLASS_OVR)); - locations.add(new Integer(OverlayIcon.TOP_LEFT)); + overlayImages[IDecoration.TOP_LEFT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_HOURGLASS_OVR); + hasOverlay = true; } // Decorate with propagated conflicts and problem markers int kind = element.getKind(); if ((kind & SyncInfo.DIRECTION_MASK) != SyncInfo.CONFLICTING) { + // if the folder is already conflicting then don't bother propagating + // the conflict if (hasDecendantConflicts(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CONFLICT_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_RIGHT)); + overlayImages[IDecoration.BOTTOM_RIGHT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CONFLICT_OVR); + hasOverlay = true; } } if (hasErrorMarker(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_ERROR_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_LEFT)); + overlayImages[IDecoration.BOTTOM_LEFT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_ERROR_OVR); + hasOverlay = true; } else if (hasWarningMarker(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WARNING_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_LEFT)); + overlayImages[IDecoration.BOTTOM_LEFT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WARNING_OVR); + hasOverlay = true; } - if (!overlays.isEmpty()) { - ImageDescriptor[] overlayImages = (ImageDescriptor[]) overlays.toArray(new ImageDescriptor[overlays.size()]); - int[] locationInts = new int[locations.size()]; - for (int i = 0; i < locations.size(); i++) { - locationInts[i] = ((Integer) locations.get(i)).intValue(); - } - ImageDescriptor overlay = new OverlayIcon(base, overlayImages, locationInts, new Point(base.getBounds().width, base.getBounds().height)); + if (hasOverlay) { + ImageDescriptor overlay = new DecorationOverlayIcon(base, overlayImages, new Point(base.getBounds().width, base.getBounds().height)); if (fgImageCache == null) { fgImageCache = new HashMap(10); } diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java index eb5bc43e3..6449b25b7 100644 --- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java +++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/AbstractSynchronizeLabelProvider.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.team.ui.synchronize; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.compare.CompareConfiguration; import org.eclipse.compare.structuremergeviewer.ICompareInput; import org.eclipse.core.resources.IMarker; @@ -248,38 +245,33 @@ public abstract class AbstractSynchronizeLabelProvider implements ILabelProvider private Image addOverlays(Image base, Object element) { if (!isIncludeOverlays()) return base; - // if the folder is already conflicting then don't bother propagating - // the conflict - List overlays = new ArrayList(); - List locations = new ArrayList(); + + ImageDescriptor[] overlayImages = new ImageDescriptor[4]; + boolean hasOverlay = false; // Decorate with the busy indicator if (isBusy(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_HOURGLASS_OVR)); - locations.add(new Integer(OverlayIcon.TOP_LEFT)); + overlayImages[IDecoration.TOP_LEFT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_HOURGLASS_OVR); + hasOverlay = true; } // Decorate with propagated conflicts and problem markers if (!isConflicting(element)) { + // if the folder is already conflicting then don't bother propagating if (hasDecendantConflicts(element)) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CONFLICT_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_RIGHT)); + overlayImages[IDecoration.BOTTOM_RIGHT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_CONFLICT_OVR); + hasOverlay = true; } } int severity = getMarkerSeverity(element); if (severity == IMarker.SEVERITY_ERROR) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_ERROR_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_LEFT)); + overlayImages[IDecoration.BOTTOM_LEFT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_ERROR_OVR); + hasOverlay = true; } else if (severity == IMarker.SEVERITY_WARNING) { - overlays.add(TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WARNING_OVR)); - locations.add(new Integer(OverlayIcon.BOTTOM_LEFT)); + overlayImages[IDecoration.BOTTOM_LEFT] = TeamUIPlugin.getImageDescriptor(ISharedImages.IMG_WARNING_OVR); + hasOverlay = true; } - if (!overlays.isEmpty()) { - ImageDescriptor[] overlayImages = (ImageDescriptor[]) overlays.toArray(new ImageDescriptor[overlays.size()]); - int[] locationInts = new int[locations.size()]; - for (int i = 0; i < locations.size(); i++) { - locationInts[i] = ((Integer) locations.get(i)).intValue(); - } - ImageDescriptor overlay = new OverlayIcon(base, overlayImages, locationInts, new Point(base.getBounds().width, base.getBounds().height)); + if (hasOverlay) { + ImageDescriptor overlay = new DecorationOverlayIcon(base, overlayImages, new Point(base.getBounds().width, base.getBounds().height)); return getImageManager().getImage(overlay); } return base; |