1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.example.demo;
21
22 import javax.enterprise.context.SessionScoped;
23 import javax.faces.event.FacesEvent;
24 import javax.inject.Named;
25 import javax.swing.DefaultBoundedRangeModel;
26 import java.io.Serializable;
27 import java.text.SimpleDateFormat;
28 import java.util.Date;
29
30 @SessionScoped
31 @Named
32 public class ProgressController implements Serializable {
33
34 private DefaultBoundedRangeModel progress = new DefaultBoundedRangeModel(3, 0, 0, 5);
35
36 public DefaultBoundedRangeModel getProgress() {
37 return progress;
38 }
39
40 public void addProgress() {
41 final int value = progress.getValue();
42
43 if (value >= progress.getMaximum()) {
44 progress.setValue(0);
45 } else {
46 progress.setValue(value + 1);
47 }
48 }
49
50 public void resetProgress(final FacesEvent event) {
51 progress.setValue(0);
52 }
53
54 public Date getCurrentDate() {
55 return new Date();
56 }
57
58 public double getCurrentHours() {
59 final SimpleDateFormat sdf = new SimpleDateFormat("HH");
60 return Double.valueOf(sdf.format(getCurrentDate()));
61 }
62
63 public double getCurrentMinutes() {
64 final SimpleDateFormat sdf = new SimpleDateFormat("mm");
65 return Double.valueOf(sdf.format(getCurrentDate()));
66 }
67
68 public double getCurrentSeconds() {
69 final SimpleDateFormat sdf = new SimpleDateFormat("ss");
70 return Double.valueOf(sdf.format(getCurrentDate()));
71 }
72 }