1 |
35292
|
stefania.m
|
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 |
45972
|
panagiotis
|
import eu.dnetlib.goldoa.domain.Identifier;
|
13 |
35292
|
stefania.m
|
|
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 |
37543
|
stefania.m
|
identifierTypes.addItem("arXiv", "arxiv");
|
33 |
|
|
identifierTypes.addItem("handle", "handle");
|
34 |
|
|
identifierTypes.addItem("PMC", "pmc");
|
35 |
|
|
identifierTypes.addItem("PubMed", "pubMed");
|
36 |
35292
|
stefania.m
|
identifierTypes.setAlternateSize(AlternateSize.LARGE);
|
37 |
|
|
identifierTypes.addStyleName("inlineBlock");
|
38 |
|
|
|
39 |
35700
|
stefania.m
|
identifierValue.setAlternateSize(AlternateSize.LARGE);
|
40 |
35292
|
stefania.m
|
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 |
35483
|
stefania.m
|
|
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 |
45972
|
panagiotis
|
public Identifier getPublicationIdentifier() {
|
82 |
35483
|
stefania.m
|
|
83 |
|
|
if(isComplete()) {
|
84 |
|
|
|
85 |
45972
|
panagiotis
|
Identifier publicationIdentifier = new Identifier();
|
86 |
35483
|
stefania.m
|
publicationIdentifier.setType(identifierTypes.getValue());
|
87 |
|
|
publicationIdentifier.setValue(identifierValue.getValue().trim());
|
88 |
|
|
return publicationIdentifier;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
return null;
|
92 |
|
|
}
|
93 |
35519
|
stefania.m
|
|
94 |
45972
|
panagiotis
|
public void loadPublicationIdentifier(Identifier publicationIdentifier) {
|
95 |
35519
|
stefania.m
|
|
96 |
37543
|
stefania.m
|
if(publicationIdentifier.getType().equals("pmc") || publicationIdentifier.getType().equals("pubMed")
|
97 |
|
|
|| publicationIdentifier.getType().equals("arxiv") || publicationIdentifier.getType().equals("handle")) {
|
98 |
35575
|
stefania.m
|
identifierTypes.setSelectedValue(publicationIdentifier.getType());
|
99 |
|
|
identifierValue.setValue(publicationIdentifier.getValue());
|
100 |
|
|
}
|
101 |
35519
|
stefania.m
|
}
|
102 |
35292
|
stefania.m
|
}
|