01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.keys;
11:
12: import org.eclipse.swt.SWT;
13: import org.eclipse.swt.widgets.Event;
14: import org.eclipse.swt.widgets.Listener;
15: import org.eclipse.swt.widgets.Widget;
16:
17: /**
18: * A listener that removes the out-of-order listener if a modification occurs
19: * before reaching it. This is a workaround for Bug 53497.
20: *
21: * @since 3.0
22: */
23: final class CancelOnModifyListener implements Listener {
24:
25: /**
26: * The listener to remove when this listener catches any event. This value
27: * should not be <code>null</code>.
28: */
29: private final Listener chainedListener;
30:
31: /**
32: * Constructs a new instance of <code>CancelOnModifyListener</code>
33: *
34: * @param listener
35: * The listener which should be removed in the event of a
36: * modification event arriving; should not be <code>null</code>.
37: */
38: CancelOnModifyListener(Listener listener) {
39: chainedListener = listener;
40: }
41:
42: /*
43: * (non-Javadoc)
44: *
45: * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
46: */
47: public void handleEvent(Event event) {
48: Widget widget = event.widget;
49: widget.removeListener(SWT.Modify, this);
50: widget.removeListener(SWT.KeyDown, chainedListener);
51: }
52: }
|