1
|
package eu.dnetlib.repo.manager.client.widgets.wizard;
|
2
|
|
3
|
import com.google.gwt.user.client.ui.HTML;
|
4
|
import com.google.gwt.user.client.ui.IsWidget;
|
5
|
import com.google.gwt.user.client.ui.Widget;
|
6
|
import org.gwtbootstrap3.client.ui.gwt.FlowPanel;
|
7
|
|
8
|
import java.util.ArrayList;
|
9
|
import java.util.List;
|
10
|
|
11
|
/**
|
12
|
* Created by stefania on 12/17/15.
|
13
|
*/
|
14
|
public class BreadcrumbWidget implements IsWidget {
|
15
|
|
16
|
private FlowPanel breadcrumbPanel = new FlowPanel();
|
17
|
private FlowPanel wizardStepsPanel = new FlowPanel();
|
18
|
|
19
|
private List<FlowPanel> wizardSteps = new ArrayList<FlowPanel>();
|
20
|
|
21
|
public BreadcrumbWidget(List<String> wizardStepNames) {
|
22
|
|
23
|
breadcrumbPanel.addStyleName("wizardBreadcrumbs");
|
24
|
|
25
|
wizardStepsPanel.addStyleName("steps clearfix");
|
26
|
breadcrumbPanel.add(wizardStepsPanel);
|
27
|
|
28
|
for(int i=0; i<wizardStepNames.size(); i++) {
|
29
|
|
30
|
FlowPanel step = new FlowPanel();
|
31
|
step.addStyleName("step");
|
32
|
|
33
|
step.add(new HTML(wizardStepNames.get(i) + " <span></span>"));
|
34
|
if(i==0)
|
35
|
step.addStyleName("active");
|
36
|
|
37
|
wizardSteps.add(step);
|
38
|
wizardStepsPanel.add(step);
|
39
|
}
|
40
|
}
|
41
|
|
42
|
@Override
|
43
|
public Widget asWidget() {
|
44
|
return breadcrumbPanel;
|
45
|
}
|
46
|
|
47
|
public void setActiveStep(int stepNumber) {
|
48
|
|
49
|
for(int i=0; i<wizardSteps.size(); i++) {
|
50
|
if(i<=stepNumber)
|
51
|
wizardSteps.get(i).addStyleName("active");
|
52
|
else
|
53
|
wizardSteps.get(i).removeStyleName("active");
|
54
|
}
|
55
|
}
|
56
|
}
|