KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > subscribers > SubscriberChangeEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.team.core.subscribers;
12
13 import org.eclipse.core.resources.IResource;
14
15 /**
16  * A concrete implementation of <code>ISubscriberChangeEvent</code> that can
17  * be used by clients.
18  *
19  * @see ISubscriberChangeEvent
20  * @see Subscriber
21  *
22  * @since 3.0
23  */

24 public class SubscriberChangeEvent implements ISubscriberChangeEvent {
25
26     private Subscriber subscriber;
27     private int flags;
28     private IResource resource;
29     
30     /**
31      * Create a change event with the given flags for the given subscriber and resource.
32      * @param subscriber the subscriber to which the state change applies
33      * @param flags the flags that describe the change
34      * @param resource the resource whose state has change
35      */

36     public SubscriberChangeEvent(Subscriber subscriber, int flags, IResource resource) {
37         this.subscriber = subscriber;
38         this.flags = flags;
39         this.resource = resource;
40     }
41
42     /* (non-Javadoc)
43      * @see org.eclipse.team.core.subscribers.ISubscriberChangeEvent#getFlags()
44      */

45     public int getFlags() {
46         return flags;
47     }
48
49     /* (non-Javadoc)
50      * @see org.eclipse.team.core.subscribers.ISubscriberChangeEvent#getResource()
51      */

52     public IResource getResource() {
53         return resource;
54     }
55
56     /* (non-Javadoc)
57      * @see org.eclipse.team.core.subscribers.ISubscriberChangeEvent#getSubscriber()
58      */

59     public Subscriber getSubscriber() {
60         return subscriber;
61     }
62     
63     /**
64      * Returns an array of deltas for the resources with <code>ISubscriberChangeEvent.SYNC_CHANGED</code>
65      * as the flag.
66      * @param subscriber the subscriber
67      * @param resources the resources whose sync info has changed
68      * @return an array of change events
69      */

70     public static SubscriberChangeEvent[] asSyncChangedDeltas(Subscriber subscriber, IResource[] resources) {
71         SubscriberChangeEvent[] deltas = new SubscriberChangeEvent[resources.length];
72         for (int i = 0; i < resources.length; i++) {
73             IResource resource = resources[i];
74             deltas[i] = new SubscriberChangeEvent(subscriber, ISubscriberChangeEvent.SYNC_CHANGED, resource);
75         }
76         return deltas;
77     }
78 }
79
Popular Tags