View Javadoc

1   /*
2   * The contents of this file are subject to the BT "ZEUS" Open Source 
3   * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file 
4   * except in compliance with the Licence. You may obtain a copy of the Licence
5   * from $ZEUS_INSTALL/licence.html or alternatively from
6   * http://www.labs.bt.com/projects/agents/zeus/licence.htm
7   * 
8   * Except as stated in Clause 7 of the Licence, software distributed under the
9   * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or 
10  * implied. See the Licence for the specific language governing rights and 
11  * limitations under the Licence.
12  * 
13  * The Original Code is within the package zeus.*.
14  * The Initial Developer of the Original Code is British Telecommunications
15  * public limited company, whose registered office is at 81 Newgate Street, 
16  * London, EC1A 7AJ, England. Portions created by British Telecommunications 
17  * public limited company are Copyright 1996-9. All Rights Reserved.
18  * 
19  * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
20  */
21  
22  
23  
24  package zeus.agentviewer.rete;
25  
26  import javax.swing.*;
27  import javax.swing.text.*;
28  import java.util.*;
29  import zeus.util.*;
30  import zeus.actors.AgentContext;
31  import zeus.actors.event.*;
32  import zeus.rete.ReteEngine;
33  
34  public class ReteEngineDataModel extends PlainDocument implements ReteEngineMonitor {
35     protected Vector data;
36     protected ReteEngine engine;
37  
38     public ReteEngineDataModel(AgentContext context){
39        data = new Vector();
40        ReteEngine engine = context.ReteEngine();
41        engine.addMonitor(this,
42           ReteEngineEvent.ADD_MASK | ReteEngineEvent.DELETE_MASK |
43  	 ReteEngineEvent.ACTIVATE_MASK | ReteEngineEvent.DEACTIVATE_MASK |
44           ReteEngineEvent.FIRE_MASK
45        );
46     }
47  
48     public void removeZeusEventMonitors() {
49        engine.removeMonitor(this,
50           ReteEngineEvent.ADD_MASK | ReteEngineEvent.DELETE_MASK |
51  	 ReteEngineEvent.ACTIVATE_MASK | ReteEngineEvent.DEACTIVATE_MASK |
52           ReteEngineEvent.FIRE_MASK
53        );
54     }
55  
56     public void reteRuleAddedEvent(ReteEngineEvent event) {
57        try {
58           insertString(getLength(),event.getDiagnostic() + "\n", null);
59        }
60        catch(BadLocationException e) {
61        }
62     }
63     public void reteRuleDeletedEvent(ReteEngineEvent event) {
64        try {
65           insertString(getLength(),event.getDiagnostic() + "\n", null);
66        }
67        catch(BadLocationException e) {
68        }
69     }
70     public void reteRuleActivatedEvent(ReteEngineEvent event) {
71        try {
72           insertString(getLength(),event.getDiagnostic() + "\n", null);
73        }
74        catch(BadLocationException e) {
75        }
76     }
77     public void reteRuleDeactivatedEvent(ReteEngineEvent event) {
78        try {
79           insertString(getLength(),event.getDiagnostic() + "\n", null);
80        }
81        catch(BadLocationException e) {
82        }
83     }
84     public void reteRuleFiredEvent(ReteEngineEvent event) {
85        try {
86           insertString(getLength(),event.getDiagnostic() + "\n", null);
87        }
88        catch(BadLocationException e) {
89        }
90     }
91  }