1 11 package org.eclipse.ui.internal.commands; 12 13 import java.net.URL ; 14 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.ui.commands.ICommandService; 17 18 26 public final class CommandImageService implements ICommandImageService { 27 28 32 private final CommandImageManager commandImageManager; 33 34 37 private final CommandImagePersistence commandImagePersistence; 38 39 51 public CommandImageService(final CommandImageManager commandImageManager, 52 final ICommandService commandService) { 53 if (commandImageManager == null) { 54 throw new NullPointerException ( 55 "Cannot create a command image service with a null manager"); } 57 if (commandService == null) { 58 throw new NullPointerException ( 59 "Cannot create a command image service with a null command service"); } 61 this.commandImageManager = commandImageManager; 62 this.commandImagePersistence = new CommandImagePersistence( 63 commandImageManager, commandService); 64 } 65 66 public final void bind(final String commandId, final int type, 67 final String style, final ImageDescriptor descriptor) { 68 commandImageManager.bind(commandId, type, style, descriptor); 69 } 70 71 public final void bind(final String commandId, final int type, 72 final String style, final URL url) { 73 commandImageManager.bind(commandId, type, style, url); 74 } 75 76 public final void dispose() { 77 commandImagePersistence.dispose(); 78 } 79 80 public final String generateUnusedStyle(final String commandId) { 81 return commandImageManager.generateUnusedStyle(commandId); 82 } 83 84 public final ImageDescriptor getImageDescriptor(final String commandId) { 85 return commandImageManager.getImageDescriptor(commandId); 86 } 87 88 public final ImageDescriptor getImageDescriptor(final String commandId, 89 final int type) { 90 return commandImageManager.getImageDescriptor(commandId, type); 91 } 92 93 public final ImageDescriptor getImageDescriptor(final String commandId, 94 final int type, final String style) { 95 return commandImageManager.getImageDescriptor(commandId, type, style); 96 } 97 98 public final ImageDescriptor getImageDescriptor(final String commandId, 99 final String style) { 100 return commandImageManager.getImageDescriptor(commandId, style); 101 } 102 103 public final void readRegistry() { 104 commandImagePersistence.read(); 105 } 106 } 107 | Popular Tags |