KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > viewers > deferred > IConcurrentModel


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.jface.viewers.deferred;
12
13
14 /**
15  * Interface for a set of unordered elements that can fire change notifications.
16  * IConcurrentModel returns its contents asynchronous. Rather than implementing
17  * "get" methods, listeners can request an update and the model fires back
18  * information at its earliest convenience.
19  *
20  * <p>
21  * The model is allowed to send back notifications to its listeners in any thread,
22  * and the listeners must not assume that the notifications will arrive in the UI
23  * thread.
24  * </p>
25  *
26  * <p>
27  * Not intended to be implemented by clients. Clients should subclass
28  * <code>AbstractConcurrentModel</code> instead.
29  * </p>
30  *
31  * @since 3.1
32  */

33 public interface IConcurrentModel {
34
35     /**
36      * Requests that the receiver to call the given listener's setContents(...)
37      * method at its earliest convenience. The receiver is allowed to compute the
38      * elements asynchronously. That is, it can compute the result in a background
39      * thread and call setContents(...) once the result is ready. If the result is
40      * too large to return in one batch, it can call setContents with an empty array
41      * followed by a sequence of adds.
42      * <p>
43      * Has no effect if an update is already queued for an identical listener.
44      * </p>
45      *
46      * @param listener listener whose setContents method should be called. The
47      * listener must have been previously registered with addListener.
48      */

49     public void requestUpdate(IConcurrentModelListener listener);
50     
51     /**
52      * Adds a listener to this model. The listener should be given the model's
53      * current contents (either through setContents or a sequence of adds) at the
54      * receiver's earliest convenience. The receiver will notify the listener
55      * about any changes in state until the listener is removed.
56      *
57      * <p>
58      * Has no effect if an identical listener is already registered.
59      * </p>
60      *
61      * @param listener listener to add
62      */

63     public void addListener(IConcurrentModelListener listener);
64     
65     /**
66      * Removes a listener from this model. The receiver will stop sending
67      * notifications to the given listener as soon as possible (although
68      * some additional notifications may still if arrive if the receiver
69      * was in the process of sending notifications in another thread).
70      * Any pending updates for this listener will be cancelled.
71      * <p>
72      * Has no effect if the given listener is not known to this model.
73      * </p>
74      *
75      * @param listener listener to remove
76      */

77     public void removeListener(IConcurrentModelListener listener);
78 }
79
Popular Tags