KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > commands > HandlerEvent


1 /*******************************************************************************
2  * Copyright (c) 2004, 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 package org.eclipse.core.commands;
12
13 import org.eclipse.core.commands.common.AbstractBitSetEvent;
14
15 /**
16  * An instance of this class describes changes to an instance of
17  * <code>IHandler</code>.
18  * <p>
19  * This class is not intended to be extended by clients.
20  * </p>
21  *
22  * @since 3.1
23  * @see IHandlerListener#handlerChanged(HandlerEvent)
24  */

25 public final class HandlerEvent extends AbstractBitSetEvent {
26
27     /**
28      * The bit used to represent whether the handler has changed its enabled
29      * state.
30      */

31     private static final int CHANGED_ENABLED = 1;
32
33     /**
34      * The bit used to represent whether the handler has changed its handled
35      * state.
36      */

37     private static final int CHANGED_HANDLED = 1 << 1;
38
39     /**
40      * The handler that changed; this value is never <code>null</code>.
41      */

42     private final IHandler handler;
43
44     /**
45      * Creates a new instance of this class.
46      *
47      * @param handler
48      * the instance of the interface that changed; must not be
49      * <code>null</code>.
50      * @param enabledChanged
51      * Whether the enabled state of the handler has changed.
52      * @param handledChanged
53      * Whether the handled state of the handler has changed.
54      */

55     public HandlerEvent(final IHandler handler, final boolean enabledChanged,
56             final boolean handledChanged) {
57         if (handler == null) {
58             throw new NullPointerException JavaDoc();
59         }
60         this.handler = handler;
61
62         if (enabledChanged) {
63             changedValues |= CHANGED_ENABLED;
64         }
65         if (handledChanged) {
66             changedValues |= CHANGED_HANDLED;
67         }
68     }
69
70     /**
71      * Returns the instance of the interface that changed.
72      *
73      * @return the instance of the interface that changed. Guaranteed not to be
74      * <code>null</code>.
75      */

76     public IHandler getHandler() {
77         return handler;
78     }
79
80     /**
81      * Returns whether or not the enabled property changed.
82      *
83      * @return <code>true</code>, iff the enabled property changed.
84      */

85     public boolean isEnabledChanged() {
86         return ((changedValues & CHANGED_ENABLED) != 0);
87     }
88
89     /**
90      * Returns whether or not the handled property changed.
91      *
92      * @return <code>true</code>, iff the handled property changed.
93      */

94     public boolean isHandledChanged() {
95         return ((changedValues & CHANGED_HANDLED) != 0);
96     }
97 }
98
Popular Tags