1 11 12 package org.eclipse.ui.internal.commands; 13 14 import java.util.ArrayList ; 15 import java.util.Collections ; 16 import java.util.List ; 17 18 abstract class AbstractCommandRegistry implements ICommandRegistry { 19 20 protected List activeKeyConfigurationDefinitions = Collections.EMPTY_LIST; 21 protected List categoryDefinitions = Collections.EMPTY_LIST; 22 protected List commandDefinitions = Collections.EMPTY_LIST; 23 24 private CommandRegistryEvent commandRegistryEvent; 25 private List commandRegistryListeners; 26 protected List handlers = Collections.EMPTY_LIST; 27 protected List imageBindingDefinitions = Collections.EMPTY_LIST; 28 protected List keyConfigurationDefinitions = Collections.EMPTY_LIST; 29 protected List keySequenceBindingDefinitions = Collections.EMPTY_LIST; 30 31 protected AbstractCommandRegistry() { 32 } 34 35 public void addCommandRegistryListener(ICommandRegistryListener commandRegistryListener) { 36 if (commandRegistryListener == null) 37 throw new NullPointerException (); 38 39 if (commandRegistryListeners == null) 40 commandRegistryListeners = new ArrayList (); 41 42 if (!commandRegistryListeners.contains(commandRegistryListener)) 43 commandRegistryListeners.add(commandRegistryListener); 44 } 45 46 protected void fireCommandRegistryChanged() { 47 if (commandRegistryListeners != null) { 48 for (int i = 0; i < commandRegistryListeners.size(); i++) { 49 if (commandRegistryEvent == null) 50 commandRegistryEvent = new CommandRegistryEvent(this); 51 52 ( 53 (ICommandRegistryListener) commandRegistryListeners.get( 54 i)).commandRegistryChanged( 55 commandRegistryEvent); 56 } 57 } 58 } 59 60 public List getActiveKeyConfigurationDefinitions() { 61 return activeKeyConfigurationDefinitions; 62 } 63 64 public List getCategoryDefinitions() { 65 return categoryDefinitions; 66 } 67 68 public List getCommandDefinitions() { 69 return commandDefinitions; 70 } 71 72 78 public List getHandlers() { 79 return handlers; 80 } 81 82 public List getImageBindingDefinitions() { 83 return imageBindingDefinitions; 84 } 85 86 public List getKeyConfigurationDefinitions() { 87 return keyConfigurationDefinitions; 88 } 89 90 public List getKeySequenceBindingDefinitions() { 91 return keySequenceBindingDefinitions; 92 } 93 94 public void removeCommandRegistryListener(ICommandRegistryListener commandRegistryListener) { 95 if (commandRegistryListener == null) 96 throw new NullPointerException (); 97 98 if (commandRegistryListeners != null) 99 commandRegistryListeners.remove(commandRegistryListener); 100 } 101 } 102 | Popular Tags |