Example usage for java.awt.event InputEvent getModifiersExText

List of usage examples for java.awt.event InputEvent getModifiersExText

Introduction

In this page you can find the example usage for java.awt.event InputEvent getModifiersExText.

Prototype

public static String getModifiersExText(int modifiers) 

Source Link

Document

Returns a String describing the extended modifier keys and mouse buttons, such as "Shift", "Button1", or "Ctrl+Shift".

Usage

From source file:org.eclipse.jubula.client.ui.rcp.constants.InputCodeHelper.java

/**
 * private constructor/*from w  ww.  j a v  a 2  s . c om*/
 *
 */
private InputCodeHelper() {

    m_modifier[0] = InputEvent.CTRL_DOWN_MASK;
    m_modifier[1] = InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
    m_modifier[2] = InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK;
    m_modifier[3] = InputEvent.ALT_DOWN_MASK;
    m_modifier[4] = InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK;
    m_modifier[5] = 0; // no modifier pressed

    List<UserInput> inputList = new ArrayList<UserInput>();
    List<String> inputStringList = new ArrayList<String>();
    for (int i = KeyEvent.VK_0; i <= KeyEvent.VK_9; i++) {
        inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS));
        inputStringList.add(KeyEvent.getKeyText(i));
    }
    for (int i = KeyEvent.VK_A; i <= KeyEvent.VK_Z; i++) {
        inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS));
        inputStringList.add(KeyEvent.getKeyText(i));
    }
    for (int i = KeyEvent.VK_NUMPAD0; i <= KeyEvent.VK_ADD; i++) {
        inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS));
        inputStringList.add(KeyEvent.getKeyText(i));
    }
    for (int i = KeyEvent.VK_SUBTRACT; i <= KeyEvent.VK_DIVIDE; i++) {
        inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS));
        inputStringList.add(KeyEvent.getKeyText(i));
    }
    for (int i = KeyEvent.VK_F1; i <= KeyEvent.VK_F12; i++) {
        inputList.add(new UserInput(i, InputConstants.TYPE_KEY_PRESS));
        inputStringList.add(KeyEvent.getKeyText(i));
    }

    m_modifierString = new String[m_modifier.length];
    for (int i = 0; i < m_modifier.length; i++) {
        m_modifierString[i] = InputEvent.getModifiersExText(m_modifier[i]);
    }

    m_keys = inputList.toArray(new UserInput[inputList.size()]);
    m_keyStrings = inputStringList.toArray(new String[inputStringList.size()]);

    inputList.add(new UserInput(InputConstants.MOUSE_BUTTON_LEFT, InputConstants.TYPE_MOUSE_CLICK));
    inputList.add(new UserInput(InputConstants.MOUSE_BUTTON_MIDDLE, InputConstants.TYPE_MOUSE_CLICK));
    inputList.add(new UserInput(InputConstants.MOUSE_BUTTON_RIGHT, InputConstants.TYPE_MOUSE_CLICK));

    inputStringList.add(Messages.ObjectMappingPreferencePageMouseButton1);
    inputStringList.add(Messages.ObjectMappingPreferencePageMouseButton2);
    inputStringList.add(Messages.ObjectMappingPreferencePageMouseButton3);

    m_inputs = inputList.toArray(new UserInput[inputList.size()]);
    m_inputStrings = inputStringList.toArray(new String[inputStringList.size()]);
}