import java.util.List;
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.FocusEvent;
+import com.google.gwt.event.dom.client.FocusHandler;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.event.dom.client.KeyUpEvent;
+import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.Event.NativePreviewEvent;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CheckBox;
-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.FocusListenerAdapter;
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.KeyboardListenerAdapter;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.SuggestBox;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
/**
* @author kman
groups = _groups;
userAdd = _userAdd;
permList = _permList;
+
+ groupBox.getElement().setId("addPermission.dropDown");
+
+ suggestBox.getElement().setId("addPermission.textBox");
+
+ read.getElement().setId("addPermission.read");
+
+ write.getElement().setId("addPermission.write");
+
+ modifyACL.getElement().setId("addpermission.modify");
+
for (GroupResource group : _groups)
groupBox.addItem(group.getName(), group.getName());
final VerticalPanel panel = new VerticalPanel();
permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
if (userAdd) {
- suggestBox.addFocusListener(new FocusListenerAdapter() {
+ suggestBox.getTextBox().addFocusHandler(new FocusHandler() {
+
@Override
- public void onFocus(Widget sender) {
+ public void onFocus(FocusEvent event) {
if (selectedUser != null && selectedUser.endsWith("@"))
updateSuggestions();
+
}
});
- suggestBox.addKeyboardListener(new KeyboardListenerAdapter() {
+
+ suggestBox.addKeyUpHandler(new KeyUpHandler() {
+
@Override
- public void onKeyUp(Widget sender, char keyCode, int modifiers) {
+ public void onKeyUp(KeyUpEvent event) {
// Ignore the arrow keys.
- if (keyCode==KEY_UP || keyCode==KEY_DOWN || keyCode==KEY_LEFT || keyCode==KEY_RIGHT)
+ int keyCode = event.getNativeKeyCode();
+ if (keyCode == KeyCodes.KEY_UP ||
+ keyCode == KeyCodes.KEY_DOWN ||
+ keyCode == KeyCodes.KEY_LEFT ||
+ keyCode == KeyCodes.KEY_RIGHT)
return;
+ if (keyCode==KeyCodes.KEY_ESCAPE) {
+ suggestBox.hideSuggestionList();
+ return;
+ }
String text = suggestBox.getText().trim();
- // Avoid useless queries for keystrokes that do not modify the text.
+ // Avoid useless queries for keystrokes that do not modify
+ // the text.
if (text.equals(selectedUser))
return;
selectedUser = text;
permTable.getFlexCellFormatter().setHorizontalAlignment(1, 3, HasHorizontalAlignment.ALIGN_CENTER);
panel.add(permTable);
- final Button ok = new Button("OK", new ClickListener() {
-
- public void onClick(Widget sender) {
+ final Button ok = new Button("OK", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
addPermission();
hide();
}
});
+ ok.getElement().setId("addPermission.button.ok");
buttons.add(ok);
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
// Create the 'Cancel' button, along with a listener that hides the
// dialog
// when the button is clicked.
- final Button cancel = new Button("Cancel", new ClickListener() {
-
- public void onClick(Widget sender) {
+ final Button cancel = new Button("Cancel", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
hide();
}
});
+ cancel.getElement().setId("addPermission.button.cancel");
buttons.add(cancel);
buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
buttons.setSpacing(8);
- buttons.addStyleName("gwt-TabPanelBottom");
+ buttons.addStyleName("gss-TabPanelBottom");
panel.add(buttons);
- panel.addStyleName("gwt-TabPanelBottom");
+ panel.addStyleName("gss-TabPanelBottom");
}
private void addPermission() {
}
perm.setGroup(selected.getName());
}
- boolean readValue = read.isChecked();
- boolean writeValue = write.isChecked();
- boolean modifyValue = modifyACL.isChecked();
+ boolean readValue = read.getValue();
+ boolean writeValue = write.getValue();
+ boolean modifyValue = modifyACL.getValue();
perm.setRead(readValue);
perm.setWrite(writeValue);
}
@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:
- addPermission();
- 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:
+ addPermission();
+ hide();
+ break;
+ case KeyCodes.KEY_ESCAPE:
+ hide();
+ break;
+ }
}
+
@Override
public void center() {
super.center();
GWT.log("Searching for " + query, null);
GetCommand<UserSearchResource> eg = new GetCommand<UserSearchResource>(UserSearchResource.class,
- app.getApiPath() + "users/" + URL.encodeComponent(query), false) {
+ app.getApiPath() + "users/" + URL.encodeComponent(query), false, null) {
@Override
public void onComplete() {
- DisplayHelper.hideSuggestions(suggestBox);
+ suggestBox.hideSuggestionList();
oracle.clear();
UserSearchResource s = getResult();
for (UserResource user : s.getUsers()) {
GWT.log("Found " + user.getUsername(), null);
oracle.add(user.getUsername());
}
- DisplayHelper.showSuggestions(suggestBox, selectedUser);
+ suggestBox.showSuggestionList();
}
@Override