View Javadoc
1   /**
2    * Copyright By Grandsoft Company Limited.  
3    * 2012-9-25 下午06:33:07
4    */
5   package gboat2.web.service.impl;
6   
7   import gboat2.base.core.util.ActionUtil;
8   import gboat2.base.core.web.BaseActionSupport;
9   import gboat2.base.core.web.SystemButtonProvider;
10  import gboat2.web.action.MetadataAction;
11  import net.sf.json.JSONArray;
12  import net.sf.json.JSONObject;
13  
14  /**
15   * 
16   * 注册web bundle中的系统级按钮提供器
17   * @author tanxw
18   * @since jdk1.6
19   * @date 2012-9-25
20   *  
21   */
22  
23  public class MetadataEditSystemButtonProviderImpl implements SystemButtonProvider {
24  	
25  	/** 
26  	  * {@inheritDoc}   
27  	  * @see gboat2.base.core.web.SystemButtonProvider#getSystemButtons(gboat2.base.core.web.BaseActionSupport, java.lang.String) 
28  	  */
29  	@Override
30  	public JSONArray getSystemButtons(BaseActionSupport action, String invokeMethod) {
31  		//所有按钮列表
32  		JSONArray jsonArr = new JSONArray();
33  		
34  		JSONObject designBtn = new JSONObject();
35  		designBtn.put("code", "design");
36  		designBtn.put("text", "设计");
37  		designBtn.put("system", true);
38  		designBtn.put("tooltip", "页面设计");
39  		designBtn.put("uri", "metadata!design.do");
40  		designBtn.put("clientValidation", false);
41  		designBtn.put("actionName",MetadataAction.class.getName());
42  		
43  		if (ActionUtil.isListPage(invokeMethod,action)) {
44  			//保存后刷新页面
45  			designBtn.put("action", "relayout");
46  			designBtn.put("icon", "static/gboat2.web/themes/default/images/shared/icons/16/cog_edit.png");
47  			designBtn.put("target", "_blank");
48  		} else if (ActionUtil.isFormPage(invokeMethod,action)) {
49  			//保存后重新加载页面
50  			designBtn.put("handler", "createNewWin");
51  		}
52  		
53  		JSONObject param = new JSONObject();
54  		param.accumulate("actionName", action.getClass().getName());
55  		param.accumulate("invokeMethod", invokeMethod);
56  		designBtn.accumulate("params", param);
57  		
58  		jsonArr.add(designBtn);
59  		return jsonArr;
60  	}
61  }