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 | |
|
9 | |
import org.kuali.student.common.ui.client.application.Application; |
10 | |
import org.kuali.student.common.ui.client.widgets.KSButton; |
11 | |
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract; |
12 | |
import org.kuali.student.common.ui.client.widgets.KSLabel; |
13 | |
import org.kuali.student.lum.program.client.ProgramMsgConstants; |
14 | |
import org.kuali.student.lum.program.client.events.ChangeViewEvent; |
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | 0 | public class EditableHeader extends Composite { |
20 | |
|
21 | 0 | private FlowPanel content = new FlowPanel(); |
22 | |
|
23 | |
private KSLabel sectionTitle; |
24 | |
|
25 | 0 | private KSButton editButton = new KSButton(getLabel(ProgramMsgConstants.COMMON_EDIT), KSButtonAbstract.ButtonStyle.DEFAULT_ANCHOR); |
26 | |
|
27 | |
private Enum<?> viewToken; |
28 | |
|
29 | |
private HandlerManager eventBus; |
30 | |
|
31 | 0 | public EditableHeader(String title, Enum<?> viewToken, HandlerManager eventBus) { |
32 | 0 | initWidget(content); |
33 | 0 | this.eventBus = eventBus; |
34 | 0 | this.viewToken = viewToken; |
35 | 0 | sectionTitle = new KSLabel(title); |
36 | 0 | buildLayout(); |
37 | 0 | setStyles(); |
38 | 0 | bind(); |
39 | 0 | } |
40 | |
|
41 | |
private void bind() { |
42 | 0 | editButton.addClickHandler(new ClickHandler() { |
43 | |
@Override |
44 | |
public void onClick(ClickEvent event) { |
45 | 0 | eventBus.fireEvent(new ChangeViewEvent(viewToken)); |
46 | 0 | } |
47 | |
}); |
48 | 0 | } |
49 | |
|
50 | |
private void setStyles() { |
51 | 0 | sectionTitle.addStyleName("sectionTitle"); |
52 | 0 | content.addStyleName("editableHeader"); |
53 | 0 | editButton.addStyleName("sectionEditLink"); |
54 | 0 | } |
55 | |
|
56 | |
private void buildLayout() { |
57 | 0 | content.add(sectionTitle); |
58 | 0 | content.add(editButton); |
59 | 0 | } |
60 | |
|
61 | |
protected String getLabel(String messageKey) { |
62 | 0 | return Application.getApplicationContext().getUILabel(ProgramMsgConstants.PROGRAM_MSG_GROUP, messageKey); |
63 | |
} |
64 | |
} |