*/
package gr.ebs.gss.client;
+import com.google.gwt.dom.client.NativeEvent;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.user.client.Event.NativePreviewEvent;
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
/**
VerticalPanel outer = new VerticalPanel();
HorizontalPanel buttons = new HorizontalPanel();
- HTML text = new HTML("<table><tr><td rowspan='2'>" + MessagePanel.images.warn().getHTML() +
- "</td><td>" + message + "</td></tr></table>");
+ HTML text = new HTML("<table><tr><td rowspan='2'>" +
+ AbstractImagePrototype.create(MessagePanel.images.warn()).getHTML() +
+ "</td><td>" + message + "</td></tr></table>");
text.setStyleName("gss-warnMessage");
outer.add(text);
- // Create the 'Update' button, along with a listener that hides the dialog
- // when the button is clicked and renames the file.
- Button ok = new Button(buttonLabel, new ClickListener() {
+ // Create the 'Update' button, along with a listener that hides the
+ // dialog when the button is clicked and renames the file.
+ Button ok = new Button(buttonLabel, new ClickHandler() {
- public void onClick(Widget sender) {
+ @Override
+ public void onClick(ClickEvent event) {
confirm();
hide();
}
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
// Create the 'Cancel' button, along with a listener that hides the
// dialog when the button is clicked.
- Button cancel = new Button("Cancel", new ClickListener() {
+ Button cancel = new Button("Cancel", new ClickHandler() {
- public void onClick(Widget sender) {
+ @Override
+ public void onClick(ClickEvent event) {
hide();
cancel();
}
}
@Override
- public boolean onKeyDownPreview(final char key, final int modifiers) {
- // Use the popup's key preview hooks to close the dialog when either
- // enter or escape is pressed.
- switch (key) {
- case KeyboardListener.KEY_ENTER:
- hide();
- confirm();
- break;
- case KeyboardListener.KEY_ESCAPE:
- hide();
- cancel();
- break;
- }
- return true;
+ protected void onPreviewNativeEvent(NativePreviewEvent preview) {
+ super.onPreviewNativeEvent(preview);
+ NativeEvent evt = preview.getNativeEvent();
+ if (evt.getType().equals("keydown"))
+ // Use the popup's key preview hooks to close the dialog when either
+ // enter or escape is pressed.
+ switch (evt.getKeyCode()) {
+ case KeyCodes.KEY_ENTER:
+ hide();
+ confirm();
+ break;
+ case KeyCodes.KEY_ESCAPE:
+ hide();
+ cancel();
+ break;
+ }
}
public abstract void confirm();