litesoft
@ HEAD
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 |
// This Source Code is in the Public Domain per: http://unlicense.org package org.litesoft.GWT.client.widgets.nonpublic; import org.litesoft.commonfoundation.base.*; import com.google.gwt.user.client.*; import com.google.gwt.user.client.ui.*; import java.util.*; public abstract class AbstractSizeablePanel extends AbstractSizeableWidget implements HasWidgets { private AbstractSizeableHelper mHelper = new AbstractSizeableHelper( this ); // Outer Element: A Table to Constrain the Style Elements size (Must be the get/set Element) // Style Element: Normally the Div that is sandwiched between the inner and outer tables // Inner Element: Inner most Element @Override protected AbstractSizeableHelper getHelper() { return mHelper; } protected void initializeElements( Element pContainerElement, String pStyleClassName ) { mContainerElement = pContainerElement; setElement( getHelper().getOuterElement() ); initialize(); if ( null != (pStyleClassName = ConstrainTo.significantOrNull( pStyleClassName )) ) { setStyleName( getHelper().getStyleElement(), pStyleClassName, true ); } } abstract public boolean anyChildren(); // vvvvvvvvvvv HasWidgets /** * Removes all child widgets. */ @Override public void clear() { Iterator<Widget> it = iterator(); while ( it.hasNext() ) { it.next(); it.remove(); } } // ^^^^^^^^^^^ HasWidgets /** * This method must be called as part of the add method of any panel. It * ensures that the Widget's parent is set properly, and that it is removed * from any existing parent widget. It also attaches the child widget's * DOM element to its new container, ensuring that this process occurs in the * right order. * * @param w the widget to be adopted * @param container the element within which it will be contained * * @return container element passed in */ protected Element adopt( Widget w, Element container ) { // Remove the widget from its current parent, if any. w.removeFromParent(); // Attach it at the DOM and GWT levels. if ( container != null ) { appendChild( container, w.getElement() ); } //noinspection NonJREEmulationClassesInClientCode BackDoorToWidget.setParent( w, this ); return container; } /** * This method must be called whenever a Widget is removed. It ensures that * the Widget's parent is cleared. * * @param w the widget to be disowned * * @return Parent Element */ protected Element disown( Widget w ) { // Only disown it if it's actually contained in this panel. if ( !isOur( w ) ) { throw new IllegalArgumentException( "widget (" + w + ") is not a child of this panel" ); } // Remove it at the DOM and GWT levels. Element elem = w.getElement(); //noinspection NonJREEmulationClassesInClientCode BackDoorToWidget.setParent( w, null ); return removeAsChildAndGetParent( elem ); } protected Element removeAsChildAndGetParent( Element pElem ) { Element zParent = DOM.getParent( pElem ); DOM.removeChild( zParent, pElem ); return zParent; } protected static Element prependChild( Element pParent, Element pChild ) { DOM.insertChild( pParent, pChild, 0 ); return pParent; } protected static Element appendChild( Element pParent, Element pChild ) { DOM.appendChild( pParent, pChild ); return pParent; } protected static Element getParentElement( Widget pWidget ) { return DOM.getParent( pWidget.getElement() ); } protected static Element getGrandParentElement( Widget pWidget ) { return DOM.getParent( getParentElement( pWidget ) ); } @Override protected void onAttach() { super.onAttach(); // Ensure that all child widgets are attached. for ( Widget child : this ) { //noinspection NonJREEmulationClassesInClientCode BackDoorToWidget.onAttach( child ); } } @Override protected void onDetach() { super.onDetach(); // Ensure that all child widgets are detached. for ( Widget child : this ) { //noinspection NonJREEmulationClassesInClientCode BackDoorToWidget.onDetach( child ); } } /** * Override this method to specify that an element other than the root element * be the container for the panel's child widget. This can be useful when you * want to create a simple panel that decorates its contents. * * @return the element to be used as the panel's container */ protected Element getContainerElement() { return mContainerElement; } private Element mContainerElement; public void setContainerElement( Element pContainerElement ) { mContainerElement = pContainerElement; } protected boolean isOur( Widget pWidget ) { return (pWidget != null) && (pWidget.getParent() == this); } protected ISizeableWidget getSizeableWidget( Widget pWidget ) { return (pWidget instanceof ISizeableWidget) ? (ISizeableWidget) pWidget : ISizeableWidget.NULL; } } |
Commits for litesoft/trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/nonpublic/AbstractSizeablePanel.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 |
801 Diff | GeorgeS | Wed 15 Aug, 2012 03:59:02 +0000 | |
151 Diff | GeorgeS | Thu 17 Mar, 2011 04:16:22 +0000 | |
60 Diff | GeorgeS | Tue 24 Aug, 2010 00:37:36 +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 |