Project

General

Profile

Download (1.88 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2012 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.dataportal.elements;
11

    
12
import org.openqa.selenium.By;
13
import org.openqa.selenium.Dimension;
14
import org.openqa.selenium.Point;
15
import org.openqa.selenium.WebElement;
16
import org.openqa.selenium.remote.RemoteWebElement;
17

    
18
import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl;
19

    
20
/**
21
 *
22
 * <div class="cdm_taxontree_scroller_xy">
23
 * <ul class="cdm_taxontree"><li
24
 *
25
 * @author andreas
26
 * @date May 21, 2012
27
 *
28
 */
29
public class ClassificationTreeBlock extends DrupalBlock {
30

    
31
    private ClassificationTreeElement focusedElement;
32

    
33
    private RemoteWebElement viewPortElement;
34

    
35
    public ClassificationTreeElement getFocusedElement(){
36
        return focusedElement;
37
    }
38

    
39
    public ClassificationTreeBlock(WebElement element) {
40
        super(element);
41

    
42
        focusedElement = new ClassificationTreeElement(element.findElement(By.className("focused")));
43
        viewPortElement = (RemoteWebElement)element.findElement(By.className("cdm_taxontree_scroller_xy"));
44
    }
45

    
46
    public Point positionInViewPort(ClassificationTreeElement element){
47
        Point elementLocation = ((RemoteWebElement)element.getElement()).getLocationOnScreenOnceScrolledIntoView();
48
        Point viewPortLocation = viewPortElement.getLocationOnScreenOnceScrolledIntoView();
49
        return new Point(elementLocation.x - viewPortLocation.x, elementLocation.y - viewPortLocation.y);
50
    }
51

    
52
    public boolean isVisibleInViewPort(ClassificationTreeElement element){
53
        Point elementOffset = positionInViewPort(element);
54
        Dimension viewPortDimension = viewPortElement.getSize();
55
        return elementOffset.y < viewPortDimension.height;
56
    }
57

    
58

    
59
}
(2-2/15)