Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/GWT_Sandbox/UIdesign/src/com/test/uidesign/client/UIdesign.java

Diff revisions: vs.
  @@ -1,208 +1,208 @@
1 - package com.test.uidesign.client;
2 -
3 - import org.litesoft.GWT.client.*;
4 - import org.litesoft.GWT.client.widgets.*;
5 - import org.litesoft.commonfoundation.typeutils.*;
6 - import org.litesoft.commonfoundation.typeutils.gregorian.*;
7 - import org.litesoft.ui.*;
8 -
9 - import com.google.gwt.event.dom.client.*;
10 - import com.google.gwt.user.client.*;
11 - import com.google.gwt.user.client.ui.Button;
12 - import com.google.gwt.user.client.ui.*;
13 -
14 - import static org.litesoft.ui.CompassPoint.*;
15 -
16 - public class UIdesign extends AbstractClientMainAppEntryPoint {
17 - private Widget createMainWidget() {
18 - // AccordionVerticalPairPanel zAVP = new AccordionVerticalPairPanel();
19 - // SizeableBorderedHorizontalSplitPairPanel zPairPanel = new SizeableBorderedHorizontalSplitPairPanel().stretchable();
20 - // zPairPanel.add(new SizeableScrollPanel(zAVP));
21 - // zPairPanel.add(new PersonalInfoForm());
22 - //// return new OrigFormComponents();
23 - //// return new PersonalInfoForm();
24 - //// return new Button( "Test" );
25 - // SizeableVerticalPanel zPanel = new SizeableVerticalPanel().stretchable();
26 - // zPanel.add(zPairPanel);
27 - // zPanel.add(new Spacer(15));
28 - // zPanel.add(createButtonPanel(zAVP));
29 - // return new SizeableSimplePanel(zPanel).stretchable().style("MainPageIndent");
30 - return new SizeableSimplePanel( new PersonalInfoForm() ).stretchable().style( "MainPageIndent" );
31 - }
32 -
33 - public UIdesign() {
34 - super( new AppNames( "UIdesign" ) );
35 - }
36 -
37 - @Override
38 - public void onAppLoad() {
39 - super.onAppLoad();
40 -
41 - replaceAppPanel();
42 -
43 - WindowSizingPanel.setContent( createMainWidget() );
44 -
45 - System.err.println( new UtilDateAdaptor() + " | Application Client Ready" );
46 - }
47 -
48 - private static Widget createSubordinateWidget( int pRows ) {
49 - if ( pRows == 0 ) {
50 - return null;
51 - }
52 - VerticalPanel zPanel = new VerticalPanel();
53 - for (; pRows > 0; pRows-- ) {
54 - zPanel.add( createSubordinateRow( pRows ) );
55 - }
56 - return zPanel;
57 - }
58 -
59 - private static Widget createSubordinateRow( int pRows ) {
60 - HorizontalPanel zPanel = new HorizontalPanel();
61 - zPanel.add( new Spacer().width( 15 ) );
62 - zPanel.add( new Label( Strings.dupChars( '*', pRows ) ) );
63 - zPanel.add( new Spacer().width( 15 ) );
64 - return zPanel;
65 - }
66 -
67 - private static AccordionVerticalPairPanel.WidgetPair createWidgetPair( AccordionVerticalPairPanel pAVP ) {
68 - int zRows = (int) (System.currentTimeMillis() & 31);
69 - Widget zSubordinateWidget = createSubordinateWidget( zRows );
70 - return new AccordionVerticalPairPanel.WidgetPair( createPrimeWidget( pAVP, zRows, zSubordinateWidget ), zSubordinateWidget );
71 - }
72 -
73 - private Widget createButtonPanel( final AccordionVerticalPairPanel pAVP ) {
74 - SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally();
75 - zPanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_BOTTOM );
76 - zPanel.add( new Button( "Clear", new ClickHandler() {
77 - @Override
78 - public void onClick( ClickEvent event ) {
79 - pAVP.clear();
80 - }
81 - } ) );
82 - zPanel.add( new SizeableSpacer().stretchableHorizontally() );
83 - zPanel.add( new CssInlineImageTestPanel( "Add" ) );
84 - zPanel.add( new Spacer( 4 ) );
85 - zPanel.add( new CssInlineImageTestPanel( "Subtract" ) );
86 - zPanel.add( new SizeableSpacer().stretchableHorizontally() );
87 - zPanel.add( new Button( "Add", new ClickHandler() {
88 - @Override
89 - public void onClick( ClickEvent event ) {
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 - final HorizontalPanel zPanel = new HorizontalPanel();
98 - zPanel.add( new Spacer().width( 15 ) );
99 - zPanel.add( new Button( "Remove", new ClickHandler() {
100 - @Override
101 - public void onClick( ClickEvent event ) {
102 - int zIndex = (pSubordinateWidget != null) ? pAVP.indexOfSubordinateWidget( pSubordinateWidget ) : pAVP.indexOfPrimeWidget( zPanel );
103 - pAVP.remove( zIndex );
104 - }
105 - } ) );
106 - zPanel.add( new Spacer().width( 5 ) );
107 - zPanel.add( new Label( "Row: " + pAVP.size() ) );
108 - zPanel.add( new Spacer().width( 15 ) );
109 - if ( pSubordinateWidget == null ) {
110 - zPanel.add( new Label( "No Details" ) );
111 - } else {
112 - zPanel.add( new Label( "(" + pRows + ")" ) );
113 - zPanel.add( new Spacer().width( 5 ) );
114 - zPanel.add( createShowHideButton( pAVP, pSubordinateWidget ) );
115 - }
116 - zPanel.add( new Spacer().width( 15 ) );
117 -
118 - return zPanel;
119 - }
120 -
121 - private static Button createShowHideButton( final AccordionVerticalPairPanel pAVP, final Widget pSubordinateWidget ) {
122 - final Button zButton = new Button( "Details" );
123 - zButton.addClickHandler( new ClickHandler() {
124 - private boolean mShowing;
125 -
126 - @Override
127 - public void onClick( ClickEvent event ) {
128 - pAVP.show( pSubordinateWidget, mShowing = !mShowing );
129 - zButton.setText( mShowing ? "Hide" : "Details" );
130 - }
131 - } );
132 - return zButton;
133 - }
134 -
135 - private static class CssInlineImageTestPanel extends Composite {
136 - private Element styleElement;
137 -
138 - public CssInlineImageTestPanel( String name ) {
139 - SimplePanel panel =
140 - new SimplePanel( new NcellBorderedWidgets( "DataImgButton", new TransparentImage( "BgImageCell" ), new Spacer( 5 ), new TextCell( name ) ) );
141 - styleElement = panel.getElement();
142 - HorizontalPanel wrapper = new HorizontalPanel();
143 - wrapper.add( panel );
144 - wrapper.setStyleName( "Test" + name );
145 - initWidget( wrapper );
146 - }
147 -
148 - @Override
149 - protected Element getStyleElement() {
150 - return styleElement;
151 - }
152 -
153 - private static class TextCell extends Label {
154 - public TextCell( String text ) {
155 - super( text );
156 - setStyleName( "TextCell" );
157 - }
158 - }
159 -
160 - private static class NcellBorderedWidgets extends Composite {
161 - public NcellBorderedWidgets( String cssClassName, Widget... centerWidgets ) {
162 - String id = HTMLPanel.createUniqueId();
163 - StringBuilder sb = new StringBuilder( "<table cellpadding='0' cellspacing='0'>" );
164 - addRow( sb, NW, N, NE );
165 - addRow( sb, W, center, id, E );
166 - addRow( sb, SW, S, SE );
167 - sb.append( "</table>" );
168 - HTMLPanel panel = new HTMLPanel( sb.toString() );
169 - initWidget( panel );
170 - panel.add( createCenterWidget( centerWidgets ), id );
171 - setStyleName( cssClassName );
172 - }
173 -
174 - private void addRow( StringBuilder sb, CompassPoint... cps ) {
175 - sb.append( "<tr>" );
176 - for ( CompassPoint cp : cps ) {
177 - addCell( sb, cp );
178 - }
179 - sb.append( "</tr>" );
180 - }
181 -
182 - private void addRow( StringBuilder sb, CompassPoint w, CompassPoint center, String id, CompassPoint e ) {
183 - sb.append( "<tr>" );
184 - addCell( sb, w );
185 - addCell( sb, center, id );
186 - addCell( sb, e );
187 - sb.append( "</tr>" );
188 - }
189 -
190 - private void addCell( StringBuilder sb, CompassPoint cp ) {
191 - sb.append( "<td class='CP_" ).append( cp.name() ).append( "'><img src='" ).append( TransparentImage.URL ).append( "'></td>" );
192 - }
193 -
194 - private void addCell( StringBuilder sb, CompassPoint cp, String id ) {
195 - sb.append( "<td class='CP_" ).append( cp.name() ).append( "' id='" ).append( id ).append( "'></td>" );
196 - }
197 -
198 - private Widget createCenterWidget( Widget[] centerWidgets ) {
199 - HorizontalPanel panel = new HorizontalPanel();
200 - panel.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
201 - for ( Widget widget : centerWidgets ) {
202 - panel.add( widget );
203 - }
204 - return panel;
205 - }
206 - }
207 - }
208 - }
1 + package com.test.uidesign.client;
2 +
3 + import org.litesoft.GWT.client.*;
4 + import org.litesoft.GWT.client.widgets.*;
5 + import org.litesoft.commonfoundation.typeutils.*;
6 + import org.litesoft.commonfoundation.typeutils.gregorian.*;
7 + import org.litesoft.ui.*;
8 +
9 + import com.google.gwt.event.dom.client.*;
10 + import com.google.gwt.user.client.*;
11 + import com.google.gwt.user.client.ui.Button;
12 + import com.google.gwt.user.client.ui.*;
13 +
14 + import static org.litesoft.ui.CompassPoint.*;
15 +
16 + public class UIdesign extends AbstractClientMainAppEntryPoint {
17 + private Widget createMainWidget() {
18 + // AccordionVerticalPairPanel zAVP = new AccordionVerticalPairPanel();
19 + // SizeableBorderedHorizontalSplitPairPanel zPairPanel = new SizeableBorderedHorizontalSplitPairPanel().stretchable();
20 + // zPairPanel.add(new SizeableScrollPanel(zAVP));
21 + // zPairPanel.add(new PersonalInfoForm());
22 + //// return new OrigFormComponents();
23 + //// return new PersonalInfoForm();
24 + //// return new Button( "Test" );
25 + // SizeableVerticalPanel zPanel = new SizeableVerticalPanel().stretchable();
26 + // zPanel.add(zPairPanel);
27 + // zPanel.add(new Spacer(15));
28 + // zPanel.add(createButtonPanel(zAVP));
29 + // return new SizeableSimplePanel(zPanel).stretchable().style("MainPageIndent");
30 + return new SizeableSimplePanel( new PersonalInfoForm() ).stretchable().style( "MainPageIndent" );
31 + }
32 +
33 + public UIdesign() {
34 + super( new AppNames( "UIdesign" ) );
35 + }
36 +
37 + @Override
38 + public void onAppLoad() {
39 + super.onAppLoad();
40 +
41 + replaceAppPanel();
42 +
43 + WindowSizingPanel.setContent( createMainWidget() );
44 +
45 + System.err.println( new UtilDateAdaptor() + " | Application Client Ready" );
46 + }
47 +
48 + private static Widget createSubordinateWidget( int pRows ) {
49 + if ( pRows == 0 ) {
50 + return null;
51 + }
52 + VerticalPanel zPanel = new VerticalPanel();
53 + for (; pRows > 0; pRows-- ) {
54 + zPanel.add( createSubordinateRow( pRows ) );
55 + }
56 + return zPanel;
57 + }
58 +
59 + private static Widget createSubordinateRow( int pRows ) {
60 + HorizontalPanel zPanel = new HorizontalPanel();
61 + zPanel.add( new Spacer().width( 15 ) );
62 + zPanel.add( new Label( Strings.dupChars( '*', pRows ) ) );
63 + zPanel.add( new Spacer().width( 15 ) );
64 + return zPanel;
65 + }
66 +
67 + private static AccordionVerticalPairPanel.WidgetPair createWidgetPair( AccordionVerticalPairPanel pAVP ) {
68 + int zRows = (int) (System.currentTimeMillis() & 31);
69 + Widget zSubordinateWidget = createSubordinateWidget( zRows );
70 + return new AccordionVerticalPairPanel.WidgetPair( createPrimeWidget( pAVP, zRows, zSubordinateWidget ), zSubordinateWidget );
71 + }
72 +
73 + private Widget createButtonPanel( final AccordionVerticalPairPanel pAVP ) {
74 + SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally();
75 + zPanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_BOTTOM );
76 + zPanel.add( new Button( "Clear", new ClickHandler() {
77 + @Override
78 + public void onClick( ClickEvent event ) {
79 + pAVP.clear();
80 + }
81 + } ) );
82 + zPanel.add( new SizeableSpacer().stretchableHorizontally() );
83 + zPanel.add( new CssInlineImageTestPanel( "Add" ) );
84 + zPanel.add( new Spacer( 4 ) );
85 + zPanel.add( new CssInlineImageTestPanel( "Subtract" ) );
86 + zPanel.add( new SizeableSpacer().stretchableHorizontally() );
87 + zPanel.add( new Button( "Add", new ClickHandler() {
88 + @Override
89 + public void onClick( ClickEvent event ) {
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 + final HorizontalPanel zPanel = new HorizontalPanel();
98 + zPanel.add( new Spacer().width( 15 ) );
99 + zPanel.add( new Button( "Remove", new ClickHandler() {
100 + @Override
101 + public void onClick( ClickEvent event ) {
102 + int zIndex = (pSubordinateWidget != null) ? pAVP.indexOfSubordinateWidget( pSubordinateWidget ) : pAVP.indexOfPrimeWidget( zPanel );
103 + pAVP.remove( zIndex );
104 + }
105 + } ) );
106 + zPanel.add( new Spacer().width( 5 ) );
107 + zPanel.add( new Label( "Row: " + pAVP.size() ) );
108 + zPanel.add( new Spacer().width( 15 ) );
109 + if ( pSubordinateWidget == null ) {
110 + zPanel.add( new Label( "No Details" ) );
111 + } else {
112 + zPanel.add( new Label( "(" + pRows + ")" ) );
113 + zPanel.add( new Spacer().width( 5 ) );
114 + zPanel.add( createShowHideButton( pAVP, pSubordinateWidget ) );
115 + }
116 + zPanel.add( new Spacer().width( 15 ) );
117 +
118 + return zPanel;
119 + }
120 +
121 + private static Button createShowHideButton( final AccordionVerticalPairPanel pAVP, final Widget pSubordinateWidget ) {
122 + final Button zButton = new Button( "Details" );
123 + zButton.addClickHandler( new ClickHandler() {
124 + private boolean mShowing;
125 +
126 + @Override
127 + public void onClick( ClickEvent event ) {
128 + pAVP.show( pSubordinateWidget, mShowing = !mShowing );
129 + zButton.setText( mShowing ? "Hide" : "Details" );
130 + }
131 + } );
132 + return zButton;
133 + }
134 +
135 + private static class CssInlineImageTestPanel extends Composite {
136 + private Element styleElement;
137 +
138 + public CssInlineImageTestPanel( String name ) {
139 + SimplePanel panel =
140 + new SimplePanel( new NcellBorderedWidgets( "DataImgButton", new TransparentImage( "BgImageCell" ), new Spacer( 5 ), new TextCell( name ) ) );
141 + styleElement = panel.getElement();
142 + HorizontalPanel wrapper = new HorizontalPanel();
143 + wrapper.add( panel );
144 + wrapper.setStyleName( "Test" + name );
145 + initWidget( wrapper );
146 + }
147 +
148 + @Override
149 + protected Element getStyleElement() {
150 + return styleElement;
151 + }
152 +
153 + private static class TextCell extends Label {
154 + public TextCell( String text ) {
155 + super( text );
156 + setStyleName( "TextCell" );
157 + }
158 + }
159 +
160 + private static class NcellBorderedWidgets extends Composite {
161 + public NcellBorderedWidgets( String cssClassName, Widget... centerWidgets ) {
162 + String id = HTMLPanel.createUniqueId();
163 + StringBuilder sb = new StringBuilder( "<table cellpadding='0' cellspacing='0'>" );
164 + addRow( sb, NW, N, NE );
165 + addRow( sb, W, center, id, E );
166 + addRow( sb, SW, S, SE );
167 + sb.append( "</table>" );
168 + HTMLPanel panel = new HTMLPanel( sb.toString() );
169 + initWidget( panel );
170 + panel.add( createCenterWidget( centerWidgets ), id );
171 + setStyleName( cssClassName );
172 + }
173 +
174 + private void addRow( StringBuilder sb, CompassPoint... cps ) {
175 + sb.append( "<tr>" );
176 + for ( CompassPoint cp : cps ) {
177 + addCell( sb, cp );
178 + }
179 + sb.append( "</tr>" );
180 + }
181 +
182 + private void addRow( StringBuilder sb, CompassPoint w, CompassPoint center, String id, CompassPoint e ) {
183 + sb.append( "<tr>" );
184 + addCell( sb, w );
185 + addCell( sb, center, id );
186 + addCell( sb, e );
187 + sb.append( "</tr>" );
188 + }
189 +
190 + private void addCell( StringBuilder sb, CompassPoint cp ) {
191 + sb.append( "<td class='CP_" ).append( cp.name() ).append( "'><img src='" ).append( TransparentImage.URL ).append( "'></td>" );
192 + }
193 +
194 + private void addCell( StringBuilder sb, CompassPoint cp, String id ) {
195 + sb.append( "<td class='CP_" ).append( cp.name() ).append( "' id='" ).append( id ).append( "'></td>" );
196 + }
197 +
198 + private Widget createCenterWidget( Widget[] centerWidgets ) {
199 + HorizontalPanel panel = new HorizontalPanel();
200 + panel.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
201 + for ( Widget widget : centerWidgets ) {
202 + panel.add( widget );
203 + }
204 + return panel;
205 + }
206 + }
207 + }
208 + }