1 | |
package org.kuali.student.lum.program.client.widgets; |
2 | |
|
3 | |
import com.google.gwt.event.dom.client.ClickEvent; |
4 | |
import com.google.gwt.event.dom.client.ClickHandler; |
5 | |
import com.google.gwt.event.shared.HandlerManager; |
6 | |
import com.google.gwt.user.client.ui.Composite; |
7 | |
import com.google.gwt.user.client.ui.FlowPanel; |
8 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
9 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract; |
10 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
11 | |
import org.kuali.student.lum.program.client.events.ChangeViewEvent; |
12 | |
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | 0 | public class EditableHeader extends Composite { |
18 | |
|
19 | 0 | private FlowPanel content = new FlowPanel(); |
20 | |
|
21 | |
private KSLabel sectionTitle; |
22 | |
|
23 | 0 | private KSButton editButton = new KSButton(ProgramProperties.get().common_edit(), KSButtonAbstract.ButtonStyle.DEFAULT_ANCHOR); |
24 | |
|
25 | |
private Enum<?> viewToken; |
26 | |
|
27 | |
private HandlerManager eventBus; |
28 | |
|
29 | 0 | public EditableHeader(String title, Enum<?> viewToken, HandlerManager eventBus) { |
30 | 0 | initWidget(content); |
31 | 0 | this.eventBus = eventBus; |
32 | 0 | this.viewToken = viewToken; |
33 | 0 | sectionTitle = new KSLabel(title); |
34 | 0 | buildLayout(); |
35 | 0 | setStyles(); |
36 | 0 | bind(); |
37 | 0 | } |
38 | |
|
39 | |
private void bind() { |
40 | 0 | editButton.addClickHandler(new ClickHandler() { |
41 | |
@Override |
42 | |
public void onClick(ClickEvent event) { |
43 | 0 | eventBus.fireEvent(new ChangeViewEvent(viewToken)); |
44 | 0 | } |
45 | |
}); |
46 | 0 | } |
47 | |
|
48 | |
private void setStyles() { |
49 | 0 | sectionTitle.addStyleName("sectionTitle"); |
50 | 0 | content.addStyleName("editableHeader"); |
51 | 0 | editButton.addStyleName("sectionEditLink"); |
52 | 0 | } |
53 | |
|
54 | |
private void buildLayout() { |
55 | 0 | content.add(sectionTitle); |
56 | 0 | content.add(editButton); |
57 | 0 | } |
58 | |
} |