1
|
/**
|
2
|
* Copyright (C) 2012 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.dataportal.elements;
|
10
|
|
11
|
import org.openqa.selenium.By;
|
12
|
import org.openqa.selenium.Dimension;
|
13
|
import org.openqa.selenium.Point;
|
14
|
import org.openqa.selenium.WebElement;
|
15
|
import org.openqa.selenium.remote.RemoteWebElement;
|
16
|
|
17
|
/**
|
18
|
*
|
19
|
* <div class="cdm_taxontree_scroller_xy">
|
20
|
* <ul class="cdm_taxontree"><li
|
21
|
*
|
22
|
* @author andreas
|
23
|
* @since May 21, 2012
|
24
|
*
|
25
|
*/
|
26
|
public class ClassificationTreeBlock extends DrupalBlock {
|
27
|
|
28
|
private final ClassificationTreeElement focusedElement;
|
29
|
|
30
|
private final RemoteWebElement viewPortElement;
|
31
|
|
32
|
public ClassificationTreeElement getFocusedElement(){
|
33
|
return focusedElement;
|
34
|
}
|
35
|
|
36
|
public ClassificationTreeBlock(WebElement element) {
|
37
|
super(element);
|
38
|
|
39
|
focusedElement = new ClassificationTreeElement(element.findElement(By.className("focused")));
|
40
|
viewPortElement = (RemoteWebElement)element.findElement(By.className("cdm_taxontree_scroller_xy"));
|
41
|
}
|
42
|
|
43
|
public boolean isVisibleInViewPort(ClassificationTreeElement element){
|
44
|
Point elementOffset = ((RemoteWebElement)element.getElement()).getCoordinates().inViewPort();
|
45
|
Point viewPortElementOffset = viewPortElement.getCoordinates().inViewPort();
|
46
|
Point elementRelativeToViewPort = elementOffset.moveBy(-1 * viewPortElementOffset.x, -1 * viewPortElementOffset.y);
|
47
|
Dimension viewPortDimension = viewPortElement.getSize();
|
48
|
return elementRelativeToViewPort.y < viewPortDimension.height;
|
49
|
}
|
50
|
|
51
|
|
52
|
}
|