Example usage for java.awt.event KeyEvent VK_ENTER

List of usage examples for java.awt.event KeyEvent VK_ENTER

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_ENTER.

Prototype

int VK_ENTER

To view the source code for java.awt.event KeyEvent VK_ENTER.

Click Source Link

Document

Constant for the ENTER virtual key.

Usage

From source file:vista.Venta.java

private void txtEntradaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEntradaKeyPressed
    // TODO add your handling code here:
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        this.comandos();
    }//from   w w  w.  j  av a 2s  .com
    if (evt.getKeyCode() == KeyEvent.VK_F1) {
        //            this.rbtnEfectivo.setSelected(true);
        //            this.rbtnCredito.setSelected(false);
    }
    if (evt.getKeyCode() == KeyEvent.VK_F2) {
        //            this.rbtnEfectivo.setSelected(false);
        //            this.rbtnCredito.setSelected(true);
    }

}

From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryFieldPanel.java

/**
 * @param iconSize/*w  w  w  .jav a2  s .c  om*/
 * @param returnWidths
 * @return
 */
protected int[] buildControlLayout(final IconManager.IconSize iconSize, final boolean returnWidths,
        final Component saveBtn) {
    FocusListener focusListener = new FocusListener() {

        /*
         * (non-Javadoc)
         * 
         * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
         */
        // @Override
        public void focusGained(FocusEvent e) {
            //Checking oppositeComponent to work around
            //weird behavior after addBtn is clicked which
            //causes top queryFieldPanel to be selected.
            if (ownerQuery.getAddBtn() != null && e.getOppositeComponent() != ownerQuery.getAddBtn()) {
                ownerQuery.selectQFP(QueryFieldPanel.this);
            }

        }

        /*
         * (non-Javadoc)
         * 
         * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
         */
        // @Override
        public void focusLost(FocusEvent e) {
            // nada
        }

    };

    KeyListener enterListener = new KeyListener() {

        @Override
        public void keyPressed(KeyEvent arg0) {
            //nuthin
        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            //nuthin
        }

        @Override
        public void keyTyped(KeyEvent arg0) {
            if (arg0.getKeyChar() == KeyEvent.VK_ENTER && ownerQuery != null) {
                ownerQuery.doSearch();
            }

        }

    };

    comparators = getComparatorList(fieldQRI);
    //XXX need to build schemaItem for header panel too...
    if (schemaMapping != null) {
        schemaItemCBX = edu.ku.brc.ui.UIHelper.createComboBox();
        schemaItemCBX.addItem("empty"); //to work around validator blow up for empty lists.
        DataChangeNotifier dcnsi = validator.hookupComponent(schemaItemCBX, "sicbx", UIValidator.Type.Changed,
                "", true);
        schemaItemCBX.addActionListener(dcnsi);

        schemaItemCBX.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (!QueryFieldPanel.this.ownerQuery.isUpdatingAvailableConcepts()) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        if (e.getItem() instanceof SpExportSchemaItem) {
                            QueryFieldPanel.this.schemaItem = (SpExportSchemaItem) e.getItem();
                        } else {
                            SpExportSchemaItemMapping m = QueryFieldPanel.this.getItemMapping();
                            SpExportSchemaItem si = QueryFieldPanel.this.schemaItem;
                            String item = e.getItem().toString();
                            if (StringUtils.isNotBlank(item)
                                    && ownerQuery.isAvailableExportFieldName(QueryFieldPanel.this, item)) {
                                if (m != null) {
                                    m.setExportedFieldName(e.getItem().toString());
                                }
                                if (si != null) {
                                    si.setFieldName(e.getItem().toString());
                                }
                            } else {
                                if (StringUtils.isBlank(item)) {
                                    UIRegistry.displayErrorDlgLocalized(
                                            "QueryFieldPanel.ExportFieldNameInvalid", item);
                                } else {
                                    UIRegistry.displayErrorDlgLocalized(
                                            "QueryFieldPanel.ExportFieldNameAlreadyUsed", item);
                                }
                                schemaItemCBX.setSelectedIndex(0);
                            }
                        }
                        ownerQuery.updateAvailableConcepts();
                    }
                }
            }
        });
    } else {
        schemaItemCBX = null;
    }

    iconLabel = new JLabel(icon);
    iconLabel.addFocusListener(focusListener);
    String fieldLabelText = fieldQRI != null ? fieldQRI.getTitle() : "WXYZ";
    if (fieldQRI instanceof RelQRI) {
        DBRelationshipInfo.RelationshipType relType = ((RelQRI) fieldQRI).getRelationshipInfo().getType();
        if (relType.equals(DBRelationshipInfo.RelationshipType.OneToMany)
                || relType.equals(DBRelationshipInfo.RelationshipType.ManyToMany)) {
            fieldLabelText += " " + UIRegistry.getResourceString("QB_AGGREGATED");
        } else {
            fieldLabelText += " " + UIRegistry.getResourceString("QB_FORMATTED");
        }

    }
    fieldLabel = createLabel(fieldLabelText);
    fieldLabel.addFocusListener(focusListener);
    fieldLabel.addKeyListener(enterListener);
    isNotCheckbox = createCheckBox("isNotCheckbox");
    isNotCheckbox.addFocusListener(focusListener);
    isNotCheckbox.addKeyListener(enterListener);
    operatorCBX = createComboBox(comparators);
    operatorCBX.addFocusListener(focusListener);
    operatorCBX.addKeyListener(enterListener);
    boolean isBool = fieldQRI != null && fieldQRI.getDataClass().equals(Boolean.class);
    if (!isBool) {
        operatorCBX.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    criteria.setVisible(!operatorCBX.getSelectedItem().equals(SpQueryField.OperatorType.EMPTY));
                }
            }
        });
    }
    if (pickList == null) {
        boolean hasBetweenOp = false;
        for (int o = 0; o < comparators.length; o++) {
            if (comparators[o].equals(OperatorType.BETWEEN)) {
                hasBetweenOp = true;
                break;
            }
        }
        if (hasBetweenOp) {
            criteria = new CriteriaPair(enterListener);
            operatorCBX.addActionListener(this);
        } else {
            criteria = createTextField("1");
            criteria.addKeyListener(enterListener);
        }
    } else {
        criteria = createPickList(saveBtn);
        if (!ownerQuery.isPromptMode()) {
            ((PickListCriteriaCombo) criteria)
                    .setCurrentOp((SpQueryField.OperatorType) operatorCBX.getModel().getElementAt(0));
        }
        criteria.addKeyListener(enterListener);
        operatorCBX.addItemListener(new ItemListener() {

            /*
             * (non-Javadoc)
             * 
             * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
             */
            //@Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    // System.out.println("setting curront op");
                    ((PickListCriteriaCombo) criteria)
                            .setCurrentOp((SpQueryField.OperatorType) operatorCBX.getSelectedItem());
                }
            }

        });
    }
    //criteria.addFocusListener(focusListener);

    sortCheckbox = new MultiStateIconButon(
            new ImageIcon[] { IconManager.getImage("GrayDot", IconManager.IconSize.Std16),
                    IconManager.getImage("UpArrow", IconManager.IconSize.Std16),
                    IconManager.getImage("DownArrow", IconManager.IconSize.Std16) });
    DataChangeNotifier dcn = validator.hookupComponent(sortCheckbox, "scb", UIValidator.Type.Changed, "", true);
    sortCheckbox.addFocusListener(focusListener);
    sortCheckbox.addActionListener(dcn);
    sortCheckbox.addKeyListener(enterListener);
    if (!this.ownerQuery.isPromptMode()) {
        isEnforcedCkbx = createCheckBox("isEnforcedCkbx");
        dcn = validator.hookupComponent(isEnforcedCkbx, "iecb", UIValidator.Type.Changed, "", true);
        isEnforcedCkbx.addActionListener(dcn);
        isEnforcedCkbx.addFocusListener(focusListener);
        isEnforcedCkbx.addKeyListener(enterListener);
    }
    if (!this.ownerQuery.isPromptMode()) {
        isDisplayedCkbx = createCheckBox("isDisplayedCkbx");
        dcn = validator.hookupComponent(isDisplayedCkbx, "idcb", UIValidator.Type.Changed, "", true);
        isDisplayedCkbx.addFocusListener(focusListener);
        isDisplayedCkbx.addKeyListener(enterListener);
        isDisplayedCkbx.addActionListener(dcn);
        isDisplayedCkbx.addActionListener(new ActionListener() {

            /* (non-Javadoc)
             * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
             */
            @Override
            public void actionPerformed(ActionEvent arg0) {
                SwingUtilities.invokeLater(new Runnable() {

                    /* (non-Javadoc)
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        sortCheckbox.setEnabled(isDisplayedCkbx.isSelected());
                        ownerQuery.changeNotification(QueryFieldPanel.this);
                    }
                });
            }
        });
        isPromptCkbx = createCheckBox("isPromptCkbx");
        dcn = validator.hookupComponent(isPromptCkbx, "ipcb", UIValidator.Type.Changed, "", true);
        isPromptCkbx.addActionListener(dcn);
        isPromptCkbx.addFocusListener(focusListener);
        isPromptCkbx.addKeyListener(enterListener);
        closeBtn = edu.ku.brc.ui.UIHelper.createIconBtn("Close", "QB_REMOVE_FLD", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                boolean clearIt = schemaItem != null;
                ownerQuery.removeQueryFieldItem((QueryFieldPanel) ((JComponent) ae.getSource()).getParent());
                if (clearIt) {
                    setField(null, null);
                }
            }
        });
        closeBtn.setEnabled(true);
        closeBtn.setFocusable(false);
        closeBtn.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseEntered(MouseEvent e) {
                ((JButton) e.getSource()).setIcon(IconManager.getIcon("CloseHover"));
                super.mouseEntered(e);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                ((JButton) e.getSource()).setIcon(IconManager.getIcon("Close"));
                super.mouseExited(e);
            }

        });
    } else {
        isDisplayedCkbx = null;
        this.isPromptCkbx = null;
        this.isEnforcedCkbx = null;
        this.closeBtn = null;
    }

    JComponent[] qComps = { iconLabel, fieldLabel, isNotCheckbox, operatorCBX, criteria, sortCheckbox,
            isDisplayedCkbx, isPromptCkbx, isEnforcedCkbx, closeBtn, null };
    JComponent[] sComps = { schemaItemCBX, iconLabel, fieldLabel, isNotCheckbox, operatorCBX, criteria,
            sortCheckbox, isDisplayedCkbx, isEnforcedCkbx, closeBtn, null };
    // 0 1 2 3 4 5 6 7 8 9
    if (schemaMapping == null) {
        comps = qComps;
    } else {
        comps = sComps;
    }

    StringBuilder sb = new StringBuilder();
    Integer[] qFixedCmps = { 300 };
    Integer[] sFixedCmps = { 268, 300 };
    Integer[] fixedCmps;
    if (schemaMapping != null) {
        fixedCmps = sFixedCmps;
    } else {
        fixedCmps = qFixedCmps;
    }
    if (columnDefStr == null) {
        for (int i = 0; i < comps.length; i++) {
            sb.append(i == 0 ? "" : ",");
            if (isCenteredComp(i))
                sb.append("c:");
            if (i >= fixedCmps.length) {
                sb.append("p");
            } else {
                sb.append(fixedCmps[i] + "px");
            }
            if (isGrowComp(i))
                sb.append(":g");
            sb.append(",4px");
        }
    } else {
        sb.append(columnDefStr);
    }

    PanelBuilder builder = new PanelBuilder(new FormLayout("3px, " + sb.toString() + ", 3px", "3px, p, 3px"),
            this);
    CellConstraints cc = new CellConstraints();

    int col = 1;
    for (JComponent comp : comps) {
        if (comp != null) {
            builder.add(comp, cc.xy(col + 1, 2));
        }
        col += 2;
    }

    if (fieldQRI != null) {
        icon = IconManager.getIcon(fieldQRI.getTableInfo().getName(), iconSize);
        setIcon(icon);
    }
    if (!ownerQuery.isPromptMode()) {
        isDisplayedCkbx.setSelected(true);
        isPromptCkbx.setSelected(!(fieldQRI instanceof RelQRI));
        isEnforcedCkbx.setSelected(false);
    }

    if (fieldQRI == null && !returnWidths) {
        for (int c = 1; c < comps.length; c++) {
            if (comps[c] != null) {
                comps[c].setVisible(false);
            }
        }
    } else {
        // for now
        boolean isRel = fieldQRI != null && fieldQRI instanceof RelQRI;
        boolean isTreeLevel = fieldQRI instanceof TreeLevelQRI;
        isNotCheckbox.setVisible(!isRel || pickList != null);
        operatorCBX.setVisible(!isRel || pickList != null);
        criteria.setVisible((!isRel && !isBool) || pickList != null);
        if (schemaMapping != null) {
            this.sortCheckbox.setVisible(!(isTreeLevel || isRel));
        } else {
            if (!isRel) {
                this.sortCheckbox.setVisible(true);
            } else {
                this.sortCheckbox.setVisible(
                        ((RelQRI) fieldQRI).getRelationshipInfo().getType() != RelationshipType.OneToMany);
            }
        }

        if (!ownerQuery.isPromptMode()) {
            isDisplayedCkbx.setVisible(!isRel);
            isPromptCkbx.setVisible(!isRel);
            isEnforcedCkbx.setVisible(!isRel);
        }
    }
    validate();
    doLayout();

    int[] widths = null;
    if (returnWidths) {
        widths = new int[comps.length];
        for (int i = 0; i < comps.length; i++) {
            widths[i] = comps[i] != null ? comps[i].getSize().width : 0;
        }
        if (this.schemaMapping == null) {
            widths[0] = iconSize.size();
            widths[1] = 200;
        } else {
            widths[1] = iconSize.size();
            widths[2] = 200;
        }
    }
    return widths;
}

From source file:vista.Venta.java

private void txtEntradaEfectivoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEntradaEfectivoKeyPressed
    // TODO add your handling code here:
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        this.calcularRecaudacion();
        this.calcularVuelto();
    }// ww w .  jav  a  2s .  c o m
    if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
        this.formPagoOff();
    }
}

From source file:Report_PRCR_New_EPF_Excel_File_Generator.java

private void dayfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dayfieldKeyPressed
    ///////////////////////////////////////////////////  Days Decrement/////////////////////////////////////////////////////////////////////////////

    if (dayfield.getText().equals("1")) { // Jumping to 31 and 30 from 1st
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {

            if (monthfield.getText().equals("Feb") || monthfield.getText().equals("Apr")
                    || monthfield.getText().equals("Jun") || monthfield.getText().equals("Aug")
                    || monthfield.getText().equals("Sep") || monthfield.getText().equals("Nov")
                    || monthfield.getText().equals("Feb")) {
                dayfield.setText("31");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth - 1));

            } else if (monthfield.getText().equals("May") || monthfield.getText().equals("Jul")
                    || monthfield.getText().equals("Oct") || monthfield.getText().equals("Dec")) {
                dayfield.setText("30");
                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth - 1));

            } else if (monthfield.getText().equals("Mar")) { // from march 1st jump to 28th or 29th checking leap years
                int yr = Integer.parseInt(yearfield.getText());
                if (yr % 4 == 0) {
                    if (yr % 100 == 0) {
                        if (yr % 400 == 0) {
                            dayfield.setText("29"); // Leap Year
                        }/*from  ww  w .  j  a  va 2 s .c  o m*/
                    }
                    if (yr % 100 == 0) {
                        if (yr % 400 != 0) {
                            dayfield.setText("28"); // not a leap year
                        }
                    }
                    dayfield.setText("29"); // leap year

                }
                if (yr % 4 != 0) {
                    dayfield.setText("28"); // not a leap year
                }
                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth - 1));

            } else if (monthfield.getText().equals("Jan")) { // From jan 1st jump to december 31st decrementing year
                dayfield.setText("31");

                int yr = Integer.parseInt(yearfield.getText());
                monthfield.setText("Dec");
                yearfield.setText("" + (yr - 1)); // year
            }
            dayfield.selectAll();
        } // /// decrementing normal values
    } else if (dayfield.getText().equals("2") || dayfield.getText().equals("3")
            || dayfield.getText().equals("4") || dayfield.getText().equals("5")
            || dayfield.getText().equals("6") || dayfield.getText().equals("7")
            || dayfield.getText().equals("8") || dayfield.getText().equals("9")
            || dayfield.getText().equals("10") || dayfield.getText().equals("11")
            || dayfield.getText().equals("12") || dayfield.getText().equals("13")
            || dayfield.getText().equals("14") || dayfield.getText().equals("15")
            || dayfield.getText().equals("16") || dayfield.getText().equals("17")
            || dayfield.getText().equals("18") || dayfield.getText().equals("19")
            || dayfield.getText().equals("20") || dayfield.getText().equals("21")
            || dayfield.getText().equals("22") || dayfield.getText().equals("23")
            || dayfield.getText().equals("24") || dayfield.getText().equals("25")
            || dayfield.getText().equals("26") || dayfield.getText().equals("27")
            || dayfield.getText().equals("28") || dayfield.getText().equals("29")
            || dayfield.getText().equals("30") || dayfield.getText().equals("31")) {
        if (evt.getKeyCode() == KeyEvent.VK_DOWN) {

            dayfield.setText("" + (Integer.parseInt(dayfield.getText()) - 1));
            dayfield.selectAll();
        }
    }
    /////////////////////////////////////////////////  Days Increment///////////////////////////////////////////////////////////////////////////////////////////////////
    if (dayfield.getText().equals("30")) { // from 30th to 1st of next month
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            if (monthfield.getText().equals("Apr") || monthfield.getText().equals("Jun")
                    || monthfield.getText().equals("Sep") || monthfield.getText().equals("Nov")) {
                dayfield.setText("0");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth + 1));

            }
            dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1));
            dayfield.selectAll();
        }

    } else if (dayfield.getText().equals("31")) { // from 31st to 1st of next month
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            if (monthfield.getText().equals("Jan") || monthfield.getText().equals("Mar")
                    || monthfield.getText().equals("May") || monthfield.getText().equals("Jul")
                    || monthfield.getText().equals("Aug") || monthfield.getText().equals("Oct")) {
                dayfield.setText("1");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth + 1));

            } else if (monthfield.getText().equals("Dec")) { // December to january incrementing the year

                dayfield.setText("1");

                int yr = Integer.parseInt(yearfield.getText());
                monthfield.setText("Jan");
                yearfield.setText("" + (yr + 1));
            }
            dayfield.selectAll();
        }

    } else if (monthfield.getText().equals("Feb")) { // for february
        if (evt.getKeyCode() == KeyEvent.VK_UP) {
            if (dayfield.getText().equals("28")) { // at 28 check for leap year
                int yr = Integer.parseInt(yearfield.getText());
                if (yr % 4 == 0) {
                    if (yr % 100 == 0) {
                        if (yr % 400 == 0) {
                            dayfield.setText("29"); // Leap Year       // increment to 29
                        }
                    }
                    if (yr % 100 == 0) {
                        if (yr % 400 != 0) {
                            dayfield.setText("1");
                            int mnth = datechooser.return_index(monthfield.getText());
                            monthfield.setText(datechooser.Return_month(mnth + 1));

                            // not a leap year                             // jump to next month
                        }
                    }
                    dayfield.setText("29"); // leap year             // increment to 29th

                }
                if (yr % 4 != 0) {
                    dayfield.setText("1");
                    int mnth = datechooser.return_index(monthfield.getText());
                    monthfield.setText(datechooser.Return_month(mnth + 1)); // not a leap year
                }

            } else if (dayfield.getText().equals("29")) { // at 29 jump to next month normally
                dayfield.setText("1");

                int mnth = datechooser.return_index(monthfield.getText());
                monthfield.setText(datechooser.Return_month(mnth + 1));
                // incrementing normal values/////////////////////// for february separately
            } else if (dayfield.getText().equals("1") || dayfield.getText().equals("2")
                    || dayfield.getText().equals("3") || dayfield.getText().equals("4")
                    || dayfield.getText().equals("5") || dayfield.getText().equals("6")
                    || dayfield.getText().equals("7") || dayfield.getText().equals("8")
                    || dayfield.getText().equals("9") || dayfield.getText().equals("10")
                    || dayfield.getText().equals("11") || dayfield.getText().equals("12")
                    || dayfield.getText().equals("13") || dayfield.getText().equals("14")
                    || dayfield.getText().equals("15") || dayfield.getText().equals("16")
                    || dayfield.getText().equals("17") || dayfield.getText().equals("18")
                    || dayfield.getText().equals("19") || dayfield.getText().equals("20")
                    || dayfield.getText().equals("21") || dayfield.getText().equals("22")
                    || dayfield.getText().equals("23") || dayfield.getText().equals("24")
                    || dayfield.getText().equals("25") || dayfield.getText().equals("26")
                    || dayfield.getText().equals("27") || dayfield.getText().equals("28")
                    || dayfield.getText().equals("29") || dayfield.getText().equals("30")
                    || dayfield.getText().equals("31")) {

                dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1));

            }
            dayfield.selectAll();
        }
        // incrementing normal values
    } else if (dayfield.getText().equals("1") || dayfield.getText().equals("2")
            || dayfield.getText().equals("3") || dayfield.getText().equals("4")
            || dayfield.getText().equals("5") || dayfield.getText().equals("6")
            || dayfield.getText().equals("7") || dayfield.getText().equals("8")
            || dayfield.getText().equals("9") || dayfield.getText().equals("10")
            || dayfield.getText().equals("11") || dayfield.getText().equals("12")
            || dayfield.getText().equals("13") || dayfield.getText().equals("14")
            || dayfield.getText().equals("15") || dayfield.getText().equals("16")
            || dayfield.getText().equals("17") || dayfield.getText().equals("18")
            || dayfield.getText().equals("19") || dayfield.getText().equals("20")
            || dayfield.getText().equals("21") || dayfield.getText().equals("22")
            || dayfield.getText().equals("23") || dayfield.getText().equals("24")
            || dayfield.getText().equals("25") || dayfield.getText().equals("26")
            || dayfield.getText().equals("27") || dayfield.getText().equals("28")
            || dayfield.getText().equals("29") || dayfield.getText().equals("30")
            || dayfield.getText().equals("31")) {
        if (evt.getKeyCode() == KeyEvent.VK_UP) {

            dayfield.setText("" + (Integer.parseInt(dayfield.getText()) + 1));
            dayfield.selectAll();

        }
    }
    if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {
        monthfield.requestFocus();
        monthfield.selectAll();
    }

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
    }
}

