10
|
1 /*******************************************************************************
|
90
|
2 * Copyright (c) 2004, 2008 IBM Corporation and others.
|
10
|
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 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module dwtx.jface.viewers.deferred.IConcurrentModel;
|
|
14
|
|
15 import dwtx.jface.viewers.deferred.IConcurrentModelListener;
|
|
16
|
|
17 /**
|
|
18 * Interface for a set of unordered elements that can fire change notifications.
|
|
19 * IConcurrentModel returns its contents asynchronous. Rather than implementing
|
|
20 * "get" methods, listeners can request an update and the model fires back
|
|
21 * information at its earliest convenience.
|
|
22 *
|
|
23 * <p>
|
|
24 * The model is allowed to send back notifications to its listeners in any thread,
|
|
25 * and the listeners must not assume that the notifications will arrive in the UI
|
|
26 * thread.
|
|
27 * </p>
|
|
28 *
|
|
29 * <p>
|
|
30 * Not intended to be implemented by clients. Clients should subclass
|
|
31 * <code>AbstractConcurrentModel</code> instead.
|
|
32 * </p>
|
|
33 *
|
|
34 * @since 3.1
|
90
|
35 * @noimplement This interface is not intended to be implemented by clients.
|
10
|
36 */
|
|
37 public interface IConcurrentModel {
|
|
38
|
|
39 /**
|
|
40 * Requests that the receiver to call the given listener's setContents(...)
|
|
41 * method at its earliest convenience. The receiver is allowed to compute the
|
|
42 * elements asynchronously. That is, it can compute the result in a background
|
|
43 * thread and call setContents(...) once the result is ready. If the result is
|
|
44 * too large to return in one batch, it can call setContents with an empty array
|
|
45 * followed by a sequence of adds.
|
|
46 * <p>
|
|
47 * Has no effect if an update is already queued for an identical listener.
|
|
48 * </p>
|
|
49 *
|
|
50 * @param listener listener whose setContents method should be called. The
|
|
51 * listener must have been previously registered with addListener.
|
|
52 */
|
|
53 public void requestUpdate(IConcurrentModelListener listener);
|
|
54
|
|
55 /**
|
|
56 * Adds a listener to this model. The listener should be given the model's
|
|
57 * current contents (either through setContents or a sequence of adds) at the
|
|
58 * receiver's earliest convenience. The receiver will notify the listener
|
|
59 * about any changes in state until the listener is removed.
|
|
60 *
|
|
61 * <p>
|
|
62 * Has no effect if an identical listener is already registered.
|
|
63 * </p>
|
|
64 *
|
|
65 * @param listener listener to add
|
|
66 */
|
|
67 public void addListener(IConcurrentModelListener listener);
|
|
68
|
|
69 /**
|
|
70 * Removes a listener from this model. The receiver will stop sending
|
|
71 * notifications to the given listener as soon as possible (although
|
|
72 * some additional notifications may still if arrive if the receiver
|
|
73 * was in the process of sending notifications in another thread).
|
|
74 * Any pending updates for this listener will be cancelled.
|
|
75 * <p>
|
|
76 * Has no effect if the given listener is not known to this model.
|
|
77 * </p>
|
|
78 *
|
|
79 * @param listener listener to remove
|
|
80 */
|
|
81 public void removeListener(IConcurrentModelListener listener);
|
|
82 }
|