Example usage for java.awt.datatransfer StringSelection StringSelection

List of usage examples for java.awt.datatransfer StringSelection StringSelection

Introduction

In this page you can find the example usage for java.awt.datatransfer StringSelection StringSelection.

Prototype

public StringSelection(String data) 

Source Link

Document

Creates a Transferable capable of transferring the specified String .

Usage

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

private void copyCiteKey() {
    List<BibEntry> bes = mainTable.getSelectedEntries();
    if (!bes.isEmpty()) {
        storeCurrentEdit();//from  ww w.  ja  va  2 s. com
        List<String> keys = new ArrayList<>(bes.size());
        // Collect all non-null keys.
        for (BibEntry be : bes) {
            if (be.getCiteKey() != null) {
                keys.add(be.getCiteKey());
            }
        }
        if (keys.isEmpty()) {
            output(Localization.lang("None of the selected entries have BibTeX keys."));
            return;
        }

        String sb = String.join(",", keys);
        StringSelection ss = new StringSelection("\\cite{" + sb + '}');
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this);

        if (keys.size() == bes.size()) {
            // All entries had keys.
            output(bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key") + '.');
        } else {
            output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.",
                    Integer.toString(bes.size() - keys.size()), Integer.toString(bes.size())));
        }
    }
}

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

private void copyKey() {
    List<BibEntry> bes = mainTable.getSelectedEntries();
    if (!bes.isEmpty()) {
        storeCurrentEdit();/*ww w. jav a2  s .  c o  m*/
        List<String> keys = new ArrayList<>(bes.size());
        // Collect all non-null keys.
        for (BibEntry be : bes) {
            if (be.getCiteKey() != null) {
                keys.add(be.getCiteKey());
            }
        }
        if (keys.isEmpty()) {
            output(Localization.lang("None of the selected entries have BibTeX keys."));
            return;
        }

        StringSelection ss = new StringSelection(String.join(",", keys));
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this);

        if (keys.size() == bes.size()) {
            // All entries had keys.
            output((bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key")) + '.');
        } else {
            output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.",
                    Integer.toString(bes.size() - keys.size()), Integer.toString(bes.size())));
        }
    }
}

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

private void putStringToClipboard(String s) {
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(new StringSelection(s), this);
}

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