From source file:net.sf.jabref.gui.BasePanel.java

private void createMainTable() {
    database.registerListener(tableModel.getListSynchronizer());
    database.registerListener(SpecialFieldDatabaseChangeListener.getInstance());

    tableFormat = new MainTableFormat(database);
    tableFormat.updateTableFormat();/*w  ww.  j a  va  2 s . c om*/
    mainTable = new MainTable(tableFormat, tableModel, frame, this);

    selectionListener = new MainTableSelectionListener(this, mainTable);
    mainTable.updateFont();
    mainTable.addSelectionListener(selectionListener);
    mainTable.addMouseListener(selectionListener);
    mainTable.addKeyListener(selectionListener);
    mainTable.addFocusListener(selectionListener);

    // Add the listener that will take care of highlighting groups as the selection changes:
    groupsHighlightListener = listEvent -> {
        HighlightMatchingGroupPreferences highlightMatchingGroupPreferences = new HighlightMatchingGroupPreferences(
                Globals.prefs);
        if (highlightMatchingGroupPreferences.isAny()) {
            getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), false);
        } else if (highlightMatchingGroupPreferences.isAll()) {
            getGroupSelector().showMatchingGroups(mainTable.getSelectedEntries(), true);
        } else {
            // no highlight
            getGroupSelector().showMatchingGroups(null, true);
        }
    };
    mainTable.addSelectionListener(groupsHighlightListener);

    mainTable.getActionMap().put(Actions.CUT, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.CUT);
            } catch (Throwable ex) {
                LOGGER.warn("Could not cut", ex);
            }
        }
    });
    mainTable.getActionMap().put(Actions.COPY, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.COPY);
            } catch (Throwable ex) {
                LOGGER.warn("Could not copy", ex);
            }
        }
    });
    mainTable.getActionMap().put(Actions.PASTE, new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                runCommand(Actions.PASTE);
            } catch (Throwable ex) {
                LOGGER.warn("Could not paste", ex);
            }
        }
    });

    mainTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            final int keyCode = e.getKeyCode();
            final TreePath path = frame.getGroupSelector().getSelectionPath();
            final GroupTreeNodeViewModel node = path == null ? null
                    : (GroupTreeNodeViewModel) path.getLastPathComponent();

            if (e.isControlDown()) {
                switch (keyCode) {
                // The up/down/left/rightkeystrokes are displayed in the
                // GroupSelector's popup menu, so if they are to be changed,
                // edit GroupSelector.java accordingly!
                case KeyEvent.VK_UP:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeUp(node, true);
                    }
                    break;
                case KeyEvent.VK_DOWN:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeDown(node, true);
                    }
                    break;
                case KeyEvent.VK_LEFT:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeLeft(node, true);
                    }
                    break;
                case KeyEvent.VK_RIGHT:
                    e.consume();
                    if (node != null) {
                        frame.getGroupSelector().moveNodeRight(node, true);
                    }
                    break;
                case KeyEvent.VK_PAGE_DOWN:
                    frame.nextTab.actionPerformed(null);
                    e.consume();
                    break;
                case KeyEvent.VK_PAGE_UP:
                    frame.prevTab.actionPerformed(null);
                    e.consume();
                    break;
                default:
                    break;
                }
            } else if (keyCode == KeyEvent.VK_ENTER) {
                e.consume();
                try {
                    runCommand(Actions.EDIT);
                } catch (Throwable ex) {
                    LOGGER.warn("Could not run action based on key press", ex);
                }
            }
        }
    });
}

