Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

HTMLUtils.java

Go to the documentation of this file.
00001 package cedar.jetweb.html;
00002 
00003 import java.io.PrintWriter;
00004 import java.io.IOException;
00005 
00006 import java.text.DecimalFormat;
00007 
00008 import java.util.List;
00009 import java.util.Iterator;
00010 
00011 import cedar.jetweb.*;
00012 import cedar.jetweb.model.*;
00013 import cedar.jetweb.model.paper.*;
00014 import cedar.jetweb.model.plots.*;
00015 import cedar.jetweb.model.fit.*;
00016 
00017 import cedar.jetweb.job.JobUtils;
00018 import cedar.jetweb.job.JobRequest;
00019 
00020 import cedar.jetweb.generator.Generator;
00021 
00032 public abstract class HTMLUtils {
00033 
00035     public static final String PTHAT = "pthat";
00037     public static final String DATE  = "date";
00039     public static final String CHI2ALL  = "Fit (All data)";
00041     public static final String CHI2HIGH = "Fit (High ET)";
00043     public static final String CHI2LOW = "Fit (Low ET)";
00045     public static final String CHI2SHAPE = "Fit (Jet Shapes)";
00047     public static final String CHI2CHARM = "Fit (Charm)";
00048 
00050     public static final String CHI2ALLEP  = "ep Fit (All data)";
00052     public static final String CHI2HIGHEP = "ep Fit (High ET)";
00054     public static final String CHI2LOWEP = "ep Fit (Low ET)";
00056     public static final String CHI2SHAPEEP = "ep Fit (Jet Shapes)";
00058     public static final String CHI2CHARMEP = "ep Fit (Charm)";
00059 
00061     public static final String CHI2ALLEE  = "ee Fit (All data)";
00063     public static final String CHI2HIGHEE = "ee Fit (High ET)";
00065     public static final String CHI2LOWEE = "ee Fit (Low ET)";
00067     public static final String CHI2SHAPEEE = "ee Fit (Jet Shapes)";
00069     public static final String CHI2CHARMEE = "ee Fit (Charm)";
00070 
00072     public static final String CHI2ALLPP  = "pp Fit (All data)";
00074     public static final String CHI2HIGHPP = "pp Fit (High ET)";
00076     public static final String CHI2LOWPP = "pp Fit (Low ET)";
00078     public static final String CHI2SHAPEPP = "pp Fit (Jet Shapes)";
00080     public static final String CHI2CHARMPP = "pp Fit (Charm)";
00081 
00082 
00084     public static final String DONTCARE = "Don't care";
00086     public static final String LATEST   = "All Latest";
00088     public static final String LATESTEP = "Latest ep Data";
00090     public static final String LATESTEE = "Latest e+e- Data";
00092     public static final String LATESTPP = "Latest pp(bar) Data";
00093 
00094 
00099     public static void writeProcScreen(String modelIdString,PrintWriter out,String servletPath) 
00100     throws JetWebException{
00101 
00102     // Start newpage.
00103     HTMLProcessWriter op = new HTMLProcessWriter(out,servletPath);
00104     op.write("<p>Generate more events for Model " + 
00105          modelIdString + 
00106          ".<p>");
00107     op.write("<p>");
00108     op.startForm();
00109     op.write("Minimum PT (GeV) for generated events ");
00110     op.write
00111         ("<input type='text' size='3'" + 
00112          " name='GENPTMIN' title='Enter the minimum PT to generate'><p>");
00113     op.write("Which processes do you wish to generate?<p>");
00114     op.writeMCProcessSelector(modelIdString);
00115     op.endForm();
00116     op.close();
00117     }
00118 
00122     public static void writeQueryScreen(String message, 
00123                     ResultSearchPattern pattern, 
00124                     PlotSelection whichpapers, 
00125                     PrintWriter out,
00126                     String servletPath
00127                     ) throws JetWebException {
00128 
00129 
00130     HTMLWriter op = new HTMLWriter(out,servletPath);
00131 
00132     if (message!=null) {op.write(message);}
00133     
00134     // allow the user to select fit id 
00135     op.writeInputId("Fit ID","FITID","Get the fit with this ID.",null);     
00136     // allow the user to select model id 
00137     op.writeInputId("Model ID","MODELID","Get the model with this ID.",null);
00138 
00139     op.searchByXML();
00140 
00141     op.startForm();
00142     
00143     op.makeActionButtons();     
00144 
00145     // Now the PlotSelection
00146     HTMLPlotWriter plotOp = new HTMLPlotWriter(op.getWriter(),servletPath);
00147     plotOp.setModifiable(true);
00148     plotOp.displaySelection(null);
00149 
00150     try {
00151 
00152         op.getWriter().newLine();
00153         op.getWriter().write(HTMLUtils.writeSubmitButton("PROCESSTYPE",
00154                                  "View all the physics processes known to JetWeb",
00155                                  "View Processes"));
00156         op.getWriter().newLine();
00157         op.getWriter().write(HTMLUtils.writeSubmitButton("COLLISION",
00158                                  "View all the colliding beams known to JetWeb",
00159                                  "View Beams"));
00160         //op.getWriter().write("<input type='hidden' name='COLLISIONID' value='5'>");
00161         //op.getWriter().write("<input type='hidden' name='COLLISIONID' value='2'>");
00162         op.getWriter().newLine();
00163         op.getWriter().write(HTMLUtils.writeSubmitButton("PAPER",
00164                                  "View all the papers known to JetWeb",
00165                                  "View Papers"));
00166 
00167         op.getWriter().newLine();
00168 
00169 
00170     } catch (IOException e) {
00171         throw new JetWebException(e,"problem writing button");
00172 
00173     }
00174     op.makeRequestForm(pattern);    
00175 
00176     op.endForm();
00177     
00178     op.close();
00179 
00180     }
00181 
00182 
00183 
00187     public static void writeControlScreen(String message, 
00188                       ResultSearchPattern pattern, 
00189                       PlotSelection whichpapers, 
00190                       PrintWriter out,
00191                       String servletPath
00192                       ){
00193 
00194     // Start new page.
00195     HTMLWriter op = new HTMLWriter(out,servletPath);
00196     op.startControlForm(message);
00197     op.makeControlForm();
00198     op.close();
00199     }
00200 
00201 
00205     public static void writeJobRequestForm(String message, 
00206                        ResultSearchPattern pattern, 
00207                        PlotSelection whichpapers, 
00208                        PrintWriter out,
00209                        String servletPath
00210                        ) throws JetWebException {
00211 
00212     // Start new page.
00213     HTMLProcessWriter op = new HTMLProcessWriter(out,servletPath);
00214     op.startForm();
00215     if (message!=null) {
00216         op.write(message);
00217     }
00218     pattern.setSoftDefaults();// Set unspecified parameters to default values
00219     op.makeSubmitButtons();
00220     op.makeRequestForm(pattern);
00221     op.writeMCProcessSelector(null);
00222     op.endForm();
00223     op.close();
00224     }
00225 
00226     public static void listPendingJobs(PrintWriter out,
00227                        String servletPath
00228                        ){
00229 
00230     // Start new page.
00231     HTMLWriter op = new HTMLWriter(out,servletPath);
00232     op.startForm();
00233     op.listPendingJobs();
00234     op.endForm();
00235     //op.writeTrailer();
00236     op.close();
00237     }
00242     public static void writeParameterScreen(ResultSearchPattern pattern,
00243                         PrintWriter out, 
00244                         String servletPath,
00245                         boolean submitting) 
00246     throws JetWebException {
00247 
00248     Generator gen = pattern.getGenerator();
00249 
00250     // Start new page.
00251     HTMLGeneratorWriter op = new HTMLGeneratorWriter(out,servletPath);
00252     op.write("<p>Specify any "+gen.getName()+"-"+gen.getVersion()
00253          +" parameters to be changed.</p>");
00254     op.startForm();
00255     if (submitting){
00256         op.makeSubmitButtons();
00257     } else {
00258         op.makeActionButtons();
00259     }
00260     op.makeCommonForm(pattern);
00261     op.setModifiable(true);
00262     op.setVerbose(true);
00263     op.display(gen);
00264 
00265     op.endForm();
00266     op.close();
00267 
00268     }
00269 
00273     public static void writeSelectPlotsPage(ResultSearchPattern pattern, 
00274                         PlotSelection whichPlots, 
00275                         PrintWriter out,
00276                         String servletPath
00277                         ) throws JetWebException {
00278 
00279     // Start new page.
00280     HTMLPlotWriter op = new HTMLPlotWriter(out,servletPath);
00281     op.write("<p>Select the plots to be included in the Chi2 sum.</p>");
00282     op.startForm();
00283     op.makeActionButtons();
00284 
00285     op.setVerbose(true);
00286     op.setModifiable(true);
00287     op.displaySelection(whichPlots);
00288 
00289     op.makeRequestForm(pattern);
00290     op.endForm();
00291     op.close();
00292 
00293     }
00294 
00295 
00299     public static String writeInputBox(String name, String hover, Object obj){
00300     return writeInputTag("text",name,hover,obj);
00301     }
00305     public static String writeInputBox(String name, Object obj){
00306     return writeInputTag("text",name,null,obj);
00307     }
00308 
00315     public static String writeSubmitButton(String name, String hover, String text){
00316 
00317     return writeInputTag("submit",name,hover,text);
00318 
00319     }
00327     public static String writeInputTag(String type, String name, String hover, Object obj){
00328 
00329     int length = 5;
00330     if (obj!=null){
00331         length = obj.toString().length()+1;
00332     }
00333     StringBuffer htmlText = 
00334         new StringBuffer("<input type='"+type+"' size='"+length+"' name='"+name+"'");
00335     if (hover!=null) {
00336         htmlText.append(" title='"   +hover+"'"); 
00337     }
00338     if (obj!=null) {
00339         htmlText.append(" value='"+obj+"'");
00340     }
00341 
00342     htmlText.append(">");
00343     return htmlText.toString();
00344     }
00345 
00349     public static void displayListContinued(PrintWriter out,
00350                         String servletPath,
00351                         boolean verbose, 
00352                         String listKey) 
00353     throws JetWebException {
00354     displayListContinued(out,servletPath,verbose,false,listKey);
00355 
00356     }
00360     public static void displayListContinued(PrintWriter out,
00361                         String servletPath,
00362                         boolean verbose, boolean modifiable,
00363                         String listKey) 
00364     throws JetWebException {
00365 
00366     List<? extends Object> list = JetWebConfig.getResultList(listKey);
00367     if (list==null){
00368         throw new JetWebException("Sorry, this Search has timed out, you will have to go back and repeat",null);
00369     }
00370 
00371     HTMLWriter writer;
00372     if (list.size()>0) {
00373         writer = HTMLWriter.makeWriter(out,servletPath,list.get(0));
00374     } else {
00375         writer = new HTMLWriter(out,servletPath);
00376     }
00377     writer.setVerbose(verbose);
00378     writer.setModifiable(modifiable);
00379     writer.displayList(list);
00380     if (list.size()>0){
00381         
00382         // Terminate file.
00383         writer.endListPage(listKey);
00384 
00385     }
00386 
00387     writer.close();
00388     }
00389 
00399     public static void displayList(PrintWriter out, String servletPath, 
00400                    boolean verbose, 
00401                    List<?> list)
00402     throws JetWebException {
00403     displayList(out,servletPath,verbose,false,list);
00404     }
00405 
00416     public static void displayList(PrintWriter out, String servletPath, 
00417                    boolean verbose, boolean modifiable,
00418                    List<?> list)
00419     throws JetWebException {
00420     
00421     HTMLWriter writer;
00422     if (list.size()>0){
00423 
00424         writer = HTMLWriter.makeWriter(out,servletPath,list.get(0));
00425 
00426         if (list.size()==1) { 
00427         writer.setVerbose(true); 
00428         } else {
00429         writer.setVerbose(verbose); 
00430         }
00431 
00432         int start = list.size();
00433         int stop = 0;
00434 
00435         writer.setModifiable(modifiable);
00436 
00437         writer.displayList(list);
00438 
00439         if (list.size()>0){
00440         
00441         stop = list.size();
00442         String listKey = JetWebConfig.cacheList(list);
00443 
00444         // Terminate file.
00445         writer.endListPage(listKey);
00446 
00447         }
00448     } else {
00449         writer = new HTMLWriter(out,servletPath);
00450         writer.write("No results found");
00451     }
00452 
00453     writer.close();
00454 
00455     }
00456 
00457 
00458 }
00459 
00460 

Generated Wed Jan 17 09:14:27 GMT 2007