KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > commands > common > AbstractNamedHandleEvent


1 /*******************************************************************************
2  * Copyright (c) 2005 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.common;
13
14 /**
15  * <p>
16  * An event fired from a <code>NamedHandleObject</code>. This provides
17  * notification of changes to the defined state, the name and the description.
18  * </p>
19  *
20  * @since 3.1
21  */

22 public abstract class AbstractNamedHandleEvent extends
23         AbstractHandleObjectEvent {
24
25     /**
26      * The bit used to represent whether the category has changed its
27      * description.
28      */

29     protected static final int CHANGED_DESCRIPTION = 1 << LAST_BIT_USED_ABSTRACT_HANDLE;
30
31     /**
32      * The bit used to represent whether the category has changed its name.
33      */

34     protected static final int CHANGED_NAME = 1 << LAST_BIT_USED_ABSTRACT_HANDLE;
35
36     /**
37      * The last used bit so that subclasses can add more properties.
38      */

39     protected static final int LAST_USED_BIT = CHANGED_NAME;
40
41     /**
42      * Constructs a new instance of <code>AbstractHandleObjectEvent</code>.
43      *
44      * @param definedChanged
45      * <code>true</code>, iff the defined property changed.
46      * @param descriptionChanged
47      * <code>true</code>, iff the description property changed.
48      * @param nameChanged
49      * <code>true</code>, iff the name property changed.
50      */

51     protected AbstractNamedHandleEvent(final boolean definedChanged,
52             final boolean descriptionChanged, final boolean nameChanged) {
53         super(definedChanged);
54
55         if (descriptionChanged) {
56             changedValues |= CHANGED_DESCRIPTION;
57         }
58         if (nameChanged) {
59             changedValues |= CHANGED_NAME;
60         }
61     }
62
63     /**
64      * Returns whether or not the description property changed.
65      *
66      * @return <code>true</code>, iff the description property changed.
67      */

68     public final boolean isDescriptionChanged() {
69         return ((changedValues & CHANGED_DESCRIPTION) != 0);
70     }
71
72     /**
73      * Returns whether or not the name property changed.
74      *
75      * @return <code>true</code>, iff the name property changed.
76      */

77     public final boolean isNameChanged() {
78         return ((changedValues & CHANGED_NAME) != 0);
79     }
80
81 }
82
Popular Tags