From source file:br.com.atmatech.sac.view.ViewAtendimento.java

private void jTtdclienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTtdclienteKeyPressed
    // TODO add your handling code here:        
    if ((evt.getKeyCode() == KeyEvent.VK_F)) {
        if (evt.isControlDown()) {
            atalhoBuscaCliente();/*from  w w w.  ja  v  a  2  s .co m*/
        }
    }
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        clienteSelecionado();
    }
}

From source file:org.martin.ftp.gui.GUIClient.java

private void txtServerKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtServerKeyReleased

    String text = txtServer.getText();

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {

        txtUser.requestFocus();/*from w  w w  .  j  ava2 s. co m*/
        if (!txtUser.getText().isEmpty())
            txtUser.selectAll();

    }
}

From source file:org.martin.ftp.gui.GUIClient.java

private void txtUserKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtUserKeyReleased

    String text = txtUser.getText();

    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {

        if (!text.trim().isEmpty())
            txtUser.setText(text.trim());

        txtPassword.requestFocus();//from  ww  w  . j  ava2 s  .c o m
        if (!txtPassword.getText().isEmpty())
            txtPassword.selectAll();

    }

}

From source file:org.martin.ftp.gui.GUIClient.java

private void txtPasswordKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPasswordKeyReleased

    if (evt.getKeyCode() == KeyEvent.VK_ENTER)
        btnConnect.doClick();// w w w.  j  av  a  2  s  .com
}

