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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.GWT.forms.client.components.nonpublic; import org.litesoft.GWT.client.widgets.*; import org.litesoft.GWT.client.widgets.nonpublic.*; import org.litesoft.GWT.forms.client.components.*; import org.litesoft.commonfoundation.base.*; import com.google.gwt.event.dom.client.*; import com.google.gwt.user.client.*; import com.google.gwt.user.client.ui.*; public abstract class AbstractTextElement extends AbstractFocusWidgetErrorableFormElement implements ISizeableWidget, IFormComponentWithRawTextAccess { protected TextBoxBase mTextBoxBase; protected ISizeableDimensionHelper mWidthHelper; protected ISizeableDimensionHelper mHeightHelper; // private HandlerRegistration mChangeHandlerDisposer; protected AbstractTextElement( IFocusWidget pTextBoxBase, String pTooltip, String pWidgetStyle ) { this( pTextBoxBase, (TextBoxBase) pTextBoxBase, pTooltip, pWidgetStyle ); } protected AbstractTextElement( IFocusWidget pInputWidget, TextBoxBase pTextBoxBase, String pTooltip, String pWidgetStyle ) { super( pInputWidget, pTooltip, pWidgetStyle, false ); // mChangeHandlerDisposer = (mTextBoxBase = pTextBoxBase).addChangeHandler( new ChangeHandler() { @Override public void onChange( ChangeEvent event ) { fireChangeListeners(); } } ); } // Example of unregistering // public void dispose() // { // if ( mChangeHandlerDisposer != null ) // { // mChangeHandlerDisposer.removeHandler(); // mChangeHandlerDisposer = null; // } // } // ISizeableWidget @Override public ISizeableDimensionHelper getWidthHelper() { return mWidthHelper; } @Override public ISizeableDimensionHelper getHeightHelper() { return mHeightHelper; } @Override public void relayout() { } /** * Sets the object's width. This width does not include decorations such as * border, margin, and padding. * * @param width the object's new width, in CSS units (e.g. "10px", "1em") */ @Override public void setWidth( String width ) { setDimensionFromWidget( getWidthHelper(), width ); } /** * Sets the object's height. This height does not include decorations such as * border, margin, and padding. * * @param height the object's new height, in CSS units (e.g. "10px", "1em") */ @Override public void setHeight( String height ) { setDimensionFromWidget( getHeightHelper(), height ); } // IFormComponent @Override public Object getCurrentValue() { return getCurrentText(); } @Override public void setCurrentValue( Object pNewValue ) { setCurrentText( (pNewValue == null) ? "" : pNewValue.toString() ); } // Support... @Override public void simulateUserTextEntry( String pText ) { String zCurrentText = getCurrentText(); setCurrentText( pText ); if ( !zCurrentText.equals( getCurrentText() ) ) { fireChangeListeners(); } pullFocusTo( getTextBoxBase() ); } @Override public String getCurrentText() { return ConstrainTo.notNull( getTextBoxBase().getText() ); } public void setCurrentText( String pNewText ) { getTextBoxBase().setText( ConstrainTo.notNull( pNewText ) ); } public TextBoxBase getTextBoxBase() { return mTextBoxBase; } private void setDimensionFromWidget( ISizeableDimensionHelper pDimensionHelper, String pSize_1D ) { int zSize_1D; try { zSize_1D = AbstractSizeableWidget.parse( pSize_1D ); } catch ( NumberFormatException e ) { throw new IllegalArgumentException( "Attempt to set" + pDimensionHelper.getWhat() + "( \"" + pSize_1D + "\" ) on " + getClass().getName() ); } pDimensionHelper.deligateSetDimensionFromWidget( zSize_1D ); } protected static abstract class AbstractHeightHelper extends AbstractDimensionHelper { protected AbstractHeightHelper( boolean pStretchable ) { super( pStretchable, HeightDimensionHelper.INSTANCE ); } } protected static class NullHeightHelper extends AbstractHeightHelper { public static final NullHeightHelper INSTANCE = new NullHeightHelper(); private NullHeightHelper() { super( false ); } } private static abstract class AbstractWidthHelper extends AbstractDimensionHelper { protected AbstractWidthHelper( boolean pStretchable ) { super( pStretchable, WidthDimensionHelper.INSTANCE ); } } protected static class NullWidthHelper extends AbstractWidthHelper { public static final NullWidthHelper INSTANCE = new NullWidthHelper(); private NullWidthHelper() { super( false ); } } protected static class StretchableWidthHelper extends AbstractWidthHelper { private AbstractTextElement mOurWidget; public StretchableWidthHelper( AbstractTextElement pOurWidget ) { super( true ); mOurWidget = pOurWidget; } @Override public void setDimension( int pDimension ) { setDimension( mOurWidget, pDimension ); } @Override public int getDimension() { return getDimension( mOurWidget ); } @Override public int getDimensionMaxShrinkability() { return getDimension( mOurWidget.getInjectedInputWidget() ) - 5; } @Override public int getDecorationSize() { return getDimension() - getDimension( mOurWidget.getInjectedInputWidget() ); } @Override public void deligateSetDimensionFromWidget( int pDimension ) { int zIndicatorSize = 0;//getDimension( mOurWidget.mIndicatorTd ); // Appears to have been a refactor that eliminated the need for this! int zInputDecorationSize = getInputDecorationSize(); int zOuterSandwichDecorationSize = getOuterSandwichDecorationSize(); pDimension -= zIndicatorSize + zInputDecorationSize + zOuterSandwichDecorationSize; if ( pDimension > 5 ) { setDimension( mOurWidget.getInjectedInputWidget(), pDimension ); } } private Integer mInputDecorationSize = null; private int getInputDecorationSize() { if ( mInputDecorationSize == null ) { if ( !mOurWidget.isAttached() ) { return 9999; } mInputDecorationSize = (getDimension( getGrandParent( mOurWidget.getInjectedInputWidget() ) ) - // getDimension( mOurWidget.getInjectedInputWidget() )); } return mInputDecorationSize; } private Integer mOuterSandwichDecorationSize = null; private int getOuterSandwichDecorationSize() { if ( mOuterSandwichDecorationSize == null ) { if ( !mOurWidget.isAttached() ) { return 9999; } Element zDivOrFS = mOurWidget.mInnerHTMLpanel.getElement(); int children = DOM.getChildCount( zDivOrFS ); Element zInnerBread = DOM.getChild( zDivOrFS, children - 1 ); mOuterSandwichDecorationSize = (getDimension( mOurWidget ) - getDimension( zInnerBread )); } return mOuterSandwichDecorationSize; } private Element getGrandParent( Widget pWidget ) { return getGrandParent( pWidget.getElement() ); } private Element getGrandParent( Element pElement ) { return getParent( getParent( pElement ) ); } private Element getParent( Element pElement ) { return DOM.getParent( pElement ); } } } |
Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/forms/client/components/nonpublic/AbstractTextElement.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 |
802 Diff | GeorgeS | Wed 15 Aug, 2012 04:04:47 +0000 | |
49 Diff | GeorgeS | Mon 12 Apr, 2010 02:59:10 +0000 | License Text |
23 Diff | GeorgeS | Wed 24 Feb, 2010 00:34:32 +0000 | |
2 | GeorgeS | Sun 07 Feb, 2010 12:50:58 +0000 |