1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.common.ui.client.widgets.buttonlayout;
17
18 import org.kuali.student.common.ui.client.widgets.KSButton;
19
20 import com.google.gwt.user.client.ui.DockPanel;
21 import com.google.gwt.user.client.ui.HasAlignment;
22 import com.google.gwt.user.client.ui.HorizontalPanel;
23 import com.google.gwt.user.client.ui.SimplePanel;
24 import com.google.gwt.user.client.ui.Widget;
25
26 public class ButtonRow extends ButtonLayoutTwoGroups{
27 private HorizontalPanel leftPanel = new HorizontalPanel();
28 private HorizontalPanel rightPanel = new HorizontalPanel();
29 private SimplePanel contentPanel = new SimplePanel();
30 private DockPanel mainPanel = new DockPanel();
31 private Widget content = null;
32
33 public ButtonRow(){
34 setupDefaultStyles();
35 mainPanel.add(contentPanel, DockPanel.NORTH);
36 mainPanel.add(leftPanel, DockPanel.WEST);
37 mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
38 mainPanel.add(rightPanel, DockPanel.EAST);
39 this.initWidget(mainPanel);
40 }
41
42 public ButtonRow(boolean contentBottom){
43 setupDefaultStyles();
44 if(contentBottom){
45 mainPanel.add(contentPanel, DockPanel.SOUTH);
46 }
47 else{
48 mainPanel.add(contentPanel, DockPanel.NORTH);
49 }
50 mainPanel.add(leftPanel, DockPanel.WEST);
51 mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
52 mainPanel.add(rightPanel, DockPanel.EAST);
53 this.initWidget(mainPanel);
54 }
55
56 @Override
57 protected void onLoad() {
58 super.onLoad();
59 if(content != null){
60 mainPanel.setWidth(content.getOffsetWidth() + "px");
61 }
62 }
63
64 private void setupDefaultStyles(){
65 mainPanel.addStyleName("KS-Button-Row-MainPanel");
66 contentPanel.addStyleName("KS-Button-Row-ContentPanel");
67 }
68
69 @Override
70 public void setContent(Widget w) {
71 contentPanel.setWidget(w);
72 content = w;
73
74 }
75
76 @Override
77 public void addButtonToPrimaryGroup(KSButton button) {
78 leftPanel.add(button);
79 buttons.add(button);
80 }
81
82 @Override
83 public void addButtonToSecondaryGroup(KSButton button) {
84 rightPanel.add(button);
85 buttons.add(button);
86 }
87
88 @Override
89 public void addButton(KSButton button) {
90 this.addButtonToPrimaryGroup(button);
91 }
92
93 }