1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package org.gwe.app.client.web.view;
18  
19  import java.util.List;
20  
21  import org.gwe.GWEAppContext;
22  import org.gwe.p2elv2.model.PVariable;
23  import org.gwe.utils.web.HtmlLink;
24  import org.gwe.utils.web.HtmlTable;
25  import org.gwe.utils.web.HtmlTableCell;
26  
27  
28  
29  
30  
31  public class HtmlPVarTable extends HtmlTable {
32  	
33  	public HtmlPVarTable(List<PVariable> vars) {
34  	    super("Variable", "Value Generator", "Parameters");
35  	    if (vars == null) return;
36  		for (PVariable var : vars) {
37  	        String params = var.getFunctionInvocation().getParams().toString();
38  	        params = params.substring(1, params.length() - 1);
39  	        String functionName = var.getFunctionInvocation().getFunctionName();
40  	        
41  	        boolean isFunction = GWEAppContext.getP2ELFunctionNames().contains(functionName);
42  	        String caption = new StringBuffer(functionName).append(" (").append(isFunction ? "function" : "macro").append(")").toString();
43  	        
44  			HtmlTableCell function = new HtmlTableCell(caption, "", getURLLink(functionName, isFunction));
45  			addRow(var.getFullName(), function, params);
46          }
47      }
48  
49  	private HtmlLink getURLLink(String functionName, boolean isFunction) {
50  	    String baseURL = isFunction ? "http://www.gridwizardenterprise.org/guides/p2el-semantics.html" : "grid?expanded=true";
51  		String url = new StringBuffer(baseURL).append("#").append(functionName).toString();
52  		return new HtmlLink(isFunction, url);
53      }
54  }