001 // Java tool interface class FactbrowserTool
002 // This file is generated automatically, please do not edit!
003 // generation time: Aug 17, 2007 9:19:04 AM
004
005 package nl.cwi.sen1.visbase.factbrowser;
006
007 import java.util.HashSet;
008 import java.util.List;
009 import java.util.Set;
010
011 import toolbus.SwingTool;
012
013 import aterm.ATerm;
014 import aterm.ATermAppl;
015 import aterm.ATermFactory;
016 import aterm.ATermList;
017
018 abstract public class FactbrowserTool
019 extends SwingTool
020 implements FactbrowserTif
021 {
022 // This table will hold the complete input signature
023 private Set<ATerm> sigTable = new HashSet<ATerm>();
024
025 // Patterns that are used to match against incoming terms
026 private ATerm PfbRstoreUnloaded0;
027 private ATerm PfbAddVisualizationPlugin0;
028 private ATerm PfbShowRstoreFacts0;
029 private ATerm PshowPopup0;
030 private ATerm PgetSelectedRstoreid0;
031 private ATerm PrecAckEvent0;
032 private ATerm PrecTerminate0;
033
034 // Mimic the constructor from the AbstractTool class
035 protected FactbrowserTool(ATermFactory factory)
036 {
037 super(factory);
038 initSigTable();
039 initPatterns();
040 }
041
042 // This method initializes the table with input signatures
043 private void initSigTable()
044 {
045 sigTable.add(factory.parse("rec-do(<factbrowser>,fb-add-visualization-plugin(<term>,<int>,<str>))"));
046 sigTable.add(factory.parse("rec-eval(<factbrowser>,get-selected-rstoreid)"));
047 sigTable.add(factory.parse("rec-do(<factbrowser>,fb-show-rstore-facts(<str>,<int>,<list>))"));
048 sigTable.add(factory.parse("rec-ack-event(<factbrowser>,<term>)"));
049 sigTable.add(factory.parse("rec-do(<factbrowser>,show-popup(<int>,<list>))"));
050 sigTable.add(factory.parse("rec-do(<factbrowser>,fb-rstore-unloaded(<int>))"));
051 sigTable.add(factory.parse("rec-terminate(<factbrowser>,<term>)"));
052 }
053
054 // Initialize the patterns that are used to match against incoming terms
055 private void initPatterns()
056 {
057 PfbRstoreUnloaded0 = factory.parse("rec-do(fb-rstore-unloaded(<int>))");
058 PfbAddVisualizationPlugin0 = factory.parse("rec-do(fb-add-visualization-plugin(<term>,<int>,<str>))");
059 PfbShowRstoreFacts0 = factory.parse("rec-do(fb-show-rstore-facts(<str>,<int>,<term>))");
060 PshowPopup0 = factory.parse("rec-do(show-popup(<int>,<term>))");
061 PgetSelectedRstoreid0 = factory.parse("rec-eval(get-selected-rstoreid)");
062 PrecAckEvent0 = factory.parse("rec-ack-event(<term>)");
063 PrecTerminate0 = factory.parse("rec-terminate(<term>)");
064 }
065
066 // The generic handler calls the specific handlers
067 public ATerm handler(ATerm term)
068 {
069 List<?> result;
070
071 result = term.match(PfbRstoreUnloaded0);
072 if (result != null) {
073 fbRstoreUnloaded(((Integer)result.get(0)).intValue());
074 return null;
075 }
076 result = term.match(PfbAddVisualizationPlugin0);
077 if (result != null) {
078 fbAddVisualizationPlugin((ATerm)result.get(0), ((Integer)result.get(1)).intValue(), (String)result.get(2));
079 return null;
080 }
081 result = term.match(PfbShowRstoreFacts0);
082 if (result != null) {
083 fbShowRstoreFacts((String)result.get(0), ((Integer)result.get(1)).intValue(), (ATerm)result.get(2));
084 return null;
085 }
086 result = term.match(PshowPopup0);
087 if (result != null) {
088 showPopup(((Integer)result.get(0)).intValue(), (ATerm)result.get(1));
089 return null;
090 }
091 result = term.match(PgetSelectedRstoreid0);
092 if (result != null) {
093 return getSelectedRstoreid();
094 }
095 result = term.match(PrecAckEvent0);
096 if (result != null) {
097 recAckEvent((ATerm)result.get(0));
098 return null;
099 }
100 result = term.match(PrecTerminate0);
101 if (result != null) {
102 recTerminate((ATerm)result.get(0));
103 return null;
104 }
105
106 notInInputSignature(term);
107 return null;
108 }
109
110 // Check the input signature
111 public void checkInputSignature(ATermList sigs)
112 {
113 while(!sigs.isEmpty()) {
114 ATermAppl sig = (ATermAppl)sigs.getFirst();
115 sigs = sigs.getNext();
116 if (!sigTable.contains(sig)) {
117 // Sorry, but the term is not in the input signature!
118 notInInputSignature(sig);
119 }
120 }
121 }
122
123 // This function is called when an input term
124 // was not in the input signature.
125 void notInInputSignature(ATerm t)
126 {
127 throw new RuntimeException("term not in input signature: " + t);
128 }
129 }