diff options
Diffstat (limited to 'bundles/org.eclipse.ui.workbench/Eclipse UI/org')
3 files changed, 64 insertions, 30 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkingSet.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkingSet.java index 63c5cf0cc9a..ccd6bcde44e 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkingSet.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IWorkingSet.java @@ -11,6 +11,7 @@ Contributors: package org.eclipse.ui; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.resource.ImageDescriptor; /** * A working set holds a number of IAdaptable elements. @@ -45,6 +46,20 @@ public interface IWorkingSet { public String getId(); /** + * Returns the working set icon. + * Currently, this is one of the icons specified in the extensions + * of the org.eclipse.ui.workingSets extension point. + * The extension is identified using the value returned by + * <code>getId()</code>. + * Returns <code>null</code> if no icon has been specified in the + * extension or if <code>getId()</code> returns <code>null</code>. + * + * @return the working set icon or <code>null</code>. + * @since 2.1 + */ + public ImageDescriptor getImage(); + + /** * Returns the name of the working set. * * @return the name of the working set diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkingSet.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkingSet.java index 722fbfbe518..8bd70dc8626 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkingSet.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkingSet.java @@ -13,8 +13,11 @@ package org.eclipse.ui.internal; import java.util.*; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.Assert; import org.eclipse.ui.*; +import org.eclipse.ui.internal.registry.WorkingSetDescriptor; +import org.eclipse.ui.internal.registry.WorkingSetRegistry; /** * A working set holds a number of IAdaptable elements. @@ -96,24 +99,6 @@ public class WorkingSet implements IAdaptable, IPersistableElement, IWorkingSet /** * Implements IWorkingSet * - * @see org.eclipse.ui.IWorkingSet#getName() - */ - public String getName() { - return name; - } - /** - * Implements IWorkingSet - * - * @see org.eclipse.ui.IWorkingSet#getId() - * @see org.eclipse.ui.dialogs.IWorkingSetPage - * @since 2.1 - */ - public String getId() { - return editPageId; - } - /** - * Implements IWorkingSet - * * @see org.eclipse.ui.IWorkingSet#getElements() */ public IAdaptable[] getElements() { @@ -143,6 +128,48 @@ public class WorkingSet implements IAdaptable, IPersistableElement, IWorkingSet return FACTORY_ID; } /** + * Implements IWorkingSet + * + * @see org.eclipse.ui.IWorkingSet#getId() + * @see org.eclipse.ui.dialogs.IWorkingSetPage + * @since 2.1 + */ + public String getId() { + return editPageId; + } + /** + * Returns the working set icon. + * Currently, this is one of the icons specified in the extensions + * of the org.eclipse.ui.workingSets extension point. + * The extension is identified using the value returned by + * <code>getId()</code>. + * Returns <code>null</code> if no icon has been specified in the + * extension or if <code>getId()</code> returns <code>null</code>. + * + * @return the working set icon or <code>null</code>. + * @since 2.1 + */ + public ImageDescriptor getImage() { + WorkingSetRegistry registry = WorkbenchPlugin.getDefault().getWorkingSetRegistry(); + WorkingSetDescriptor descriptor = null; + + if (editPageId != null) { + descriptor = registry.getWorkingSetDescriptor(editPageId); + } + if (descriptor == null) { + return null; + } + return descriptor.getIcon(); + } + /** + * Implements IWorkingSet + * + * @see org.eclipse.ui.IWorkingSet#getName() + */ + public String getName() { + return name; + } + /** * Returns the hash code. * * @return the hash code. diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkingSetSelectionDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkingSetSelectionDialog.java index aa5e11e1cfc..12d0b3b2071 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkingSetSelectionDialog.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkingSetSelectionDialog.java @@ -14,7 +14,6 @@ package org.eclipse.ui.internal.dialogs; import java.util.*; import java.util.List; -import java.util.Map; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.ImageDescriptor; @@ -34,8 +33,6 @@ import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.dialogs.*; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.internal.*; -import org.eclipse.ui.internal.registry.WorkingSetDescriptor; -import org.eclipse.ui.internal.registry.WorkingSetRegistry; import org.eclipse.ui.model.WorkbenchViewerSorter; /** @@ -67,16 +64,11 @@ public class WorkingSetSelectionDialog extends SelectionDialog implements IWorki public Image getImage(Object object) { Assert.isTrue(object instanceof IWorkingSet); IWorkingSet workingSet = (IWorkingSet) object; - WorkingSetRegistry registry = WorkbenchPlugin.getDefault().getWorkingSetRegistry(); - WorkingSetDescriptor descriptor = registry.getWorkingSetDescriptor(workingSet.getId()); - - if (descriptor == null) { - return null; - } - ImageDescriptor imageDescriptor = descriptor.getIcon(); - if (imageDescriptor == null) { + ImageDescriptor imageDescriptor = workingSet.getImage(); + + if (imageDescriptor == null) return null; - } + Image icon = (Image) icons.get(imageDescriptor); if (icon == null) { icon = imageDescriptor.createImage(); |