KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > commands > contexts > ContextEvent


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
12 package org.eclipse.core.commands.contexts;
13
14 import org.eclipse.core.commands.common.AbstractNamedHandleEvent;
15
16 /**
17  * An instance of this class describes changes to an instance of
18  * <code>IContext</code>.
19  * <p>
20  * This class is not intended to be extended by clients.
21  * </p>
22  *
23  * @since 3.1
24  * @see IContextListener#contextChanged(ContextEvent)
25  */

26 public final class ContextEvent extends AbstractNamedHandleEvent {
27
28     /**
29      * The bit used to represent whether the context has changed its parent.
30      */

31     private static final int CHANGED_PARENT_ID = LAST_USED_BIT << 1;
32
33     /**
34      * The context that has changed. This value is never <code>null</code>.
35      */

36     private final Context context;
37
38     /**
39      * Creates a new instance of this class.
40      *
41      * @param context
42      * the instance of the interface that changed; must not be
43      * <code>null</code>.
44      * @param definedChanged
45      * <code>true</code>, iff the defined property changed.
46      * @param nameChanged
47      * <code>true</code>, iff the name property changed.
48      * @param descriptionChanged
49      * <code>true</code>, iff the description property changed.
50      * @param parentIdChanged
51      * <code>true</code>, iff the parentId property changed.
52      */

53     public ContextEvent(final Context context, final boolean definedChanged,
54             final boolean nameChanged, final boolean descriptionChanged,
55             final boolean parentIdChanged) {
56         super(definedChanged, descriptionChanged, nameChanged);
57         
58         if (context == null) {
59             throw new NullPointerException JavaDoc();
60         }
61         this.context = context;
62         
63         if (parentIdChanged) {
64             changedValues |= CHANGED_PARENT_ID;
65         }
66     }
67
68     /**
69      * Returns the instance of the interface that changed.
70      *
71      * @return the instance of the interface that changed. Guaranteed not to be
72      * <code>null</code>.
73      */

74     public final Context getContext() {
75         return context;
76     }
77
78     /**
79      * Returns whether or not the parentId property changed.
80      *
81      * @return <code>true</code>, iff the parentId property changed.
82      */

83     public final boolean isParentIdChanged() {
84         return ((changedValues & CHANGED_PARENT_ID) != 0);
85     }
86 }
87
Popular Tags