Subversion Repository Public Repository

litesoft

Diff Revisions 586 vs 587 for /trunk/GWT_Sandbox/UIdesign/src/com/test/uidesign/client/UIdesign.java

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