private void copyKeyAndTitle() {
    List<BibEntry> bes = mainTable.getSelectedEntries();
    if (!bes.isEmpty()) {
        storeCurrentEdit();/*from   w w w  . j  ava  2 s  . c o  m*/

        // OK: in a future version, this string should be configurable to allow arbitrary exports
        StringReader sr = new StringReader(
                "\\bibtexkey - \\begin{title}\\format[RemoveBrackets]{\\title}\\end{title}\n");
        Layout layout;
        try {
            layout = new LayoutHelper(sr, Globals.prefs, Globals.journalAbbreviationLoader).getLayoutFromText();
        } catch (IOException e) {
            LOGGER.info("Could not get layout", e);
            return;
        }

        StringBuilder sb = new StringBuilder();

        int copied = 0;
        // Collect all non-null keys.
        for (BibEntry be : bes) {
            if (be.getCiteKey() != null) {
                copied++;
                sb.append(layout.doLayout(be, database));
            }
        }

        if (copied == 0) {
            output(Localization.lang("None of the selected entries have BibTeX keys."));
            return;
        }

        final StringSelection ss = new StringSelection(sb.toString());
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, BasePanel.this);

        if (copied == bes.size()) {
            // All entries had keys.
            output((bes.size() > 1 ? Localization.lang("Copied keys") : Localization.lang("Copied key")) + '.');
        } else {
            output(Localization.lang("Warning: %0 out of %1 entries have undefined BibTeX key.",
                    Integer.toString(bes.size() - copied), Integer.toString(bes.size())));
        }
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

@Override
public void typeUsingRobot(String locator, String value) {
    WebElement we = findElement(locator);
    // try to click otherwise ignore if it fails
    try {/*from  w  ww.ja  va2  s. c o  m*/
        we.click();
    } catch (Exception e) {
    }
    ClipboardOwner clipboardOwner = new ClipboardOwner() {
        @Override
        public void lostOwnership(Clipboard clipboard, Transferable contents) {
        }
    };
    Robot robot;
    try {
        robot = new Robot();
        try {
            we.sendKeys(value);
        } catch (Exception e) {
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            StringSelection stringSelection = new StringSelection(value);
            clipboard.setContents(stringSelection, clipboardOwner);
            robot.keyPress(KeyEvent.VK_CONTROL);
            robot.keyPress(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_V);
            robot.keyRelease(KeyEvent.VK_CONTROL);
        }
    } catch (AWTException e1) {
        e1.printStackTrace();
    }
}

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

private void miCopyToExcelActionPerformed(ActionEvent e) {
    StringBuilder sb = new StringBuilder();

    if (listsPopupMenu.getInvoker() == vechicleTypesList) {
        for (VechicleType vechicleType : vechicleTypes) {
            sb.append(String.format("%s\n", vechicleType.getName()));
        }/*from w ww .ja  va 2 s .  co  m*/
    }

    if (listsPopupMenu.getInvoker() == manufactorsList) {
        for (Manufactor manufactor : manufactors) {
            sb.append(String.format("%s\n", manufactor.getName()));
        }
    }

    if (listsPopupMenu.getInvoker() == seriesList) {
        for (Seria seria : series) {
            sb.append(String.format("%s\n", seria.getName()));
        }
    }

    if (listsPopupMenu.getInvoker() == motorsTable) {
        SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");

        for (Motor motor : motors) {
            String dateF = motor.getDateF() != null ? sdf.format(motor.getDateF()) : "";
            String dateT = motor.getDateT() != null ? sdf.format(motor.getDateT()) : "";

            sb.append(String.format("%s\t%s\t%s\t%s\t%s\t%s\n", motor.getName(), motor.getEngine(),
                    motor.getKw(), motor.getHp(), dateF, dateT));
        }
    }

    if (listsPopupMenu.getInvoker() == filtersTable) {
        for (Filter filter : filters) {
            sb.append(String.format("%s\t%s\n", filter.getName(),
                    filterTypeResolver.resolve(filter.getFilterTypeCode())));
        }
    }

    if (listsPopupMenu.getInvoker() == allFiltersTable) {
        for (Filter filter : allFilters) {
            sb.append(String.format("%s\t%s\n", filter.getName(),
                    filterTypeResolver.resolve(filter.getFilterTypeCode())));
        }
    }

    if (!StringUtils.isBlank(sb.toString())) {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(new StringSelection(sb.toString()), this);

        String text = "  ?   .    ?  Microsoft Excel.";
        UIUtils.info(text);
    }
}

From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java

private void copyStatsToClipboard(String pType, String pStatText) {
    if (pStatText == null) {
        JOptionPaneHelper.showInformationBox(DSWorkbenchStatsFrame.this,
                "Bitte erstelle erst eine Auswertung bevor du die Daten kopierst", "Information");
        return;/* w  w  w .java2  s  .c  o  m*/
    }
    try {
        Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(pStatText), null);
        JOptionPaneHelper.showInformationBox(DSWorkbenchStatsFrame.this,
                "Daten der Auswertung '" + pType + "' in Zwischenablage kopiert", "Information");
    } catch (HeadlessException he) {
        JOptionPaneHelper.showErrorBox(DSWorkbenchStatsFrame.this, "Fehler beim Kopieren in die Zwischenablage",
                "Fehler");
    }
}

From source file:ca.phon.ipamap.IpaMap.java

/**
 * Copy text to system clipboard/*from   w  ww. j  ava 2s . c om*/
 */
public void onCopyToClipboard(PhonActionEvent pae) {
    String txt = pae.getData().toString();
    Transferable toClipboard = new StringSelection(txt);
    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(toClipboard, this);
}

From source file:org.isatools.isacreator.spreadsheet.SpreadsheetFunctions.java

protected void putStringOnClipboard(String toPlace) {
    StringSelection stsel = new StringSelection(toPlace);
    spreadsheet.system.setContents(stsel, stsel);
}

From source file:SwiftSeleniumWeb.WebHelper.java

/**
 * This class performs the reuired action on an element
 * //from   w  w w  .jav a  2  s. co  m
 * @param imageType
 * @param controlType
 * @param controlId
 * @param controlName
 * @param ctrlValue
 * @param logicalName
 * @param action
 * @param webElement
 * @param Results
 * @param strucSheet
 * @param valSheet
 * @param rowIndex
 * @param rowcount
 * @param rowNo
 * @param colNo
 * @return
 * @throws Exception
 */
@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;
    String uniqueNumber = "";
    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("")) {
        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 = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                        webElement.clear();
                        webElement.sendKeys(ctrlValue);
                    } 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 = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                        webElement.click();
                    }
                    break;
                case NC:
                    webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                    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:
                    boolean textPresent = false;
                    textPresent = webElement.getText().contains(ctrlValue);
                    if (textPresent == false)
                        currentValue = webElement.getText();
                    else
                        currentValue = ctrlValue;
                    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 = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                        webElement.click();
                    }
                    break;
                case NC:
                    webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                    webElement.click();
                    break;
                }
                break;

            case Radio:
                switch (actionName) {
                case I:
                    if (ctrlValue.equalsIgnoreCase("Y") || ctrlValue.equalsIgnoreCase("Yes")) {
                        webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                        if (!webElement.isSelected()) {
                            webElement.click();
                        }
                    }
                    break;
                case NC:
                    webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                    if (!webElement.isSelected()) {
                        webElement.click();
                    }
                    break;
                case V:
                    if (webElement.isSelected()) {
                        currentValue = webElement.getAttribute(controlName.toString());
                    }
                    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 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:
                    webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                    ExpectedCondition<Boolean> isTextPresent = CommonExpectedConditions
                            .textToBePresentInElement(webElement, ctrlValue);
                    if (isTextPresent != null) {
                        if (webElement != null) {
                            new Select(webElement).selectByVisibleText(ctrlValue);
                        }
                    }
                    break;
                case V:
                    currentValue = new Select(webElement).getFirstSelectedOption().getText();
                    if (currentValue.isEmpty()) {
                        currentValue = new Select(webElement).getFirstSelectedOption().getAttribute("value");
                    }
                    break;
                }
                break;

            case IFrame:
                Automation.driver = Automation.driver.switchTo().frame(controlName);
                break;

            case Browser:
                //Thread.sleep(3000); //DS:Check if required
                Set<String> handlers = Automation.driver.getWindowHandles();
                handlers = Automation.driver.getWindowHandles();
                for (String handler : handlers) {
                    Automation.driver = Automation.driver.switchTo().window(handler);
                    if (Automation.driver.getTitle().equalsIgnoreCase(controlName)) {
                        System.out.println("Focus on window with title: " + Automation.driver.getTitle());
                        break;
                    }
                }
                break;

            case URL:
                switch (actionName) {
                case I:
                    Automation.driver.navigate().to(ctrlValue);
                    break;
                case NC:
                    break;
                }
                break;

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

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

            case WebImage:
                webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                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:
                webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                Actions builderClick = new Actions(Automation.driver);
                Action clickAction = builderClick.moveToElement(webElement).clickAndHold().release().build();
                clickAction.perform();
                break;

            case ActionDoubleClick:
                webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                Actions builderdoubleClick = new Actions(Automation.driver);
                Action doubleClickAction = builderdoubleClick.moveToElement(webElement).click().build();
                doubleClickAction.perform();
                doubleClickAction.perform();
                break;

            case ActionClickandEsc:
                webElement = wait.until(ExpectedConditions.elementToBeClickable(webElement));
                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 CalendarNew:
                Boolean 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(2000);
                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')]")));
                //following is to click the title once again to reach the year page
                Automation.driver
                        .findElement(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";

                //each of the following line selects the year, month and date
                wait.until(ExpectedConditions.elementToBeClickable(
                        By.xpath(pathToVisibleCalendar + "/div[contains(text()," + yearEBP + ")]"))).click();
                wait.until(ExpectedConditions.elementToBeClickable(By.xpath(pathToVisibleCalendar
                        + "/div[@class='ajax__calendar_month'][contains(text(),'" + monthNumEBP + "')]")))
                        .click();
                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().equalsIgnoreCase(controlName)) {
                            Automation.driver.close();
                        }
                    }
                    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;
                }
                break;

            case Robot:
                if (controlName.equalsIgnoreCase("SetFilePath")) {
                    StringSelection stringSelection = new StringSelection(ctrlValue);
                    Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);
                    robot.delay(1000);
                    robot.keyPress(KeyEvent.VK_CONTROL);
                    robot.keyPress(KeyEvent.VK_V);
                    robot.keyRelease(KeyEvent.VK_V);
                    robot.keyRelease(KeyEvent.VK_CONTROL);

                } 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 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;
                Point p = element.getCoordinates().onScreen();
                JavascriptExecutor js = (JavascriptExecutor) Automation.driver;
                js.executeScript("window.scrollTo(" + p.getX() + "," + (p.getY() + 150) + ");");
                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());
        }
    }

    if (action.toString().equalsIgnoreCase("V") && !ctrlValue.equalsIgnoreCase("")) {
        if (Results == true) {
            SwiftSeleniumWeb.WebDriver.report = WriteToDetailResults(ctrlValue, currentValue, logicalName);
        }
    }

    return currentValue;

}