1 11 package org.eclipse.ui.internal.keys; 12 13 import org.eclipse.jface.bindings.BindingManager; 14 import org.eclipse.jface.bindings.ISchemeListener; 15 import org.eclipse.jface.bindings.SchemeEvent; 16 import org.eclipse.ui.commands.IKeyConfiguration; 17 import org.eclipse.ui.commands.IKeyConfigurationListener; 18 import org.eclipse.ui.commands.KeyConfigurationEvent; 19 20 25 final class SchemeListenerWrapper implements ISchemeListener { 26 27 30 private final BindingManager bindingManager; 31 32 35 private final IKeyConfigurationListener listener; 36 37 44 SchemeListenerWrapper(final IKeyConfigurationListener listener, 45 final BindingManager bindingManager) { 46 if (listener == null) { 47 throw new NullPointerException ("Cannot wrap a null listener"); } 49 50 if (bindingManager == null) { 51 throw new NullPointerException ( 52 "Cannot wrap a listener without a binding manager"); } 54 55 this.listener = listener; 56 this.bindingManager = bindingManager; 57 } 58 59 public final boolean equals(final Object object) { 60 if (object instanceof SchemeListenerWrapper) { 61 final SchemeListenerWrapper wrapper = (SchemeListenerWrapper) object; 62 return listener.equals(wrapper.listener); 63 } 64 65 if (object instanceof IKeyConfigurationListener) { 66 final IKeyConfigurationListener other = (IKeyConfigurationListener) object; 67 return listener.equals(other); 68 } 69 70 return false; 71 } 72 73 public final int hashCode() { 74 return listener.hashCode(); 75 } 76 77 82 public final void schemeChanged(final SchemeEvent schemeEvent) { 83 final IKeyConfiguration keyConfiguration = new SchemeWrapper( 84 schemeEvent.getScheme(), bindingManager); 85 final boolean definedChanged = schemeEvent.isDefinedChanged(); 86 final boolean nameChanged = schemeEvent.isNameChanged(); 87 final boolean parentIdChanged = schemeEvent.isParentIdChanged(); 88 89 listener.keyConfigurationChanged(new KeyConfigurationEvent( 90 keyConfiguration, false, definedChanged, nameChanged, 91 parentIdChanged)); 92 } 93 } 94 | Popular Tags |