|
@@ -10,17 +10,14 @@ |
10 |
10 |
|
import com.google.gwt.user.client.*; |
11 |
11 |
|
import com.google.gwt.user.client.ui.*; |
12 |
12 |
|
|
13 |
|
- |
public abstract class AbstractContextPopup extends PopupPanel |
14 |
|
- |
{ |
|
13 |
+ |
public abstract class AbstractContextPopup extends PopupPanel { |
15 |
14 |
|
private static final String ERROR_FROM = "AbstractContextPopup"; |
16 |
15 |
|
|
17 |
|
- |
protected AbstractContextPopup( boolean pAutoHide ) |
18 |
|
- |
{ |
|
16 |
+ |
protected AbstractContextPopup( boolean pAutoHide ) { |
19 |
17 |
|
super( pAutoHide ); |
20 |
18 |
|
} |
21 |
19 |
|
|
22 |
|
- |
protected void error( String pProblem, RuntimeException pRTE ) |
23 |
|
- |
{ |
|
20 |
+ |
protected void error( String pProblem, RuntimeException pRTE ) { |
24 |
21 |
|
AlertManager.alert( ERROR_FROM, "Contextual Options Error", pProblem, pRTE ); |
25 |
22 |
|
} |
26 |
23 |
|
|
|
@@ -30,29 +27,24 @@ |
30 |
27 |
|
* Show the Context Popup, positioning it based on the pEvent's Client X & Y positions, and |
31 |
28 |
|
* the two provided Relative Rectangular "meeting" Points. |
32 |
29 |
|
* |
33 |
|
- |
* @param pEvent !null - used to get the Target (Source) Element & the Mouse |
34 |
|
- |
* location (Client X & Y) |
35 |
|
- |
* @param pRectangleContainmentStrategy !null - Controls Popup location should any of the Popup be off screen. |
36 |
|
- |
* @param pSourceElementRelativeMeetingPoint |
37 |
|
- |
* if not null then indicates to use the clicked on element's |
38 |
|
- |
* location, size, and this "point" as the "meeting" point |
39 |
|
- |
* @param pPopupRelativeMeetingPoint the Popup's "meeting" point. null defaults to "CornerTopLeft" |
|
30 |
+ |
* @param pEvent !null - used to get the Target (Source) Element & the Mouse |
|
31 |
+ |
* location (Client X & Y) |
|
32 |
+ |
* @param pRectangleContainmentStrategy !null - Controls Popup location should any of the Popup be off screen. |
|
33 |
+ |
* @param pSourceElementRelativeMeetingPoint if not null then indicates to use the clicked on element's |
|
34 |
+ |
* location, size, and this "point" as the "meeting" point |
|
35 |
+ |
* @param pPopupRelativeMeetingPoint the Popup's "meeting" point. null defaults to "CornerTopLeft" |
40 |
36 |
|
*/ |
41 |
37 |
|
public void showContextPopup( Event pEvent, // |
42 |
38 |
|
RectangleContainmentStrategy pRectangleContainmentStrategy, // |
43 |
|
- |
CommonRectangularPoint pSourceElementRelativeMeetingPoint, CommonRectangularPoint pPopupRelativeMeetingPoint ) |
44 |
|
- |
{ |
|
39 |
+ |
CommonRectangularPoint pSourceElementRelativeMeetingPoint, CommonRectangularPoint pPopupRelativeMeetingPoint ) { |
45 |
40 |
|
Widget zWidget; |
46 |
|
- |
try |
47 |
|
- |
{ |
48 |
|
- |
if ( null == (zWidget = createPopupWidget()) ) |
49 |
|
- |
{ |
|
41 |
+ |
try { |
|
42 |
+ |
if ( null == (zWidget = createPopupWidget()) ) { |
50 |
43 |
|
error( "No Widget", null ); |
51 |
44 |
|
return; |
52 |
45 |
|
} |
53 |
46 |
|
} |
54 |
|
- |
catch ( RuntimeException e ) |
55 |
|
- |
{ |
|
47 |
+ |
catch ( RuntimeException e ) { |
56 |
48 |
|
error( e.getMessage(), e ); |
57 |
49 |
|
return; |
58 |
50 |
|
} |
|
@@ -66,12 +58,10 @@ |
66 |
58 |
|
} |
67 |
59 |
|
|
68 |
60 |
|
@Override |
69 |
|
- |
public void show() |
70 |
|
- |
{ |
|
61 |
+ |
public void show() { |
71 |
62 |
|
super.show(); |
72 |
63 |
|
mSavedCaptureElement = DOM.getCaptureElement(); |
73 |
|
- |
if ( mSavedCaptureElement != null ) |
74 |
|
- |
{ |
|
64 |
+ |
if ( mSavedCaptureElement != null ) { |
75 |
65 |
|
DOM.releaseCapture( mSavedCaptureElement ); |
76 |
66 |
|
} |
77 |
67 |
|
} |
|
@@ -79,32 +69,26 @@ |
79 |
69 |
|
private Element mSavedCaptureElement = null; |
80 |
70 |
|
|
81 |
71 |
|
@Override |
82 |
|
- |
public void hide() |
83 |
|
- |
{ |
84 |
|
- |
if ( mSavedCaptureElement != null ) |
85 |
|
- |
{ |
|
72 |
+ |
public void hide() { |
|
73 |
+ |
if ( mSavedCaptureElement != null ) { |
86 |
74 |
|
DOM.setCapture( mSavedCaptureElement ); |
87 |
75 |
|
mSavedCaptureElement = null; |
88 |
76 |
|
} |
89 |
77 |
|
super.hide(); |
90 |
78 |
|
} |
91 |
79 |
|
|
92 |
|
- |
private class MyPositionCallback implements PositionCallback |
93 |
|
- |
{ |
|
80 |
+ |
private class MyPositionCallback implements PositionCallback { |
94 |
81 |
|
private ContextPopupPositioner mPositioner; |
95 |
82 |
|
|
96 |
|
- |
public MyPositionCallback( RectangleContainmentStrategy pRectangleContainmentStrategy, CommonRectangularPoint pSourceElementRelativeMeetingPoint, Event pEvent, CommonRectangularPoint pPopupRelativeMeetingPoint ) |
97 |
|
- |
{ |
|
83 |
+ |
public MyPositionCallback( RectangleContainmentStrategy pRectangleContainmentStrategy, CommonRectangularPoint pSourceElementRelativeMeetingPoint, |
|
84 |
+ |
Event pEvent, CommonRectangularPoint pPopupRelativeMeetingPoint ) { |
98 |
85 |
|
SizeXY zClientSize = new SizeXY( Window.getClientWidth(), Window.getClientHeight() ); |
99 |
86 |
|
PointXY zClientPos = new PointXY( DOM.eventGetClientX( pEvent ), DOM.eventGetClientY( pEvent ) ); |
100 |
87 |
|
|
101 |
|
- |
if ( pSourceElementRelativeMeetingPoint == null ) |
102 |
|
- |
{ |
|
88 |
+ |
if ( pSourceElementRelativeMeetingPoint == null ) { |
103 |
89 |
|
mPositioner = new ContextPopupPositioner( pRectangleContainmentStrategy, pPopupRelativeMeetingPoint,// |
104 |
90 |
|
zClientPos, zClientSize ); |
105 |
|
- |
} |
106 |
|
- |
else |
107 |
|
- |
{ |
|
91 |
+ |
} else { |
108 |
92 |
|
Element zTargetElement = DOM.eventGetTarget( pEvent ); |
109 |
93 |
|
int zSrcElementXpos = DOM.getAbsoluteLeft( zTargetElement ); |
110 |
94 |
|
int zSrcElementYpos = DOM.getAbsoluteTop( zTargetElement ); |
|
@@ -112,24 +96,22 @@ |
112 |
96 |
|
int zSrcElementYsize = CommonElementHelper.getOffsetHeight( zTargetElement ); |
113 |
97 |
|
Rect zSourceElementRect = new Rect( zSrcElementXpos, zSrcElementYpos, // |
114 |
98 |
|
zSrcElementXsize, zSrcElementYsize ); |
115 |
|
- |
mPositioner = new SourceRelativeContextPopupPositioner( pRectangleContainmentStrategy, pPopupRelativeMeetingPoint, zClientPos, zClientSize, pSourceElementRelativeMeetingPoint, zSourceElementRect ); |
|
99 |
+ |
mPositioner = new SourceRelativeContextPopupPositioner( pRectangleContainmentStrategy, pPopupRelativeMeetingPoint, zClientPos, zClientSize, |
|
100 |
+ |
pSourceElementRelativeMeetingPoint, zSourceElementRect ); |
116 |
101 |
|
} |
117 |
102 |
|
} |
118 |
103 |
|
|
119 |
104 |
|
@Override |
120 |
|
- |
public String toString() |
121 |
|
- |
{ |
|
105 |
+ |
public String toString() { |
122 |
106 |
|
return mPositioner.toString(); |
123 |
107 |
|
} |
124 |
108 |
|
|
125 |
109 |
|
@Override |
126 |
|
- |
public void setPosition( int pPopupXsize, int pPopupYsize ) |
127 |
|
- |
{ |
|
110 |
+ |
public void setPosition( int pPopupXsize, int pPopupYsize ) { |
128 |
111 |
|
adjustPopup( mPositioner.determinePosition( new Rect( 0, 0, pPopupXsize, pPopupYsize ) ) ); |
129 |
112 |
|
} |
130 |
113 |
|
|
131 |
|
- |
protected void adjustPopup( Rect pRect ) |
132 |
|
- |
{ |
|
114 |
+ |
protected void adjustPopup( Rect pRect ) { |
133 |
115 |
|
setPopupPosition( pRect.getXpos(), pRect.getYpos() ); |
134 |
116 |
|
} |
135 |
117 |
|
} |