Revision afd3a0ef src/gr/ebs/gss/client/ConfirmationDialog.java
b/src/gr/ebs/gss/client/ConfirmationDialog.java | ||
---|---|---|
18 | 18 |
*/ |
19 | 19 |
package gr.ebs.gss.client; |
20 | 20 |
|
21 |
import com.google.gwt.dom.client.NativeEvent; |
|
22 |
import com.google.gwt.event.dom.client.ClickEvent; |
|
23 |
import com.google.gwt.event.dom.client.ClickHandler; |
|
24 |
import com.google.gwt.event.dom.client.KeyCodes; |
|
25 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
|
26 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
|
21 | 27 |
import com.google.gwt.user.client.ui.Button; |
22 |
import com.google.gwt.user.client.ui.ClickListener; |
|
23 | 28 |
import com.google.gwt.user.client.ui.DialogBox; |
24 | 29 |
import com.google.gwt.user.client.ui.HTML; |
25 | 30 |
import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
26 | 31 |
import com.google.gwt.user.client.ui.HorizontalPanel; |
27 |
import com.google.gwt.user.client.ui.KeyboardListener; |
|
28 | 32 |
import com.google.gwt.user.client.ui.VerticalPanel; |
29 |
import com.google.gwt.user.client.ui.Widget; |
|
30 | 33 |
|
31 | 34 |
|
32 | 35 |
/** |
... | ... | |
50 | 53 |
VerticalPanel outer = new VerticalPanel(); |
51 | 54 |
HorizontalPanel buttons = new HorizontalPanel(); |
52 | 55 |
|
53 |
HTML text = new HTML("<table><tr><td rowspan='2'>" + MessagePanel.images.warn().getHTML() +
|
|
56 |
HTML text = new HTML("<table><tr><td rowspan='2'>" + AbstractImagePrototype.create(MessagePanel.images.warn()).getHTML() +
|
|
54 | 57 |
"</td><td>" + message + "</td></tr></table>"); |
55 | 58 |
text.setStyleName("gss-warnMessage"); |
56 | 59 |
outer.add(text); |
57 | 60 |
|
58 | 61 |
// Create the 'Update' button, along with a listener that hides the dialog |
59 | 62 |
// when the button is clicked and renames the file. |
60 |
Button ok = new Button(buttonLabel, new ClickListener() {
|
|
63 |
Button ok = new Button(buttonLabel, new ClickHandler() {
|
|
61 | 64 |
|
62 |
public void onClick(Widget sender) { |
|
65 |
@Override |
|
66 |
public void onClick(ClickEvent event) { |
|
63 | 67 |
confirm(); |
64 | 68 |
hide(); |
65 | 69 |
} |
... | ... | |
68 | 72 |
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); |
69 | 73 |
// Create the 'Cancel' button, along with a listener that hides the |
70 | 74 |
// dialog when the button is clicked. |
71 |
Button cancel = new Button("Cancel", new ClickListener() {
|
|
75 |
Button cancel = new Button("Cancel", new ClickHandler() {
|
|
72 | 76 |
|
73 |
public void onClick(Widget sender) { |
|
77 |
@Override |
|
78 |
public void onClick(ClickEvent event) { |
|
74 | 79 |
hide(); |
75 | 80 |
cancel(); |
76 | 81 |
} |
... | ... | |
87 | 92 |
} |
88 | 93 |
|
89 | 94 |
@Override |
90 |
public boolean onKeyDownPreview(final char key, final int modifiers) { |
|
91 |
// Use the popup's key preview hooks to close the dialog when either |
|
92 |
// enter or escape is pressed. |
|
93 |
switch (key) { |
|
94 |
case KeyboardListener.KEY_ENTER: |
|
95 |
hide(); |
|
96 |
confirm(); |
|
97 |
break; |
|
98 |
case KeyboardListener.KEY_ESCAPE: |
|
99 |
hide(); |
|
100 |
cancel(); |
|
101 |
break; |
|
102 |
} |
|
103 |
return true; |
|
95 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
|
96 |
super.onPreviewNativeEvent(preview); |
|
97 |
|
|
98 |
NativeEvent evt = preview.getNativeEvent(); |
|
99 |
if (evt.getType().equals("keydown")) |
|
100 |
// Use the popup's key preview hooks to close the dialog when either |
|
101 |
// enter or escape is pressed. |
|
102 |
switch (evt.getKeyCode()) { |
|
103 |
case KeyCodes.KEY_ENTER: |
|
104 |
hide(); |
|
105 |
confirm(); |
|
106 |
break; |
|
107 |
case KeyCodes.KEY_ESCAPE: |
|
108 |
hide(); |
|
109 |
cancel(); |
|
110 |
break; |
|
111 |
} |
|
104 | 112 |
} |
105 | 113 |
|
106 | 114 |
public abstract void confirm(); |
Also available in: Unified diff