View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.common.ui.client.configurable.mvc.sections;
17  
18  import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
19  import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityItem;
20  import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityComposite.StyleType;
21  
22  import com.google.gwt.event.dom.client.ClickEvent;
23  import com.google.gwt.event.dom.client.ClickHandler;
24  import com.google.gwt.user.client.ui.FlowPanel;
25  
26  /**
27   * @deprecated
28   */
29  @Deprecated
30  public class RemovableItemWithHeader extends MultiplicityItem{
31  
32  	private MultiplicityHeader header;
33  	private FlowPanel layout = new FlowPanel();
34  	private FlowPanel body = new FlowPanel();
35  	private StyleType style;
36  	private String itemLabel;
37      private boolean readOnly=false;
38  	private boolean loaded = false;
39  	
40  	
41      public void isReadOnly(boolean readOnly){
42          this.readOnly=readOnly;
43      }
44  
45  	public void setReadOnly(boolean readOnly) {
46  		this.readOnly = readOnly;
47  	}
48  	
49  	public RemovableItemWithHeader(StyleType style){
50  		this.style = style;
51  		this.initWidget(layout);
52  		
53  	}
54  	
55  	public RemovableItemWithHeader(StyleType style, boolean readOnly){
56  		this.style = style;
57  		this.readOnly = readOnly;
58  		this.initWidget(layout);
59  		
60  	}
61  	
62  	@Override
63  	public void clear() {
64          loaded = false;
65  		
66  	}
67  	
68      public void setItemLabel(String itemLabel) {
69          this.itemLabel = itemLabel;
70      }
71  
72  	@Override
73  	public void redraw() {
74  		if (!loaded){
75  			layout.clear();
76  	    	if(style == StyleType.TOP_LEVEL){
77  	    		SectionTitle title = SectionTitle.generateH4Title(itemLabel);
78  	    		title.addStyleName("ks-form-bordered-header-title");
79  	    		header = new MultiplicityHeader(title, readOnly);
80  	    		header.setStyleName("ks-form-bordered-header");
81  	    		layout.setStyleName("ks-form-bordered");
82  	    		body.setStyleName("ks-form-bordered-body");
83  	    	}
84  	    	else if(style == StyleType.SUB_LEVEL){
85  	    		SectionTitle title = SectionTitle.generateH5Title(itemLabel);
86  	    		title.addStyleName("ks-form-course-format-activity-header-title");
87  	    		header = new MultiplicityHeader(title, readOnly);
88  	    		header.setStyleName("ks-form-course-format-activity-header");
89  	    		layout.setStyleName("ks-form-course-format-activity");
90  	    	}
91  	    	
92  	    	//This check is to disable delete of items in case of readonly mode.
93  	    	if(!readOnly){
94  	    	    header.addDeleteHandler(new ClickHandler() {
95  	                public void onClick(ClickEvent event) {
96  	                    getRemoveCallback().exec(RemovableItemWithHeader.this);
97  	                }
98  	            });
99  	    	}
100 	    	
101 	    	layout.add(header);
102 	    	body.add(this.getItemWidget());
103 	    	layout.add(body);
104 		}
105 		
106 /*        if (this.getItemWidget() instanceof Section){
107             ((Section)this.getItemWidget()).redraw();
108         }*/
109 		
110 	}
111 
112 }