|
@@ -3,13 +3,12 @@ |
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 AbstractSizeableComplexPanel extends AbstractSizeablePanel |
12 |
|
- |
{ |
|
9 |
+ |
import java.util.*; |
|
10 |
+ |
|
|
11 |
+ |
public abstract class AbstractSizeableComplexPanel extends AbstractSizeablePanel { |
13 |
12 |
|
private WidgetCollection mChildren = new WidgetCollection( this ); |
14 |
13 |
|
|
15 |
14 |
|
/** |
|
@@ -17,44 +16,37 @@ |
17 |
16 |
|
* |
18 |
17 |
|
* @return a collection of child widgets |
19 |
18 |
|
*/ |
20 |
|
- |
protected WidgetCollection getChildren() |
21 |
|
- |
{ |
|
19 |
+ |
protected WidgetCollection getChildren() { |
22 |
20 |
|
return mChildren; |
23 |
21 |
|
} |
24 |
22 |
|
|
25 |
|
- |
protected Widget getWidget( int index ) |
26 |
|
- |
{ |
|
23 |
+ |
protected Widget getWidget( int index ) { |
27 |
24 |
|
return getChildren().get( index ); |
28 |
25 |
|
} |
29 |
26 |
|
|
30 |
|
- |
protected int getWidgetCount() |
31 |
|
- |
{ |
|
27 |
+ |
protected int getWidgetCount() { |
32 |
28 |
|
return getChildren().size(); |
33 |
29 |
|
} |
34 |
30 |
|
|
35 |
|
- |
protected int getWidgetIndex( Widget child ) |
36 |
|
- |
{ |
|
31 |
+ |
protected int getWidgetIndex( Widget child ) { |
37 |
32 |
|
return getChildren().indexOf( child ); |
38 |
33 |
|
} |
39 |
34 |
|
|
40 |
35 |
|
@Override |
41 |
|
- |
public boolean anyChildren() |
42 |
|
- |
{ |
|
36 |
+ |
public boolean anyChildren() { |
43 |
37 |
|
return (mChildren.size() != 0); |
44 |
38 |
|
} |
45 |
39 |
|
|
46 |
|
- |
@SuppressWarnings({"unchecked"}) @Override |
47 |
|
- |
public Iterator iterator() |
48 |
|
- |
{ |
|
40 |
+ |
@SuppressWarnings({"unchecked"}) |
|
41 |
+ |
@Override |
|
42 |
+ |
public Iterator iterator() { |
49 |
43 |
|
return mChildren.iterator(); |
50 |
44 |
|
} |
51 |
45 |
|
|
52 |
46 |
|
@Override |
53 |
|
- |
public boolean remove( Widget w ) |
54 |
|
- |
{ |
|
47 |
+ |
public boolean remove( Widget w ) { |
55 |
48 |
|
// Make sure this panel actually contains the child widget. |
56 |
|
- |
if ( !mChildren.contains( w ) ) |
57 |
|
- |
{ |
|
49 |
+ |
if ( !mChildren.contains( w ) ) { |
58 |
50 |
|
return false; |
59 |
51 |
|
} |
60 |
52 |
|
|
|
@@ -71,8 +63,7 @@ |
71 |
63 |
|
* @param w the child widget to be added |
72 |
64 |
|
* @param container the element within which the child will be contained |
73 |
65 |
|
*/ |
74 |
|
- |
protected void add( Widget w, Element container ) |
75 |
|
- |
{ |
|
66 |
+ |
protected void add( Widget w, Element container ) { |
76 |
67 |
|
insert( w, container, mChildren.size() ); |
77 |
68 |
|
} |
78 |
69 |
|
|
|
@@ -83,8 +74,7 @@ |
83 |
74 |
|
* @param container the element within which the child will be contained |
84 |
75 |
|
* @param beforeIndex the index before which the widget will be added |
85 |
76 |
|
*/ |
86 |
|
- |
protected void insert( Widget child, Element container, int beforeIndex ) |
87 |
|
- |
{ |
|
77 |
+ |
protected void insert( Widget child, Element container, int beforeIndex ) { |
88 |
78 |
|
beforeIndex = adjustIndexIfChildInteracts( beforeIndex, child ); |
89 |
79 |
|
|
90 |
80 |
|
adopt( child, container ); |
|
@@ -92,25 +82,21 @@ |
92 |
82 |
|
mChildren.insert( child, beforeIndex ); |
93 |
83 |
|
} |
94 |
84 |
|
|
95 |
|
- |
protected int adjustIndexIfChildInteracts( int pBeforeIndex, Widget pChild ) |
96 |
|
- |
{ |
|
85 |
+ |
protected int adjustIndexIfChildInteracts( int pBeforeIndex, Widget pChild ) { |
97 |
86 |
|
validateInsertionIndex( pBeforeIndex ); |
98 |
87 |
|
|
99 |
|
- |
if ( (pChild.getParent() == this) && (getWidgetIndex( pChild ) < pBeforeIndex) ) |
100 |
|
- |
{ |
|
88 |
+ |
if ( (pChild.getParent() == this) && (getWidgetIndex( pChild ) < pBeforeIndex) ) { |
101 |
89 |
|
return pBeforeIndex - 1; |
102 |
90 |
|
} |
103 |
91 |
|
|
104 |
92 |
|
return pBeforeIndex; |
105 |
93 |
|
} |
106 |
94 |
|
|
107 |
|
- |
protected void validateReadIndex( int pIndex ) |
108 |
|
- |
{ |
|
95 |
+ |
protected void validateReadIndex( int pIndex ) { |
109 |
96 |
|
Integers.validateIndex( pIndex, getWidgetCount(), false ); |
110 |
97 |
|
} |
111 |
98 |
|
|
112 |
|
- |
protected void validateInsertionIndex( int pIndex ) |
113 |
|
- |
{ |
|
99 |
+ |
protected void validateInsertionIndex( int pIndex ) { |
114 |
100 |
|
Integers.validateIndex( pIndex, getWidgetCount(), true ); |
115 |
101 |
|
} |
116 |
102 |
|
} |