|
@@ -1,11 +1,8 @@ |
1 |
1 |
|
package com.temp.client.foundation.widget; |
2 |
2 |
|
|
3 |
|
- |
import com.temp.shared.utils.StringUtils; |
4 |
|
- |
|
5 |
|
- |
import com.google.gwt.event.dom.client.ClickHandler; |
6 |
|
- |
import com.google.gwt.user.client.ui.HorizontalPanel; |
7 |
|
- |
import com.google.gwt.user.client.ui.Label; |
8 |
|
- |
import com.google.gwt.user.client.ui.VerticalPanel; |
|
3 |
+ |
import com.google.gwt.event.dom.client.*; |
|
4 |
+ |
import com.google.gwt.user.client.ui.*; |
|
5 |
+ |
import com.temp.shared.utils.*; |
9 |
6 |
|
|
10 |
7 |
|
public class PageHeader extends AbstractHorizontalLabeledPageWidget { |
11 |
8 |
|
private static final String PAGE_HEADER_STYLE_NAME = "page-header"; |
|
@@ -19,26 +16,26 @@ |
19 |
16 |
|
private Label bottomDescriptionLabel; |
20 |
17 |
|
|
21 |
18 |
|
public PageHeader() { |
22 |
|
- |
super(PAGE_HEADER_STYLE_NAME, TITLE_STYLE_NAME); |
|
19 |
+ |
super( PAGE_HEADER_STYLE_NAME, TITLE_STYLE_NAME ); |
23 |
20 |
|
|
24 |
|
- |
overallVerticalPanel.setWidth("100%"); |
25 |
|
- |
horizontalPanel.add(overallVerticalPanel); |
|
21 |
+ |
overallVerticalPanel.setWidth( "100%" ); |
|
22 |
+ |
horizontalPanel.add( overallVerticalPanel ); |
26 |
23 |
|
HorizontalPanel innerHorizontalPanel = new HorizontalPanel(); |
27 |
|
- |
overallVerticalPanel.add(innerHorizontalPanel); |
|
24 |
+ |
overallVerticalPanel.add( innerHorizontalPanel ); |
28 |
25 |
|
|
29 |
|
- |
innerHorizontalPanel.add(leftPanel); |
30 |
|
- |
innerHorizontalPanel.add(new LeftRightSiblings(false)); |
31 |
|
- |
innerHorizontalPanel.add(rightPanel); |
|
26 |
+ |
innerHorizontalPanel.add( leftPanel ); |
|
27 |
+ |
innerHorizontalPanel.add( new LeftRightSiblings( false ) ); |
|
28 |
+ |
innerHorizontalPanel.add( rightPanel ); |
32 |
29 |
|
|
33 |
|
- |
leftPanel.add(titleLabel); |
|
30 |
+ |
leftPanel.add( titleLabel ); |
34 |
31 |
|
} |
35 |
32 |
|
|
36 |
|
- |
public void setDescription(String description) { |
37 |
|
- |
descriptionLabel = setLabelAsDescription(leftPanel, descriptionLabel, description); |
|
33 |
+ |
public void setDescription( String description ) { |
|
34 |
+ |
descriptionLabel = setLabelAsDescription( leftPanel, descriptionLabel, description ); |
38 |
35 |
|
} |
39 |
36 |
|
|
40 |
|
- |
public void setBottomDescription(String description) { |
41 |
|
- |
bottomDescriptionLabel = setLabelAsDescription(overallVerticalPanel, bottomDescriptionLabel, description); |
|
37 |
+ |
public void setBottomDescription( String description ) { |
|
38 |
+ |
bottomDescriptionLabel = setLabelAsDescription( overallVerticalPanel, bottomDescriptionLabel, description ); |
42 |
39 |
|
} |
43 |
40 |
|
|
44 |
41 |
|
public VerticalPanel getLeftPanel() { |
|
@@ -49,15 +46,15 @@ |
49 |
46 |
|
return rightPanel; |
50 |
47 |
|
} |
51 |
48 |
|
|
52 |
|
- |
public CompositeButton addButton(String name, ClickHandler clickHandler) { |
53 |
|
- |
return addButton(new OurPushButton(name, clickHandler)); |
|
49 |
+ |
public CompositeButton addButton( String name, ClickHandler clickHandler ) { |
|
50 |
+ |
return addButton( new OurPushButton( name, clickHandler ) ); |
54 |
51 |
|
} |
55 |
52 |
|
|
56 |
|
- |
public CompositeButton addButton(CompositeButton button) { |
57 |
|
- |
if (rightPanel.getWidgetCount() > 0) { |
58 |
|
- |
rightPanel.add(new Spacer()); |
|
53 |
+ |
public CompositeButton addButton( CompositeButton button ) { |
|
54 |
+ |
if ( rightPanel.getWidgetCount() > 0 ) { |
|
55 |
+ |
rightPanel.add( new Spacer() ); |
59 |
56 |
|
} |
60 |
|
- |
rightPanel.add(button); |
|
57 |
+ |
rightPanel.add( button ); |
61 |
58 |
|
return button; |
62 |
59 |
|
} |
63 |
60 |
|
|
|
@@ -67,28 +64,28 @@ |
67 |
64 |
|
* it contains is an empty label. So if the description is null or empty, |
68 |
65 |
|
* then the label must be removed! |
69 |
66 |
|
*/ |
70 |
|
- |
private static Label setLabelAsDescription(VerticalPanel parent, Label label, String description) { |
71 |
|
- |
description = StringUtils.noEmpty(description); |
72 |
|
- |
if (description == null) { |
73 |
|
- |
return removeDescriptionLabel(parent, label); |
|
67 |
+ |
private static Label setLabelAsDescription( VerticalPanel parent, Label label, String description ) { |
|
68 |
+ |
description = StringUtils.noEmpty( description ); |
|
69 |
+ |
if ( description == null ) { |
|
70 |
+ |
return removeDescriptionLabel( parent, label ); |
74 |
71 |
|
} |
75 |
|
- |
label = insureDescriptionLabel(parent, label); |
76 |
|
- |
label.setText(description); |
|
72 |
+ |
label = insureDescriptionLabel( parent, label ); |
|
73 |
+ |
label.setText( description ); |
77 |
74 |
|
return label; |
78 |
75 |
|
} |
79 |
76 |
|
|
80 |
|
- |
private static Label insureDescriptionLabel(VerticalPanel parent, Label label) { |
81 |
|
- |
if (label == null) { |
|
77 |
+ |
private static Label insureDescriptionLabel( VerticalPanel parent, Label label ) { |
|
78 |
+ |
if ( label == null ) { |
82 |
79 |
|
label = new Label(); |
83 |
|
- |
label.setStyleName(DESCRIPTION_STYLE_NAME); |
84 |
|
- |
parent.add(label); |
|
80 |
+ |
label.setStyleName( DESCRIPTION_STYLE_NAME ); |
|
81 |
+ |
parent.add( label ); |
85 |
82 |
|
} |
86 |
83 |
|
return label; |
87 |
84 |
|
} |
88 |
85 |
|
|
89 |
|
- |
private static Label removeDescriptionLabel(VerticalPanel parent, Label label) { |
90 |
|
- |
if (label != null) { |
91 |
|
- |
parent.remove(label); |
|
86 |
+ |
private static Label removeDescriptionLabel( VerticalPanel parent, Label label ) { |
|
87 |
+ |
if ( label != null ) { |
|
88 |
+ |
parent.remove( label ); |
92 |
89 |
|
} |
93 |
90 |
|
return null; |
94 |
91 |
|
} |