Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -1,99 +1,99 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.client.nonpublic;
3 -
4 - import org.litesoft.GWT.client.*;
5 - import org.litesoft.GWT.client.widgets.*;
6 - import org.litesoft.GWT.client.widgets.Button;
7 - import org.litesoft.GWT.forms.client.components.nonpublic.*;
8 - import org.litesoft.commonfoundation.typeutils.*;
9 -
10 - import com.google.gwt.user.client.ui.*;
11 -
12 - public abstract class AbstractMessageDialog extends AbstractDialog // PopupPanel is a SimplePanel
13 - {
14 - private SizeableVerticalPanel mOuterPanel = new SizeableVerticalPanel().stretchable();
15 - protected String mBodyPanelStyle;
16 - protected String mBodyPanelMessageHtmlStyle;
17 - protected String mDialogIconReference;
18 - protected String mButtonBarStyle;
19 - private Button[] mButtons;
20 -
21 - protected AbstractMessageDialog( String pDefaultTitle, String pMainPanelStyle, //
22 - String pBodyPanelStyle, String pBodyPanelMessageHtmlStyle, String pButtonBarStyle, String pDialogIconReference ) {
23 - super( pDefaultTitle, Opaqueness.None );
24 - mOuterPanel.addStyleName( pMainPanelStyle );
25 - mBodyPanelStyle = pBodyPanelStyle;
26 - mBodyPanelMessageHtmlStyle = pBodyPanelMessageHtmlStyle;
27 - mDialogIconReference = pDialogIconReference;
28 - mButtonBarStyle = pButtonBarStyle;
29 - }
30 -
31 - protected void initialize( String pTitle, String pMessage, DialogCloseCallBack pCloseCallBack ) {
32 - mOuterPanel.add( createMainBodyPanel( pMessage ) );
33 - augmentMainPanelBeforeButtons( mOuterPanel );
34 - mOuterPanel.add( new SizeableSpacer().stretchableVertically() );
35 - mOuterPanel.add( createButtonPanel() );
36 - initialize( pTitle, pCloseCallBack );
37 - }
38 -
39 - @Override
40 - protected Widget createBodyPanel() {
41 - return mOuterPanel;
42 - }
43 -
44 - protected SizeableHorizontalPanel createMainBodyPanel( String pMessage ) {
45 - SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally();
46 - zPanel.add( new BackgroundImage( mDialogIconReference ) );
47 - zPanel.add( new Spacer( 8 ) );
48 - zPanel.add( wrapWithSizeable( createBodyPanelMessageHTML( Strings.deEmpty( pMessage, //
49 - "Unknown" ) ) ) );
50 - zPanel.add( new Spacer( 20 ) );
51 - return zPanel.style( mBodyPanelStyle );
52 - }
53 -
54 - protected void augmentMainPanelBeforeButtons( HasWidgets pVerticalPanel ) {
55 - }
56 -
57 - protected Widget createButtonPanel() {
58 - SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel() {
59 - @Override
60 - protected void onAttach() {
61 - super.onAttach();
62 - DialogButtonPanel.sizeAllButtons( mButtons );
63 - }
64 - };
65 - zPanel.stretchableHorizontally();
66 - zPanel.add( new SizeableSpacer().stretchableHorizontally() );
67 - mButtons = createButtons();
68 - zPanel.add( mButtons[0] );
69 - for ( int i = 1; i < mButtons.length; i++ ) {
70 - zPanel.add( new Spacer( 20 ) );
71 - zPanel.add( mButtons[i] );
72 - }
73 - zPanel.add( new SizeableSpacer().stretchableHorizontally() );
74 - return zPanel.style( mButtonBarStyle );
75 - }
76 -
77 - protected Button[] createButtons() {
78 - return new Button[]{OKButton.factory().add( new HideCommand() ).create()};
79 - }
80 -
81 - private Widget wrapWithSizeable( Widget pWidget ) {
82 - Grid zGrid = new Grid( 2, 2 );
83 - zGrid.setWidget( 0, 0, pWidget );
84 - zGrid.setWidget( 0, 1, new Spacer() );
85 - zGrid.setWidget( 1, 0, new Spacer() );
86 - zGrid.setWidget( 1, 1, new Spacer( 22 ) );
87 - return new SizeableSimplePanel( false, zGrid ).stretchableHorizontally();
88 - }
89 -
90 - protected Widget createBodyPanelMessageHTML( String pText ) {
91 - Widget rv = new HTML( wrapWithPre( pText ) );
92 - rv.setStyleName( mBodyPanelMessageHtmlStyle );
93 - return rv;
94 - }
95 -
96 - protected String wrapWithPre( String pText ) {
97 - return "<pre style='font-family:sans-serif; font-size:smaller; margin:0; padding:0;'>" + pText + "</pre>";
98 - }
99 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.client.nonpublic;
3 +
4 + import org.litesoft.GWT.client.*;
5 + import org.litesoft.GWT.client.widgets.*;
6 + import org.litesoft.GWT.client.widgets.Button;
7 + import org.litesoft.GWT.forms.client.components.nonpublic.*;
8 + import org.litesoft.commonfoundation.base.*;
9 +
10 + import com.google.gwt.user.client.ui.*;
11 +
12 + public abstract class AbstractMessageDialog extends AbstractDialog // PopupPanel is a SimplePanel
13 + {
14 + private SizeableVerticalPanel mOuterPanel = new SizeableVerticalPanel().stretchable();
15 + protected String mBodyPanelStyle;
16 + protected String mBodyPanelMessageHtmlStyle;
17 + protected String mDialogIconReference;
18 + protected String mButtonBarStyle;
19 + private Button[] mButtons;
20 +
21 + protected AbstractMessageDialog( String pDefaultTitle, String pMainPanelStyle, //
22 + String pBodyPanelStyle, String pBodyPanelMessageHtmlStyle, String pButtonBarStyle, String pDialogIconReference ) {
23 + super( pDefaultTitle, Opaqueness.None );
24 + mOuterPanel.addStyleName( pMainPanelStyle );
25 + mBodyPanelStyle = pBodyPanelStyle;
26 + mBodyPanelMessageHtmlStyle = pBodyPanelMessageHtmlStyle;
27 + mDialogIconReference = pDialogIconReference;
28 + mButtonBarStyle = pButtonBarStyle;
29 + }
30 +
31 + protected void initialize( String pTitle, String pMessage, DialogCloseCallBack pCloseCallBack ) {
32 + mOuterPanel.add( createMainBodyPanel( pMessage ) );
33 + augmentMainPanelBeforeButtons( mOuterPanel );
34 + mOuterPanel.add( new SizeableSpacer().stretchableVertically() );
35 + mOuterPanel.add( createButtonPanel() );
36 + initialize( pTitle, pCloseCallBack );
37 + }
38 +
39 + @Override
40 + protected Widget createBodyPanel() {
41 + return mOuterPanel;
42 + }
43 +
44 + protected SizeableHorizontalPanel createMainBodyPanel( String pMessage ) {
45 + SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel().stretchableHorizontally();
46 + zPanel.add( new BackgroundImage( mDialogIconReference ) );
47 + zPanel.add( new Spacer( 8 ) );
48 + zPanel.add( wrapWithSizeable( createBodyPanelMessageHTML( ConstrainTo.significantOrNull( pMessage, //
49 + "Unknown" ) ) ) );
50 + zPanel.add( new Spacer( 20 ) );
51 + return zPanel.style( mBodyPanelStyle );
52 + }
53 +
54 + protected void augmentMainPanelBeforeButtons( HasWidgets pVerticalPanel ) {
55 + }
56 +
57 + protected Widget createButtonPanel() {
58 + SizeableHorizontalPanel zPanel = new SizeableHorizontalPanel() {
59 + @Override
60 + protected void onAttach() {
61 + super.onAttach();
62 + DialogButtonPanel.sizeAllButtons( mButtons );
63 + }
64 + };
65 + zPanel.stretchableHorizontally();
66 + zPanel.add( new SizeableSpacer().stretchableHorizontally() );
67 + mButtons = createButtons();
68 + zPanel.add( mButtons[0] );
69 + for ( int i = 1; i < mButtons.length; i++ ) {
70 + zPanel.add( new Spacer( 20 ) );
71 + zPanel.add( mButtons[i] );
72 + }
73 + zPanel.add( new SizeableSpacer().stretchableHorizontally() );
74 + return zPanel.style( mButtonBarStyle );
75 + }
76 +
77 + protected Button[] createButtons() {
78 + return new Button[]{OKButton.factory().add( new HideCommand() ).create()};
79 + }
80 +
81 + private Widget wrapWithSizeable( Widget pWidget ) {
82 + Grid zGrid = new Grid( 2, 2 );
83 + zGrid.setWidget( 0, 0, pWidget );
84 + zGrid.setWidget( 0, 1, new Spacer() );
85 + zGrid.setWidget( 1, 0, new Spacer() );
86 + zGrid.setWidget( 1, 1, new Spacer( 22 ) );
87 + return new SizeableSimplePanel( false, zGrid ).stretchableHorizontally();
88 + }
89 +
90 + protected Widget createBodyPanelMessageHTML( String pText ) {
91 + Widget rv = new HTML( wrapWithPre( pText ) );
92 + rv.setStyleName( mBodyPanelMessageHtmlStyle );
93 + return rv;
94 + }
95 +
96 + protected String wrapWithPre( String pText ) {
97 + return "<pre style='font-family:sans-serif; font-size:smaller; margin:0; padding:0;'>" + pText + "</pre>";
98 + }
99 + }