1 /*
   2  * Copyright (c) 2007, 2017 Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package org.jemmy.interfaces;
  27 
  28 import org.jemmy.dock.Shortcut;
  29 import org.jemmy.env.Timeout;
  30 
  31 
  32 /**
  33  * Defines how to simulate keyboard operations.
  34  */
  35 public interface Keyboard extends ControlInterface {
  36 
  37     /**
  38      *
  39      */
  40     public static final Timeout PUSH = new Timeout("keyboard.push", 100);
  41 
  42     /**
  43      *
  44      * @param key
  45      * @param modifiers
  46      */
  47     @Shortcut
  48     public void pressKey(KeyboardButton key, Modifier... modifiers);
  49     /**
  50      *
  51      * @param key
  52      */
  53     @Shortcut
  54     public void pressKey(KeyboardButton key);
  55 
  56     /**
  57      *
  58      * @param key
  59      * @param modifiers
  60      */
  61     @Shortcut
  62     public void releaseKey(KeyboardButton key, Modifier... modifiers);
  63     /**
  64      *
  65      * @param key
  66      */
  67     @Shortcut
  68     public void releaseKey(KeyboardButton key);
  69 
  70     /**
  71      *
  72      * @param key
  73      * @param modifiers
  74      * @param pushTime
  75      */
  76     @Shortcut
  77     public void pushKey(Timeout pushTime, KeyboardButton key, Modifier... modifiers);
  78     /**
  79      *
  80      * @param key
  81      * @param modifiers
  82      */
  83     @Shortcut
  84     public void pushKey(KeyboardButton key, Modifier... modifiers);
  85     /**
  86      *
  87      * @param key
  88      */
  89     @Shortcut
  90     public void pushKey(KeyboardButton key);
  91 
  92     /**
  93      *
  94      * @param keyChar
  95      * @param pushTime
  96      */
  97     @Shortcut
  98     public void typeChar(char keyChar, Timeout pushTime);
  99     /**
 100      *
 101      * @param keyChar
 102      */
 103     @Shortcut
 104     public void typeChar(char keyChar);
 105 
 106     /**
 107      * Detaches the implementation so that all actions of it will be ran detached.
 108      * @see org.jemmy.action.ActionExecutor#executeDetached(org.jemmy.env.Environment, org.jemmy.action.Action, java.lang.Object[])
 109      * @return
 110      */
 111     public Keyboard detached();
 112 
 113     /**
 114      * Keyboard button interface (i. e. Q, W, ENTER, LEFT, F1, etc.)
 115      * created to left the possibility for extention as enums can't be extended
 116      */
 117     public static interface KeyboardButton extends Button {
 118 
 119     }
 120 
 121     /**
 122      * Keyboard modifier interface (i. e. SHIFT_DOWN_MASK)
 123      * created to left the possibility for extention as enums can't be extended
 124      */
 125     public static interface KeyboardModifier extends Modifier {
 126 
 127     }
 128 
 129     /**
 130      * Keyboard modifiers enum (i. e. SHIFT_DOWN_MASK)
 131      * to be used in Keyboard interface methods
 132      */
 133     public static enum KeyboardModifiers implements KeyboardModifier {
 134         SHIFT_DOWN_MASK,
 135         CTRL_DOWN_MASK,
 136         ALT_DOWN_MASK,
 137         META_DOWN_MASK
 138     }
 139 
 140     /**
 141      * Keyboard buttons enum (i. e. Q, W, ENTER, LEFT, F1, etc.)
 142      * to be used in Keyboard interface methods
 143      */
 144     public static enum KeyboardButtons implements KeyboardButton {
 145 
 146         /**
 147          *
 148          */
 149         ESCAPE,
 150         /**
 151          *
 152          */
 153         F1,
 154         /**
 155          *
 156          */
 157         F2,
 158         /**
 159          *
 160          */
 161         F3,
 162         /**
 163          *
 164          */
 165         F4,
 166         /**
 167          *
 168          */
 169         F5,
 170         /**
 171          *
 172          */
 173         F6,
 174         /**
 175          *
 176          */
 177         F7,
 178         /**
 179          *
 180          */
 181         F8,
 182         /**
 183          *
 184          */
 185         F9,
 186         /**
 187          *
 188          */
 189         F10,
 190         /**
 191          *
 192          */
 193         F11,
 194         /**
 195          *
 196          */
 197         F12,
 198         /**
 199          *
 200          */
 201         F13,
 202         /**
 203          *
 204          */
 205         PRINTSCREEN,
 206         /**
 207          *
 208          */
 209         SCROLL_LOCK,
 210         /**
 211          *
 212          */
 213         PAUSE,
 214         /**
 215          *
 216          */
 217         BACK_QUOTE,
 218         /**
 219          *
 220          */
 221         D1,
 222         /**
 223          *
 224          */
 225         D2,
 226         /**
 227          *
 228          */
 229         D3,
 230         /**
 231          *
 232          */
 233         D4,
 234         /**
 235          *
 236          */
 237         D5,
 238         /**
 239          *
 240          */
 241         D6,
 242         /**
 243          *
 244          */
 245         D7,
 246         /**
 247          *
 248          */
 249         D8,
 250         /**
 251          *
 252          */
 253         D9,
 254         /**
 255          *
 256          */
 257         D0,
 258         /**
 259          *
 260          */
 261         MINUS,
 262         /**
 263          *
 264          */
 265         EQUALS,
 266         /**
 267          *
 268          */
 269         BACK_SLASH,
 270         /**
 271          *
 272          */
 273         BACK_SPACE,
 274         /**
 275          *
 276          */
 277         INSERT,
 278         /**
 279          *
 280          */
 281         HOME,
 282         /**
 283          *
 284          */
 285         PAGE_UP,
 286         /**
 287          *
 288          */
 289         NUM_LOCK,
 290         /**
 291          *
 292          */
 293         DIVIDE,
 294         /**
 295          *
 296          */
 297         MULTIPLY,
 298         /**
 299          *
 300          */
 301         SUBTRACT,
 302         /**
 303          *
 304          */
 305         TAB,
 306         /**
 307          *
 308          */
 309         Q,
 310         /**
 311          *
 312          */
 313         W,
 314         /**
 315          *
 316          */
 317         E,
 318         /**
 319          *
 320          */
 321         R,
 322         /**
 323          *
 324          */
 325         T,
 326         /**
 327          *
 328          */
 329         Y,
 330         /**
 331          *
 332          */
 333         U,
 334         /**
 335          *
 336          */
 337         I,
 338         /**
 339          *
 340          */
 341         O,
 342         /**
 343          *
 344          */
 345         P,
 346         /**
 347          *
 348          */
 349         OPEN_BRACKET,
 350         /**
 351          *
 352          */
 353         CLOSE_BRACKET,
 354         /**
 355          *
 356          */
 357         DELETE,
 358         /**
 359          *
 360          */
 361         END,
 362         /**
 363          *
 364          */
 365         PAGE_DOWN,
 366         /**
 367          *
 368          */
 369         NUMPAD7,
 370         /**
 371          *
 372          */
 373         NUMPAD8,
 374         /**
 375          *
 376          */
 377         NUMPAD9,
 378         /**
 379          *
 380          */
 381         ADD,
 382         /**
 383          *
 384          */
 385         CAPS_LOCK,
 386         /**
 387          *
 388          */
 389         A,
 390         /**
 391          *
 392          */
 393         S,
 394         /**
 395          *
 396          */
 397         D,
 398         /**
 399          *
 400          */
 401         F,
 402         /**
 403          *
 404          */
 405         G,
 406         /**
 407          *
 408          */
 409         H,
 410         /**
 411          *
 412          */
 413         J,
 414         /**
 415          *
 416          */
 417         K,
 418         /**
 419          *
 420          */
 421         L,
 422         /**
 423          *
 424          */
 425         SEMICOLON,
 426         /**
 427          *
 428          */
 429         QUOTE,
 430         /**
 431          *
 432          */
 433         ENTER,
 434         /**
 435          *
 436          */
 437         NUMPAD4,
 438         /**
 439          *
 440          */
 441         NUMPAD5,
 442         /**
 443          *
 444          */
 445         NUMPAD6,
 446         /**
 447          *
 448          */
 449         SHIFT,
 450         /**
 451          *
 452          */
 453         Z,
 454         /**
 455          *
 456          */
 457         X,
 458         /**
 459          *
 460          */
 461         C,
 462         /**
 463          *
 464          */
 465         V,
 466         /**
 467          *
 468          */
 469         B,
 470         /**
 471          *
 472          */
 473         N,
 474         /**
 475          *
 476          */
 477         M,
 478         /**
 479          *
 480          */
 481         COMMA,
 482         /**
 483          *
 484          */
 485         PERIOD,
 486         /**
 487          *
 488          */
 489         SLASH,
 490         /**
 491          *
 492          */
 493         UP,
 494         /**
 495          *
 496          */
 497         NUMPAD1,
 498         /**
 499          *
 500          */
 501         NUMPAD2,
 502         /**
 503          *
 504          */
 505         NUMPAD3,
 506         /**
 507          *
 508          */
 509         CONTROL,
 510         /**
 511          *
 512          */
 513         WINDOWS,
 514         /**
 515          *
 516          */
 517         ALT,
 518         /**
 519          * Represents meta key on some platforms (eg Command key on MacOS X)
 520          */
 521         META,
 522         /**
 523          *
 524          */
 525         SPACE,
 526         /**
 527          *
 528          */
 529         CONTEXT_MENU,
 530         /**
 531          *
 532          */
 533         LEFT,
 534         /**
 535          *
 536          */
 537         DOWN,
 538         /**
 539          *
 540          */
 541         RIGHT,
 542         /**
 543          *
 544          */
 545         NUMPAD0,
 546         /**
 547          *
 548          */
 549         DECIMAL,
 550         /**
 551         *
 552         */
 553         DEAD_DIAERESIS,
 554         /**
 555         *
 556         */
 557         PLUS
 558     }
 559 
 560 }