Example usage for java.awt AWTEvent KEY_EVENT_MASK

List of usage examples for java.awt AWTEvent KEY_EVENT_MASK

Introduction

In this page you can find the example usage for java.awt AWTEvent KEY_EVENT_MASK.

Prototype

long KEY_EVENT_MASK

To view the source code for java.awt AWTEvent KEY_EVENT_MASK.

Click Source Link

Document

The event mask for selecting key events.

Usage

From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java

/**
 * {@inheritDoc}/*w  w  w.j  a va2s  .  com*/
 */
public void keyType(Object graphicsComponent, int keycode) throws RobotException {
    try {
        InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK });
        IRobotEventConfirmer confirmer = m_interceptor.intercept(options);
        try {
            m_robot.keyPress(keycode);
            m_eventFlusher.flush();
        } finally {
            m_robot.keyRelease(keycode);
            m_eventFlusher.flush();
        }
        confirmer.waitToConfirm(graphicsComponent, new KeyAwtEventMatcher(KeyEvent.KEY_RELEASED));
    } catch (IllegalArgumentException e) {
        throw new RobotException(e);
    }
}

From source file:org.eclipse.jubula.rc.swing.driver.RobotAwtImpl.java

/**
 * Implements the key press or release. 
 * @param graphicsComponent The component, may be <code>null</code>
 * @param keyCode  The key code/*from w w  w  . ja  v a2s  .c  om*/
 * @param press If <code>true</code>, the key is pressed, otherwise released
 */
private void keyPressReleaseImpl(Object graphicsComponent, int keyCode, boolean press) {

    InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK });
    IRobotEventConfirmer confirmer = m_interceptor.intercept(options);
    if (press) {
        m_robot.keyPress(keyCode);
        m_eventFlusher.flush();
    } else {
        m_robot.keyRelease(keyCode);
        m_eventFlusher.flush();
    }
    confirmer.waitToConfirm(graphicsComponent,
            new KeyAwtEventMatcher(press ? KeyEvent.KEY_PRESSED : KeyEvent.KEY_RELEASED));
}

From source file:org.pentaho.reporting.designer.core.ReportDesignerFrame.java

public ReportDesignerFrame() throws XulException {
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    final ImageIcon icon = IconLoader.getInstance().getProductIcon();
    if (icon != null) {
        setIconImage(icon.getImage());//from  ww w. j  av  a  2s.co  m
    }

    setTitle(Messages.getString("ReportDesignerFrame.Title"));
    addWindowListener(new WindowCloseHandler());

    viewController = new FrameViewController(this);
    context = new DefaultReportDesignerContext(viewController);
    viewController.initializeXulDesignerFrame(context);

    welcomePane = new WelcomePane(ReportDesignerFrame.this, getContext());
    fieldSelectorPaletteDialog = new FieldSelectorPaletteDialog(ReportDesignerFrame.this, getContext());

    statusBar = new StatusBar(context);

    reportEditorPane = new FancyTabbedPane();
    reportEditorPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    reportEditorPane.getModel().addChangeListener(new ReportTabActivationHandler());
    reportEditorPane.addMouseListener(new ReportTabPanePopupHandler());

    dockingPane = new GlobalPane(false);
    dockingPane.setMainComponent(reportEditorPane);

    attributeEditorPanel = new ElementPropertiesPanel();
    attributeEditorPanel.setAllowAttributeCard(true);
    attributeEditorPanel.setReportDesignerContext(context);

    treePanel = new TreeSidePanel(context, attributeEditorPanel);

    initializeToolWindows();

    paletteToolBar = createPaletteToolBar();

    final JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(context.getToolBar("main-toolbar"), BorderLayout.NORTH); // NON-NLS
    contentPane.add(dockingPane, BorderLayout.CENTER);
    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(paletteToolBar, BorderLayout.WEST);
    setContentPane(contentPane);

    setJMenuBar(createMenuBar());
    setDropTarget(new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, new DefaultDropTargetListener()));

    context.addPropertyChangeListener(ReportDesignerContext.ACTIVE_CONTEXT_PROPERTY,
            new ReportTabActivationHandler());
    context.addPropertyChangeListener(ReportDesignerContext.STATUS_TEXT_PROPERTY, new StatusTextHandler());
    context.addPropertyChangeListener(ReportDesignerContext.PAGE_PROPERTY, new PageTextHandler());
    context.addPropertyChangeListener(ReportDesignerContext.REPORT_RENDER_CONTEXT_PROPERTY,
            new ReportEditorContextHandler());

    Toolkit.getDefaultToolkit().addAWTEventListener(new DragSelectionToggleHandler(), AWTEvent.KEY_EVENT_MASK);

    if (MacOSXIntegration.MAC_OS_X) {
        try {
            final AboutAction aboutAction = new AboutAction();
            aboutAction.setReportDesignerContext(context);

            final SettingsAction settingsAction = new SettingsAction();
            settingsAction.setReportDesignerContext(context);

            final QuitAction quitAction = new QuitAction();
            quitAction.setReportDesignerContext(context);

            final OpenReportAction openReportAction = new OpenReportAction();
            openReportAction.setReportDesignerContext(context);

            MacOSXIntegration.setOpenFileAction(openReportAction);
            MacOSXIntegration.setAboutAction(aboutAction);
            MacOSXIntegration.setPreferencesAction(settingsAction);
            MacOSXIntegration.setQuitAction(quitAction);
        } catch (Throwable e) {
            DebugLog.log("Failed to activate MacOS-X integration", e); // NON-NLS
        }
    }

    visibleElementsUpdateHandler = new VisibleElementsUpdateHandler();
    WorkspaceSettings.getInstance().addSettingsListener(visibleElementsUpdateHandler);
}

