Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/view/ScreenView.java

Diff revisions: vs.
  @@ -1,344 +1,344 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client.view;
3 -
4 - import org.litesoft.GWT.client.*;
5 - import org.litesoft.GWT.client.command.*;
6 - import org.litesoft.GWT.client.context.*;
7 - import org.litesoft.GWT.client.dev.*;
8 - import org.litesoft.GWT.client.widgets.*;
9 - import org.litesoft.commonfoundation.base.*;
10 - import org.litesoft.commonfoundation.typeutils.*;
11 - import org.litesoft.core.*;
12 - import org.litesoft.uispecification.*;
13 -
14 - import com.google.gwt.event.dom.client.*;
15 - import com.google.gwt.user.client.*;
16 - import com.google.gwt.user.client.ui.*;
17 -
18 - import java.util.*;
19 -
20 - public abstract class ScreenView extends UiView implements PageRefreshable,
21 - SuspendLogoutCallBacks {
22 - public interface TitleCustomizer {
23 - void addTitleCustomizations( ScreenView pView );
24 - }
25 -
26 - private static TitleCustomizer sTitleCustomizer;
27 -
28 - public static void setTitleCustomizer( TitleCustomizer pTitleCustomizer ) {
29 - sTitleCustomizer = pTitleCustomizer;
30 - }
31 -
32 - private static boolean sOpenApp = false; // True would mean NO User Login / Management
33 -
34 - public static boolean isOpenApp() {
35 - return sOpenApp;
36 - }
37 -
38 - public static void setOpenApp( boolean pOpenApp ) {
39 - sOpenApp = pOpenApp;
40 - }
41 -
42 - private LeftCenterRightHorizontalPanel mTopBar = new LeftCenterRightHorizontalPanel().style( "TopBar" );
43 -
44 - private SimpleLabel mTitleLabel = null;
45 -
46 - protected ScreenView( CO pCO ) {
47 - super( pCO );
48 - mTopBar.addRight( new Spacer( 5 ).style( "CACHE_BUG" ) );
49 -
50 - if ( hasViewTitle() ) {
51 - updateTitle();
52 - }
53 -
54 - PageRefreshableProxy zRefreshableProxy = ClientContext.get().checkGet( PageRefreshableProxy.class );
55 - if ( zRefreshableProxy != null ) {
56 - zRefreshableProxy.setProxyTo( this );
57 - }
58 - }
59 -
60 - @Override
61 - public Widget getContent() {
62 - return mContent;
63 - }
64 -
65 - public Widget getTopBar() {
66 - return mTopBar;
67 - }
68 -
69 - protected void add( Widget pWidget ) {
70 - mContent.add( pWidget );
71 - }
72 -
73 - protected void addSectionTitle( String pText ) {
74 - add( createSectionTitle( pText ) );
75 - }
76 -
77 - protected void addSectionTitle( OurLabel pLabel ) {
78 - add( createSectionTitle( pLabel ) );
79 - }
80 -
81 - protected void setLeftValign( HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
82 - mTopBar.setLeftValign( pValign );
83 - }
84 -
85 - protected HorizontalPanel getLeftContainer() {
86 - return mTopBar.getLeftContainer();
87 - }
88 -
89 - protected void addLeft( Widget pWidget ) {
90 - mTopBar.addLeft( pWidget );
91 - }
92 -
93 - protected void setCenterValign( HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
94 - mTopBar.setCenterValign( pValign );
95 - }
96 -
97 - protected HorizontalPanel getCenterContainer() {
98 - return mTopBar.getCenterContainer();
99 - }
100 -
101 - protected void addCenter( Widget pWidget ) {
102 - mTopBar.addCenter( pWidget );
103 - }
104 -
105 - protected void setRightValign( HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
106 - mTopBar.setRightValign( pValign );
107 - }
108 -
109 - protected HorizontalPanel getRightContainer() {
110 - return mTopBar.getRightContainer();
111 - }
112 -
113 - protected void addRight( Widget pWidget ) {
114 - mTopBar.addRight( pWidget );
115 - }
116 -
117 - protected void addStandardTitleBar() {
118 - styleTitleBar();
119 - if ( !isHomeScreen() ) {
120 - addHome();
121 - }
122 - if ( sTitleCustomizer != null ) {
123 - sTitleCustomizer.addTitleCustomizations( this );
124 - }
125 - addQuickLinkRightButtons();
126 - if ( !sOpenApp ) {
127 - addLogout();
128 - }
129 - }
130 -
131 - protected void addQuickLinkRightButtons() {
132 - Widget[] zWidgets = getQuickLinkRightButtons();
133 - if ( zWidgets != null ) {
134 - for ( Widget zWidget : zWidgets ) {
135 - if ( zWidget != null ) {
136 - addRight( zWidget );
137 - }
138 - }
139 - }
140 - }
141 -
142 - protected Widget[] getQuickLinkRightButtons() {
143 - QuickLinkRightButtonsHandler zHandler = ClientContext.get().checkGet( QuickLinkRightButtonsHandler.class );
144 - return (zHandler != null) ? zHandler.getQuickLinkRightButtons( this ) : null;
145 - }
146 -
147 - protected void styleTitleBar() {
148 - styleTitleBar( "TitleBar" );
149 - }
150 -
151 - protected void styleTitleBar( String pStyle ) {
152 - mTopBar.addStyleName( pStyle );
153 - }
154 -
155 - protected void addHome() {
156 - addLeft( HomeButton.factory().add( ViewDef.HOME ).create() );
157 - }
158 -
159 - protected boolean isHomeScreen() {
160 - return "Home".equals( ClassName.simple( this ) );
161 - }
162 -
163 - protected void addTitle( String pTitle ) {
164 - setViewTitle( pTitle );
165 - updateTitle();
166 - }
167 -
168 - private void updateTitle() {
169 - if ( mTitleLabel == null ) {
170 - addCenter( mTitleLabel = new SimpleLabel( getViewTitle() ).style( "Title" ) );
171 - } else {
172 - mTitleLabel.setText( getViewTitle() );
173 - }
174 - }
175 -
176 - protected void addLogout( ClickHandler pClickHandler ) {
177 - addRight( LogoutBlueIconButton.factory().add( pClickHandler ).create() );
178 - }
179 -
180 - protected void addLogout() {
181 - addLogout( new ClickHandler() {
182 - @Override
183 - public void onClick( ClickEvent event ) {
184 - logoutButtonClicked();
185 - }
186 - } );
187 - }
188 -
189 - protected void logoutButtonClicked() {
190 - if ( UtilsGwt.wasCtrlKeyDownOnCurrentEvent() && Dev.isDevMode() && isHomeScreen() ) {
191 - NextDemoUserRequestHandler zHandler = ClientContext.get().get( NextDemoUserRequestHandler.class );
192 - if ( zHandler != null ) {
193 - zHandler.nextDemoUser();
194 - return;
195 - }
196 - }
197 - if ( UtilsGwt.wasAltKeyDownOnCurrentEvent() ) {
198 - switchUserRequested();
199 - } else {
200 - logoutRequested();
201 - }
202 - }
203 -
204 - protected void switchUserRequested() {
205 - new DialogViewDialog( ClientContext.get().get( LoginDialogViewFactory.class ).createDialog( true, createLoginOnSuccessCommand() ) ).show();
206 - }
207 -
208 - protected void logoutRequested() {
209 - new LogoutSuspendDialog( this, this ).show();
210 - }
211 -
212 - @Override
213 - public void logoutConfirmed() {
214 - ClientContext.get().get( SecurityUserViewDataProvider.class ).logoutUser();
215 - new ShowScreenCommand( ViewDef.HOME ).execute();
216 - }
217 -
218 - @Override
219 - public void suspendRequested() {
220 - new DialogViewDialog( ClientContext.get().get( SuspendDialogViewFactory.class ).createDialog( this ) ).show();
221 - }
222 -
223 - private Command createLoginOnSuccessCommand() {
224 - return new Command() {
225 - @Override
226 - public void execute() {
227 - refreshPage();
228 - }
229 - };
230 - }
231 -
232 - @Override
233 - public void refreshPage() {
234 - if ( mViewDef == null ) {
235 - new ShowScreenCommand( ViewDef.HOME ).execute();
236 - } else {
237 - new ShowScreenCommand( mViewDef, createRefreshParams() ).execute();
238 - }
239 - }
240 -
241 - abstract protected UriFragmentIdParams createRefreshParams();
242 -
243 - protected Widget addVerticallyDistributed( Widget... pWidgets ) {
244 - return addVerticallyDistributed( Arrays.asList( pWidgets ) );
245 - }
246 -
247 - protected Widget addVerticallyDistributed( List<Widget> pWidgets ) {
248 - SizeableVerticalPanel zPanel = new SizeableVerticalPanel().stretchable();
249 - zPanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
250 - zPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
251 -
252 - for ( Widget zWidget : pWidgets ) {
253 - if ( zWidget != null ) {
254 - zPanel.add( new SizeableSpacer().stretchable() );
255 - zPanel.add( zWidget );
256 - }
257 - }
258 - zPanel.add( new SizeableSpacer().stretchable() );
259 - return zPanel;
260 - }
261 -
262 - protected Widget viewStandIn() {
263 - String zTitle = getViewTitle();
264 - zTitle = Strings.replace( zTitle, ": ", "+" );
265 - zTitle = Strings.replace( zTitle, ":", "+" );
266 - zTitle = Strings.replace( zTitle, " ", "+" );
267 - return new SizeableFrame( "http://www.google.com/search?q=" + zTitle );
268 - }
269 -
270 - protected abstract class BigButtonScreenHelper {
271 - protected ViewFactoryAccessor mViewFactoryAccessor = ClientContext.get().get( ViewFactoryAccessor.class );
272 -
273 - abstract public Widget build();
274 -
275 - protected Widget createSection( String pTitle, ViewDef... pDefs ) {
276 - return createSection( pTitle, null, pDefs );
277 - }
278 -
279 - protected Widget createSection( String pTitle, Widget pExtraButton, ViewDef... pDefs ) {
280 - return createSection( pTitle, createButtons( pExtraButton, pDefs ) );
281 - }
282 -
283 - protected Widget createSection( String pTitle, SizeableHorizontalPanel pButtonPanel ) {
284 - if ( (pButtonPanel == null) || Strings.isNullOrEmpty( pTitle ) ) {
285 - return pButtonPanel;
286 - }
287 - SizeableVerticalPanel zVpanel = new SizeableVerticalPanel().stretchableHorizontally();
288 - zVpanel.add( createSectionTitle( pTitle ) );
289 - zVpanel.add( pButtonPanel );
290 - return zVpanel;
291 - }
292 -
293 - protected SizeableHorizontalPanel createButtons( Widget pExtraButton, ViewDef... pDefs ) {
294 - return createButtons( pExtraButton, Arrays.asList( pDefs ) );
295 - }
296 -
297 - protected SizeableHorizontalPanel createButtons( Widget pExtraButton, List<ViewDef> pDefs ) {
298 - List<Widget> zButtons = new ArrayList<Widget>();
299 - for ( ViewDef zDef : pDefs ) {
300 - Widget zButton = createButton( zDef );
301 - if ( zButton != null ) {
302 - zButtons.add( zButton );
303 - }
304 - }
305 - if ( pExtraButton != null ) {
306 - zButtons.add( pExtraButton );
307 - }
308 - return createButtons( zButtons );
309 - }
310 -
311 - protected SizeableHorizontalPanel createButtons( List<Widget> pButtons ) {
312 - if ( (pButtons == null) || pButtons.isEmpty() ) {
313 - return null;
314 - }
315 -
316 - SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally().style( "Buttons" );
317 - zPanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
318 - zPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
319 -
320 - zPanel.add( new SizeableSpacer().stretchable() );
321 - for ( Widget zButton : pButtons ) {
322 - zPanel.add( zButton );
323 - zPanel.add( new SizeableSpacer().stretchable() );
324 - }
325 - return zPanel;
326 - }
327 -
328 - protected Widget createButton( ViewDef pViewDef ) {
329 - ViewFactory zFactory = mViewFactoryAccessor.getViewFactory( pViewDef );
330 - if ( zFactory instanceof ScreenViewFactory ) {
331 - return createScreenButton( pViewDef );
332 - }
333 - if ( zFactory instanceof DialogViewFactory ) {
334 - return ScreenBigButton.factory( pViewDef.getUiString() ).add( new ShowDialogCommand( pViewDef ) ).create();
335 - }
336 - if ( zFactory == ViewFactory.NO_ACCESS ) {
337 - return null;
338 - }
339 - return ScreenBigButton.factory( pViewDef.getUiString() ).disabled().create();
340 - }
341 -
342 - abstract protected Widget createScreenButton( ViewDef pViewDef );
343 - }
344 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client.view;
3 +
4 + import org.litesoft.GWT.client.*;
5 + import org.litesoft.GWT.client.command.*;
6 + import org.litesoft.GWT.client.context.*;
7 + import org.litesoft.GWT.client.dev.*;
8 + import org.litesoft.GWT.client.widgets.*;
9 + import org.litesoft.commonfoundation.base.*;
10 + import org.litesoft.commonfoundation.typeutils.*;
11 + import org.litesoft.core.*;
12 + import org.litesoft.uispecification.*;
13 +
14 + import com.google.gwt.event.dom.client.*;
15 + import com.google.gwt.user.client.*;
16 + import com.google.gwt.user.client.ui.*;
17 +
18 + import java.util.*;
19 +
20 + public abstract class ScreenView extends UiView implements PageRefreshable,
21 + SuspendLogoutCallBacks {
22 + public interface TitleCustomizer {
23 + void addTitleCustomizations( ScreenView pView );
24 + }
25 +
26 + private static TitleCustomizer sTitleCustomizer;
27 +
28 + public static void setTitleCustomizer( TitleCustomizer pTitleCustomizer ) {
29 + sTitleCustomizer = pTitleCustomizer;
30 + }
31 +
32 + private static boolean sOpenApp = false; // True would mean NO User Login / Management
33 +
34 + public static boolean isOpenApp() {
35 + return sOpenApp;
36 + }
37 +
38 + public static void setOpenApp( boolean pOpenApp ) {
39 + sOpenApp = pOpenApp;
40 + }
41 +
42 + private LeftCenterRightHorizontalPanel mTopBar = new LeftCenterRightHorizontalPanel().style( "TopBar" );
43 +
44 + private SimpleLabel mTitleLabel = null;
45 +
46 + protected ScreenView( CO pCO ) {
47 + super( pCO );
48 + mTopBar.addRight( new Spacer( 5 ).style( "CACHE_BUG" ) );
49 +
50 + if ( hasViewTitle() ) {
51 + updateTitle();
52 + }
53 +
54 + PageRefreshableProxy zRefreshableProxy = ClientContext.get().checkGet( PageRefreshableProxy.class );
55 + if ( zRefreshableProxy != null ) {
56 + zRefreshableProxy.setProxyTo( this );
57 + }
58 + }
59 +
60 + @Override
61 + public Widget getContent() {
62 + return mContent;
63 + }
64 +
65 + public Widget getTopBar() {
66 + return mTopBar;
67 + }
68 +
69 + protected void add( Widget pWidget ) {
70 + mContent.add( pWidget );
71 + }
72 +
73 + protected void addSectionTitle( String pText ) {
74 + add( createSectionTitle( pText ) );
75 + }
76 +
77 + protected void addSectionTitle( OurLabel pLabel ) {
78 + add( createSectionTitle( pLabel ) );
79 + }
80 +
81 + protected void setLeftValign( HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
82 + mTopBar.setLeftValign( pValign );
83 + }
84 +
85 + protected HorizontalPanel getLeftContainer() {
86 + return mTopBar.getLeftContainer();
87 + }
88 +
89 + protected void addLeft( Widget pWidget ) {
90 + mTopBar.addLeft( pWidget );
91 + }
92 +
93 + protected void setCenterValign( HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
94 + mTopBar.setCenterValign( pValign );
95 + }
96 +
97 + protected HorizontalPanel getCenterContainer() {
98 + return mTopBar.getCenterContainer();
99 + }
100 +
101 + protected void addCenter( Widget pWidget ) {
102 + mTopBar.addCenter( pWidget );
103 + }
104 +
105 + protected void setRightValign( HasVerticalAlignment.VerticalAlignmentConstant pValign ) {
106 + mTopBar.setRightValign( pValign );
107 + }
108 +
109 + protected HorizontalPanel getRightContainer() {
110 + return mTopBar.getRightContainer();
111 + }
112 +
113 + protected void addRight( Widget pWidget ) {
114 + mTopBar.addRight( pWidget );
115 + }
116 +
117 + protected void addStandardTitleBar() {
118 + styleTitleBar();
119 + if ( !isHomeScreen() ) {
120 + addHome();
121 + }
122 + if ( sTitleCustomizer != null ) {
123 + sTitleCustomizer.addTitleCustomizations( this );
124 + }
125 + addQuickLinkRightButtons();
126 + if ( !sOpenApp ) {
127 + addLogout();
128 + }
129 + }
130 +
131 + protected void addQuickLinkRightButtons() {
132 + Widget[] zWidgets = getQuickLinkRightButtons();
133 + if ( zWidgets != null ) {
134 + for ( Widget zWidget : zWidgets ) {
135 + if ( zWidget != null ) {
136 + addRight( zWidget );
137 + }
138 + }
139 + }
140 + }
141 +
142 + protected Widget[] getQuickLinkRightButtons() {
143 + QuickLinkRightButtonsHandler zHandler = ClientContext.get().checkGet( QuickLinkRightButtonsHandler.class );
144 + return (zHandler != null) ? zHandler.getQuickLinkRightButtons( this ) : null;
145 + }
146 +
147 + protected void styleTitleBar() {
148 + styleTitleBar( "TitleBar" );
149 + }
150 +
151 + protected void styleTitleBar( String pStyle ) {
152 + mTopBar.addStyleName( pStyle );
153 + }
154 +
155 + protected void addHome() {
156 + addLeft( HomeButton.factory().add( ViewDef.HOME ).create() );
157 + }
158 +
159 + protected boolean isHomeScreen() {
160 + return "Home".equals( ClassName.simple( this ) );
161 + }
162 +
163 + protected void addTitle( String pTitle ) {
164 + setViewTitle( pTitle );
165 + updateTitle();
166 + }
167 +
168 + private void updateTitle() {
169 + if ( mTitleLabel == null ) {
170 + addCenter( mTitleLabel = new SimpleLabel( getViewTitle() ).style( "Title" ) );
171 + } else {
172 + mTitleLabel.setText( getViewTitle() );
173 + }
174 + }
175 +
176 + protected void addLogout( ClickHandler pClickHandler ) {
177 + addRight( LogoutBlueIconButton.factory().add( pClickHandler ).create() );
178 + }
179 +
180 + protected void addLogout() {
181 + addLogout( new ClickHandler() {
182 + @Override
183 + public void onClick( ClickEvent event ) {
184 + logoutButtonClicked();
185 + }
186 + } );
187 + }
188 +
189 + protected void logoutButtonClicked() {
190 + if ( UtilsGwt.wasCtrlKeyDownOnCurrentEvent() && Dev.isDevMode() && isHomeScreen() ) {
191 + NextDemoUserRequestHandler zHandler = ClientContext.get().get( NextDemoUserRequestHandler.class );
192 + if ( zHandler != null ) {
193 + zHandler.nextDemoUser();
194 + return;
195 + }
196 + }
197 + if ( UtilsGwt.wasAltKeyDownOnCurrentEvent() ) {
198 + switchUserRequested();
199 + } else {
200 + logoutRequested();
201 + }
202 + }
203 +
204 + protected void switchUserRequested() {
205 + new DialogViewDialog( ClientContext.get().get( LoginDialogViewFactory.class ).createDialog( true, createLoginOnSuccessCommand() ) ).show();
206 + }
207 +
208 + protected void logoutRequested() {
209 + new LogoutSuspendDialog( this, this ).show();
210 + }
211 +
212 + @Override
213 + public void logoutConfirmed() {
214 + ClientContext.get().get( SecurityUserViewDataProvider.class ).logoutUser();
215 + new ShowScreenCommand( ViewDef.HOME ).execute();
216 + }
217 +
218 + @Override
219 + public void suspendRequested() {
220 + new DialogViewDialog( ClientContext.get().get( SuspendDialogViewFactory.class ).createDialog( this ) ).show();
221 + }
222 +
223 + private Command createLoginOnSuccessCommand() {
224 + return new Command() {
225 + @Override
226 + public void execute() {
227 + refreshPage();
228 + }
229 + };
230 + }
231 +
232 + @Override
233 + public void refreshPage() {
234 + if ( mViewDef == null ) {
235 + new ShowScreenCommand( ViewDef.HOME ).execute();
236 + } else {
237 + new ShowScreenCommand( mViewDef, createRefreshParams() ).execute();
238 + }
239 + }
240 +
241 + abstract protected UriFragmentIdParams createRefreshParams();
242 +
243 + protected Widget addVerticallyDistributed( Widget... pWidgets ) {
244 + return addVerticallyDistributed( Arrays.asList( pWidgets ) );
245 + }
246 +
247 + protected Widget addVerticallyDistributed( List<Widget> pWidgets ) {
248 + SizeableVerticalPanel zPanel = new SizeableVerticalPanel().stretchable();
249 + zPanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
250 + zPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
251 +
252 + for ( Widget zWidget : pWidgets ) {
253 + if ( zWidget != null ) {
254 + zPanel.add( new SizeableSpacer().stretchable() );
255 + zPanel.add( zWidget );
256 + }
257 + }
258 + zPanel.add( new SizeableSpacer().stretchable() );
259 + return zPanel;
260 + }
261 +
262 + protected Widget viewStandIn() {
263 + String zTitle = getViewTitle();
264 + zTitle = Strings.replace( zTitle, ": ", "+" );
265 + zTitle = Strings.replace( zTitle, ":", "+" );
266 + zTitle = Strings.replace( zTitle, " ", "+" );
267 + return new SizeableFrame( "http://www.google.com/search?q=" + zTitle );
268 + }
269 +
270 + protected abstract class BigButtonScreenHelper {
271 + protected ViewFactoryAccessor mViewFactoryAccessor = ClientContext.get().get( ViewFactoryAccessor.class );
272 +
273 + abstract public Widget build();
274 +
275 + protected Widget createSection( String pTitle, ViewDef... pDefs ) {
276 + return createSection( pTitle, null, pDefs );
277 + }
278 +
279 + protected Widget createSection( String pTitle, Widget pExtraButton, ViewDef... pDefs ) {
280 + return createSection( pTitle, createButtons( pExtraButton, pDefs ) );
281 + }
282 +
283 + protected Widget createSection( String pTitle, SizeableHorizontalPanel pButtonPanel ) {
284 + if ( (pButtonPanel == null) || Currently.isNullOrEmpty( pTitle ) ) {
285 + return pButtonPanel;
286 + }
287 + SizeableVerticalPanel zVpanel = new SizeableVerticalPanel().stretchableHorizontally();
288 + zVpanel.add( createSectionTitle( pTitle ) );
289 + zVpanel.add( pButtonPanel );
290 + return zVpanel;
291 + }
292 +
293 + protected SizeableHorizontalPanel createButtons( Widget pExtraButton, ViewDef... pDefs ) {
294 + return createButtons( pExtraButton, Arrays.asList( pDefs ) );
295 + }
296 +
297 + protected SizeableHorizontalPanel createButtons( Widget pExtraButton, List<ViewDef> pDefs ) {
298 + List<Widget> zButtons = new ArrayList<Widget>();
299 + for ( ViewDef zDef : pDefs ) {
300 + Widget zButton = createButton( zDef );
301 + if ( zButton != null ) {
302 + zButtons.add( zButton );
303 + }
304 + }
305 + if ( pExtraButton != null ) {
306 + zButtons.add( pExtraButton );
307 + }
308 + return createButtons( zButtons );
309 + }
310 +
311 + protected SizeableHorizontalPanel createButtons( List<Widget> pButtons ) {
312 + if ( (pButtons == null) || pButtons.isEmpty() ) {
313 + return null;
314 + }
315 +
316 + SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally().style( "Buttons" );
317 + zPanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
318 + zPanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
319 +
320 + zPanel.add( new SizeableSpacer().stretchable() );
321 + for ( Widget zButton : pButtons ) {
322 + zPanel.add( zButton );
323 + zPanel.add( new SizeableSpacer().stretchable() );
324 + }
325 + return zPanel;
326 + }
327 +
328 + protected Widget createButton( ViewDef pViewDef ) {
329 + ViewFactory zFactory = mViewFactoryAccessor.getViewFactory( pViewDef );
330 + if ( zFactory instanceof ScreenViewFactory ) {
331 + return createScreenButton( pViewDef );
332 + }
333 + if ( zFactory instanceof DialogViewFactory ) {
334 + return ScreenBigButton.factory( pViewDef.getUiString() ).add( new ShowDialogCommand( pViewDef ) ).create();
335 + }
336 + if ( zFactory == ViewFactory.NO_ACCESS ) {
337 + return null;
338 + }
339 + return ScreenBigButton.factory( pViewDef.getUiString() ).disabled().create();
340 + }
341 +
342 + abstract protected Widget createScreenButton( ViewDef pViewDef );
343 + }
344 + }