Subversion Repository Public Repository

litesoft

Diff Revisions 486 vs 487 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/view/UiView.java

Diff revisions: vs.
  @@ -20,6 +20,8 @@
20 20 import com.google.gwt.event.dom.client.*;
21 21 import com.google.gwt.user.client.ui.*;
22 22
23 + import static org.litesoft.uispecification.FormWidgetCtrl.*;
24 +
23 25 public abstract class UiView
24 26 {
25 27 public static final Logger LOGGER = LoggerFactory.getLogger( UiView.class );
  @@ -53,32 +55,11 @@
53 55
54 56 }
55 57
56 - protected UiView()
57 - {
58 - }
59 -
60 - protected UiView( String pViewTitle )
61 - {
62 - this();
63 - setViewTitle( pViewTitle );
64 - }
65 -
66 - protected UiView( ViewDef pViewDef )
67 - {
68 - this();
69 - setViewTitle( (mViewDef = pViewDef).getUiString() );
70 - }
71 -
72 - protected UiView( String pSection, ViewDef pViewDef )
73 - {
74 - this();
75 - setViewTitle( ((pSection == null) ? "" : pSection + ": ") + (mViewDef = pViewDef) );
76 - }
77 -
78 - protected UiView( String pSection, String pViewSubTitle )
58 + protected UiView( CO pCO )
79 59 {
80 - this();
81 - setViewTitle( ((pSection == null) ? "" : pSection + ": ") + pViewSubTitle );
60 + pCO = deNull( pCO );
61 + mViewDef = pCO.mViewDef;
62 + mTitle = pCO.mTitle;
82 63 }
83 64
84 65 public final boolean hasViewTitle()
  @@ -102,7 +83,10 @@
102 83
103 84 abstract public Widget getContent();
104 85
105 - abstract public Widget getBottomBar();
86 + public Widget getBottomBar()
87 + {
88 + return null;
89 + }
106 90
107 91 protected CenterHorizontalPanel createSectionTitle( String pText )
108 92 {
  @@ -297,6 +281,16 @@
297 281 return (pObject != null) ? pObject.toString() : null;
298 282 }
299 283
284 + protected FormWidgetCtrl userViewable( boolean pFlag )
285 + {
286 + return pFlag ? VISIBLE_BUT_DISABLED : HIDDEN;
287 + }
288 +
289 + protected FormWidgetCtrl userEditable( boolean pFlag )
290 + {
291 + return pFlag ? EDIT_ONLY : HIDDEN;
292 + }
293 +
300 294 protected ClickHandler todoClickHandler( final String pTitle )
301 295 {
302 296 return new ClickHandler()
  @@ -313,4 +307,101 @@
313 307 {
314 308 InfoManager.info( this.getClass().getName(), pTitle, pTitle + " Not Implimented Yet" );
315 309 }
310 +
311 + private static CO deNull( CO pCO )
312 + {
313 + return (pCO != null) ? pCO : new CO();
314 + }
315 +
316 + protected static CO title( String pTitle )
317 + {
318 + return new CO().title( pTitle );
319 + }
320 +
321 + protected static CO title( String pSection, String pSubTitle )
322 + {
323 + return new CO().title( pSection, pSubTitle );
324 + }
325 +
326 + protected static CO title( String pSection, ViewDef pViewDef )
327 + {
328 + return new CO().title( pSection, pViewDef );
329 + }
330 +
331 + protected static CO title( ViewDef pViewDef )
332 + {
333 + return new CO().title( pViewDef );
334 + }
335 +
336 + protected static CO set( ViewDef pViewDef )
337 + {
338 + return new CO().set( pViewDef );
339 + }
340 +
341 + protected static CO set( CO pCO, ViewDef pViewDef )
342 + {
343 + return deNull( pCO ).set( pViewDef );
344 + }
345 +
346 + protected static CO title( CO pCO, ViewDef pViewDef )
347 + {
348 + return deNull( pCO ).title( pViewDef );
349 + }
350 +
351 + protected static CO title( CO pCO, String pSection, ViewDef pViewDef )
352 + {
353 + return deNull( pCO ).title( pSection, pViewDef );
354 + }
355 +
356 + protected static CO title( CO pCO, String pSection, String pSubTitle )
357 + {
358 + return deNull( pCO ).title( pSection, pSubTitle );
359 + }
360 +
361 + protected static CO title( CO pCO, String pTitle )
362 + {
363 + return deNull( pCO ).title( pTitle );
364 + }
365 +
366 + public static class CO
367 + {
368 + private ViewDef mViewDef;
369 + private String mTitle;
370 +
371 + private CO()
372 + {
373 + }
374 +
375 + public CO set( ViewDef pViewDef )
376 + {
377 + mViewDef = pViewDef;
378 + return this;
379 + }
380 +
381 + public CO title( String pTitle )
382 + {
383 + mTitle = UtilsCommon.assertNotNullNotEmpty( "Title", pTitle );
384 + return this;
385 + }
386 +
387 + public CO title( ViewDef pViewDef )
388 + {
389 + return title( (mViewDef = pViewDef).getUiString() );
390 + }
391 +
392 + public CO title( String pSection, ViewDef pViewDef )
393 + {
394 + return title( formatSection( pSection ) + (mViewDef = pViewDef) );
395 + }
396 +
397 + public CO title( String pSection, String pSubTitle )
398 + {
399 + return title( formatSection( pSection ) + pSubTitle );
400 + }
401 +
402 + private String formatSection( String pSection )
403 + {
404 + return (pSection == null) ? "" : pSection + ": ";
405 + }
406 + }
316 407 }