From source file:org.sikuli.ide.SikuliIDE.java

private void initShortcutKeys() {
    final int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
        private boolean isKeyNextTab(java.awt.event.KeyEvent ke) {
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_TAB
                    && ke.getModifiers() == InputEvent.CTRL_MASK) {
                return true;
            }//from w  w  w  .java2 s.com
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_CLOSE_BRACKET
                    && ke.getModifiers() == (InputEvent.META_MASK | InputEvent.SHIFT_MASK)) {
                return true;
            }
            return false;
        }

        private boolean isKeyPrevTab(java.awt.event.KeyEvent ke) {
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_TAB
                    && ke.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)) {
                return true;
            }
            if (ke.getKeyCode() == java.awt.event.KeyEvent.VK_OPEN_BRACKET
                    && ke.getModifiers() == (InputEvent.META_MASK | InputEvent.SHIFT_MASK)) {
                return true;
            }
            return false;
        }

        public void eventDispatched(AWTEvent e) {
            java.awt.event.KeyEvent ke = (java.awt.event.KeyEvent) e;
            //Debug.log(ke.toString());
            if (ke.getID() == java.awt.event.KeyEvent.KEY_PRESSED) {
                if (isKeyNextTab(ke)) {
                    nextTab();
                } else if (isKeyPrevTab(ke)) {
                    prevTab();
                }
            }
        }
    }, AWTEvent.KEY_EVENT_MASK);

}

From source file:ru.goodfil.catalog.ui.forms.FilterWindow.java

public FilterWindow() {
    this.filter = new Filter();

    reReadFilterTypes();/* ww  w.  j a  v  a2  s .co  m*/

    initComponents();

    filterFormsCombo = new ComboAdapter(cbFilterForm, filterForms);
    filterTypesCombo = new ComboAdapter(cbFilterType, filterTypes);

    init(filter);

    adjustButtonsEnabled();

    Toolkit.getDefaultToolkit().addAWTEventListener(eventListener, AWTEvent.KEY_EVENT_MASK);
}

From source file:ru.goodfil.catalog.ui.forms.FilterWindow.java

public FilterWindow(Filter fitler) {
    this.filter = fitler;
    reReadFilterTypes();/*w  w  w .  java 2s .  c  o m*/

    initComponents();

    filterFormsCombo = new ComboAdapter(cbFilterForm, filterForms);
    filterTypesCombo = new ComboAdapter(cbFilterType, filterTypes);

    cbFilterForm.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            adjustButtonsEnabled();
        }
    });

    cbFilterType.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            adjustButtonsEnabled();
        }
    });

    cbFilterStatus.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            adjustButtonsEnabled();
        }
    });

    init(filter);

    adjustButtonsEnabled();

    Toolkit.getDefaultToolkit().addAWTEventListener(eventListener, AWTEvent.KEY_EVENT_MASK);
}