001 // Java tool interface class DialogTool 002 // This file is generated automatically, please do not edit! 003 // generation time: Mar 28, 2007 3:57:36 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 013 import aterm.ATerm; 014 import aterm.ATermAppl; 015 import aterm.ATermFactory; 016 import aterm.ATermList; 017 018 abstract public class DialogTool 019 extends SwingTool 020 implements DialogTif 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 PshowProgressMessage0; 027 private ATerm PshowErrorDialogWithArguments0; 028 private ATerm PshowMessageDialog0; 029 private ATerm PshowProgressList0; 030 private ATerm PshowProgressMessageWithArguments0; 031 private ATerm PshowErrorDialog0; 032 private ATerm PcloseProgressList0; 033 private ATerm PshowQuestionDialog0; 034 private ATerm PshowDirectoryDialog0; 035 private ATerm PshowFileDialog0; 036 private ATerm PrecTerminate0; 037 038 // Mimic the constructor from the AbstractTool class 039 protected DialogTool(ATermFactory factory) 040 { 041 super(factory); 042 initSigTable(); 043 initPatterns(); 044 } 045 046 // This method initializes the table with input signatures 047 private void initSigTable() 048 { 049 sigTable.add(factory.parse("rec-do(<dialog>,show-error-dialog(<str>))")); 050 sigTable.add(factory.parse("rec-do(<dialog>,show-message-dialog(<str>))")); 051 sigTable.add(factory.parse("rec-do(<dialog>,show-error-dialog-with-arguments(<str>,<list>))")); 052 sigTable.add(factory.parse("rec-eval(<dialog>,show-directory-dialog(<str>,<list>))")); 053 sigTable.add(factory.parse("rec-eval(<dialog>,show-file-dialog(<str>,<list>,<str>))")); 054 sigTable.add(factory.parse("rec-eval(<dialog>,show-question-dialog(<str>))")); 055 sigTable.add(factory.parse("rec-do(<dialog>,show-progress-list(<str>))")); 056 sigTable.add(factory.parse("rec-do(<dialog>,show-progress-message(<str>))")); 057 sigTable.add(factory.parse("rec-do(<dialog>,show-progress-message-with-arguments(<str>,<list>))")); 058 sigTable.add(factory.parse("rec-do(<dialog>,close-progress-list)")); 059 sigTable.add(factory.parse("rec-terminate(<dialog>,<term>)")); 060 } 061 062 // Initialize the patterns that are used to match against incoming terms 063 private void initPatterns() 064 { 065 PshowProgressMessage0 = factory.parse("rec-do(show-progress-message(<str>))"); 066 PshowErrorDialogWithArguments0 = factory.parse("rec-do(show-error-dialog-with-arguments(<str>,<term>))"); 067 PshowMessageDialog0 = factory.parse("rec-do(show-message-dialog(<str>))"); 068 PshowProgressList0 = factory.parse("rec-do(show-progress-list(<str>))"); 069 PshowProgressMessageWithArguments0 = factory.parse("rec-do(show-progress-message-with-arguments(<str>,<term>))"); 070 PshowErrorDialog0 = factory.parse("rec-do(show-error-dialog(<str>))"); 071 PcloseProgressList0 = factory.parse("rec-do(close-progress-list)"); 072 PshowQuestionDialog0 = factory.parse("rec-eval(show-question-dialog(<str>))"); 073 PshowDirectoryDialog0 = factory.parse("rec-eval(show-directory-dialog(<str>,<term>))"); 074 PshowFileDialog0 = factory.parse("rec-eval(show-file-dialog(<str>,<term>,<str>))"); 075 PrecTerminate0 = factory.parse("rec-terminate(<term>)"); 076 } 077 078 // The generic handler calls the specific handlers 079 public ATerm handler(ATerm term) 080 { 081 List<?> result; 082 083 result = term.match(PshowProgressMessage0); 084 if (result != null) { 085 showProgressMessage((String)result.get(0)); 086 return null; 087 } 088 result = term.match(PshowErrorDialogWithArguments0); 089 if (result != null) { 090 showErrorDialogWithArguments((String)result.get(0), (ATerm)result.get(1)); 091 return null; 092 } 093 result = term.match(PshowMessageDialog0); 094 if (result != null) { 095 showMessageDialog((String)result.get(0)); 096 return null; 097 } 098 result = term.match(PshowProgressList0); 099 if (result != null) { 100 showProgressList((String)result.get(0)); 101 return null; 102 } 103 result = term.match(PshowProgressMessageWithArguments0); 104 if (result != null) { 105 showProgressMessageWithArguments((String)result.get(0), (ATerm)result.get(1)); 106 return null; 107 } 108 result = term.match(PshowErrorDialog0); 109 if (result != null) { 110 showErrorDialog((String)result.get(0)); 111 return null; 112 } 113 result = term.match(PcloseProgressList0); 114 if (result != null) { 115 closeProgressList(); 116 return null; 117 } 118 result = term.match(PshowQuestionDialog0); 119 if (result != null) { 120 return showQuestionDialog((String)result.get(0)); 121 } 122 result = term.match(PshowDirectoryDialog0); 123 if (result != null) { 124 return showDirectoryDialog((String)result.get(0), (ATerm)result.get(1)); 125 } 126 result = term.match(PshowFileDialog0); 127 if (result != null) { 128 return showFileDialog((String)result.get(0), (ATerm)result.get(1), (String)result.get(2)); 129 } 130 result = term.match(PrecTerminate0); 131 if (result != null) { 132 recTerminate((ATerm)result.get(0)); 133 return null; 134 } 135 136 notInInputSignature(term); 137 return null; 138 } 139 140 // Check the input signature 141 public void checkInputSignature(ATermList sigs) 142 { 143 while(!sigs.isEmpty()) { 144 ATermAppl sig = (ATermAppl)sigs.getFirst(); 145 sigs = sigs.getNext(); 146 if (!sigTable.contains(sig)) { 147 // Sorry, but the term is not in the input signature! 148 notInInputSignature(sig); 149 } 150 } 151 } 152 153 // This function is called when an input term 154 // was not in the input signature. 155 void notInInputSignature(ATerm t) 156 { 157 throw new RuntimeException("term not in input signature: " + t); 158 } 159 }