1 11 12 package org.eclipse.ui.internal.contexts; 13 14 import java.util.ArrayList ; 15 import java.util.Collections ; 16 import java.util.List ; 17 18 abstract class AbstractContextRegistry implements IContextRegistry { 19 protected List contextContextBindingDefinitions = Collections.EMPTY_LIST; 20 protected List contextDefinitions = Collections.EMPTY_LIST; 21 private ContextRegistryEvent contextRegistryEvent; 22 private List contextRegistryListeners; 23 24 protected AbstractContextRegistry() { 25 } 26 27 public void addContextRegistryListener(IContextRegistryListener contextRegistryListener) { 28 if (contextRegistryListener == null) 29 throw new NullPointerException (); 30 31 if (contextRegistryListeners == null) 32 contextRegistryListeners = new ArrayList (); 33 34 if (!contextRegistryListeners.contains(contextRegistryListener)) 35 contextRegistryListeners.add(contextRegistryListener); 36 } 37 38 protected void fireContextRegistryChanged() { 39 if (contextRegistryListeners != null) { 40 for (int i = 0; i < contextRegistryListeners.size(); i++) { 41 if (contextRegistryEvent == null) 42 contextRegistryEvent = new ContextRegistryEvent(this); 43 44 ( 45 (IContextRegistryListener) contextRegistryListeners.get( 46 i)).contextRegistryChanged( 47 contextRegistryEvent); 48 } 49 } 50 } 51 52 public List getContextContextBindingDefinitions() { 53 return contextContextBindingDefinitions; 54 } 55 56 public List getContextDefinitions() { 57 return contextDefinitions; 58 } 59 60 public void removeContextRegistryListener(IContextRegistryListener contextRegistryListener) { 61 if (contextRegistryListener == null) 62 throw new NullPointerException (); 63 64 if (contextRegistryListeners != null) 65 contextRegistryListeners.remove(contextRegistryListener); 66 } 67 } 68 | Popular Tags |