KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > keys > CancelOnModifyListener


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.keys;
13
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.widgets.Event;
16 import org.eclipse.swt.widgets.Listener;
17 import org.eclipse.swt.widgets.Widget;
18
19 /**
20  * A listener that removes the out-of-order listener if a modification occurs
21  * before reaching it. This is a workaround for Bug 53497.
22  *
23  * @since 3.0
24  */

25 final class CancelOnModifyListener implements Listener {
26
27     /**
28      * The listener to remove when this listener catches any event. This value
29      * should not be <code>null</code>.
30      */

31     private final Listener chainedListener;
32
33     /**
34      * Constructs a new instance of <code>CancelOnModifyListener</code>
35      *
36      * @param listener
37      * The listener which should be removed in the event of a
38      * modification event arriving; should not be <code>null</code>.
39      */

40     CancelOnModifyListener(Listener listener) {
41         chainedListener = listener;
42     }
43
44     /*
45      * (non-Javadoc)
46      *
47      * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
48      */

49     public void handleEvent(Event event) {
50         Widget widget = event.widget;
51         widget.removeListener(SWT.Modify, this);
52         widget.removeListener(SWT.KeyDown, chainedListener);
53     }
54 }
55
Popular Tags