|
@@ -1,179 +1,178 @@ |
1 |
|
- |
// This Source Code is in the Public Domain per: http://unlicense.org |
2 |
|
- |
package org.litesoft.GWT.client.widgets; |
3 |
|
- |
|
4 |
|
- |
import org.litesoft.GWT.client.command.*; |
5 |
|
- |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
6 |
|
- |
import org.litesoft.commonfoundation.typeutils.Objects; |
7 |
|
- |
import org.litesoft.commonfoundation.typeutils.*; |
8 |
|
- |
import org.litesoft.uispecification.*; |
9 |
|
- |
|
10 |
|
- |
import com.google.gwt.event.dom.client.*; |
11 |
|
- |
import com.google.gwt.user.client.*; |
12 |
|
- |
|
13 |
|
- |
import java.util.*; |
14 |
|
- |
|
15 |
|
- |
public abstract class DefButtonNamedTypedFactory { |
16 |
|
- |
public enum BasicForm { |
17 |
|
- |
Text, Image |
18 |
|
- |
} |
19 |
|
- |
|
20 |
|
- |
public enum Form { |
21 |
|
- |
Text( BasicForm.Text ), BigText( BasicForm.Text ), Icon( BasicForm.Image ), Picker( BasicForm.Image ); |
22 |
|
- |
|
23 |
|
- |
private BasicForm mBasicForm; |
24 |
|
- |
|
25 |
|
- |
Form( BasicForm pBasicForm ) { |
26 |
|
- |
mBasicForm = pBasicForm; |
27 |
|
- |
} |
28 |
|
- |
|
29 |
|
- |
public BasicForm getBasicForm() { |
30 |
|
- |
return mBasicForm; |
31 |
|
- |
} |
32 |
|
- |
} |
33 |
|
- |
|
34 |
|
- |
protected final DefButtonNamedTyped mTyped; |
35 |
|
- |
private final Form mForm; |
36 |
|
- |
private String mCustomStyle, mEnabledToolTip, mDisabledToolTip; // initialized to null |
37 |
|
- |
private boolean mDisabled = false; |
38 |
|
- |
private List<ClickHandler> mClickHandlers; |
39 |
|
- |
|
40 |
|
- |
protected DefButtonNamedTypedFactory( DefButtonNamedTyped pTyped, Form pForm ) { |
41 |
|
- |
Objects.assertNotNull( "Typed", mTyped = pTyped ); |
42 |
|
- |
Objects.assertNotNull( "Form", mForm = pForm ); |
43 |
|
- |
} |
44 |
|
- |
|
45 |
|
- |
public final String getName() { |
46 |
|
- |
return mTyped.getName(); |
47 |
|
- |
} |
48 |
|
- |
|
49 |
|
- |
public String getSize() { |
50 |
|
- |
return mTyped.getSize(); |
51 |
|
- |
} |
52 |
|
- |
|
53 |
|
- |
public final String getType() { |
54 |
|
- |
return mTyped.getType(); |
55 |
|
- |
} |
56 |
|
- |
|
57 |
|
- |
public final Form getForm() { |
58 |
|
- |
return mForm; |
59 |
|
- |
} |
60 |
|
- |
|
61 |
|
- |
public final boolean isDisabled() { |
62 |
|
- |
return mDisabled; |
63 |
|
- |
} |
64 |
|
- |
|
65 |
|
- |
public final String getEnabledToolTip() { |
66 |
|
- |
return mEnabledToolTip; |
67 |
|
- |
} |
68 |
|
- |
|
69 |
|
- |
public final String getDisabledToolTip() { |
70 |
|
- |
return mDisabledToolTip; |
71 |
|
- |
} |
72 |
|
- |
|
73 |
|
- |
public final List<ClickHandler> getClickHandlers() { |
74 |
|
- |
return (mClickHandlers != null) ? mClickHandlers : Collections.<ClickHandler>emptyList(); |
75 |
|
- |
} |
76 |
|
- |
|
77 |
|
- |
public final DefButtonNamedTypedFactory disabled() { |
78 |
|
- |
mDisabled = true; |
79 |
|
- |
return this; |
80 |
|
- |
} |
81 |
|
- |
|
82 |
|
- |
public final DefButtonNamedTypedFactory add( ClickHandler pClickHandler ) { |
83 |
|
- |
if ( pClickHandler != null ) { |
84 |
|
- |
if ( mClickHandlers == null ) { |
85 |
|
- |
mClickHandlers = new ArrayList<ClickHandler>(); |
86 |
|
- |
} |
87 |
|
- |
mClickHandlers.add( pClickHandler ); |
88 |
|
- |
} |
89 |
|
- |
return this; |
90 |
|
- |
} |
91 |
|
- |
|
92 |
|
- |
public final DefButtonNamedTypedFactory add( CommandHandlerAdaptor pAdaptor ) { |
93 |
|
- |
return add( (ClickHandler) pAdaptor ); |
94 |
|
- |
} |
95 |
|
- |
|
96 |
|
- |
public final DefButtonNamedTypedFactory add( Command pCommand ) { |
97 |
|
- |
return (pCommand == null) ? this : add( new ClickHandlerCommandAdaptor( pCommand ) ); |
98 |
|
- |
} |
99 |
|
- |
|
100 |
|
- |
public final DefButtonNamedTypedFactory add( ViewDef pTarget ) { |
101 |
|
- |
Objects.assertNotNull( "Target (ViewDef)", pTarget ); |
102 |
|
- |
return add( new ShowScreenCommand( pTarget ) ); |
103 |
|
- |
} |
104 |
|
- |
|
105 |
|
- |
public final DefButtonNamedTypedFactory add( ViewDef pTarget, UriFragmentIdParams pParams ) { |
106 |
|
- |
Objects.assertNotNull( "Target (ViewDef)", pTarget ); |
107 |
|
- |
return add( new ShowScreenCommand( pTarget, pParams ) ); |
108 |
|
- |
} |
109 |
|
- |
|
110 |
|
- |
public final DefButtonNamedTypedFactory add( final ViewDef pTarget, final UriFragmentIdParams.ScreenParamsFactory pFactory ) { |
111 |
|
- |
Objects.assertNotNull( "Target (ViewDef)", pTarget ); |
112 |
|
- |
Objects.assertNotNull( "Factory", pFactory ); |
113 |
|
- |
return add( new ClickHandler() { |
114 |
|
- |
@Override |
115 |
|
- |
public void onClick( ClickEvent event ) { |
116 |
|
- |
new ShowScreenCommand( pTarget, pFactory.create( pTarget ) ).execute(); |
117 |
|
- |
} |
118 |
|
- |
} ); |
119 |
|
- |
} |
120 |
|
- |
|
121 |
|
- |
public String getCustomStyle() { |
122 |
|
- |
return mCustomStyle; |
123 |
|
- |
} |
124 |
|
- |
|
125 |
|
- |
public DefButtonNamedTypedFactory customStyle( String pCustomStyle ) { |
126 |
|
- |
mCustomStyle = Strings.noEmpty( pCustomStyle ); |
127 |
|
- |
return this; |
128 |
|
- |
} |
129 |
|
- |
|
130 |
|
- |
public final DefButtonNamedTypedFactory enabledToolTip( String pEnabledToolTip ) { |
131 |
|
- |
mEnabledToolTip = Strings.noEmpty( pEnabledToolTip ); |
132 |
|
- |
return this; |
133 |
|
- |
} |
134 |
|
- |
|
135 |
|
- |
public final DefButtonNamedTypedFactory disabledToolTip( String pDisabledToolTip ) { |
136 |
|
- |
mDisabledToolTip = (pDisabledToolTip == null) ? null : pDisabledToolTip.trim(); |
137 |
|
- |
return this; |
138 |
|
- |
} |
139 |
|
- |
|
140 |
|
- |
public final Button create() { |
141 |
|
- |
Button zButton = ButtonFactoryFactory.getFactory().create( this ); |
142 |
|
- |
for ( ClickHandler zHandler : getClickHandlers() ) { |
143 |
|
- |
zButton.addClickHandler( zHandler ); |
144 |
|
- |
} |
145 |
|
- |
return zButton; |
146 |
|
- |
} |
147 |
|
- |
|
148 |
|
- |
protected abstract String getFormDescription(); |
149 |
|
- |
|
150 |
|
- |
@Override |
151 |
|
- |
public String toString() { |
152 |
|
- |
StringBuilder sb = new StringBuilder(); |
153 |
|
- |
sb.append( getType() ).append( "( " ).append( getName() ).append( " )" ); |
154 |
|
- |
if ( mDisabled ) { |
155 |
|
- |
sb.append( " Disabled" ); |
156 |
|
- |
} |
157 |
|
- |
if ( mCustomStyle != null ) { |
158 |
|
- |
sb.append( " + " ).append( mCustomStyle ); |
159 |
|
- |
} |
160 |
|
- |
sb.append( ": " ).append( mForm ).append( getFormDescription() ); |
161 |
|
- |
if ( (mEnabledToolTip != null) || (mDisabledToolTip != null) ) { |
162 |
|
- |
if ( mDisabledToolTip == null ) { |
163 |
|
- |
sb.append( "\n ToolTip: " ).append( mEnabledToolTip ); |
164 |
|
- |
} else { |
165 |
|
- |
if ( mEnabledToolTip != null ) { |
166 |
|
- |
sb.append( "\n Enabled ToolTip: " ).append( mEnabledToolTip ); |
167 |
|
- |
} |
168 |
|
- |
if ( mDisabledToolTip != null ) { |
169 |
|
- |
if ( mDisabledToolTip.length() == 0 ) { |
170 |
|
- |
sb.append( "\n No Disabled ToolTip" ); |
171 |
|
- |
} else { |
172 |
|
- |
sb.append( "\n Disabled ToolTip: " ).append( mDisabledToolTip ); |
173 |
|
- |
} |
174 |
|
- |
} |
175 |
|
- |
} |
176 |
|
- |
} |
177 |
|
- |
return sb.toString(); |
178 |
|
- |
} |
179 |
|
- |
} |
|
1 |
+ |
// This Source Code is in the Public Domain per: http://unlicense.org |
|
2 |
+ |
package org.litesoft.GWT.client.widgets; |
|
3 |
+ |
|
|
4 |
+ |
import org.litesoft.GWT.client.command.*; |
|
5 |
+ |
import org.litesoft.GWT.client.widgets.nonpublic.*; |
|
6 |
+ |
import org.litesoft.commonfoundation.base.*; |
|
7 |
+ |
import org.litesoft.uispecification.*; |
|
8 |
+ |
|
|
9 |
+ |
import com.google.gwt.event.dom.client.*; |
|
10 |
+ |
import com.google.gwt.user.client.*; |
|
11 |
+ |
|
|
12 |
+ |
import java.util.*; |
|
13 |
+ |
|
|
14 |
+ |
public abstract class DefButtonNamedTypedFactory { |
|
15 |
+ |
public enum BasicForm { |
|
16 |
+ |
Text, Image |
|
17 |
+ |
} |
|
18 |
+ |
|
|
19 |
+ |
public enum Form { |
|
20 |
+ |
Text( BasicForm.Text ), BigText( BasicForm.Text ), Icon( BasicForm.Image ), Picker( BasicForm.Image ); |
|
21 |
+ |
|
|
22 |
+ |
private BasicForm mBasicForm; |
|
23 |
+ |
|
|
24 |
+ |
Form( BasicForm pBasicForm ) { |
|
25 |
+ |
mBasicForm = pBasicForm; |
|
26 |
+ |
} |
|
27 |
+ |
|
|
28 |
+ |
public BasicForm getBasicForm() { |
|
29 |
+ |
return mBasicForm; |
|
30 |
+ |
} |
|
31 |
+ |
} |
|
32 |
+ |
|
|
33 |
+ |
protected final DefButtonNamedTyped mTyped; |
|
34 |
+ |
private final Form mForm; |
|
35 |
+ |
private String mCustomStyle, mEnabledToolTip, mDisabledToolTip; // initialized to null |
|
36 |
+ |
private boolean mDisabled = false; |
|
37 |
+ |
private List<ClickHandler> mClickHandlers; |
|
38 |
+ |
|
|
39 |
+ |
protected DefButtonNamedTypedFactory( DefButtonNamedTyped pTyped, Form pForm ) { |
|
40 |
+ |
Confirm.isNotNull( "Typed", mTyped = pTyped ); |
|
41 |
+ |
Confirm.isNotNull( "Form", mForm = pForm ); |
|
42 |
+ |
} |
|
43 |
+ |
|
|
44 |
+ |
public final String getName() { |
|
45 |
+ |
return mTyped.getName(); |
|
46 |
+ |
} |
|
47 |
+ |
|
|
48 |
+ |
public String getSize() { |
|
49 |
+ |
return mTyped.getSize(); |
|
50 |
+ |
} |
|
51 |
+ |
|
|
52 |
+ |
public final String getType() { |
|
53 |
+ |
return mTyped.getType(); |
|
54 |
+ |
} |
|
55 |
+ |
|
|
56 |
+ |
public final Form getForm() { |
|
57 |
+ |
return mForm; |
|
58 |
+ |
} |
|
59 |
+ |
|
|
60 |
+ |
public final boolean isDisabled() { |
|
61 |
+ |
return mDisabled; |
|
62 |
+ |
} |
|
63 |
+ |
|
|
64 |
+ |
public final String getEnabledToolTip() { |
|
65 |
+ |
return mEnabledToolTip; |
|
66 |
+ |
} |
|
67 |
+ |
|
|
68 |
+ |
public final String getDisabledToolTip() { |
|
69 |
+ |
return mDisabledToolTip; |
|
70 |
+ |
} |
|
71 |
+ |
|
|
72 |
+ |
public final List<ClickHandler> getClickHandlers() { |
|
73 |
+ |
return (mClickHandlers != null) ? mClickHandlers : Collections.<ClickHandler>emptyList(); |
|
74 |
+ |
} |
|
75 |
+ |
|
|
76 |
+ |
public final DefButtonNamedTypedFactory disabled() { |
|
77 |
+ |
mDisabled = true; |
|
78 |
+ |
return this; |
|
79 |
+ |
} |
|
80 |
+ |
|
|
81 |
+ |
public final DefButtonNamedTypedFactory add( ClickHandler pClickHandler ) { |
|
82 |
+ |
if ( pClickHandler != null ) { |
|
83 |
+ |
if ( mClickHandlers == null ) { |
|
84 |
+ |
mClickHandlers = new ArrayList<ClickHandler>(); |
|
85 |
+ |
} |
|
86 |
+ |
mClickHandlers.add( pClickHandler ); |
|
87 |
+ |
} |
|
88 |
+ |
return this; |
|
89 |
+ |
} |
|
90 |
+ |
|
|
91 |
+ |
public final DefButtonNamedTypedFactory add( CommandHandlerAdaptor pAdaptor ) { |
|
92 |
+ |
return add( (ClickHandler) pAdaptor ); |
|
93 |
+ |
} |
|
94 |
+ |
|
|
95 |
+ |
public final DefButtonNamedTypedFactory add( Command pCommand ) { |
|
96 |
+ |
return (pCommand == null) ? this : add( new ClickHandlerCommandAdaptor( pCommand ) ); |
|
97 |
+ |
} |
|
98 |
+ |
|
|
99 |
+ |
public final DefButtonNamedTypedFactory add( ViewDef pTarget ) { |
|
100 |
+ |
Confirm.isNotNull( "Target (ViewDef)", pTarget ); |
|
101 |
+ |
return add( new ShowScreenCommand( pTarget ) ); |
|
102 |
+ |
} |
|
103 |
+ |
|
|
104 |
+ |
public final DefButtonNamedTypedFactory add( ViewDef pTarget, UriFragmentIdParams pParams ) { |
|
105 |
+ |
Confirm.isNotNull( "Target (ViewDef)", pTarget ); |
|
106 |
+ |
return add( new ShowScreenCommand( pTarget, pParams ) ); |
|
107 |
+ |
} |
|
108 |
+ |
|
|
109 |
+ |
public final DefButtonNamedTypedFactory add( final ViewDef pTarget, final UriFragmentIdParams.ScreenParamsFactory pFactory ) { |
|
110 |
+ |
Confirm.isNotNull( "Target (ViewDef)", pTarget ); |
|
111 |
+ |
Confirm.isNotNull( "Factory", pFactory ); |
|
112 |
+ |
return add( new ClickHandler() { |
|
113 |
+ |
@Override |
|
114 |
+ |
public void onClick( ClickEvent event ) { |
|
115 |
+ |
new ShowScreenCommand( pTarget, pFactory.create( pTarget ) ).execute(); |
|
116 |
+ |
} |
|
117 |
+ |
} ); |
|
118 |
+ |
} |
|
119 |
+ |
|
|
120 |
+ |
public String getCustomStyle() { |
|
121 |
+ |
return mCustomStyle; |
|
122 |
+ |
} |
|
123 |
+ |
|
|
124 |
+ |
public DefButtonNamedTypedFactory customStyle( String pCustomStyle ) { |
|
125 |
+ |
mCustomStyle = ConstrainTo.significantOrNull( pCustomStyle ); |
|
126 |
+ |
return this; |
|
127 |
+ |
} |
|
128 |
+ |
|
|
129 |
+ |
public final DefButtonNamedTypedFactory enabledToolTip( String pEnabledToolTip ) { |
|
130 |
+ |
mEnabledToolTip = ConstrainTo.significantOrNull( pEnabledToolTip ); |
|
131 |
+ |
return this; |
|
132 |
+ |
} |
|
133 |
+ |
|
|
134 |
+ |
public final DefButtonNamedTypedFactory disabledToolTip( String pDisabledToolTip ) { |
|
135 |
+ |
mDisabledToolTip = (pDisabledToolTip == null) ? null : pDisabledToolTip.trim(); |
|
136 |
+ |
return this; |
|
137 |
+ |
} |
|
138 |
+ |
|
|
139 |
+ |
public final Button create() { |
|
140 |
+ |
Button zButton = ButtonFactoryFactory.getFactory().create( this ); |
|
141 |
+ |
for ( ClickHandler zHandler : getClickHandlers() ) { |
|
142 |
+ |
zButton.addClickHandler( zHandler ); |
|
143 |
+ |
} |
|
144 |
+ |
return zButton; |
|
145 |
+ |
} |
|
146 |
+ |
|
|
147 |
+ |
protected abstract String getFormDescription(); |
|
148 |
+ |
|
|
149 |
+ |
@Override |
|
150 |
+ |
public String toString() { |
|
151 |
+ |
StringBuilder sb = new StringBuilder(); |
|
152 |
+ |
sb.append( getType() ).append( "( " ).append( getName() ).append( " )" ); |
|
153 |
+ |
if ( mDisabled ) { |
|
154 |
+ |
sb.append( " Disabled" ); |
|
155 |
+ |
} |
|
156 |
+ |
if ( mCustomStyle != null ) { |
|
157 |
+ |
sb.append( " + " ).append( mCustomStyle ); |
|
158 |
+ |
} |
|
159 |
+ |
sb.append( ": " ).append( mForm ).append( getFormDescription() ); |
|
160 |
+ |
if ( (mEnabledToolTip != null) || (mDisabledToolTip != null) ) { |
|
161 |
+ |
if ( mDisabledToolTip == null ) { |
|
162 |
+ |
sb.append( "\n ToolTip: " ).append( mEnabledToolTip ); |
|
163 |
+ |
} else { |
|
164 |
+ |
if ( mEnabledToolTip != null ) { |
|
165 |
+ |
sb.append( "\n Enabled ToolTip: " ).append( mEnabledToolTip ); |
|
166 |
+ |
} |
|
167 |
+ |
if ( mDisabledToolTip != null ) { |
|
168 |
+ |
if ( mDisabledToolTip.length() == 0 ) { |
|
169 |
+ |
sb.append( "\n No Disabled ToolTip" ); |
|
170 |
+ |
} else { |
|
171 |
+ |
sb.append( "\n Disabled ToolTip: " ).append( mDisabledToolTip ); |
|
172 |
+ |
} |
|
173 |
+ |
} |
|
174 |
+ |
} |
|
175 |
+ |
} |
|
176 |
+ |
return sb.toString(); |
|
177 |
+ |
} |
|
178 |
+ |
} |