1
|
package eu.dnetlib.client.fundingrequest.newrequest;
|
2
|
|
3
|
import com.github.gwtbootstrap.client.ui.Button;
|
4
|
import com.github.gwtbootstrap.client.ui.ButtonGroup;
|
5
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
6
|
import com.google.gwt.event.dom.client.ClickEvent;
|
7
|
import com.google.gwt.event.dom.client.ClickHandler;
|
8
|
import com.google.gwt.user.client.ui.FlowPanel;
|
9
|
import com.google.gwt.user.client.ui.IsWidget;
|
10
|
import com.google.gwt.user.client.ui.Widget;
|
11
|
|
12
|
/**
|
13
|
* Created by stefania on 2/25/15.
|
14
|
*/
|
15
|
public class FundingNavigationWidget implements IsWidget {
|
16
|
|
17
|
private FlowPanel fundingNavigationPanel = new FlowPanel();
|
18
|
|
19
|
private ButtonGroup backAndNextButtonGroup = new ButtonGroup();
|
20
|
|
21
|
private Button back = new Button();
|
22
|
private Button next = new Button();
|
23
|
|
24
|
private int currentActiveStep = 0;
|
25
|
|
26
|
private NextButtonListener nextButtonListener;
|
27
|
private BackButtonListener backButtonListener;
|
28
|
|
29
|
public FundingNavigationWidget() {
|
30
|
|
31
|
backAndNextButtonGroup.addStyleName("backAndNextButtons");
|
32
|
|
33
|
back.setText("Back");
|
34
|
back.setType(ButtonType.DEFAULT);
|
35
|
back.addClickHandler(new ClickHandler() {
|
36
|
@Override
|
37
|
public void onClick(ClickEvent event) {
|
38
|
fireBackEvent();
|
39
|
}
|
40
|
});
|
41
|
if(currentActiveStep==0)
|
42
|
back.setEnabled(false);
|
43
|
|
44
|
next.setText("Next");
|
45
|
next.setType(ButtonType.PRIMARY);
|
46
|
next.addClickHandler(new ClickHandler() {
|
47
|
@Override
|
48
|
public void onClick(ClickEvent event) {
|
49
|
fireNextEvent();
|
50
|
}
|
51
|
});
|
52
|
|
53
|
backAndNextButtonGroup.add(back);
|
54
|
backAndNextButtonGroup.add(next);
|
55
|
|
56
|
fundingNavigationPanel.add(backAndNextButtonGroup);
|
57
|
}
|
58
|
|
59
|
|
60
|
@Override
|
61
|
public Widget asWidget() {
|
62
|
return fundingNavigationPanel;
|
63
|
}
|
64
|
|
65
|
public void setActiveStep(int stepNumber) {
|
66
|
|
67
|
currentActiveStep = stepNumber;
|
68
|
|
69
|
if(currentActiveStep==0)
|
70
|
back.setEnabled(false);
|
71
|
else
|
72
|
back.setEnabled(true);
|
73
|
}
|
74
|
|
75
|
public void setNextButtonText(String text) {
|
76
|
next.setText(text);
|
77
|
}
|
78
|
|
79
|
public interface NextButtonListener {
|
80
|
public void nextClicked(int newActiveStep);
|
81
|
}
|
82
|
|
83
|
public void setNextButtonListener(NextButtonListener nextButtonListener) {
|
84
|
this.nextButtonListener = nextButtonListener;
|
85
|
}
|
86
|
|
87
|
public interface BackButtonListener {
|
88
|
public void backClicked(int newActiveStep);
|
89
|
}
|
90
|
|
91
|
public void setBackButtonListener(BackButtonListener backButtonListener) {
|
92
|
this.backButtonListener = backButtonListener;
|
93
|
}
|
94
|
|
95
|
private void fireNextEvent() {
|
96
|
if(nextButtonListener !=null) {
|
97
|
nextButtonListener.nextClicked(currentActiveStep+1);
|
98
|
}
|
99
|
}
|
100
|
|
101
|
private void fireBackEvent() {
|
102
|
if(backButtonListener !=null) {
|
103
|
backButtonListener.backClicked(currentActiveStep-1);
|
104
|
}
|
105
|
}
|
106
|
}
|