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.Identifier;
|
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("arXiv", "arxiv");
|
33
|
identifierTypes.addItem("handle", "handle");
|
34
|
identifierTypes.addItem("PMC", "pmc");
|
35
|
identifierTypes.addItem("PubMed", "pubMed");
|
36
|
identifierTypes.setAlternateSize(AlternateSize.LARGE);
|
37
|
identifierTypes.addStyleName("inlineBlock");
|
38
|
|
39
|
identifierValue.setAlternateSize(AlternateSize.LARGE);
|
40
|
identifierValue.setPlaceholder(" value");
|
41
|
identifierValue.addStyleName("inlineBlock");
|
42
|
|
43
|
deleteIcon.setIcon(IconType.REMOVE);
|
44
|
deleteIcon.addStyleName("inlineBlock");
|
45
|
deleteIcon.addStyleName("deleteIcon");
|
46
|
deleteIcon.addClickHandler(new ClickHandler() {
|
47
|
@Override
|
48
|
public void onClick(ClickEvent clickEvent) {
|
49
|
|
50
|
if(deleteIdentifierListener!=null)
|
51
|
deleteIdentifierListener.deleteIdentifier();
|
52
|
}
|
53
|
});
|
54
|
|
55
|
identifierInfoPanel.add(identifierTypes);
|
56
|
identifierInfoPanel.add(identifierValue);
|
57
|
identifierInfoPanel.add(deleteIcon);
|
58
|
}
|
59
|
|
60
|
@Override
|
61
|
public Widget asWidget() {
|
62
|
return identifierInfoPanel;
|
63
|
}
|
64
|
|
65
|
public interface DeleteIdentifierListener {
|
66
|
public void deleteIdentifier();
|
67
|
}
|
68
|
|
69
|
public void setDeleteIdentifierListener(DeleteIdentifierListener deleteIdentifierListener) {
|
70
|
this.deleteIdentifierListener = deleteIdentifierListener;
|
71
|
}
|
72
|
|
73
|
public boolean isComplete() {
|
74
|
|
75
|
if(!identifierTypes.getValue().equals("noneSelected") && !identifierValue.getValue().trim().equals(""))
|
76
|
return true;
|
77
|
|
78
|
return false;
|
79
|
}
|
80
|
|
81
|
public Identifier getPublicationIdentifier() {
|
82
|
|
83
|
if(isComplete()) {
|
84
|
|
85
|
Identifier publicationIdentifier = new Identifier();
|
86
|
publicationIdentifier.setType(identifierTypes.getValue());
|
87
|
publicationIdentifier.setValue(identifierValue.getValue().trim());
|
88
|
return publicationIdentifier;
|
89
|
}
|
90
|
|
91
|
return null;
|
92
|
}
|
93
|
|
94
|
public void loadPublicationIdentifier(Identifier publicationIdentifier) {
|
95
|
|
96
|
if(publicationIdentifier.getType().equals("pmc") || publicationIdentifier.getType().equals("pubMed")
|
97
|
|| publicationIdentifier.getType().equals("arxiv") || publicationIdentifier.getType().equals("handle")) {
|
98
|
identifierTypes.setSelectedValue(publicationIdentifier.getType());
|
99
|
identifierValue.setValue(publicationIdentifier.getValue());
|
100
|
}
|
101
|
}
|
102
|
}
|