blob: e616a33c29cbd83b110ad592641ed4dd24919a7b (
plain)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
Wotonomy: OpenStep design patterns for pure Java applications.
Copyright (C) 2001 Intersect Software Corporation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see http://www.gnu.org
*/
package net.wotonomy.control;
import net.wotonomy.foundation.NSSelector;
/**
* A convenience observer for objects that do not or cannot
* subclass EODelayedObserver. EOObserverProxy will invoke
* an NSSelector on an object when it receives a subjectChanged
* message.
*
* @author michael@mpowers.net
* @author $Author: cgruber $
* @version $Revision: 893 $
*/
public class EOObserverProxy
extends EODelayedObserver
{
protected Object target;
protected NSSelector selector;
protected int priority;
/**
* Constructs an EODelayedObserver that will invoke the specified selector
* on the specified object, and will run at the specified priority.
*/
public EOObserverProxy (
Object anObject, NSSelector aSelector, int aPriority )
{
target = anObject;
selector = aSelector;
priority = aPriority;
}
/**
* Constructs an EODelayedObserver that will invoke the specified selector
* on the specified object, and will run at ObserverPriorityThird priority,
* which is the default.
*/
public EOObserverProxy (
Object anObject, NSSelector aSelector )
{
this( anObject, aSelector, ObserverPriorityThird );
}
/**
* Returns the priority of this observer in the queue.
* This implementation returns the priority specified
* in the constructor.
*/
public int priority ()
{
return priority;
}
/**
* Notifies observer that one or more objects that
* it is observing have changed. The observer should
* check all objects it is observing for changes.
*/
public void subjectChanged ()
{
try
{
selector.invoke( target );
}
catch ( Exception exc )
{
System.out.println( "Error notifying observer: " );
exc.printStackTrace();
}
}
}
/*
* $Log$
* Revision 1.1 2006/02/16 13:19:57 cgruber
* Check in all sources in eclipse-friendly maven-enabled packages.
*
* Revision 1.1 2001/10/22 21:55:32 mpowers
* This turns out to be a really useful class.
*
*
*/
|