Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Feb 10, 2014
1 parent 54a3d81 commit f0d4c54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 93 deletions.
Expand Up @@ -20,10 +20,9 @@
*/
package org.zanata.page.webtrans;

import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Predicate;
import lombok.extern.slf4j.Slf4j;
import java.util.Collections;
import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand All @@ -36,9 +35,6 @@
import com.google.common.base.Predicate;
import lombok.extern.slf4j.Slf4j;

import java.util.Collections;
import java.util.List;

/**
* @author Patrick Huang <a
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
Expand Down Expand Up @@ -180,87 +176,6 @@ public String getBasicTranslationTargetAtRowIndex(final int rowIndex) {
return getContentAtRowIndex(rowIndex, TARGET_ID_FMT, SINGULAR);
}

/**
* Get content from a target using the non-CodeMirror configuration
* @param rowIndex
* @return row target content
*/
private String getContentAtRowIndex(final long rowIndex,
final String idFormat,
final int pluralIndex) {
return waitForTenSec().until(new Function<WebDriver, String>() {
@Override
public String apply(WebDriver input) {
return input.findElement(By.id(String.format(idFormat, rowIndex, pluralIndex))).getAttribute("value");
}
});
}

/**
* Translate a target using the non-CodeMirror field
* @param rowIndex
* @param text
* @return updated EditorPage
*/
public EditorPage translateTargetAtRowIndex(final int rowIndex, String text) {
setTargetContent(rowIndex, text, TARGET_ID_FMT, SINGULAR);
return new EditorPage(getDriver());
}

private void setTargetContent(final long rowIndex, final String text,
final String idFormat, final int pluralIndex) {
WebElement we = waitForTenSec().until(new Function<WebDriver, WebElement>() {
@Override
public WebElement apply(WebDriver input) {
return input.findElement(
By.id(String.format(idFormat, rowIndex, pluralIndex)));
}
});
we.click();
we.sendKeys(text);
}

/**
* Press the Approve button for the currently selected translation row
* @return new Editor page object
*/
public EditorPage approveSelectedTranslation() {
WebElement approve = waitForTenSec().until(new Function<WebDriver, WebElement>() {
@Override
public WebElement apply(WebDriver input) {
return input.findElement(By.className("selected"))
.findElement(By.className("icon-install"));
}
});
approve.click();
return new EditorPage(getDriver());
}

public EditorPage setSyntaxHighlighting(boolean option) {
openConfigurationPanel();
if (getDriver().findElement(By.id("gwt-uid-144")).isSelected() != option) {
getDriver().findElement(By.id("gwt-uid-144")).click();
}
return new EditorPage(getDriver());
}

private Boolean openConfigurationPanel() {
getDriver().findElement(By.className("icon-cog")).click();
return waitForTenSec().until(new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver input) {
return input.findElement(
By.className("gwt-TabLayoutPanelContentContainer"))
.isDisplayed();
}
});

}

public String getBasicTranslationTargetAtRowIndex(final int rowIndex) {
return getContentAtRowIndex(rowIndex, TARGET_ID_FMT, SINGULAR);
}

/**
* Get content from a target using the non-CodeMirror configuration
* @param rowIndex
Expand All @@ -272,7 +187,9 @@ private String getContentAtRowIndex(final long rowIndex,
return waitForTenSec().until(new Function<WebDriver, String>() {
@Override
public String apply(WebDriver input) {
return input.findElement(By.id(String.format(idFormat, rowIndex, pluralIndex))).getAttribute("value");
return input.findElement(
By.id(String.format(idFormat, rowIndex, pluralIndex)))
.getAttribute("value");
}
});
}
Expand Down
Expand Up @@ -20,9 +20,11 @@
*/
package org.zanata.util;

import org.apache.commons.io.FileUtils;

import java.io.*;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
import java.nio.charset.Charset;
import java.util.List;
import javax.xml.bind.JAXBContext;
Expand All @@ -33,8 +35,8 @@
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.io.FileUtils;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import lombok.Setter;

/**
Expand Down

0 comments on commit f0d4c54

Please sign in to comment.