Subversion Repository Public Repository

litesoft

Diff Revisions 947 vs 948 for /trunk/GWT_Sandbox/FormEngine/src/com/temp/client/foundation/widget/TabPanelNavPanel.java

Diff revisions: vs.
  @@ -1,14 +1,10 @@
1 1 package com.temp.client.foundation.widget;
2 2
3 - import java.util.Iterator;
3 + import com.google.gwt.event.dom.client.*;
4 + import com.google.gwt.user.client.ui.*;
5 + import com.google.web.bindery.event.shared.*;
4 6
5 - import com.google.gwt.event.dom.client.ClickEvent;
6 - import com.google.gwt.event.dom.client.ClickHandler;
7 - import com.google.gwt.user.client.ui.DeckPanel;
8 - import com.google.gwt.user.client.ui.HorizontalPanel;
9 - import com.google.gwt.user.client.ui.TabPanel;
10 - import com.google.gwt.user.client.ui.Widget;
11 - import com.google.web.bindery.event.shared.HandlerRegistration;
7 + import java.util.*;
12 8
13 9 /**
14 10 * By placing a TabPanelNavPanel widget inside a tabbed panel, it'd render
  @@ -27,53 +23,55 @@
27 23 private HandlerRegistration backRegistrationHandler;
28 24 private final String BUTTON_STYLE = "tab-nav-button";
29 25
30 - public TabPanelNavPanel(){
31 - next = new NamedLabel("Next >>");
32 - next.setStyleName(BUTTON_STYLE);
33 - nextRegistrationHandler = next.addClickHandler(new ClickHandler() {
26 + public TabPanelNavPanel() {
27 + next = new NamedLabel( "Next >>" );
28 + next.setStyleName( BUTTON_STYLE );
29 + nextRegistrationHandler = next.addClickHandler( new ClickHandler() {
34 30 @Override
35 - public void onClick(ClickEvent event) {
36 - if(masterTabPanel != null && tabIndex + 1 < masterTabPanel.getTabBar().getTabCount()){
37 - masterTabPanel.getTabBar().selectTab(tabIndex + 1);
31 + public void onClick( ClickEvent event ) {
32 + if ( masterTabPanel != null && tabIndex + 1 < masterTabPanel.getTabBar().getTabCount() ) {
33 + masterTabPanel.getTabBar().selectTab( tabIndex + 1 );
38 34 }
39 35 }
40 - });
36 + } );
41 37
42 - back = new NamedLabel("<< Back");
43 - back.setStyleName(BUTTON_STYLE);
44 - backRegistrationHandler = back.addClickHandler(new ClickHandler() {
38 + back = new NamedLabel( "<< Back" );
39 + back.setStyleName( BUTTON_STYLE );
40 + backRegistrationHandler = back.addClickHandler( new ClickHandler() {
45 41 @Override
46 - public void onClick(ClickEvent event) {
47 - if(masterTabPanel != null && tabIndex - 1 >= 0){
48 - masterTabPanel.getTabBar().selectTab(tabIndex - 1);
42 + public void onClick( ClickEvent event ) {
43 + if ( masterTabPanel != null && tabIndex - 1 >= 0 ) {
44 + masterTabPanel.getTabBar().selectTab( tabIndex - 1 );
49 45 }
50 46 }
51 - });
47 + } );
52 48
53 - add(back);
54 - add(new LeftRightSiblings());
55 - add(next);
49 + add( back );
50 + add( new LeftRightSiblings() );
51 + add( next );
56 52 }
57 53
58 54 /**
59 55 * Set a custom click handler for the next button
56 + *
60 57 * @param handler
61 58 */
62 - public void addNextClickHandler(ClickHandler handler){
63 - if(handler != null){
59 + public void addNextClickHandler( ClickHandler handler ) {
60 + if ( handler != null ) {
64 61 nextRegistrationHandler.removeHandler();
65 - next.addClickHandler(handler);
62 + next.addClickHandler( handler );
66 63 }
67 64 }
68 65
69 66 /**
70 67 * Set a custom click handler for the back button
68 + *
71 69 * @param handler
72 70 */
73 - public void addBackClickHandler(ClickHandler handler){
74 - if(handler != null){
71 + public void addBackClickHandler( ClickHandler handler ) {
72 + if ( handler != null ) {
75 73 backRegistrationHandler.removeHandler();
76 - back.addClickHandler(handler);
74 + back.addClickHandler( handler );
77 75 }
78 76 }
79 77
  @@ -87,40 +85,40 @@
87 85 // index which this nav panel is in
88 86 Widget tab = null;
89 87 Widget parent = getParent();
90 - while(parent != null){
91 - if(parent instanceof TabPanel){
88 + while ( parent != null ) {
89 + if ( parent instanceof TabPanel ) {
92 90 masterTabPanel = (TabPanel) parent;
93 91 break;
94 - }else if(parent.getParent() != null && parent.getParent() instanceof DeckPanel){
92 + } else if ( parent.getParent() != null && parent.getParent() instanceof DeckPanel ) {
95 93 tab = parent;
96 94 }
97 95
98 96 parent = parent.getParent();
99 97 }
100 98
101 - if(masterTabPanel != null && tab != null){
99 + if ( masterTabPanel != null && tab != null ) {
102 100 Iterator<Widget> widgets = masterTabPanel.iterator();
103 101 int wIndex = 0;
104 - while(widgets.hasNext()){
102 + while ( widgets.hasNext() ) {
105 103 Widget w = widgets.next();
106 - if(w == tab){
104 + if ( w == tab ) {
107 105 tabIndex = wIndex;
108 106 break;
109 107 }
110 108 wIndex++;
111 109 }
112 110
113 - if(tabIndex == 0){
114 - back.setVisible(false);
111 + if ( tabIndex == 0 ) {
112 + back.setVisible( false );
115 113 }
116 114 }
117 115
118 116 // Hide the button if necessary
119 - if(hideNextButton){
120 - next.setVisible(false);
117 + if ( hideNextButton ) {
118 + next.setVisible( false );
121 119 }
122 - if(hideBackButton){
123 - back.setVisible(false);
120 + if ( hideBackButton ) {
121 + back.setVisible( false );
124 122 }
125 123 }
126 124
  @@ -128,7 +126,7 @@
128 126 return hideNextButton;
129 127 }
130 128
131 - public void setHideNextButton(boolean hideNextButton) {
129 + public void setHideNextButton( boolean hideNextButton ) {
132 130 this.hideNextButton = hideNextButton;
133 131 }
134 132
  @@ -136,7 +134,7 @@
136 134 return hideBackButton;
137 135 }
138 136
139 - public void setHideBackButton(boolean hideBackButton) {
137 + public void setHideBackButton( boolean hideBackButton ) {
140 138 this.hideBackButton = hideBackButton;
141 139 }
142 140 }