|
@@ -3,31 +3,27 @@ |
3 |
3 |
|
|
4 |
4 |
|
import org.litesoft.commonfoundation.typeutils.*; |
5 |
5 |
|
|
6 |
|
- |
import java.util.*; |
7 |
|
- |
|
8 |
6 |
|
import com.google.gwt.user.client.*; |
9 |
7 |
|
import com.google.gwt.user.client.ui.*; |
10 |
8 |
|
|
11 |
|
- |
public abstract class AbstractSizeablePanel extends AbstractSizeableWidget implements HasWidgets |
12 |
|
- |
{ |
|
9 |
+ |
import java.util.*; |
|
10 |
+ |
|
|
11 |
+ |
public abstract class AbstractSizeablePanel extends AbstractSizeableWidget implements HasWidgets { |
13 |
12 |
|
private AbstractSizeableHelper mHelper = new AbstractSizeableHelper( this ); |
14 |
13 |
|
// Outer Element: A Table to Constrain the Style Elements size (Must be the get/set Element) |
15 |
14 |
|
// Style Element: Normally the Div that is sandwiched between the inner and outer tables |
16 |
15 |
|
// Inner Element: Inner most Element |
17 |
16 |
|
|
18 |
17 |
|
@Override |
19 |
|
- |
protected AbstractSizeableHelper getHelper() |
20 |
|
- |
{ |
|
18 |
+ |
protected AbstractSizeableHelper getHelper() { |
21 |
19 |
|
return mHelper; |
22 |
20 |
|
} |
23 |
21 |
|
|
24 |
|
- |
protected void initializeElements( Element pContainerElement, String pStyleClassName ) |
25 |
|
- |
{ |
|
22 |
+ |
protected void initializeElements( Element pContainerElement, String pStyleClassName ) { |
26 |
23 |
|
mContainerElement = pContainerElement; |
27 |
24 |
|
setElement( getHelper().getOuterElement() ); |
28 |
25 |
|
initialize(); |
29 |
|
- |
if ( null != (pStyleClassName = Strings.noEmpty( pStyleClassName )) ) |
30 |
|
- |
{ |
|
26 |
+ |
if ( null != (pStyleClassName = Strings.noEmpty( pStyleClassName )) ) { |
31 |
27 |
|
setStyleName( getHelper().getStyleElement(), pStyleClassName, true ); |
32 |
28 |
|
} |
33 |
29 |
|
} |
|
@@ -40,11 +36,9 @@ |
40 |
36 |
|
* Removes all child widgets. |
41 |
37 |
|
*/ |
42 |
38 |
|
@Override |
43 |
|
- |
public void clear() |
44 |
|
- |
{ |
|
39 |
+ |
public void clear() { |
45 |
40 |
|
Iterator<Widget> it = iterator(); |
46 |
|
- |
while ( it.hasNext() ) |
47 |
|
- |
{ |
|
41 |
+ |
while ( it.hasNext() ) { |
48 |
42 |
|
it.next(); |
49 |
43 |
|
it.remove(); |
50 |
44 |
|
} |
|
@@ -64,14 +58,12 @@ |
64 |
58 |
|
* |
65 |
59 |
|
* @return container element passed in |
66 |
60 |
|
*/ |
67 |
|
- |
protected Element adopt( Widget w, Element container ) |
68 |
|
- |
{ |
|
61 |
+ |
protected Element adopt( Widget w, Element container ) { |
69 |
62 |
|
// Remove the widget from its current parent, if any. |
70 |
63 |
|
w.removeFromParent(); |
71 |
64 |
|
|
72 |
65 |
|
// Attach it at the DOM and GWT levels. |
73 |
|
- |
if ( container != null ) |
74 |
|
- |
{ |
|
66 |
+ |
if ( container != null ) { |
75 |
67 |
|
appendChild( container, w.getElement() ); |
76 |
68 |
|
} |
77 |
69 |
|
//noinspection NonJREEmulationClassesInClientCode |
|
@@ -88,11 +80,9 @@ |
88 |
80 |
|
* |
89 |
81 |
|
* @return Parent Element |
90 |
82 |
|
*/ |
91 |
|
- |
protected Element disown( Widget w ) |
92 |
|
- |
{ |
|
83 |
+ |
protected Element disown( Widget w ) { |
93 |
84 |
|
// Only disown it if it's actually contained in this panel. |
94 |
|
- |
if ( !isOur( w ) ) |
95 |
|
- |
{ |
|
85 |
+ |
if ( !isOur( w ) ) { |
96 |
86 |
|
throw new IllegalArgumentException( "widget (" + w + ") is not a child of this panel" ); |
97 |
87 |
|
} |
98 |
88 |
|
|
|
@@ -103,56 +93,47 @@ |
103 |
93 |
|
return removeAsChildAndGetParent( elem ); |
104 |
94 |
|
} |
105 |
95 |
|
|
106 |
|
- |
protected Element removeAsChildAndGetParent( Element pElem ) |
107 |
|
- |
{ |
|
96 |
+ |
protected Element removeAsChildAndGetParent( Element pElem ) { |
108 |
97 |
|
Element zParent = DOM.getParent( pElem ); |
109 |
98 |
|
DOM.removeChild( zParent, pElem ); |
110 |
99 |
|
return zParent; |
111 |
100 |
|
} |
112 |
101 |
|
|
113 |
|
- |
protected static Element prependChild( Element pParent, Element pChild ) |
114 |
|
- |
{ |
|
102 |
+ |
protected static Element prependChild( Element pParent, Element pChild ) { |
115 |
103 |
|
DOM.insertChild( pParent, pChild, 0 ); |
116 |
104 |
|
return pParent; |
117 |
105 |
|
} |
118 |
106 |
|
|
119 |
|
- |
protected static Element appendChild( Element pParent, Element pChild ) |
120 |
|
- |
{ |
|
107 |
+ |
protected static Element appendChild( Element pParent, Element pChild ) { |
121 |
108 |
|
DOM.appendChild( pParent, pChild ); |
122 |
109 |
|
return pParent; |
123 |
110 |
|
} |
124 |
111 |
|
|
125 |
|
- |
protected static Element getParentElement( Widget pWidget ) |
126 |
|
- |
{ |
|
112 |
+ |
protected static Element getParentElement( Widget pWidget ) { |
127 |
113 |
|
return DOM.getParent( pWidget.getElement() ); |
128 |
114 |
|
} |
129 |
115 |
|
|
130 |
|
- |
protected static Element getGrandParentElement( Widget pWidget ) |
131 |
|
- |
{ |
|
116 |
+ |
protected static Element getGrandParentElement( Widget pWidget ) { |
132 |
117 |
|
return DOM.getParent( getParentElement( pWidget ) ); |
133 |
118 |
|
} |
134 |
119 |
|
|
135 |
120 |
|
@Override |
136 |
|
- |
protected void onAttach() |
137 |
|
- |
{ |
|
121 |
+ |
protected void onAttach() { |
138 |
122 |
|
super.onAttach(); |
139 |
123 |
|
|
140 |
124 |
|
// Ensure that all child widgets are attached. |
141 |
|
- |
for ( Widget child : this ) |
142 |
|
- |
{ |
|
125 |
+ |
for ( Widget child : this ) { |
143 |
126 |
|
//noinspection NonJREEmulationClassesInClientCode |
144 |
127 |
|
BackDoorToWidget.onAttach( child ); |
145 |
128 |
|
} |
146 |
129 |
|
} |
147 |
130 |
|
|
148 |
131 |
|
@Override |
149 |
|
- |
protected void onDetach() |
150 |
|
- |
{ |
|
132 |
+ |
protected void onDetach() { |
151 |
133 |
|
super.onDetach(); |
152 |
134 |
|
|
153 |
135 |
|
// Ensure that all child widgets are detached. |
154 |
|
- |
for ( Widget child : this ) |
155 |
|
- |
{ |
|
136 |
+ |
for ( Widget child : this ) { |
156 |
137 |
|
//noinspection NonJREEmulationClassesInClientCode |
157 |
138 |
|
BackDoorToWidget.onDetach( child ); |
158 |
139 |
|
} |
|
@@ -165,25 +146,21 @@ |
165 |
146 |
|
* |
166 |
147 |
|
* @return the element to be used as the panel's container |
167 |
148 |
|
*/ |
168 |
|
- |
protected Element getContainerElement() |
169 |
|
- |
{ |
|
149 |
+ |
protected Element getContainerElement() { |
170 |
150 |
|
return mContainerElement; |
171 |
151 |
|
} |
172 |
152 |
|
|
173 |
153 |
|
private Element mContainerElement; |
174 |
154 |
|
|
175 |
|
- |
public void setContainerElement( Element pContainerElement ) |
176 |
|
- |
{ |
|
155 |
+ |
public void setContainerElement( Element pContainerElement ) { |
177 |
156 |
|
mContainerElement = pContainerElement; |
178 |
157 |
|
} |
179 |
158 |
|
|
180 |
|
- |
protected boolean isOur( Widget pWidget ) |
181 |
|
- |
{ |
|
159 |
+ |
protected boolean isOur( Widget pWidget ) { |
182 |
160 |
|
return (pWidget != null) && (pWidget.getParent() == this); |
183 |
161 |
|
} |
184 |
162 |
|
|
185 |
|
- |
protected ISizeableWidget getSizeableWidget( Widget pWidget ) |
186 |
|
- |
{ |
|
163 |
+ |
protected ISizeableWidget getSizeableWidget( Widget pWidget ) { |
187 |
164 |
|
return (pWidget instanceof ISizeableWidget) ? (ISizeableWidget) pWidget : ISizeableWidget.NULL; |
188 |
165 |
|
} |
189 |
166 |
|
} |