import java.util.List;\r
\r
import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.dom.client.NativeEvent;\r
+import com.google.gwt.event.dom.client.ClickEvent;\r
+import com.google.gwt.event.dom.client.ClickHandler;\r
+import com.google.gwt.event.dom.client.KeyCodes;\r
import com.google.gwt.user.client.DeferredCommand;\r
+import com.google.gwt.user.client.Event.NativePreviewEvent;\r
import com.google.gwt.user.client.ui.Button;\r
-import com.google.gwt.user.client.ui.ClickListener;\r
import com.google.gwt.user.client.ui.DialogBox;\r
import com.google.gwt.user.client.ui.FlowPanel;\r
-import com.google.gwt.user.client.ui.KeyboardListener;\r
import com.google.gwt.user.client.ui.TabPanel;\r
import com.google.gwt.user.client.ui.TextBox;\r
-import com.google.gwt.user.client.ui.Widget;\r
\r
/**\r
* Abstract class, parent of all 'File properties' dialog boxes.\r
*/\r
public abstract class AbstractPropertiesDialog extends DialogBox {\r
\r
+ protected static final String MULTIPLE_VALUES_TEXT = "(Multiple values)";\r
\r
/**\r
* Text box with the tags associated with the file\r
List<String> userTags = tagr.getTags();\r
Iterator t = userTags.iterator();\r
while (t.hasNext()) {\r
- final Button tag = new Button((String) t.next(), new ClickListener() {\r
+ final Button tag = new Button((String) t.next(), new ClickHandler() {\r
\r
- public void onClick(Widget sender) {\r
+ @Override\r
+ public void onClick(ClickEvent event) {\r
String existing = tags.getText();\r
- String newTag = ((Button) sender).getText().trim();\r
+ if (MULTIPLE_VALUES_TEXT.equals(existing)) existing = "";\r
+ String newTag = ((Button) event.getSource()).getText().trim();\r
// insert the new tag only if it is not in the list\r
// already\r
if (existing.indexOf(newTag + ",") == -1 && !existing.trim().endsWith(newTag))\r
\r
@Override\r
@SuppressWarnings("fallthrough")\r
- public boolean onKeyDownPreview(char key, int modifiers) {\r
- // Use the popup's key preview hooks to close the dialog when either\r
- // enter or escape is pressed.\r
- switch (key) {\r
- case KeyboardListener.KEY_ENTER:\r
- accept();\r
- case KeyboardListener.KEY_ESCAPE:\r
- closeDialog();\r
- break;\r
- }\r
-\r
- return true;\r
- }\r
+ protected void onPreviewNativeEvent(NativePreviewEvent preview) {\r
+ super.onPreviewNativeEvent(preview);\r
+\r
+ NativeEvent evt = preview.getNativeEvent();\r
+ if (evt.getType().equals("keydown"))\r
+ // Use the popup's key preview hooks to close the dialog when either\r
+ // enter or escape is pressed.\r
+ switch (evt.getKeyCode()) {\r
+ case KeyCodes.KEY_ENTER:\r
+ accept();\r
+ case KeyCodes.KEY_ESCAPE:\r
+ closeDialog();\r
+ break;\r
+ }\r
+ }\r
+\r
\r
\r
public void selectTab(int _tab) {\r