001 // Java tool interface class ErrorViewerTool 002 // This file is generated automatically, please do not edit! 003 // generation time: Jan 30, 2007 7:11:53 AM 004 005 package nl.cwi.sen1.error.viewer; 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 ErrorViewerTool 019 extends SwingTool 020 implements ErrorViewerTif 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 PshowFeedbackSummary0; 027 private ATerm PrefreshFeedbackSummary0; 028 private ATerm PremoveFeedbackSummary0; 029 private ATerm PremoveFeedbackSummary1; 030 private ATerm PrecAckEvent0; 031 private ATerm PrecTerminate0; 032 033 // Mimic the constructor from the AbstractTool class 034 protected ErrorViewerTool(ATermFactory factory) 035 { 036 super(factory); 037 initSigTable(); 038 initPatterns(); 039 } 040 041 // This method initializes the table with input signatures 042 private void initSigTable() 043 { 044 sigTable.add(factory.parse("rec-do(<error-viewer>,show-feedback-summary(<str>,<term>))")); 045 sigTable.add(factory.parse("rec-do(<error-viewer>,remove-feedback-summary(<str>,<str>,<str>))")); 046 sigTable.add(factory.parse("rec-do(<error-viewer>,remove-feedback-summary(<str>,<str>))")); 047 sigTable.add(factory.parse("rec-do(<error-viewer>,refresh-feedback-summary(<str>,<term>))")); 048 sigTable.add(factory.parse("rec-ack-event(<error-viewer>,<term>)")); 049 sigTable.add(factory.parse("rec-terminate(<error-viewer>,<term>)")); 050 } 051 052 // Initialize the patterns that are used to match against incoming terms 053 private void initPatterns() 054 { 055 PshowFeedbackSummary0 = factory.parse("rec-do(show-feedback-summary(<str>,<term>))"); 056 PrefreshFeedbackSummary0 = factory.parse("rec-do(refresh-feedback-summary(<str>,<term>))"); 057 PremoveFeedbackSummary0 = factory.parse("rec-do(remove-feedback-summary(<str>,<str>))"); 058 PremoveFeedbackSummary1 = factory.parse("rec-do(remove-feedback-summary(<str>,<str>,<str>))"); 059 PrecAckEvent0 = factory.parse("rec-ack-event(<term>)"); 060 PrecTerminate0 = factory.parse("rec-terminate(<term>)"); 061 } 062 063 // The generic handler calls the specific handlers 064 public ATerm handler(ATerm term) 065 { 066 List<?> result; 067 068 result = term.match(PshowFeedbackSummary0); 069 if (result != null) { 070 showFeedbackSummary((String)result.get(0), (ATerm)result.get(1)); 071 return null; 072 } 073 result = term.match(PrefreshFeedbackSummary0); 074 if (result != null) { 075 refreshFeedbackSummary((String)result.get(0), (ATerm)result.get(1)); 076 return null; 077 } 078 result = term.match(PremoveFeedbackSummary0); 079 if (result != null) { 080 removeFeedbackSummary((String)result.get(0), (String)result.get(1)); 081 return null; 082 } 083 result = term.match(PremoveFeedbackSummary1); 084 if (result != null) { 085 removeFeedbackSummary((String)result.get(0), (String)result.get(1), (String)result.get(2)); 086 return null; 087 } 088 result = term.match(PrecAckEvent0); 089 if (result != null) { 090 recAckEvent((ATerm)result.get(0)); 091 return null; 092 } 093 result = term.match(PrecTerminate0); 094 if (result != null) { 095 recTerminate((ATerm)result.get(0)); 096 return null; 097 } 098 099 notInInputSignature(term); 100 return null; 101 } 102 103 // Check the input signature 104 public void checkInputSignature(ATermList sigs) 105 { 106 while(!sigs.isEmpty()) { 107 ATermAppl sig = (ATermAppl)sigs.getFirst(); 108 sigs = sigs.getNext(); 109 if (!sigTable.contains(sig)) { 110 // Sorry, but the term is not in the input signature! 111 notInInputSignature(sig); 112 } 113 } 114 } 115 116 // This function is called when an input term 117 // was not in the input signature. 118 void notInInputSignature(ATerm t) 119 { 120 throw new RuntimeException("term not in input signature: " + t); 121 } 122 }