1 11 package org.eclipse.ui.internal.handlers; 12 13 import org.eclipse.core.commands.IHandler; 14 import org.eclipse.ui.commands.HandlerEvent; 15 import org.eclipse.ui.commands.IHandlerListener; 16 import org.eclipse.ui.internal.commands.ILegacyAttributeNames; 17 18 24 public final class LegacyHandlerListenerWrapper implements IHandlerListener { 25 26 29 private final IHandler handler; 30 31 34 private final org.eclipse.core.commands.IHandlerListener listener; 35 36 42 public LegacyHandlerListenerWrapper(final IHandler handler, 43 final org.eclipse.core.commands.IHandlerListener listener) { 44 if (handler == null) { 45 throw new NullPointerException ( 46 "A listener wrapper cannot be created on a null handler"); } 48 49 if (listener == null) { 50 throw new NullPointerException ( 51 "A listener wrapper cannot be created on a null listener"); } 53 54 this.handler = handler; 55 this.listener = listener; 56 } 57 58 63 public void handlerChanged(HandlerEvent event) { 64 final boolean enabledChanged = ((Boolean ) event 65 .getPreviousAttributeValuesByName().get( 66 ILegacyAttributeNames.ENABLED)).booleanValue() != handler 67 .isEnabled(); 68 final boolean handledChanged = ((Boolean ) event 69 .getPreviousAttributeValuesByName().get( 70 ILegacyAttributeNames.HANDLED)).booleanValue() != handler 71 .isHandled(); 72 listener.handlerChanged(new org.eclipse.core.commands.HandlerEvent( 73 handler, enabledChanged, handledChanged)); 74 } 75 } 76 | Popular Tags |