litesoft
@ 587
litesoft / trunk / GWT_Sandbox / UIdesign / src / com / test / uidesign / client / UIdesign.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
package com.test.uidesign.client; import org.litesoft.GWT.client.*; import org.litesoft.GWT.client.widgets.*; import org.litesoft.core.simpletypes.temporal.*; import org.litesoft.core.util.*; import com.google.gwt.event.dom.client.*; import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.*; public class UIdesign extends AbstractClientMainAppEntryPoint { private Widget createMainWidget() { AccordionVerticalPairPanel zAVP = new AccordionVerticalPairPanel(); // return new OrigFormComponents(); // return new PersonalInfoForm(); // return new Button( "Test" ); SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchable(); zPanel.add( createButtonPanel( zAVP ) ); zPanel.add( new Spacer().width( 15 ) ); zPanel.add( new SizeableScrollPanel( zAVP ) ); return zPanel; } public UIdesign() { super( new AppNames( "UIdesign" ) ); } @Override public void onAppLoad() { super.onAppLoad(); replaceAppPanel(); WindowSizingPanel.setContent( createMainWidget() ); System.err.println( new UtilDateAdaptor() + " | Application Client Ready" ); } private static Widget createSubordinateWidget( int pRows ) { if ( pRows == 0 ) { return null; } VerticalPanel zPanel = new VerticalPanel(); for (; pRows > 0; pRows-- ) { zPanel.add( createSubordinateRow( pRows ) ); } return zPanel; } private static Widget createSubordinateRow( int pRows ) { HorizontalPanel zPanel = new HorizontalPanel(); zPanel.add( new Spacer().width( 15 ) ); zPanel.add( new Label( UtilsCommon.dupChars( '*', pRows ) ) ); zPanel.add( new Spacer().width( 15 ) ); return zPanel; } private static AccordionVerticalPairPanel.WidgetPair createWidgetPair( AccordionVerticalPairPanel pAVP ) { int zRows = (int) (System.currentTimeMillis() & 31); Widget zSubordinateWidget = createSubordinateWidget( zRows ); return new AccordionVerticalPairPanel.WidgetPair( createPrimeWidget( pAVP, zRows, zSubordinateWidget ), zSubordinateWidget ); } private Widget createButtonPanel( final AccordionVerticalPairPanel pAVP ) { SizeableVerticalPanel zPanel = new SizeableVerticalPanel().stretchableVertically(); zPanel.add( new Button( "Clear", new ClickHandler() { @Override public void onClick( ClickEvent event ) { pAVP.clear(); } } ) ); zPanel.add( new Button( "Add", new ClickHandler() { @Override public void onClick( ClickEvent event ) { pAVP.add( createWidgetPair( pAVP ) ); } } ) ); return zPanel; } private static Widget createPrimeWidget( final AccordionVerticalPairPanel pAVP, int pRows, final Widget pSubordinateWidget ) { final HorizontalPanel zPanel = new HorizontalPanel(); zPanel.add( new Spacer().width( 15 ) ); zPanel.add( new Button( "Remove", new ClickHandler() { @Override public void onClick( ClickEvent event ) { int zIndex = (pSubordinateWidget != null) ? pAVP.indexOfSubordinateWidget( pSubordinateWidget ) : pAVP.indexOfPrimeWidget( zPanel ); pAVP.remove( zIndex ); } } ) ); zPanel.add( new Spacer().width( 5 ) ); zPanel.add( new Label( "Row: " + pAVP.size() ) ); zPanel.add( new Spacer().width( 15 ) ); if ( pSubordinateWidget == null ) { zPanel.add( new Label( "No Details" ) ); } else { zPanel.add( new Label( "(" + pRows + ")" ) ); zPanel.add( new Spacer().width( 5 ) ); zPanel.add( createShowHideButton( pAVP, pSubordinateWidget ) ); } zPanel.add( new Spacer().width( 15 ) ); return zPanel; } private static Button createShowHideButton( final AccordionVerticalPairPanel pAVP, final Widget pSubordinateWidget ) { final Button zButton = new Button( "Details" ); zButton.addClickHandler( new ClickHandler() { private boolean mShowing; @Override public void onClick( ClickEvent event ) { pAVP.show( pSubordinateWidget, mShowing = !mShowing ); zButton.setText( mShowing ? "Hide" : "Details" ); } } ); return zButton; } } |