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 public class EditableHeader extends Composite {
18
19 private FlowPanel content = new FlowPanel();
20
21 private KSLabel sectionTitle;
22
23 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 public EditableHeader(String title, Enum<?> viewToken, HandlerManager eventBus) {
30 initWidget(content);
31 this.eventBus = eventBus;
32 this.viewToken = viewToken;
33 sectionTitle = new KSLabel(title);
34 buildLayout();
35 setStyles();
36 bind();
37 }
38
39 private void bind() {
40 editButton.addClickHandler(new ClickHandler() {
41 @Override
42 public void onClick(ClickEvent event) {
43 eventBus.fireEvent(new ChangeViewEvent(viewToken));
44 }
45 });
46 }
47
48 private void setStyles() {
49 sectionTitle.addStyleName("sectionTitle");
50 content.addStyleName("editableHeader");
51 editButton.addStyleName("sectionEditLink");
52 }
53
54 private void buildLayout() {
55 content.add(sectionTitle);
56 content.add(editButton);
57 }
58 }