1
|
package eu.dnetlib.client.fundingrequest.existingrequests;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.Button;
|
4
|
import com.google.gwt.event.dom.client.ClickEvent;
|
5
|
import com.google.gwt.event.dom.client.ClickHandler;
|
6
|
import com.google.gwt.user.client.History;
|
7
|
import com.google.gwt.user.client.ui.FlowPanel;
|
8
|
import com.google.gwt.user.client.ui.IsWidget;
|
9
|
import com.google.gwt.user.client.ui.Widget;
|
10
|
import eu.dnetlib.client.fundingrequest.newrequest.EligibilityDisplayWidget;
|
11
|
import eu.dnetlib.client.fundingrequest.stepinfo.*;
|
12
|
import eu.dnetlib.goldoa.domain.Request;
|
13
|
import eu.dnetlib.goldoa.domain.RequestInfo;
|
14
|
|
15
|
/**
|
16
|
* Created by stefania on 3/26/15.
|
17
|
*/
|
18
|
public class ExistingRequestElement implements IsWidget {
|
19
|
|
20
|
private FlowPanel requestInfoPanel = new FlowPanel();
|
21
|
|
22
|
private FlowPanel requestSummaryPanel = new FlowPanel();
|
23
|
private FlowPanel firstDivider = new FlowPanel();
|
24
|
private FlowPanel secondDivider = new FlowPanel();
|
25
|
|
26
|
private FlowPanel actionButtons = new FlowPanel();
|
27
|
private Button goToFundingWizard = new Button("Go to Funding Wizard");
|
28
|
|
29
|
public ExistingRequestElement(final RequestInfo requestInfo) {
|
30
|
|
31
|
requestInfoPanel.addStyleName("requestInfoPanel");
|
32
|
|
33
|
if(requestInfo.getResearcher()!=null) {
|
34
|
ResearcherInlineInfo researcherInlineInfo = new ResearcherInlineInfo(requestInfo.getResearcher());
|
35
|
requestSummaryPanel.add(researcherInlineInfo.asWidget());
|
36
|
}
|
37
|
|
38
|
if(requestInfo.getProject()!=null) {
|
39
|
ProjectInlineInfo projectInlineInfo = new ProjectInlineInfo(requestInfo.getProject());
|
40
|
requestSummaryPanel.add(projectInlineInfo.asWidget());
|
41
|
}
|
42
|
|
43
|
if(requestInfo.getPublication()!=null) {
|
44
|
PublicationInlineInfo publicationInlineInfo = new PublicationInlineInfo(requestInfo.getPublication());
|
45
|
requestSummaryPanel.add(publicationInlineInfo.asWidget());
|
46
|
}
|
47
|
|
48
|
float apc = 0;
|
49
|
float discount = 0;
|
50
|
|
51
|
if(requestInfo.getPublication()!=null && requestInfo.getPublication().getJournal()!=null) {
|
52
|
JournalInlineInfo journalInlineInfo = new JournalInlineInfo(requestInfo.getPublication().getJournal());
|
53
|
requestSummaryPanel.add(journalInlineInfo.asWidget());
|
54
|
apc = requestInfo.getPublication().getJournal().getApc();
|
55
|
discount = requestInfo.getPublication().getJournal().getDiscount();
|
56
|
}
|
57
|
|
58
|
if(requestInfo.getPublication()!=null && requestInfo.getPublication().getPublisher()!=null) {
|
59
|
PublisherInlineInfo publisherInlineInfo = new PublisherInlineInfo(requestInfo.getPublication().getPublisher());
|
60
|
requestSummaryPanel.add(publisherInlineInfo.asWidget());
|
61
|
apc = requestInfo.getPublication().getPublisher().getAPC();
|
62
|
discount = requestInfo.getPublication().getJournal().getDiscount();
|
63
|
}
|
64
|
|
65
|
if(requestInfo.getProjectParticipation()!=null && requestInfo.getFundingRequested()!=null) {
|
66
|
AccountingInlineInfo accountingInlineInfo = new AccountingInlineInfo(new Request(requestInfo), apc, discount);
|
67
|
requestSummaryPanel.add(accountingInlineInfo.asWidget());
|
68
|
}
|
69
|
|
70
|
actionButtons.addStyleName("requestInfoActionButtons");
|
71
|
|
72
|
goToFundingWizard.addStyleName("requestInfoActionButton");
|
73
|
goToFundingWizard.addClickHandler(new ClickHandler() {
|
74
|
@Override
|
75
|
public void onClick(ClickEvent event) {
|
76
|
History.newItem("newFundingRequest." + requestInfo.getId());
|
77
|
}
|
78
|
});
|
79
|
actionButtons.add(goToFundingWizard);
|
80
|
|
81
|
firstDivider.addStyleName("uk-grid-divider");
|
82
|
secondDivider.addStyleName("uk-grid-divider");
|
83
|
|
84
|
EligibilityDisplayWidget eligibilityDisplayWidget = new EligibilityDisplayWidget(requestInfo.getEligibility());
|
85
|
|
86
|
requestInfoPanel.add(eligibilityDisplayWidget.asWidget());
|
87
|
requestInfoPanel.add(firstDivider);
|
88
|
requestInfoPanel.add(requestSummaryPanel);
|
89
|
|
90
|
if(requestInfo.getStatus().equals(Request.RequestStatus.INCOMPLETE)) {
|
91
|
requestInfoPanel.add(secondDivider);
|
92
|
requestInfoPanel.add(actionButtons);
|
93
|
}
|
94
|
}
|
95
|
|
96
|
@Override
|
97
|
public Widget asWidget() {
|
98
|
return requestInfoPanel;
|
99
|
}
|
100
|
}
|