Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. public WizardPanel(String id) {
  2. super(id, false);
  3. // false deactivates the default style.
  4. setDefaultModel(new CompoundPropertyModel<WizardPanel>(this));
  5. WizardModel model = new WizardModel();
  6. model.add(new FirstStep());
  7. model.add(new SecondStep());
  8. model.add(new ThirdStep());
  9. model.add(new ConfirmationStep());
  10.  
  11. Iterator<IWizardStep> iterator = model.stepIterator();
  12. for(int i = 1; iterator.hasNext(); i ++){
  13. System.out.println(String.valueOf(i));
  14. }
  15. init(model);
  16. }
  17.  
  18. public class OverviewComponent extends Panel{
  19. private static final long serialVersionUID = 1L;
  20. private List<WizardStep> steps;
  21. private WizardModel model;
  22.  
  23. public OverviewComponent(String id, WizardModel model) {
  24. super(id);
  25. this.model = model;
  26. steps = fillList();
  27.  
  28. this.add(new ListView<WizardStep>("steps", steps) {
  29. private static final long serialVersionUID = 1L;
  30. /**
  31. * Wrap a markup container around the item append a css attribute to every item
  32. */
  33. @Override
  34. protected void populateItem(ListItem<WizardStep> item) {
  35. WebMarkupContainer stepOverviewItem;
  36. item.add(stepOverviewItem = new WebMarkupContainer("stepOverviewItem"));
  37. stepOverviewItem.add(new Label("index", Model.of(item.getIndex()+1)));
  38. stepOverviewItem.add(new AttributeModifier("class", getCSSProperty(item.getModelObject())));
  39. stepOverviewItem.setOutputMarkupId(true);
  40. stepOverviewItem.setOutputMarkupPlaceholderTag(true);
  41. }
  42.  
  43. });
  44. }
  45.  
  46. public String getCSSProperty(WizardStep step) {
  47. if (step.equals(model.getActiveStep())) {
  48. return "active";
  49. } else if (!step.isComplete()) {
  50. return "pending";
  51. } else if (step.isComplete()) {
  52. return "completed";
  53. }
  54. return "";
  55. }
  56.  
  57. public List<WizardStep> fillList() {
  58. List<WizardStep> iSteps = new ArrayList<WizardStep>();
  59. Iterator<IWizardStep> iterator = model.stepIterator();
  60. while (iterator.hasNext()) {
  61. iSteps.add((WizardStep)iterator.next());
  62. }
  63. return iSteps;
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement