package com.sdl.selenium.web.form;

import com.sdl.selenium.web.SearchType;
import com.sdl.selenium.web.WebDriverConfig;
import com.sdl.selenium.web.WebLocator;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

import java.util.ArrayList;
import java.util.List;

public class SimpleMultipleSelect extends SimpleComboBox {
    private static final Logger logger = Logger.getLogger(SimpleMultipleSelect.class);

    public SimpleMultipleSelect() {
        setClassName("SimpleMultipleSelect");
    }

    public SimpleMultipleSelect(WebLocator container) {
        this();
        setContainer(container);
    }

    public SimpleMultipleSelect(WebLocator container, String label) {
        this(container);
        setLabel(label);
    }

    public boolean selectRows(String... values) {
        boolean select = false;
        if (ready()) {
//            sendKeys(Keys.CONTROL);
            for (String value : values) {
                WebLocator el = new WebLocator(this).setText(value, SearchType.EQUALS);
                select = el.click();
                if (!select) {
                    return false;
                }
            }
        }
        return select;
    }

    public List<String> getValues() {
        List<WebElement> elements = WebDriverConfig.getDriver().findElements(By.xpath(new WebLocator(this).getPath()));
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < elements.size(); i++) {
            String text = elements.get(i).getText();
            logger.debug(text);
            list.add(text);
        }
        return list;
    }
}

@@ -1283,43 +1283,237 @@
     
-public List%3CString%3E getValues() %7B%0D%0A
+/**%0D%0A     *%0D%0A     * @return if return null, then component is not ready%0D%0A     */%0D%0A    public List%3CString%3E getValues() %7B%0D%0A        List%3CString%3E list = null;%0D%0A        if (ready()) %7B%0D%0A            list = new ArrayList%3CString%3E();%0D%0A    
     
@@ -1637,58 +1637,8 @@
     
-    List%3CString%3E list = new ArrayList%3CString%3E();%0D%0A
     
@@ -1698,16 +1698,20 @@
         
+   
+ 
 String t
@@ -1756,16 +1756,20 @@
         
+    
 logger.d
@@ -1789,24 +1789,28 @@
             
+   
+ 
 list.add(tex
@@ -1806,32 +1806,47 @@
 ist.add(text);%0D%0A
+            %7D%0D%0A
         %7D%0D%0A     

add ready before getValues for SimpleMultipleSelect