From source file:swift.selenium.WebHelper.java

@SuppressWarnings("incomplete-switch")
public static String doAction(String imageType, String controlType, String controlId, String controlName,
        String ctrlValue, String logicalName, String action, WebElement webElement, Boolean Results,
        HSSFSheet strucSheet, HSSFSheet valSheet, int rowIndex, int rowcount, String rowNo, String colNo)
        throws Exception {
    List<WebElement> WebElementList = null;
    String currentValue = null;//from ww w  . j a  va 2s. co m
    //HSSFSheet uniqueNumberSheet =null;
    String uniqueNumber = "";
    WebVerification.isFromVerification = false;
    //HashMap<String ,Object> uniqueValuesHashMap = null;
    //HSSFRow uniqueRow = null;
    ControlTypeEnum controlTypeEnum = ControlTypeEnum.valueOf(controlType);
    ControlTypeEnum actionName = ControlTypeEnum.valueOf(action.toString());
    if (controlType.contains("Robot") && !isIntialized) {
        robot = new Robot();
        isIntialized = true;
    }

    if (action.toString().equalsIgnoreCase("I") && !ctrlValue.equalsIgnoreCase("")
            || action.toString().equalsIgnoreCase("Read") || action.toString().equalsIgnoreCase("Write")
            || action.toString().equalsIgnoreCase("V") && !ctrlValue.equalsIgnoreCase("")
            || action.toString().equalsIgnoreCase("NC")
            || action.toString().equalsIgnoreCase("T") && !ctrlValue.equalsIgnoreCase("")
            || action.toString().equalsIgnoreCase("F") && !ctrlValue.equalsIgnoreCase("")
            || action.toString().equalsIgnoreCase("VA") && !ctrlValue.equalsIgnoreCase("")
            || action.toString().equalsIgnoreCase("O") || action.toString().equalsIgnoreCase("CP")
            || action.toString().equalsIgnoreCase("GV") || action.toString().equalsIgnoreCase("LV")
            || action.toString().equalsIgnoreCase("GB") || action.toString().equalsIgnoreCase("Get")
            || action.toString().equalsIgnoreCase("Post")) {
        try {
            switch (controlTypeEnum) {

            case WebEdit:
                switch (actionName) {
                case Read:
                    uniqueNumber = ReadFromExcel(ctrlValue);
                    webElement.clear();
                    webElement.sendKeys(uniqueNumber);
                    break;
                case Write:
                    writeToExcel(ctrlValue, webElement, controlId, controlType, controlName, rowNo, colNo);
                    break;
                case I:
                    if (!ctrlValue.equalsIgnoreCase("null")) {
                        webElement.clear();
                        webElement.sendKeys(ctrlValue);
                    } else {
                        webElement.clear();
                    }
                    break;
                case T:
                    if (!ctrlValue.equalsIgnoreCase("null")) {
                        webElement.clear();
                        webElement.sendKeys(ctrlValue);
                        ((DeviceActionShortcuts) Automation.driver).hideKeyboard();
                    } else {
                        webElement.clear();
                    }
                    break;
                case V:
                    currentValue = webElement.getText();
                    break;
                }
                break;

            case WebButton:
                switch (actionName) {
                case I:
                    if (ctrlValue.equalsIgnoreCase("Y") || ctrlValue.equalsIgnoreCase("Yes")) {
                        webElement.click();
                    }
                    break;
                case NC:
                    webElement.click();
                    break;
                case V:
                    if (webElement.isDisplayed()) {
                        if (webElement.isEnabled() == true)
                            currentValue = "True";
                        else
                            currentValue = "False";
                    }
                }
                break;

            case WebElement:
                switch (actionName) {

                case I:
                    webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                    webElement.click();
                    break;

                case Read:
                    uniqueNumber = ReadFromExcel(ctrlValue);
                    webElement.clear();
                    webElement.sendKeys(uniqueNumber);
                    break;
                case Write:
                    writeToExcel(ctrlValue, webElement, controlId, controlType, controlName, rowNo, colNo);
                    break;
                case V:
                    if (WebVerification.isFromVerification == true) {
                        currentValue = webElement.getText();
                        break;
                    }
                    boolean textPresent = false;
                    String ObservedText = webElement.getText();
                    if (StringUtils.isBlank(ObservedText)) {
                        ObservedText = webElement.getAttribute("value");
                    }

                    textPresent = ObservedText.contains(ctrlValue);
                    if (textPresent == false)
                        currentValue = Boolean.toString(textPresent);
                    else
                        currentValue = ctrlValue;
                    break;

                case T:
                    Point p = ((Locatable) webElement).getCoordinates().onPage();
                    ((MobileDriver) Automation.driver).tap(1, p.getX(), p.getY(), 1);
                    break;
                }
                break;

            case JSScript:
                ((JavascriptExecutor) Automation.driver).executeScript(controlName, ctrlValue);
                break;

            case Wait:
                Thread.sleep(Integer.parseInt(controlName) * 1000);
                break;

            case CheckBox:
                switch (actionName) {
                case I:
                    if (ctrlValue.equalsIgnoreCase("Y") || ctrlValue.equalsIgnoreCase("Yes")) {
                        webElement.click();
                    }
                    break;
                case NC:
                    webElement.click();
                    break;
                }
                break;

            case Radio:
                switch (actionName) {
                case I:
                    if (ctrlValue.equalsIgnoreCase("Y") || ctrlValue.equalsIgnoreCase("Yes")) {
                        if (!webElement.isSelected()) {
                            webElement.click();
                        }
                    }
                    break;
                case NC:
                    if (!webElement.isSelected()) {
                        webElement.click();
                    }
                    break;
                case V:
                    if (webElement.isSelected()) {
                        currentValue = webElement.getAttribute(controlName.toString());
                    }
                    break;
                case F:
                    if (webElement != null) {
                        currentValue = "Y";
                    }
                    break;
                }
                break;

            case WebLink:
                //case CloseWindow://added this Case to bypass page loading after clicking the event
                switch (actionName) {
                case Read:
                    uniqueNumber = ReadFromExcel(ctrlValue);
                    WebElementList = getElementsByType(controlId, controlName, controlType, imageType,
                            uniqueNumber);
                    webElement = GetControlByIndex("", WebElementList, controlId, controlName, controlType,
                            uniqueNumber);
                    webElement.click();
                    break;
                case Write:
                    writeToExcel(ctrlValue, webElement, controlId, controlType, controlName, rowNo, colNo);
                    break;
                case I:
                    if (controlId.equalsIgnoreCase("LinkValue")) {
                        webElement.click();
                    } else {
                        if (ctrlValue.equalsIgnoreCase("Y") || ctrlValue.equalsIgnoreCase("Yes")) {
                            webElement.click();
                        }
                    }
                    break;
                case NC:
                    webElement.click();
                    break;
                }
                break;

            case CloseWindow: //TM-09/09/2015: This case is written to help in closing any specific windows
                switch (actionName) {
                case I: //This case helps in closing a specific window on the basis on the given title            
                    Set<String> handlers = null;
                    handlers = Automation.driver.getWindowHandles();
                    for (String handler : handlers) {
                        Automation.driver = Automation.driver.switchTo().window(handler);

                        //TM-19/01/2015: Changed following comparison from equalsIgnoreCase to contains
                        if (Automation.driver.getTitle().contains(ctrlValue)) {
                            System.out.println("Closing required window :-" + Automation.driver.getTitle());
                            Automation.driver.close();
                            break;
                        }
                    }
                    break;
                case NC://This case helps in closing the window with current focus
                    Automation.driver.close();
                    break;
                }
                break;
            case WaitForJS:
                waitForCondition();
                break;

            case ListBox:
            case WebList:
                switch (actionName) {
                case Read:
                    uniqueNumber = ReadFromExcel(ctrlValue);
                    new Select(webElement).selectByVisibleText(uniqueNumber);
                    break;
                case Write:
                    writeToExcel(ctrlValue, webElement, controlId, controlType, controlName, rowNo, colNo);
                    break;
                case I:
                    ExpectedCondition<Boolean> isTextPresent = CommonExpectedConditions
                            .textToBePresentInElement(webElement, ctrlValue);
                    if (isTextPresent != null) {
                        if (webElement != null) {
                            new Select(webElement).selectByVisibleText(ctrlValue);
                        }
                    }
                    break;
                case V:
                    if (!ctrlValue.contains(",")) {
                        currentValue = new Select(webElement).getFirstSelectedOption().getText();
                        if (currentValue.isEmpty()) {
                            currentValue = new Select(webElement).getFirstSelectedOption()
                                    .getAttribute("value");
                        }

                        break;
                    } else {
                        currentValue = new String();
                        List<WebElement> currentValues = new ArrayList<WebElement>();
                        currentValues = new Select(webElement).getOptions();

                        for (int j = 0; j < currentValues.size(); j++) {
                            if (j + 1 == currentValues.size())
                                currentValue = currentValue.concat(currentValues.get(j).getText());
                            else {
                                currentValue = currentValue.concat(currentValues.get(j).getText() + ",");
                            }
                        }
                        break;
                    }
                }
                break;

            //New code for AJAX Dropdown with dojo
            case AjaxWebList:
                switch (actionName) {
                case I:
                    webElement.click();
                    break;
                case VA:
                    Thread.sleep(20000);
                    currentValue = new String();
                    List<WebElement> currentValues = new ArrayList<WebElement>();
                    currentValues = Automation.driver.findElements(By.xpath(controlName));

                    for (int j = 0; j < currentValues.size(); j++) {
                        if (j + 1 == currentValues.size())
                            currentValue = currentValue.concat(currentValues.get(j).getText());
                        else {
                            currentValue = currentValue.concat(currentValues.get(j).getText() + ",");
                        }
                    }
                    break;
                }
                break;
            case IFrame:
                Automation.driver = Automation.driver.switchTo().frame(controlName);
                break;

            case Browser:
                Set<String> handlers = null;
                handlers = Automation.driver.getWindowHandles();
                for (String handler : handlers) {
                    Automation.driver = Automation.driver.switchTo().window(handler);
                    if (Automation.driver.getTitle().contains(controlName)) {
                        System.out.println("Focus on window with title: " + Automation.driver.getTitle());
                        break;
                    }
                }
                break;

            case BrowserControl:
                Set<String> winHandles = Automation.driver.getWindowHandles();
                boolean controlfound = false;
                winHandles = Automation.driver.getWindowHandles();
                for (String handler : winHandles) {
                    Automation.driver = Automation.driver.switchTo().window(handler);

                    try {
                        Automation.driver.findElement(By.xpath(controlName));
                        System.out.println("Focus on window with Control: " + controlName);
                        controlfound = true;
                        break;

                    } catch (Exception e) {
                        // TODO: handle exception
                    }
                }

                if (!controlfound)
                    System.out.println("Unable to find control with : " + controlName);
                break;

            case BrowserType:
                switch (actionName) {
                case I:
                    if (StringUtils.isNotBlank(ctrlValue)) {
                        Automation.browser = Automation.configHashMap.get("BROWSERTYPE").toString();
                        if (StringUtils.equalsIgnoreCase("none", Automation.browser)) {
                            Automation.browser = ctrlValue.toString();
                            Automation.browserType = Automation.browserTypeEnum.valueOf(Automation.browser);
                            Automation.setUp();
                            wait = new WebDriverWait(Automation.driver,
                                    Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString()));
                            //Thread.sleep(5000);
                        }
                    }
                    break;
                case NC:
                    if (StringUtils.isNotBlank(controlName)) {
                        Automation.browser = Automation.configHashMap.get("BROWSERTYPE").toString();
                        if (StringUtils.equalsIgnoreCase("none", Automation.browser)) {
                            Automation.browser = controlName.toString();
                            Automation.browserType = Automation.browserTypeEnum.valueOf(Automation.browser);
                            Automation.setUp();
                            wait = new WebDriverWait(Automation.driver,
                                    Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString()));
                            //Thread.sleep(5000);
                        }
                    }
                    break;
                }
                break;
            case BrowserAuth:
                final String details[] = ctrlValue.split(",");
                Runnable thread2 = new Runnable() {
                    public void run() {
                        try {
                            smartRobot = new SmartRobot();
                            Thread.sleep(5000);
                            smartRobot.type(details[0].toString());// Enter username      
                            Thread.sleep(2000);
                            smartRobot.pressTab();// Click Keyboard Tab                              
                            smartRobot.type(details[1].toString());// Enter password      
                            Thread.sleep(2000);
                            smartRobot.pressEnter();// Click Enter button
                            Thread.sleep(5000);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                };
                Thread thr2 = new Thread(thread2);
                thr2.start();
                break;

            case URL:
                final String url = ctrlValue;
                if (!StringUtils.isBlank(ctrlValue)) {
                    if (Automation.browser.equals("InternetExplorer")) {
                        Automation.driver.navigate().to(url);
                        Thread.sleep(5000);
                    } else {
                        Runnable thread1 = new Runnable() {
                            public void run() {
                                try {
                                    Automation.driver.navigate().to(url);
                                    Thread.sleep(5000);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }
                        };
                        Thread thr1 = new Thread(thread1);
                        thr1.start();
                    }
                }
                break;

            case Menu:
                webElement.click();
                break;

            case Alert:
                switch (actionName) {
                case V:
                    Alert alert = wait.until(ExpectedConditions.alertIsPresent());
                    if (alert != null) {
                        Automation.driver.switchTo().alert();
                        currentValue = alert.getText();
                        System.out.println(currentValue);
                        alert.accept();
                    }
                    break;
                }
                break;

            case WebImage:
                webElement.sendKeys(Keys.TAB);
                webElement.click();
                Thread.sleep(5000);
                for (int Seconds = 0; Seconds <= Integer
                        .parseInt(Automation.configHashMap.get("TIMEOUT").toString()); Seconds++) {
                    if (!((Automation.driver.getWindowHandles().size()) > 1)) {
                        webElement.click();
                        Thread.sleep(5000);
                    } else {
                        break;
                    }
                }
                break;

            case ActionClick:
                Actions builderClick = new Actions(Automation.driver);
                Action clickAction = builderClick.moveToElement(webElement).clickAndHold().release().build();
                clickAction.perform();
                break;

            case ActionDoubleClick:
                Actions builderdoubleClick = new Actions(Automation.driver);
                builderdoubleClick.doubleClick(webElement).perform();//TM-27/01/2015 :- commented following code and used this code for simultaneous clicks
                //Action doubleClickAction = builderdoubleClick.moveToElement(webElement).click().build();
                //doubleClickAction.perform();
                //doubleClickAction.perform();                  
                break;

            case ActionClickandEsc:
                Actions clickandEsc = new Actions(Automation.driver);
                Action clickEscAction = clickandEsc.moveToElement(webElement).click()
                        .sendKeys(Keys.ENTER, Keys.ESCAPE).build();
                clickEscAction.perform();
                break;

            case ActionMouseOver:
                Actions builderMouserOver = new Actions(Automation.driver);
                Action mouseOverAction = builderMouserOver.moveToElement(webElement).build();
                mouseOverAction.perform();
                break;

            case Calendar:
                //   Thread.sleep(5000);
                Boolean isCalendarDisplayed = Automation.driver.switchTo().activeElement().isDisplayed();
                System.out.println(isCalendarDisplayed);
                if (isCalendarDisplayed == true) {
                    String[] dtMthYr = ctrlValue.split("/");
                    WebElement Year = WaitTool.waitForElement(Automation.driver, By.name("year"),
                            Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString()));//Automation.driver.findElement(By.name("year"));
                    while (!Year.getAttribute("value").equalsIgnoreCase(dtMthYr[2])) {
                        if (Integer.parseInt(Year.getAttribute("value")) > Integer.parseInt(dtMthYr[2])) {
                            WebElement yearButton = WaitTool.waitForElement(Automation.driver, By.id("button1"),
                                    Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString()));//Automation.driver.findElement(By.id("button1"));
                            yearButton.click();
                        } else if (Integer.parseInt(Year.getAttribute("value")) < Integer
                                .parseInt(dtMthYr[2])) {
                            WebElement yearButton = WaitTool.waitForElement(Automation.driver, By.id("Button5"),
                                    Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString()));//Automation.driver.findElement(By.id("Button5"));
                            yearButton.click();
                        }
                    }
                    Select date = new Select(WaitTool.waitForElement(Automation.driver, By.name("month"),
                            Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString())));
                    month = CalendarSnippet.getMonthForInt(Integer.parseInt(dtMthYr[1]));
                    date.selectByVisibleText(month);
                    WebElement Day = WaitTool.waitForElement(Automation.driver, By.id("Button6"),
                            Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString()));//Automation.driver.findElement(By.id("Button6"));
                    int day = 6;
                    while (Day.getAttribute("value") != null) {
                        Day = WaitTool.waitForElement(Automation.driver, By.id("Button" + day),
                                Integer.parseInt(Automation.configHashMap.get("TIMEOUT").toString()));//Automation.driver.findElement(By.id("Button"+day));
                        if (Day.getAttribute("value").toString().equalsIgnoreCase(dtMthYr[0])) {
                            Day.click();
                            break;
                        }
                        day++;
                    }
                } else {
                    System.out.println("Calendar not Diplayed");
                }
                //Automation.selenium.click(controlName);
                break;

            case CalendarNew:
                isCalendarDisplayed = Automation.driver.switchTo().activeElement().isDisplayed();
                System.out.println(isCalendarDisplayed);
                if (isCalendarDisplayed == true) {

                    String[] dtMthYr = ctrlValue.split("/");
                    Thread.sleep(2000);
                    //String[] CurrentDate = dtFormat.format(frmDate).split("/");
                    WebElement Monthyear = Automation.driver.findElement(By.xpath("//table/thead/tr/td[2]"));
                    String Monthyear1 = Monthyear.getText();
                    String[] Monthyear2 = Monthyear1.split(",");
                    Monthyear2[1] = Monthyear2[1].trim();

                    month = CalendarSnippet.getMonthForString(Monthyear2[0]);

                    while (!Monthyear2[1].equalsIgnoreCase(dtMthYr[2])) {
                        if (Integer.parseInt(Monthyear2[1]) > Integer.parseInt(dtMthYr[2])) {
                            WebElement yearButton = Automation.driver
                                    .findElement(By.cssSelector("td:contains('')"));
                            yearButton.click();
                            Monthyear2[1] = Integer.toString(Integer.parseInt(Monthyear2[1]) - 1);
                        } else if (Integer.parseInt(Monthyear2[1]) < Integer.parseInt(dtMthYr[2])) {
                            WebElement yearButton = Automation.driver
                                    .findElement(By.cssSelector("td:contains('')"));
                            yearButton.click();
                            Monthyear2[1] = Integer.toString(Integer.parseInt(Monthyear2[1]) + 1);
                        }
                    }

                    while (!month.equalsIgnoreCase(dtMthYr[1])) {
                        if (Integer.parseInt(month) > Integer.parseInt(dtMthYr[1])) {
                            WebElement monthButton = Automation.driver
                                    .findElement(By.cssSelector("td:contains('')"));
                            monthButton.click();
                            if (Integer.parseInt(month) < 11) {
                                month = "0" + Integer.toString(Integer.parseInt(month) - 1);
                            } else {
                                month = Integer.toString(Integer.parseInt(month) - 1);
                            }

                        } else if (Integer.parseInt(month) < Integer.parseInt(dtMthYr[1])) {
                            WebElement monthButton = Automation.driver
                                    .findElement(By.cssSelector("td:contains('')"));
                            monthButton.click();
                            if (Integer.parseInt(month) < 9) {
                                month = "0" + Integer.toString(Integer.parseInt(month) + 1);
                            } else {
                                month = Integer.toString(Integer.parseInt(month) + 1);
                            }
                        }
                    }

                    WebElement dateButton = Automation.driver
                            .findElement(By.cssSelector("td.day:contains('" + dtMthYr[0] + "')"));
                    System.out.println(dateButton);
                    dateButton.click();

                } else {
                    System.out.println("Calendar not Diplayed");
                }
                break;

            case CalendarIPF:
                String[] dtMthYr = ctrlValue.split("/");
                Thread.sleep(2000);
                String year = dtMthYr[2];
                String monthNum = dtMthYr[1];
                String day = dtMthYr[0];

                //Xpath for Year, mMnth & Days
                String xpathYear = "//div[@class='datepicker datepicker-dropdown dropdown-menu datepicker-orient-left datepicker-orient-bottom']/div[@class='datepicker-years']";
                String xpathMonth = "//div[@class='datepicker datepicker-dropdown dropdown-menu datepicker-orient-left datepicker-orient-bottom']/div[@class='datepicker-months']";
                String xpathDay = "//div[@class='datepicker datepicker-dropdown dropdown-menu datepicker-orient-left datepicker-orient-bottom']/div[@class='datepicker-days']";

                //Selecting year in 3 steps
                Automation.driver.findElement(By.xpath(xpathDay + "/table/thead/tr[1]/th[2]")).click();
                Automation.driver.findElement(By.xpath(xpathMonth + "/table/thead/tr/th[2]")).click();
                Automation.driver
                        .findElement(By.xpath(xpathYear
                                + "/table/tbody/tr/td/span[@class='year'][contains(text()," + year + ")]"))
                        .click();

                //Selecting month in 1 step   
                Automation.driver
                        .findElement(By.xpath(xpathMonth + "/table/tbody/tr/td/span[" + monthNum + "]"))
                        .click();

                //Selecting day in 1 step
                Automation.driver
                        .findElement(By.xpath(
                                xpathDay + "/table/tbody/tr/td[@class='day'][contains(text()," + day + ")]"))
                        .click();

            case CalendarEBP:
                String[] dtMthYrEBP = ctrlValue.split("/");
                Thread.sleep(500);
                String yearEBP = dtMthYrEBP[2];
                String monthNumEBP = CalendarSnippet.getMonthForInt(Integer.parseInt(dtMthYrEBP[1]))
                        .substring(0, 3);
                String dayEBP = dtMthYrEBP[0];

                //common path used for most of the elements
                String pathToVisibleCalendar = "//div[@class='ajax__calendar'][contains(@style, 'visibility: visible;')]/div";

                //following is to click the title once to reach the year page
                wait.until(ExpectedConditions.elementToBeClickable(
                        By.xpath(pathToVisibleCalendar + "/div[@class='ajax__calendar_header']/div[3]/div")))
                        .click();
                //check if 'Dec' is visibly clickable after refreshing
                wait.until(ExpectedConditions.elementToBeClickable(By.xpath(
                        pathToVisibleCalendar + "/div/div/table/tbody/tr/td/div[contains(text(), 'Dec')]")));
                Thread.sleep(5000);
                //following is to click the title once again to reach the year page
                wait.until(ExpectedConditions.elementToBeClickable(
                        (By.xpath(pathToVisibleCalendar + "/div[@class='ajax__calendar_header']/div[3]/div"))))
                        .click();
                //common path used for most of the elements while selection of year, month and date
                pathToVisibleCalendar = "//div[@class='ajax__calendar'][contains(@style, 'visibility: visible;')]/div/div/div/table/tbody/tr/td";
                Thread.sleep(2000);
                //each of the following line selects the year, month and date
                wait.until(ExpectedConditions.elementToBeClickable(
                        By.xpath(pathToVisibleCalendar + "/div[contains(text()," + yearEBP + ")]"))).click();
                Thread.sleep(2000);
                wait.until(ExpectedConditions.elementToBeClickable(By.xpath(pathToVisibleCalendar
                        + "/div[@class='ajax__calendar_month'][contains(text(),'" + monthNumEBP + "')]")))
                        .click();
                Thread.sleep(2000);
                wait.until(ExpectedConditions.elementToBeClickable(By.xpath(pathToVisibleCalendar
                        + "/div[@class='ajax__calendar_day'][contains(text()," + dayEBP + ")]"))).click();

                break;

            /**Code for window popups**/
            case Window:
                switch (actionName) {
                case O:
                    String parentHandle = Automation.driver.getWindowHandle();
                    for (String winHandle : Automation.driver.getWindowHandles()) {
                        Automation.driver.switchTo().window(winHandle);
                        if (Automation.driver.getTitle().contains(controlName)) {
                            ((JavascriptExecutor) Automation.driver)
                                    .executeScript("window.onbeforeunload = function(e){};");//By Tripti: 16/02/2015
                            Automation.driver.close();
                        } else {
                            parentHandle = winHandle;
                        }

                    }
                    Automation.driver.switchTo().window(parentHandle);
                    break;
                }
                break;

            case WebTable:
                switch (actionName) {
                case Read:
                    ReadFromExcel(ctrlValue);
                    break;
                case Write:
                    writeToExcel(ctrlValue, webElement, controlId, controlType, controlName, rowNo, colNo);
                    break;
                case NC:
                    WebElement table = webElement;
                    List<WebElement> tableRows = table.findElements(By.tagName("tr"));
                    int tableRowIndex = 0;
                    //int tableColumnIndex = 0;
                    boolean matchFound = false;
                    for (WebElement tableRow : tableRows) {
                        tableRowIndex += 1;
                        List<WebElement> tableColumns = tableRow.findElements(By.tagName("td"));
                        if (tableColumns.size() > 0) {
                            for (WebElement tableColumn : tableColumns)
                                if (tableColumn.getText().equals(ctrlValue)) {
                                    matchFound = true;
                                    System.out.println(tableRowIndex);
                                    List<Object> elementProperties = getPropertiesOfWebElement(
                                            tableColumns.get(Integer.parseInt(colNo)), imageType);
                                    controlName = elementProperties.get(0).toString();
                                    if (controlName.equals("")) {
                                        controlName = elementProperties.get(1).toString();
                                    }
                                    controlType = elementProperties.get(2).toString();
                                    webElement = (WebElement) elementProperties.get(3);
                                    doAction(imageType, controlType, controlId, controlName, ctrlValue,
                                            logicalName, action, webElement, Results, strucSheet, valSheet,
                                            tableRowIndex, rowcount, rowNo, colNo);
                                    break;
                                }
                            if (matchFound) {
                                break;
                            }
                        }

                    }
                    break;
                case V:
                    WriteToDetailResults(ctrlValue, "", logicalName);
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    break;

                case GB:
                    WebVerification.GroupBy = ctrlValue;
                    break;
                }
                break;

            case Robot:

                if (controlName.equalsIgnoreCase("SetFilePath")) {
                    StringSelection stringSelection = new StringSelection(ctrlValue);
                    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);

                    robot.delay(5000);
                    robot.keyPress(KeyEvent.VK_CONTROL);
                    robot.keyPress(KeyEvent.VK_V);
                    robot.keyRelease(KeyEvent.VK_V);
                    robot.keyRelease(KeyEvent.VK_CONTROL);

                } else if (controlName.equalsIgnoreCase("Type")) {
                    robot.keyPress(KeyEvent.VK_M);
                    robot.keyRelease(KeyEvent.VK_TAB);
                } else if (controlName.equalsIgnoreCase("TAB")) {
                    robot.keyPress(KeyEvent.VK_TAB);
                    robot.keyRelease(KeyEvent.VK_TAB);
                } else if (controlName.equalsIgnoreCase("SPACE")) {
                    robot.keyPress(KeyEvent.VK_SPACE);
                    robot.keyRelease(KeyEvent.VK_SPACE);
                } else if (controlName.equalsIgnoreCase("ENTER")) {
                    robot.keyPress(KeyEvent.VK_ENTER);
                    robot.keyRelease(KeyEvent.VK_ENTER);
                }

                break;

            case DB:
                switch (actionName) {
                case Write:
                    ResultSet rs = JDBCConnection.establishDBConn("", ctrlValue);
                    rs.next();
                    ctrlValue = String.valueOf(rs.getLong("COL_1"));
                    rs.close();
                    writeToExcel(ctrlValue, webElement, controlId, controlType, controlName, rowNo, colNo);
                    break;
                }
                break;
            //Kinjal 9/6/2015 Added for DB Approach   
            case DBV:
                switch (actionName) {
                case CP:
                    currentValue = webElement.getText();
                    if (StringUtils.isBlank(currentValue)) {
                        currentValue = webElement.getAttribute("value");
                    }
                    ctrlValue = JDBCConnection.getFirstColumnName(ctrlValue);
                    System.out.println("Database value fetched from DB is " + ctrlValue);
                    break;

                case V:

                    List<WebElement> rowElements = WebHelper.getElementsByType(controlId, controlName, "", "",
                            "");
                    if (rowElements != null) {
                        currentValue = Integer.toString(rowElements.size());
                    } else {
                        currentValue = "0";
                    }

                    ctrlValue = JDBCConnection.getFirstColumnName(ctrlValue);
                    break;
                }
                break;

            case WaitForEC:
                wait.until(CommonExpectedConditions.elementToBeClickable(webElement));
                break;

            case SikuliType:
                sikuliScreen.type(controlName, ctrlValue);
                break;

            case SikuliButton:
                sikuliScreen.click(controlName);
                System.out.println("Done");
                break;

            case Date:
                Calendar cal = new GregorianCalendar();
                int i = cal.get(Calendar.DAY_OF_MONTH);
                if (i >= 31) {
                    i = i - 10;
                }
                break;

            case FileUpload:
                webElement.sendKeys(ctrlValue);
                break;

            case ScrollTo:
                //Locatable element = (Locatable) webElement; //TM:04/03/2015-commented as incorrect
                //Point p= element.getCoordinates().onScreen();//TM:04/03/2015-commented as incorrect
                Point p = webElement.getLocation();//TM:04/03/2015-New correct code
                System.out.println("X,Y co-ordinates of textbox is:- " + p);//TM:04/03/2015-New correct code
                JavascriptExecutor js = (JavascriptExecutor) Automation.driver; //TM:04/03/2015-New correct code
                js.executeScript("window.scrollTo(" + p.getX() + "," + (p.getY() + 150) + ");");
                break;

            case SwitchContext:
                Thread.sleep(3000);
                Set<String> contexts = ((AppiumDriver) Automation.driver).getContextHandles();
                for (String s : contexts) {
                    System.out.println("Count of contexts : " + contexts.size());
                    System.out.println("Context Name : " + s);
                    if (s.contains(ctrlValue)) {
                        System.out.println("Mobile Web View found");
                        ((AppiumDriver) Automation.driver).context(s);
                        break;
                    }
                }
                Thread.sleep(2000);

                break;
            case SwipeDown:
                //((AppiumDriver)(Automation.driver)).swipe(0, 0, 0, 1500, 2000);
                ((AppiumDriver) (Automation.driver)).scrollTo(ctrlValue);
                break;

            case CaptureScreen:
                Date toDate = new Date();
                TransactionMapping.report.setFromDate(Automation.dtFormat.format(frmDate));
                TransactionMapping.report
                        .setStrIteration(Automation.configHashMap.get("CYCLENUMBER").toString());
                TransactionMapping.report.setStrTestcaseId(MainController.controllerTestCaseID.toString());
                TransactionMapping.report.setStrGroupName(MainController.controllerGroupName.toString());
                TransactionMapping.report
                        .setStrTrasactionType(MainController.controllerTransactionType.toString());
                TransactionMapping.report.setStrTestDescription(MainController.testDesciption);
                TransactionMapping.report.setStrMessage(
                        "Screenshot of Test Case Id:" + MainController.controllerTestCaseID.toString()
                                + " & Transaction Type:" + MainController.controllerTransactionType.toString());
                TransactionMapping.report.setToDate(Automation.dtFormat.format(toDate));
                saveScreenShot(TransactionMapping.report, logicalName);
                break;
            case WebService:
                switch (actionName) {
                case I:
                    if (logicalName.equalsIgnoreCase("WSDL_URL"))
                        wsdl_url = ctrlValue;
                    else if (logicalName.equalsIgnoreCase("REQUEST_URL"))
                        request_url = ctrlValue;
                    else if (logicalName.equalsIgnoreCase("REQUEST_XML"))
                        request_xml = ctrlValue;
                    break;

                case T:
                    WebService.callWebService();
                    break;

                case V:
                    currentValue = WebService.getXMLTagValue(controlName);
                    break;
                }
                break;

            case WebService_REST:
                switch (actionName) {
                case I:
                    if (logicalName.equalsIgnoreCase("REQUEST_URL"))
                        request_url = ctrlValue;
                    else if (logicalName.equalsIgnoreCase("REQUEST_XML")) {
                        request_xml = ctrlValue;
                    }
                    break;
                case Get:
                    WebService.callRESTWebService("Get", controlId);
                    break;

                case Post:
                    WebService.callRESTWebService("Post", controlId);
                    break;

                case V:
                    if (controlId.equalsIgnoreCase("JSON")) {
                        currentValue = WebService.getJSONTagValue(controlName);
                    } else {
                        currentValue = WebService.getXMLTagValue(controlName);
                    }
                    break;
                }
                break;

            case JSONResp:
                switch (actionName) {
                case I:
                    if (logicalName.equalsIgnoreCase("JSON_URL")) {
                        response_url = controlName;
                        response_fileName = ctrlValue;
                        WebService.downloadAndStoreJson(response_url, response_fileName);
                    }
                    break;
                }
                break;

            case DonutChart:
                switch (actionName) {
                case GV:

                    DonutChart donut = new DonutChart(Automation.driver, webElement);
                    WebVerification.verifyTabularData(testcaseID.toString(),
                            MainController.controllerTransactionType.toString(), donut.getDonutColumnNames(),
                            donut.getDonutChartData());
                    break;

                case LV:

                    DonutChart donutLegend = new DonutChart(Automation.driver, webElement);
                    WebVerification.verifyTabularData(testcaseID.toString(),
                            MainController.controllerTransactionType.toString(),
                            donutLegend.getDonutLegendColumnNames(), donutLegend.getDonutLegendData());
                    break;
                }
                break;

            case BarChart:
                switch (actionName) {
                case GV:

                    String[] series = ctrlValue.split("!");
                    List<String> seriesList = Arrays.asList(series);
                    BarChart barChart = new BarChart(Automation.driver, webElement);
                    WebVerification.verifyTabularData(testcaseID.toString(),
                            MainController.controllerTransactionType.toString(), barChart.getColumnNames(),
                            barChart.getChartData(seriesList));
                    break;

                case LV:

                    BarChart barchartLegend = new BarChart(Automation.driver, webElement);
                    WebVerification.verifyTabularData(testcaseID.toString(),
                            MainController.controllerTransactionType.toString(),
                            barchartLegend.getLegendColumnNames(), barchartLegend.getLegendData());
                    break;
                }
                break;
            case BasicLineChart:
                switch (actionName) {
                case GV:

                    BasicLineChart lineChart = new BasicLineChart(Automation.driver, webElement);
                    WebVerification.verifyTabularData(testcaseID.toString(),
                            MainController.controllerTransactionType.toString(), lineChart.getColumnNames(),
                            lineChart.getChartData());
                    break;

                case LV:

                    BasicLineChart linechartLegend = new BasicLineChart(Automation.driver, webElement);
                    WebVerification.verifyTabularData(testcaseID.toString(),
                            MainController.controllerTransactionType.toString(),
                            linechartLegend.getLegendColumnNames(), linechartLegend.getLegendData());
                    break;
                }
                break;
            default:
                System.out.println("U r in Default");
                break;
            }

        } catch (WebDriverException we) {
            throw new Exception("Error Occurred from Do Action " + controlName + we.getMessage());
        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }
    //TM-02/02/2015: Radio button found ("F") & AJAX control ("VA")
    if ((action.toString().equalsIgnoreCase("V") || action.toString().equalsIgnoreCase("CP")
            || action.toString().equalsIgnoreCase("F") || action.toString().equalsIgnoreCase("VA"))
            && !ctrlValue.equalsIgnoreCase("")) {
        if (Results == true) {
            TransactionMapping.report = WriteToDetailResults(ctrlValue, currentValue, logicalName);
        }
    }

    return currentValue;

}