summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-05-21 11:49:52 -0700
committerShawn O. Pearce <sop@google.com>2009-05-21 11:49:52 -0700
commitc80a47113d887406d9733521a50cf9d5e2c817be (patch)
tree25d7ab3212af17bcdffa4542e3a78b1373f70adb
parent42b27be34f41834f588c37d7e1afa18ecb7022a9 (diff)
downloadgwtexpui-c80a47113d887406d9733521a50cf9d5e2c817be.tar.gz
Expose the PopupPanel hide command used by GlobalKey
This way applications can setup a binding on the same key that is used to open the dialog to close it, making that key a toggle key. By using the same command class, the help for the dialog will show the various different methods of closing the dialog aliased under a single entry. Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r--src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java8
-rw-r--r--src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java33
2 files changed, 34 insertions, 7 deletions
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java b/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java
index 16c2970..a50f205 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java
@@ -86,13 +86,7 @@ public class GlobalKey {
assert panel.isShowing();
assert active == global;
active = new State(panel);
- active.add(new KeyCommand(0, KeyCodes.KEY_ESCAPE, Util.C
- .closeCurrentDialog()) {
- @Override
- public void onKeyPress(final KeyPressEvent event) {
- panel.hide();
- }
- });
+ active.add(new HidePopupPanelCommand(0, KeyCodes.KEY_ESCAPE, panel));
panel.addCloseHandler(restoreGlobal);
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java b/src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java
new file mode 100644
index 0000000..6d9c50e
--- /dev/null
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java
@@ -0,0 +1,33 @@
+// Copyright (C) 2009 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.gwtexpui.globalkey.client;
+
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.user.client.ui.PopupPanel;
+
+/** Hides the given popup panel when invoked. */
+public class HidePopupPanelCommand extends KeyCommand {
+ private final PopupPanel panel;
+
+ public HidePopupPanelCommand(int mask, int key, PopupPanel panel) {
+ super(mask, key, Util.C.closeCurrentDialog());
+ this.panel = panel;
+ }
+
+ @Override
+ public void onKeyPress(final KeyPressEvent event) {
+ panel.hide();
+ }
+}