1
|
package eu.dnetlib.client.fundingrequest.newrequest.publicationstep;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.Alert;
|
4
|
import com.github.gwtbootstrap.client.ui.CheckBox;
|
5
|
import com.github.gwtbootstrap.client.ui.Form;
|
6
|
import com.github.gwtbootstrap.client.ui.RadioButton;
|
7
|
import com.github.gwtbootstrap.client.ui.base.IconAnchor;
|
8
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
9
|
import com.github.gwtbootstrap.client.ui.constants.AlternateSize;
|
10
|
import com.github.gwtbootstrap.client.ui.constants.FormType;
|
11
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
12
|
import com.github.gwtbootstrap.datepicker.client.ui.DateBox;
|
13
|
import com.github.gwtbootstrap.datepicker.client.ui.base.HasStartView;
|
14
|
import com.google.gwt.event.dom.client.ClickEvent;
|
15
|
import com.google.gwt.event.dom.client.ClickHandler;
|
16
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
17
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
18
|
import com.google.gwt.user.client.ui.FlowPanel;
|
19
|
import com.google.gwt.user.client.ui.IsWidget;
|
20
|
import com.google.gwt.user.client.ui.Label;
|
21
|
import com.google.gwt.user.client.ui.Widget;
|
22
|
import eu.dnetlib.client.widgets.FormFieldSet;
|
23
|
import eu.dnetlib.client.widgets.MultipleAuthorsWidget;
|
24
|
import eu.dnetlib.client.widgets.MultipleIdentifiersWidget;
|
25
|
import eu.dnetlib.client.widgets.TextBox;
|
26
|
import eu.dnetlib.goldoa.domain.Publication;
|
27
|
|
28
|
import java.util.Date;
|
29
|
|
30
|
/**
|
31
|
* Created by stefania on 3/9/15.
|
32
|
*/
|
33
|
public class PublicationInfoStep implements IsWidget {
|
34
|
|
35
|
private FlowPanel publicationInfoStepPanel = new FlowPanel();
|
36
|
|
37
|
private Form publicationDOIForm = new Form();
|
38
|
private TextBox doi = new TextBox();
|
39
|
private IconAnchor resolveDOI = new IconAnchor();
|
40
|
private Label comment = new Label();
|
41
|
// private CheckBox noDOI = new CheckBox();
|
42
|
|
43
|
//publication info form
|
44
|
private FlowPanel publicationInfoPanel = new FlowPanel();
|
45
|
|
46
|
private Alert errorLabel = new Alert();
|
47
|
|
48
|
private Form publicationInfoForm = new Form();
|
49
|
private TextBox titleTextBox = new TextBox();
|
50
|
private DateBox publicationDateTextBox = new DateBox();
|
51
|
private TextBox languages = new TextBox();
|
52
|
|
53
|
private RadioButton articleRadio = new RadioButton("publicationType", "Article", false);
|
54
|
private RadioButton monographRadio = new RadioButton("publicationType", "Monograph", false);
|
55
|
|
56
|
private TextBox subjects = new TextBox();
|
57
|
|
58
|
private MultipleAuthorsWidget multipleAuthorsWidget = new MultipleAuthorsWidget();
|
59
|
|
60
|
private MultipleIdentifiersWidget multipleIdentifiersWidget = new MultipleIdentifiersWidget();
|
61
|
|
62
|
private PublicationTypeListener publicationTypeListener;
|
63
|
private ResolveDOIListener resolveDOIListener;
|
64
|
|
65
|
public PublicationInfoStep() {
|
66
|
|
67
|
publicationDOIForm.setType(FormType.HORIZONTAL);
|
68
|
publicationDOIForm.addStyleName("publicationDOIForm");
|
69
|
publicationInfoStepPanel.add(publicationDOIForm);
|
70
|
publicationInfoStepPanel.add(publicationInfoPanel);
|
71
|
|
72
|
doi.setAlternateSize(AlternateSize.XLARGE);
|
73
|
doi.addStyleName("inlineBlock");
|
74
|
|
75
|
resolveDOI.setText("Resolve");
|
76
|
resolveDOI.addStyleName("resolveIcon");
|
77
|
resolveDOI.addStyleName("inlineBlock");
|
78
|
resolveDOI.addClickHandler(new ClickHandler() {
|
79
|
@Override
|
80
|
public void onClick(ClickEvent clickEvent) {
|
81
|
if(resolveDOIListener!=null)
|
82
|
resolveDOIListener.resolveDOIClicked(doi.getValue().trim());
|
83
|
}
|
84
|
});
|
85
|
|
86
|
comment.setText("If you have a DOI, type it here and click resolve so that we can auto complete all the available information");
|
87
|
comment.addStyleName("comment");
|
88
|
|
89
|
publicationDOIForm.add(new FormFieldSet("DOI", doi, resolveDOI, comment));
|
90
|
|
91
|
//publication info form
|
92
|
publicationInfoPanel.addStyleName("publicationInfoPanel");
|
93
|
|
94
|
errorLabel.addStyleName("alertLabel");
|
95
|
errorLabel.setType(AlertType.ERROR);
|
96
|
errorLabel.setVisible(false);
|
97
|
errorLabel.setClose(false);
|
98
|
|
99
|
publicationInfoForm.setType(FormType.HORIZONTAL);
|
100
|
publicationInfoForm.addStyleName("publicationInfoForm");
|
101
|
publicationInfoPanel.add(publicationInfoForm);
|
102
|
|
103
|
titleTextBox.setAlternateSize(AlternateSize.XXLARGE);
|
104
|
|
105
|
publicationDateTextBox.setAlternateSize(AlternateSize.LARGE);
|
106
|
publicationDateTextBox.setStartView(HasStartView.ViewMode.YEAR);
|
107
|
publicationDateTextBox.setAutoClose(true);
|
108
|
publicationDateTextBox.setFormat("yyyy/mm/dd");
|
109
|
|
110
|
articleRadio.setValue(true);
|
111
|
articleRadio.addStyleName("inlineBlock");
|
112
|
articleRadio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
113
|
@Override
|
114
|
public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
|
115
|
if(articleRadio.getValue()) {
|
116
|
if(publicationTypeListener!=null)
|
117
|
publicationTypeListener.publicationTypeChanged("article");
|
118
|
}
|
119
|
}
|
120
|
});
|
121
|
monographRadio.addStyleName("inlineBlock");
|
122
|
monographRadio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
|
123
|
@Override
|
124
|
public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
|
125
|
if(monographRadio.getValue()) {
|
126
|
if(publicationTypeListener!=null)
|
127
|
publicationTypeListener.publicationTypeChanged("monograph");
|
128
|
}
|
129
|
}
|
130
|
});
|
131
|
|
132
|
languages.setAlternateSize(AlternateSize.XXLARGE);
|
133
|
languages.setPlaceholder(" languages as a comma-separated list");
|
134
|
|
135
|
subjects.setAlternateSize(AlternateSize.XXLARGE);
|
136
|
subjects.setPlaceholder(" subjects as a comma-separated list");
|
137
|
|
138
|
publicationInfoForm.add(errorLabel);
|
139
|
publicationInfoForm.add(new FormFieldSet("Title (*)", titleTextBox));
|
140
|
publicationInfoForm.add(new FormFieldSet("Authors (*)", multipleAuthorsWidget.asWidget()));
|
141
|
publicationInfoForm.add(new FormFieldSet("Publication Date (*)", publicationDateTextBox));
|
142
|
publicationInfoForm.add(new FormFieldSet("Type (*)", articleRadio, monographRadio));
|
143
|
publicationInfoForm.add(new FormFieldSet("Languages (*)", languages));
|
144
|
publicationInfoForm.add(new FormFieldSet("Subjects (*)", subjects));
|
145
|
publicationInfoForm.add(new FormFieldSet("Identifiers", multipleIdentifiersWidget.asWidget()));
|
146
|
}
|
147
|
|
148
|
@Override
|
149
|
public Widget asWidget() {
|
150
|
return publicationInfoStepPanel;
|
151
|
}
|
152
|
|
153
|
public interface PublicationTypeListener {
|
154
|
public void publicationTypeChanged(String publicationType);
|
155
|
}
|
156
|
|
157
|
public void setPublicationTypeListener(PublicationTypeListener publicationTypeListener) {
|
158
|
this.publicationTypeListener = publicationTypeListener;
|
159
|
}
|
160
|
|
161
|
public interface ResolveDOIListener {
|
162
|
public void resolveDOIClicked(String doi);
|
163
|
}
|
164
|
|
165
|
public void setResolveDOIListener(ResolveDOIListener resolveDOIListener) {
|
166
|
this.resolveDOIListener = resolveDOIListener;
|
167
|
}
|
168
|
|
169
|
public boolean isComplete() {
|
170
|
|
171
|
if(!titleTextBox.getValue().trim().equals("") && !multipleAuthorsWidget.getAuthors().isEmpty()
|
172
|
&& publicationDateTextBox.getValue()!=null && !languages.getValue().trim().equals("")
|
173
|
&& !subjects.getValue().trim().equals(""))
|
174
|
return true;
|
175
|
|
176
|
return false;
|
177
|
}
|
178
|
|
179
|
public Publication getPublication() {
|
180
|
|
181
|
errorLabel.setVisible(false);
|
182
|
|
183
|
if(isComplete()) {
|
184
|
Publication publication = new Publication();
|
185
|
|
186
|
if(!doi.getValue().trim().equals(""))
|
187
|
publication.setDoi(doi.getValue().trim());
|
188
|
publication.setTitle(titleTextBox.getValue().trim());
|
189
|
publication.setAuthors(multipleAuthorsWidget.getAuthors());
|
190
|
publication.setPublicationDate(publicationDateTextBox.getValue());
|
191
|
|
192
|
if(articleRadio.getValue())
|
193
|
publication.setType(Publication.Type.ARTICLE);
|
194
|
else
|
195
|
publication.setType(Publication.Type.MONOGRAPH);
|
196
|
|
197
|
publication.setLanguages(languages.getValue().trim());
|
198
|
publication.setSubjects(subjects.getValue().trim());
|
199
|
publication.setIdentifiers(multipleIdentifiersWidget.getPublicationIdentifiers());
|
200
|
|
201
|
return publication;
|
202
|
} else {
|
203
|
errorLabel.setText("All asterisk (*) fields are required.");
|
204
|
errorLabel.setVisible(true);
|
205
|
}
|
206
|
|
207
|
return null;
|
208
|
}
|
209
|
|
210
|
public void clear() {
|
211
|
|
212
|
doi.setValue("");
|
213
|
|
214
|
titleTextBox.setValue("");
|
215
|
|
216
|
articleRadio.setValue(true, true);
|
217
|
|
218
|
multipleAuthorsWidget.clear();
|
219
|
|
220
|
publicationDateTextBox.setValue(new Date());
|
221
|
languages.setValue("");
|
222
|
subjects.setValue("");
|
223
|
|
224
|
multipleIdentifiersWidget.clear();
|
225
|
}
|
226
|
|
227
|
public void loadPublicationInfo(Publication publication) {
|
228
|
|
229
|
titleTextBox.setValue(publication.getTitle());
|
230
|
|
231
|
if(publication.getType().equals(Publication.Type.ARTICLE)) {
|
232
|
articleRadio.setValue(true, true);
|
233
|
} else {
|
234
|
monographRadio.setValue(true, true);
|
235
|
}
|
236
|
|
237
|
multipleAuthorsWidget.loadAuthors(publication.getAuthors());
|
238
|
|
239
|
publicationDateTextBox.setValue(publication.getPublicationDate());
|
240
|
languages.setValue(publication.getLanguages());
|
241
|
subjects.setValue(publication.getSubjects());
|
242
|
|
243
|
multipleIdentifiersWidget.loadPublicationIdentifiers(publication.getIdentifiers());
|
244
|
}
|
245
|
}
|