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