Project

General

Profile

1
package eu.dnetlib.client.fundingrequest.stepinfo;
2

    
3
import com.google.gwt.event.dom.client.MouseOverEvent;
4
import com.google.gwt.event.dom.client.MouseOverHandler;
5
import com.google.gwt.user.client.ui.HTML;
6
import com.google.gwt.user.client.ui.IsWidget;
7
import com.google.gwt.user.client.ui.Widget;
8
import eu.dnetlib.goldoa.domain.Affiliation;
9
import eu.dnetlib.goldoa.domain.Person;
10

    
11
/**
12
 * Created by stefania on 4/27/15.
13
 */
14
public class ResearcherChronologyInfo implements IsWidget {
15

    
16
    private HTML researcherInfo = new HTML();
17
    private String researcherInfoContents = "";
18

    
19
    public ResearcherChronologyInfo(Person researcher) {
20

    
21
        researcherInfoContents = "<div>";
22

    
23
        researcherInfoContents += "<dl><dt class=\"chronologySubTitle\">RESEARCHER</dt></dl>";
24

    
25
        researcherInfoContents += "<dl><dd>" + researcher.getName()  + " ";
26
        if(researcher.getInitials()!=null && !researcher.getInitials().trim().equals(""))
27
            researcherInfoContents += researcher.getInitials() + ". ";
28
        researcherInfoContents += researcher.getLastname() + "</dd></dl>";
29

    
30
        researcherInfoContents += "</div>";
31
        researcherInfo.setHTML(researcherInfoContents);
32

    
33
        addMouseOverInfo(researcher);
34
    }
35

    
36
    @Override
37
    public Widget asWidget() {
38
        return researcherInfo;
39
    }
40

    
41
    public void addStyleName(String styleName) {
42
        researcherInfo.addStyleName(styleName);
43
    }
44

    
45
    private void addMouseOverInfo(final Person researcher) {
46

    
47
        researcherInfo.addMouseOverHandler(new MouseOverHandler() {
48
            @Override
49
            public void onMouseOver(MouseOverEvent mouseOverEvent) {
50

    
51
                String tooltipText = "";
52

    
53
                tooltipText += researcher.getName()  + " ";
54
                if(researcher.getInitials()!=null && !researcher.getInitials().trim().equals(""))
55
                    tooltipText += researcher.getInitials() + ". ";
56
                tooltipText += researcher.getLastname();
57
                tooltipText += "\n";
58

    
59
                tooltipText += researcher.getEmail() + "\n";
60

    
61
                if(researcher.getTelephone()!=null && !researcher.getTelephone().trim().equals(""))
62
                    tooltipText += researcher.getTelephone() + "\n";
63

    
64
                if(researcher.getOrcidId()!=null && !researcher.getOrcidId().trim().equals(""))
65
                    tooltipText += researcher.getOrcidId() + "\n";
66

    
67
                if(!researcher.getAffiliations().isEmpty()) {
68

    
69
                    for(Affiliation affiliation : researcher.getAffiliations()) {
70
                        tooltipText += affiliation.getOrganization().getName();
71
                        if(affiliation.getDepartment()!=null && !affiliation.getDepartment().equals(""))
72
                            tooltipText += " - " + affiliation.getDepartment();
73
                        tooltipText += "\n";
74
                    }
75
                }
76

    
77
                researcherInfo.setTitle(tooltipText);
78
            }
79
        });
80
    }
81
}
(24-24/27)