1
|
package eu.dnetlib.client.widgets;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
4
|
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
|
5
|
import com.github.gwtbootstrap.client.ui.constants.AlternateSize;
|
6
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
7
|
import com.google.gwt.event.dom.client.ClickEvent;
|
8
|
import com.google.gwt.event.dom.client.ClickHandler;
|
9
|
import com.google.gwt.user.client.ui.FlowPanel;
|
10
|
import com.google.gwt.user.client.ui.IsWidget;
|
11
|
import com.google.gwt.user.client.ui.Widget;
|
12
|
import eu.dnetlib.goldoa.domain.PublicationIdentifier;
|
13
|
|
14
|
/**
|
15
|
* Created by stefania on 3/11/15.
|
16
|
*/
|
17
|
public class IdentifierInfoWidget implements IsWidget {
|
18
|
|
19
|
private FlowPanel identifierInfoPanel = new FlowPanel();
|
20
|
|
21
|
private ListBox identifierTypes = new ListBox();
|
22
|
private TextBox identifierValue = new TextBox();
|
23
|
private IconAnchor deleteIcon = new IconAnchor();
|
24
|
|
25
|
private DeleteIdentifierListener deleteIdentifierListener;
|
26
|
|
27
|
public IdentifierInfoWidget() {
|
28
|
|
29
|
identifierInfoPanel.addStyleName("identifierInfo");
|
30
|
|
31
|
identifierTypes.addItem("Select type...", "noneSelected");
|
32
|
identifierTypes.addItem("PMC - PubMed", "pmc");
|
33
|
identifierTypes.setAlternateSize(AlternateSize.LARGE);
|
34
|
identifierTypes.addStyleName("inlineBlock");
|
35
|
|
36
|
identifierValue.setAlternateSize(AlternateSize.LARGE);
|
37
|
identifierValue.setPlaceholder(" value");
|
38
|
identifierValue.addStyleName("inlineBlock");
|
39
|
|
40
|
deleteIcon.setIcon(IconType.REMOVE);
|
41
|
deleteIcon.addStyleName("inlineBlock");
|
42
|
deleteIcon.addStyleName("deleteIcon");
|
43
|
deleteIcon.addClickHandler(new ClickHandler() {
|
44
|
@Override
|
45
|
public void onClick(ClickEvent clickEvent) {
|
46
|
|
47
|
if(deleteIdentifierListener!=null)
|
48
|
deleteIdentifierListener.deleteIdentifier();
|
49
|
}
|
50
|
});
|
51
|
|
52
|
identifierInfoPanel.add(identifierTypes);
|
53
|
identifierInfoPanel.add(identifierValue);
|
54
|
identifierInfoPanel.add(deleteIcon);
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
public Widget asWidget() {
|
59
|
return identifierInfoPanel;
|
60
|
}
|
61
|
|
62
|
public interface DeleteIdentifierListener {
|
63
|
public void deleteIdentifier();
|
64
|
}
|
65
|
|
66
|
public void setDeleteIdentifierListener(DeleteIdentifierListener deleteIdentifierListener) {
|
67
|
this.deleteIdentifierListener = deleteIdentifierListener;
|
68
|
}
|
69
|
|
70
|
public boolean isComplete() {
|
71
|
|
72
|
if(!identifierTypes.getValue().equals("noneSelected") && !identifierValue.getValue().trim().equals(""))
|
73
|
return true;
|
74
|
|
75
|
return false;
|
76
|
}
|
77
|
|
78
|
public PublicationIdentifier getPublicationIdentifier() {
|
79
|
|
80
|
if(isComplete()) {
|
81
|
|
82
|
PublicationIdentifier publicationIdentifier = new PublicationIdentifier();
|
83
|
publicationIdentifier.setType(identifierTypes.getValue());
|
84
|
publicationIdentifier.setValue(identifierValue.getValue().trim());
|
85
|
return publicationIdentifier;
|
86
|
}
|
87
|
|
88
|
return null;
|
89
|
}
|
90
|
|
91
|
public void loadPublicationIdentifier(PublicationIdentifier publicationIdentifier) {
|
92
|
|
93
|
if(publicationIdentifier.getType().equals("pmc")) {
|
94
|
identifierTypes.setSelectedValue(publicationIdentifier.getType());
|
95
|
identifierValue.setValue(publicationIdentifier.getValue());
|
96
|
}
|
97
|
}
|
98
|
}
|