X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/78137d35ffb6e6aaf0e7a40326715e393c49bb27..a60ea262c06cc5c4c53873d4835f3ba012aa4b28:/src/gr/ebs/gss/client/CredentialsDialog.java
diff --git a/src/gr/ebs/gss/client/CredentialsDialog.java b/src/gr/ebs/gss/client/CredentialsDialog.java
index 8989e5c..126a2d5 100644
--- a/src/gr/ebs/gss/client/CredentialsDialog.java
+++ b/src/gr/ebs/gss/client/CredentialsDialog.java
@@ -22,18 +22,21 @@ import gr.ebs.gss.client.rest.PostCommand;
import gr.ebs.gss.client.rest.RestException;
import com.google.gwt.core.client.GWT;
+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.DeferredCommand;
+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.FlexTable;
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.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
/**
@@ -68,14 +71,18 @@ public class CredentialsDialog extends DialogBox {
HorizontalPanel buttons = new HorizontalPanel();
HTML text;
- text = new HTML("
" + images.warn().getHTML() + " | " + "Are you sure you want to create a new WebDAV password? |
");
+ text = new HTML("" +
+ AbstractImagePrototype.create(images.warn()).getHTML() +
+ " | " + "Are you sure you want to create a new " +
+ "WebDAV password? |
");
text.setStyleName("gss-warnMessage");
outer.add(text);
- // Create the 'Yes' button, along with a listener that hides the dialog
- // when the button is clicked and resets the password.
- Button ok = new Button("Yes", new ClickListener() {
- public void onClick(Widget sender) {
+ // Create the 'Yes' button, along with a listener that hides the
+ // dialog when the button is clicked and resets the password.
+ Button ok = new Button("Yes", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
resetPassword(GSS.get().getCurrentUserResource().getUri());
hide();
}
@@ -84,8 +91,9 @@ public class CredentialsDialog extends DialogBox {
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
// Create the 'No' button, along with a listener that hides the
// dialog when the button is clicked.
- Button cancel = new Button("No", new ClickListener() {
- public void onClick(Widget sender) {
+ Button cancel = new Button("No", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
hide();
}
});
@@ -100,18 +108,19 @@ public class CredentialsDialog extends DialogBox {
setWidget(outer);
}
-
@Override
- public boolean onKeyDownPreview(final char key, final int modifiers) {
- // Use the popup's key preview hooks to close the dialog when
- // escape is pressed.
- switch (key) {
- case KeyboardListener.KEY_ESCAPE:
- hide();
- 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:
+ case KeyCodes.KEY_ESCAPE:
+ hide();
+ break;
+ }
}
}
@@ -127,17 +136,18 @@ public class CredentialsDialog extends DialogBox {
VerticalPanel outer = new VerticalPanel();
// Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("A new WebDAV password has been created.
"+
- "You will now be redirected to the initial screen for the changes to take effect. " +
- "Choose \"Show Credentials\" again afterwards to see the new password.
");
+ HTML text = new HTML("A new WebDAV password has been created." +
+ "
You will now be redirected to the initial screen" +
+ " for the changes to take effect. Choose \"Show " +
+ "Credentials\" again afterwards to see the new password.
");
text.setStyleName("gss-AboutText");
outer.add(text);
- // Create the 'OK' button, along with a listener that hides the dialog
- // when the button is clicked.
- Button confirm = new Button("Proceed", new ClickListener() {
-
- public void onClick(Widget sender) {
+ // Create the 'OK' button, along with a listener that hides the
+ // dialog when the button is clicked.
+ Button confirm = new Button("Proceed", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
GSS.get().authenticateUser();
hide();
}
@@ -149,20 +159,23 @@ public class CredentialsDialog extends DialogBox {
}
@Override
- public boolean onKeyDownPreview(char key, 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:
- GSS.get().authenticateUser();
- hide();
- break;
- case KeyboardListener.KEY_ESCAPE:
- hide();
- 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:
+ GSS.get().authenticateUser();
+ hide();
+ break;
+ case KeyCodes.KEY_ESCAPE:
+ hide();
+ break;
+ }
}
+
}
/**
@@ -172,20 +185,19 @@ public class CredentialsDialog extends DialogBox {
// Set the dialog's caption.
setText("User Credentials");
setAnimationEnabled(true);
- // Create a VerticalPanel to contain the 'about' label and the 'OK'
- // button.
+ // A VerticalPanel that contains the 'about' label and the 'OK' button.
VerticalPanel outer = new VerticalPanel();
Configuration conf = (Configuration) GWT.create(Configuration.class);
String service = conf.serviceName();
String webdavUrl = conf.serviceHome() + conf.webdavUrl();
String tokenNote = conf.tokenTTLNote();
// Create the text and set a style name so we can style it with CSS.
- HTML text = new HTML("These are the user credentials that are required " +
- "for interacting with " + service + ". " +
- "You can copy and paste the username and password in the WebDAV client" +
- " in order to use " + service + " through the WebDAV interface, at:
" +
- webdavUrl +
- "
" + tokenNote + "
");
+ HTML text = new HTML("These are the user credentials that are " +
+ "required for interacting with " + service + ". You can copy" +
+ " and paste the username and password in the WebDAV client " +
+ "in order to use " + service + " through the WebDAV " +
+ "interface, at:
" + webdavUrl + "
" + tokenNote +
+ "
");
text.setStyleName("gss-AboutText");
text.setWidth(WIDTH_TEXT);
outer.add(text);
@@ -198,11 +210,11 @@ public class CredentialsDialog extends DialogBox {
username.setText(app.getCurrentUserResource().getUsername());
username.setReadOnly(true);
username.setWidth(WIDTH_FIELD);
- username.addClickListener(new ClickListener () {
-
- public void onClick(Widget sender) {
+ username.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
GSS.enableIESelection();
- ((TextBox) sender).selectAll();
+ ((TextBox) event.getSource()).selectAll();
GSS.preventIESelection();
}
@@ -212,11 +224,11 @@ public class CredentialsDialog extends DialogBox {
passwordBox.setText(app.getWebDAVPassword());
passwordBox.setReadOnly(true);
passwordBox.setWidth(WIDTH_FIELD);
- passwordBox.addClickListener(new ClickListener () {
-
- public void onClick(Widget sender) {
+ passwordBox.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
GSS.enableIESelection();
- ((TextBox) sender).selectAll();
+ ((TextBox) event.getSource()).selectAll();
GSS.preventIESelection();
}
@@ -227,11 +239,11 @@ public class CredentialsDialog extends DialogBox {
tokenBox.setText(app.getToken());
tokenBox.setReadOnly(true);
tokenBox.setWidth(WIDTH_FIELD);
- tokenBox.addClickListener(new ClickListener () {
-
- public void onClick(Widget sender) {
+ tokenBox.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
GSS.enableIESelection();
- ((TextBox) sender).selectAll();
+ ((TextBox) event.getSource()).selectAll();
GSS.preventIESelection();
}
@@ -248,20 +260,20 @@ public class CredentialsDialog extends DialogBox {
// Create the 'OK' button, along with a listener that hides the dialog
// when the button is clicked.
- Button confirm = new Button("Close", new ClickListener() {
-
- public void onClick(Widget sender) {
+ Button confirm = new Button("Close", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
hide();
}
});
outer.add(confirm);
outer.setCellHorizontalAlignment(confirm, HasHorizontalAlignment.ALIGN_CENTER);
- // Create the 'Reset password' button, along with a listener that hides the dialog
- // when the button is clicked.
- Button resetPassword = new Button("Reset Password", new ClickListener() {
-
- public void onClick(Widget sender) {
+ // Create the 'Reset password' button, along with a listener that hides
+ // the dialog when the button is clicked.
+ Button resetPassword = new Button("Reset Password", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
ConfirmResetPasswordDialog dlg = new ConfirmResetPasswordDialog(images);
dlg.center();
}
@@ -274,16 +286,18 @@ public class CredentialsDialog extends DialogBox {
}
@Override
- public boolean onKeyDownPreview(char key, 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:
- case KeyboardListener.KEY_ESCAPE:
- hide();
- 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:
+ case KeyCodes.KEY_ESCAPE:
+ hide();
+ break;
+ }
}
@@ -313,18 +327,20 @@ public class CredentialsDialog extends DialogBox {
if(t instanceof RestException){
int statusCode = ((RestException)t).getHttpStatusCode();
if(statusCode == 405)
- GSS.get().displayError("You don't have the necessary permissions");
+ GSS.get().displayError("You don't have the necessary" +
+ " permissions");
else if(statusCode == 404)
GSS.get().displayError("Resource does not exist");
else
- GSS.get().displayError("Unable to reset password:"+((RestException)t).getHttpStatusText());
+ GSS.get().displayError("Unable to reset password:" +
+ ((RestException)t).getHttpStatusText());
}
else
- GSS.get().displayError("System error resetting password:"+t.getMessage());
+ GSS.get().displayError("System error resetting password:" +
+ t.getMessage());
}
};
DeferredCommand.addCommand(cg);
-
}
}