KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > events > LifecycleEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 package org.eclipse.core.internal.events;
12
13 import org.eclipse.core.resources.IResource;
14
15 /**
16  * Class used for broadcasting internal workspace lifecycle events. There is a
17  * singleton instance, so no listener is allowed to keep references to the event
18  * after the notification is finished.
19  */

20 public class LifecycleEvent {
21     //constants for kinds of internal workspace lifecycle events
22
public static final int PRE_PROJECT_CLOSE = 0x01;
23     public static final int PRE_PROJECT_CHANGE = 0x02;
24     public static final int PRE_PROJECT_COPY = 0x04;
25     public static final int PRE_PROJECT_CREATE = 0x08;
26
27     public static final int PRE_PROJECT_DELETE = 0x10;
28     public static final int PRE_PROJECT_OPEN = 0x20;
29     public static final int PRE_PROJECT_MOVE = 0x40;
30
31     public static final int PRE_LINK_COPY = 0x100;
32     public static final int PRE_LINK_CREATE = 0x200;
33     public static final int PRE_LINK_DELETE = 0x400;
34     public static final int PRE_LINK_MOVE = 0x800;
35
36     /**
37      * The kind of event
38      */

39     public int kind;
40     /**
41      * For events that only involve one resource, this is it. More
42      * specifically, this is used for all events that don't involve a more or
43      * copy. For copy/move events, this resource represents the source of the
44      * copy/move.
45      */

46     public IResource resource;
47     /**
48      * For copy/move events, this resource represents the destination of the
49      * copy/move.
50      */

51     public IResource newResource;
52
53     /**
54      * The update flags for the event.
55      */

56     public int updateFlags;
57
58     private static final LifecycleEvent instance = new LifecycleEvent();
59
60     private LifecycleEvent() {
61         super();
62     }
63
64     public static LifecycleEvent newEvent(int kind, IResource resource) {
65         instance.kind = kind;
66         instance.resource = resource;
67         instance.newResource = null;
68         instance.updateFlags = 0;
69         return instance;
70     }
71
72     public static LifecycleEvent newEvent(int kind, IResource oldResource, IResource newResource, int updateFlags) {
73         instance.kind = kind;
74         instance.resource = oldResource;
75         instance.newResource = newResource;
76         instance.updateFlags = updateFlags;
77         return instance;
78     }
79 }
80
Popular Tags