1 11 package org.eclipse.ui.internal.commands; 12 13 import org.eclipse.core.commands.CommandEvent; 14 import org.eclipse.core.commands.ICommandListener; 15 import org.eclipse.jface.bindings.BindingManager; 16 import org.eclipse.ui.commands.ICommand; 17 18 24 final class CommandListenerWrapper implements ICommandListener { 25 26 29 private final BindingManager bindingManager; 30 31 35 private final org.eclipse.ui.commands.ICommandListener listener; 36 37 44 CommandListenerWrapper( 45 final org.eclipse.ui.commands.ICommandListener listener, 46 final BindingManager bindingManager) { 47 if (listener == null) { 48 throw new NullPointerException ("Cannot wrap a null listener."); } 50 51 if (bindingManager == null) { 52 throw new NullPointerException ( 53 "Cannot create a listener wrapper without a binding manager"); } 55 56 this.listener = listener; 57 this.bindingManager = bindingManager; 58 } 59 60 65 public final void commandChanged(final CommandEvent commandEvent) { 66 final ICommand command = new CommandWrapper(commandEvent.getCommand(), 67 bindingManager); 68 final boolean definedChanged = commandEvent.isDefinedChanged(); 69 final boolean descriptionChanged = commandEvent.isDescriptionChanged(); 70 final boolean handledChanged = commandEvent.isHandledChanged(); 71 final boolean nameChanged = commandEvent.isNameChanged(); 72 73 listener.commandChanged(new org.eclipse.ui.commands.CommandEvent( 74 command, false, false, definedChanged, descriptionChanged, 75 handledChanged, false, nameChanged, null)); 76 77 } 78 79 public final boolean equals(final Object object) { 80 if (object instanceof CommandListenerWrapper) { 81 final CommandListenerWrapper wrapper = (CommandListenerWrapper) object; 82 return listener.equals(wrapper.listener); 83 } 84 85 if (object instanceof org.eclipse.ui.commands.ICommandListener) { 86 final org.eclipse.ui.commands.ICommandListener other = (org.eclipse.ui.commands.ICommandListener) object; 87 return listener.equals(other); 88 } 89 90 return false; 91 } 92 93 public final int hashCode() { 94 return listener.hashCode(); 95 } 96 } 97 | Popular Tags |