001 // Java tool interface class ProgressTool 002 // This file is generated automatically, please do not edit! 003 // generation time: Jan 4, 2007 3:18:21 PM 004 005 package nl.cwi.sen1.gui.plugin; 006 007 import java.util.HashSet; 008 import java.util.List; 009 import java.util.Set; 010 011 import toolbus.SwingTool; 012 import aterm.ATerm; 013 import aterm.ATermAppl; 014 import aterm.ATermFactory; 015 import aterm.ATermList; 016 017 abstract public class ProgressTool 018 extends SwingTool 019 implements ProgressTif 020 { 021 // This table will hold the complete input signature 022 private Set<ATerm> sigTable = new HashSet<ATerm>(); 023 024 // Patterns that are used to match against incoming terms 025 private ATerm PsetMessage0; 026 private ATerm PremoveStatus0; 027 private ATerm PclearStatusWindow0; 028 private ATerm PsetStatus0; 029 private ATerm PrecTerminate0; 030 031 // Mimic the constructor from the AbstractTool class 032 protected ProgressTool(ATermFactory factory) 033 { 034 super(factory); 035 initSigTable(); 036 initPatterns(); 037 } 038 039 // This method initializes the table with input signatures 040 private void initSigTable() 041 { 042 sigTable.add(factory.parse("rec-do(<progress>,set-status(<term>,<str>,<term>))")); 043 sigTable.add(factory.parse("rec-do(<progress>,set-message(<term>,<str>))")); 044 sigTable.add(factory.parse("rec-do(<progress>,remove-status(<term>))")); 045 sigTable.add(factory.parse("rec-do(<progress>,clear-status-window)")); 046 sigTable.add(factory.parse("rec-terminate(<progress>,<term>)")); 047 } 048 049 // Initialize the patterns that are used to match against incoming terms 050 private void initPatterns() 051 { 052 PsetMessage0 = factory.parse("rec-do(set-message(<term>,<str>))"); 053 PremoveStatus0 = factory.parse("rec-do(remove-status(<term>))"); 054 PclearStatusWindow0 = factory.parse("rec-do(clear-status-window)"); 055 PsetStatus0 = factory.parse("rec-do(set-status(<term>,<str>,<term>))"); 056 PrecTerminate0 = factory.parse("rec-terminate(<term>)"); 057 } 058 059 // The generic handler calls the specific handlers 060 public ATerm handler(ATerm term) 061 { 062 List<?> result; 063 064 result = term.match(PsetMessage0); 065 if (result != null) { 066 setMessage((ATerm)result.get(0), (String)result.get(1)); 067 return null; 068 } 069 result = term.match(PremoveStatus0); 070 if (result != null) { 071 removeStatus((ATerm)result.get(0)); 072 return null; 073 } 074 result = term.match(PclearStatusWindow0); 075 if (result != null) { 076 clearStatusWindow(); 077 return null; 078 } 079 result = term.match(PsetStatus0); 080 if (result != null) { 081 setStatus((ATerm)result.get(0), (String)result.get(1), (ATerm)result.get(2)); 082 return null; 083 } 084 result = term.match(PrecTerminate0); 085 if (result != null) { 086 recTerminate((ATerm)result.get(0)); 087 return null; 088 } 089 090 notInInputSignature(term); 091 return null; 092 } 093 094 // Check the input signature 095 public void checkInputSignature(ATermList sigs) 096 { 097 while(!sigs.isEmpty()) { 098 ATermAppl sig = (ATermAppl)sigs.getFirst(); 099 sigs = sigs.getNext(); 100 if (!sigTable.contains(sig)) { 101 // Sorry, but the term is not in the input signature! 102 notInInputSignature(sig); 103 } 104 } 105 } 106 107 // This function is called when an input term 108 // was not in the input signature. 109 void notInInputSignature(ATerm t) 110 { 111 throw new RuntimeException("term not in input signature: " + t); 112 } 113 }