|
@@ -1,11 +1,9 @@ |
1 |
1 |
|
package com.temp.client.foundation.widget.dialog; |
2 |
2 |
|
|
3 |
|
- |
import com.temp.client.foundation.handler.ActionHandler; |
4 |
|
- |
import com.temp.client.foundation.widget.OurPushButton; |
5 |
|
- |
|
6 |
|
- |
import com.google.gwt.event.dom.client.ClickEvent; |
7 |
|
- |
import com.google.gwt.event.dom.client.ClickHandler; |
8 |
|
- |
import com.google.gwt.user.client.ui.ButtonBase; |
|
3 |
+ |
import com.google.gwt.event.dom.client.*; |
|
4 |
+ |
import com.google.gwt.user.client.ui.*; |
|
5 |
+ |
import com.temp.client.foundation.handler.*; |
|
6 |
+ |
import com.temp.client.foundation.widget.*; |
9 |
7 |
|
|
10 |
8 |
|
/** |
11 |
9 |
|
* This custom dialog shows custom title, body lines (description, and |
|
@@ -15,38 +13,39 @@ |
15 |
13 |
|
*/ |
16 |
14 |
|
public class ConfirmationDialog<T> extends SEDIDialogBox { |
17 |
15 |
|
public interface Callback<T> extends ActionHandler<T> { |
18 |
|
- |
void dontExecute(T value); |
|
16 |
+ |
void dontExecute( T value ); |
19 |
17 |
|
} |
20 |
18 |
|
|
21 |
19 |
|
private ActionHandler<T> yesButtonClickedHandler; |
22 |
20 |
|
|
23 |
|
- |
public ConfirmationDialog(final T obj, String title, Integer contentWidth, ButtonBase yesButton, ButtonBase noButton, String... bodyTextBlocksAboveControlButtons) { |
24 |
|
- |
super("images/dialog/warningIcon.png", contentWidth, title); |
|
21 |
+ |
public ConfirmationDialog( final T obj, String title, Integer contentWidth, ButtonBase yesButton, ButtonBase noButton, |
|
22 |
+ |
String... bodyTextBlocksAboveControlButtons ) { |
|
23 |
+ |
super( "images/dialog/warningIcon.png", contentWidth, title ); |
25 |
24 |
|
|
26 |
|
- |
if (yesButton == null) { |
27 |
|
- |
yesButton = new OurPushButton("yes"); |
|
25 |
+ |
if ( yesButton == null ) { |
|
26 |
+ |
yesButton = new OurPushButton( "yes" ); |
28 |
27 |
|
} |
29 |
|
- |
if (noButton == null) { |
30 |
|
- |
noButton = new OurPushButton("noYesSize"); |
|
28 |
+ |
if ( noButton == null ) { |
|
29 |
+ |
noButton = new OurPushButton( "noYesSize" ); |
31 |
30 |
|
} |
32 |
|
- |
yesButton.addClickHandler(new ClickHandler() { |
|
31 |
+ |
yesButton.addClickHandler( new ClickHandler() { |
33 |
32 |
|
@Override |
34 |
|
- |
public void onClick(ClickEvent event) { |
35 |
|
- |
processButton(obj, true); |
|
33 |
+ |
public void onClick( ClickEvent event ) { |
|
34 |
+ |
processButton( obj, true ); |
36 |
35 |
|
} |
37 |
|
- |
}); |
38 |
|
- |
noButton.addClickHandler(new ClickHandler() { |
|
36 |
+ |
} ); |
|
37 |
+ |
noButton.addClickHandler( new ClickHandler() { |
39 |
38 |
|
@Override |
40 |
|
- |
public void onClick(ClickEvent event) { |
41 |
|
- |
processButton(obj, false); |
|
39 |
+ |
public void onClick( ClickEvent event ) { |
|
40 |
+ |
processButton( obj, false ); |
42 |
41 |
|
} |
43 |
|
- |
}); |
|
42 |
+ |
} ); |
44 |
43 |
|
|
45 |
|
- |
setBody(bodyTextBlocksAboveControlButtons, yesButton, noButton); |
|
44 |
+ |
setBody( bodyTextBlocksAboveControlButtons, yesButton, noButton ); |
46 |
45 |
|
} |
47 |
46 |
|
|
48 |
|
- |
public ConfirmationDialog(T obj, String title, String... bodyTextBlocksAboveControlButtons) { |
49 |
|
- |
this(obj, title, null, null, null, bodyTextBlocksAboveControlButtons); |
|
47 |
+ |
public ConfirmationDialog( T obj, String title, String... bodyTextBlocksAboveControlButtons ) { |
|
48 |
+ |
this( obj, title, null, null, null, bodyTextBlocksAboveControlButtons ); |
50 |
49 |
|
} |
51 |
50 |
|
|
52 |
51 |
|
public ConfirmationDialog<T> centerContent() { |
|
@@ -54,7 +53,7 @@ |
54 |
53 |
|
return this; |
55 |
54 |
|
} |
56 |
55 |
|
|
57 |
|
- |
public void show(ActionHandler<T> yesButtonClickedHandler) { |
|
56 |
+ |
public void show( ActionHandler<T> yesButtonClickedHandler ) { |
58 |
57 |
|
this.yesButtonClickedHandler = yesButtonClickedHandler; |
59 |
58 |
|
show(); |
60 |
59 |
|
} |
|
@@ -65,14 +64,14 @@ |
65 |
64 |
|
super.hide(); |
66 |
65 |
|
} |
67 |
66 |
|
|
68 |
|
- |
private void processButton(T obj, boolean yesButtonClicked) { |
|
67 |
+ |
private void processButton( T obj, boolean yesButtonClicked ) { |
69 |
68 |
|
ActionHandler<T> handler = yesButtonClickedHandler; |
70 |
69 |
|
hide(); |
71 |
|
- |
if (handler != null) { |
72 |
|
- |
if (yesButtonClicked) { |
73 |
|
- |
handler.execute(obj); |
74 |
|
- |
} else if (handler instanceof Callback) { |
75 |
|
- |
((Callback<T>) handler).dontExecute(obj); |
|
70 |
+ |
if ( handler != null ) { |
|
71 |
+ |
if ( yesButtonClicked ) { |
|
72 |
+ |
handler.execute( obj ); |
|
73 |
+ |
} else if ( handler instanceof Callback ) { |
|
74 |
+ |
((Callback<T>) handler).dontExecute( obj ); |
76 |
75 |
|
} |
77 |
76 |
|
} |
78 |
77 |
|
} |