Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/OldClient/src/org/litesoft/GWT/forms/client/components/factories/others/UiInputWidgetFactory.java

Diff revisions: vs.
  @@ -1,59 +1,59 @@
1 - // This Source Code is in the Public Domain per: http://unlicense.org
2 - package org.litesoft.GWT.forms.client.components.factories.others;
3 -
4 - import org.litesoft.GWT.forms.client.components.factories.*;
5 - import org.litesoft.GWT.forms.client.components.factories.input.*;
6 - import org.litesoft.GWT.forms.client.nonpublic.*;
7 - import org.litesoft.ui.def.*;
8 - import org.litesoft.ui.def.nonpublic.*;
9 - import org.litesoft.ui.def.nonpublic.support.*;
10 -
11 - import com.google.gwt.user.client.ui.*;
12 -
13 - import java.util.*;
14 -
15 - public class UiInputWidgetFactory implements FormComponentFactory {
16 - public Widget create( FormInstanceComponentHandler pComponentHandler, UiDef pUiDef,
17 - FormMetaData pFormMetaData, boolean pHasHorizontalPeer ) {
18 - UiInputDef zDef = (UiInputDef) pUiDef;
19 - AttributeMetaData zMD = pFormMetaData.getAttribute( zDef );
20 - if ( zMD == null ) {
21 - throw new IllegalStateException( "Metadata required for a " + zDef );
22 - }
23 - if ( zMD.getIntendedUse().isView() ) {
24 - return UiViewWidgetFactory.INSTANCE.create( pComponentHandler, //
25 - pUiDef, pFormMetaData, pHasHorizontalPeer );
26 - }
27 - InputWidgetFactory factory = get( zMD );
28 - if ( factory != null ) {
29 - return factory.create( pComponentHandler, zDef, zMD, pHasHorizontalPeer );
30 - }
31 - return new Label( "No InputWidgetFactory for " + zMD );
32 - }
33 -
34 - public static void add( String pWhatWeAre, InputWidgetFactory pInputWidgetFactory ) {
35 - sMetaDataWhatWeAreToInputWidgetFactory.put( pWhatWeAre, pInputWidgetFactory );
36 - }
37 -
38 - private static InputWidgetFactory get( AttributeMetaData pAttributeMetaData ) {
39 - return (InputWidgetFactory) sMetaDataWhatWeAreToInputWidgetFactory.get(
40 - pAttributeMetaData.getWhatWeAre() );
41 - }
42 -
43 - private static final Map sMetaDataWhatWeAreToInputWidgetFactory = new HashMap();
44 -
45 - static {
46 - add( CheckBoxMetaData.WHAT_WE_ARE, /* */ new UiCheckBoxWidgetFactory() );
47 - add( PasswordFieldMetaData.WHAT_WE_ARE, /* */ new UiPasswordFieldWidgetFactory() );
48 - add( TextFieldMetaData.WHAT_WE_ARE, /* */ new UiTextFieldWidgetFactory() );
49 - add( TextAreaMetaData.WHAT_WE_ARE, /* */ new UiTextAreaWidgetFactory() );
50 - add( ComboBoxMetaData.WHAT_WE_ARE, /* */ new UiComboBoxWidgetFactory() );
51 - add( RadioGroupMetaData.WHAT_WE_ARE, /* */ new UiRadioGroupWidgetFactory() );
52 - add( FloatMetaData.WHAT_WE_ARE, /* */ new UiFloatWidgetFactory() );
53 - add( DoubleMetaData.WHAT_WE_ARE, /* */ new UiDoubleWidgetFactory() );
54 - add( LongMetaData.WHAT_WE_ARE, /* */ new UiLongWidgetFactory() );
55 - add( CalendarYMDMetaData.WHAT_WE_ARE, /* */ new UiDatePickerWidgetFactory() );
56 - add( SimpleTimeMetaData.WHAT_WE_ARE, /* */ new UiTimePickerWidgetFactory() );
57 - add( SimpleTimestampMetaData.WHAT_WE_ARE, /**/new UiTimestampPickerWidgetFactory() );
58 - }
59 - }
1 + // This Source Code is in the Public Domain per: http://unlicense.org
2 + package org.litesoft.GWT.forms.client.components.factories.others;
3 +
4 + import org.litesoft.GWT.forms.client.components.factories.*;
5 + import org.litesoft.GWT.forms.client.components.factories.input.*;
6 + import org.litesoft.GWT.forms.client.nonpublic.*;
7 + import org.litesoft.ui.def.*;
8 + import org.litesoft.ui.def.nonpublic.*;
9 + import org.litesoft.ui.def.nonpublic.support.*;
10 +
11 + import com.google.gwt.user.client.ui.*;
12 +
13 + import java.util.*;
14 +
15 + public class UiInputWidgetFactory implements FormComponentFactory {
16 + public Widget create( FormInstanceComponentHandler pComponentHandler, UiDef pUiDef,
17 + FormMetaData pFormMetaData, boolean pHasHorizontalPeer ) {
18 + UiInputDef zDef = (UiInputDef) pUiDef;
19 + AttributeMetaData zMD = pFormMetaData.getAttribute( zDef );
20 + if ( zMD == null ) {
21 + throw new IllegalStateException( "Metadata required for a " + zDef );
22 + }
23 + if ( zMD.getIntendedUse().isView() ) {
24 + return UiViewWidgetFactory.INSTANCE.create( pComponentHandler, //
25 + pUiDef, pFormMetaData, pHasHorizontalPeer );
26 + }
27 + InputWidgetFactory factory = get( zMD );
28 + if ( factory != null ) {
29 + return factory.create( pComponentHandler, zDef, zMD, pHasHorizontalPeer );
30 + }
31 + return new Label( "No InputWidgetFactory for " + zMD );
32 + }
33 +
34 + public static void add( String pWhatWeAre, InputWidgetFactory pInputWidgetFactory ) {
35 + sMetaDataWhatWeAreToInputWidgetFactory.put( pWhatWeAre, pInputWidgetFactory );
36 + }
37 +
38 + private static InputWidgetFactory get( AttributeMetaData pAttributeMetaData ) {
39 + return (InputWidgetFactory) sMetaDataWhatWeAreToInputWidgetFactory.get(
40 + pAttributeMetaData.getWhatWeAre() );
41 + }
42 +
43 + private static final Map sMetaDataWhatWeAreToInputWidgetFactory = new HashMap();
44 +
45 + static {
46 + add( CheckBoxMetaData.WHAT_WE_ARE, /* */ new UiCheckBoxWidgetFactory() );
47 + add( PasswordFieldMetaData.WHAT_WE_ARE, /* */ new UiPasswordFieldWidgetFactory() );
48 + add( TextFieldMetaData.WHAT_WE_ARE, /* */ new UiTextFieldWidgetFactory() );
49 + add( TextAreaMetaData.WHAT_WE_ARE, /* */ new UiTextAreaWidgetFactory() );
50 + add( ComboBoxMetaData.WHAT_WE_ARE, /* */ new UiComboBoxWidgetFactory() );
51 + add( RadioGroupMetaData.WHAT_WE_ARE, /* */ new UiRadioGroupWidgetFactory() );
52 + add( FloatMetaData.WHAT_WE_ARE, /* */ new UiFloatWidgetFactory() );
53 + add( DoubleMetaData.WHAT_WE_ARE, /* */ new UiDoubleWidgetFactory() );
54 + add( LongMetaData.WHAT_WE_ARE, /* */ new UiLongWidgetFactory() );
55 + add( CalendarYMDMetaData.WHAT_WE_ARE, /* */ new UiDatePickerWidgetFactory() );
56 + add( SimpleTimeMetaData.WHAT_WE_ARE, /* */ new UiTimePickerWidgetFactory() );
57 + add( SimpleTimestampMetaData.WHAT_WE_ARE, /**/new UiTimestampPickerWidgetFactory() );
58 + }
59 + }