Skip to main content
summaryrefslogtreecommitdiffstats
blob: b4e6fd137ef40a9101449c4a8cb3202e1e3966d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package org.eclipse.jst.jsf.common.internal.resource;

import org.eclipse.core.resources.IResource;

/**
 * @author cbateman
 *
 */
public class ResourceLifecycleEvent 
{
    /**
     * the type of lifecycle event
     * this enum is not closed and may add new fields in the future
     */
    public enum EventType
    {
        /**
         * Indicates that the resource is no longer accessible (as testable with
         * IResource.isAccessible).  The reasonType will indicate why.
         */
        RESOURCE_INACCESSIBLE;
    }
    
    /**
     * encodes the cause of the event if the event type provides one
     * this enum is not closed and may add new fields in the future
     */
    public enum ReasonType
    {
        /**
         * The resource was deleted from the workspace,
         * this event is pre change if the event is project
         * and post change otherwise
         */
        RESOURCE_DELETED,
        /**
         * The resource's project was deleted.  This event is 
         * pre-change.  Note that if the tracked resource is 
         * a project, RESOURCE_DELETED will be fired, not this
         * event.
         */
        RESOURCE_PROJECT_DELETED,
        /**
         * The resource's project was closed.  This event is pre-change
         */
        RESOURCE_PROJECT_CLOSED
    }
    
    private final IResource   _affectedResource;
    private final EventType   _eventType;
    private final ReasonType  _reasonType;
    
    /**
     * @param affectedResource
     * @param eventType
     * @param reasonType
     */
    public ResourceLifecycleEvent(IResource affectedResource, EventType eventType, ReasonType reasonType)
    {
        _affectedResource = affectedResource;
        _eventType = eventType;
        _reasonType = reasonType;
    }

    /**
     * @return the affected resource
     */
    public IResource getAffectedResource() {
        return _affectedResource;
    }

    /**
     * @return the event that has occurred
     */
    public EventType getEventType() {
        return _eventType;
    }

    /**
     * @return the cause of the event
     */
    public ReasonType getReasonType() {
        return _reasonType;
    }
}

Back to the top