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.SimplePanel;
23 import com.google.gwt.user.client.ui.VerticalPanel;
24 import com.google.gwt.user.client.ui.Widget;
25
26 public class ButtonColumn extends ButtonLayoutTwoGroups{
27 private VerticalPanel topPanel = new VerticalPanel();
28 private VerticalPanel bottomPanel = new VerticalPanel();
29 private SimplePanel contentPanel = new SimplePanel();
30 private DockPanel mainPanel = new DockPanel();
31 private Widget content = null;
32
33 public ButtonColumn(){
34 setupDefaultStyles();
35 mainPanel.add(contentPanel, DockPanel.WEST);
36 mainPanel.add(topPanel, DockPanel.NORTH);
37 mainPanel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM);
38 mainPanel.add(bottomPanel, DockPanel.SOUTH);
39 this.initWidget(mainPanel);
40 }
41
42 public ButtonColumn(boolean contentRight){
43 setupDefaultStyles();
44 if(contentRight){
45 mainPanel.add(contentPanel, DockPanel.EAST);
46 }
47 else{
48 mainPanel.add(contentPanel, DockPanel.WEST);
49 }
50 mainPanel.add(topPanel, DockPanel.NORTH);
51 mainPanel.setVerticalAlignment(HasAlignment.ALIGN_BOTTOM);
52 mainPanel.add(bottomPanel, DockPanel.SOUTH);
53 this.initWidget(mainPanel);
54 }
55
56 private void setupDefaultStyles(){
57 mainPanel.addStyleName("KS-Button-Column-MainPanel");
58 topPanel.addStyleName("KS-Button-Column-TopPanel");
59 bottomPanel.addStyleName( "KS-Button-Column-BottomPanel");
60 contentPanel.addStyleName("KS-Button-Column-ContentPanel");
61 }
62
63 @Override
64 protected void onLoad() {
65 super.onLoad();
66 if(content != null){
67 mainPanel.setHeight(content.getOffsetHeight() + "px");
68 }
69 }
70
71 @Override
72 public void setContent(Widget w) {
73 contentPanel.setWidget(w);
74 content = w;
75 }
76
77 @Override
78 public void addButtonToPrimaryGroup(KSButton button) {
79 button.addStyleName("KS-Button-Column-Button");
80 topPanel.add(button);
81 buttons.add(button);
82 }
83
84 @Override
85 public void addButtonToSecondaryGroup(KSButton button) {
86 button.addStyleName("KS-Button-Column-Button");
87 bottomPanel.add(button);
88 buttons.add(button);
89 }
90
91 @Override
92 public void addButton(KSButton button) {
93 this.addButtonToPrimaryGroup(button);
94
95 }
96 }