1
1
package org .aio .gui .task_panels ;
2
2
3
- import org .aio .gui .fields .NumberField ;
3
+ import org .aio .gui .fields .IntegerField ;
4
4
import org .aio .gui .styled_components .StyledJComboBox ;
5
5
import org .aio .gui .styled_components .StyledJLabel ;
6
6
import org .aio .gui .styled_components .StyledJPanel ;
11
11
import org .json .simple .JSONObject ;
12
12
13
13
import javax .swing .*;
14
- import javax .swing .border .EtchedBorder ;
15
- import javax .swing .border .TitledBorder ;
16
14
import java .awt .*;
17
- import java .util .concurrent .TimeUnit ;
18
15
19
16
public class LoopTaskPanel extends TaskPanel {
20
17
@@ -26,33 +23,37 @@ public class LoopTaskPanel extends TaskPanel {
26
23
LoopTaskPanel (){
27
24
super (TaskType .LOOP );
28
25
29
- JPanel contentPanel = new StyledJPanel (new BorderLayout ());
26
+ JPanel contentPanel = new StyledJPanel ();
27
+ contentPanel .setLayout (new BoxLayout (contentPanel , BoxLayout .PAGE_AXIS ));
30
28
31
- JPanel controls = new StyledJPanel (new FlowLayout (FlowLayout .LEFT , 5 , 5 ));
29
+ JPanel tasksPanel = new StyledJPanel (new FlowLayout (FlowLayout .LEFT , 5 , 5 ));
32
30
33
31
// Add counter of previous tasks
34
- controls .add (new StyledJLabel ("Num Previous Tasks:" ));
35
- taskCountField = new NumberField ();
32
+ tasksPanel .add (new StyledJLabel ("Num Previous Tasks:" ));
33
+ taskCountField = new IntegerField ();
36
34
taskCountField .setColumns (4 );
37
- controls .add (taskCountField );
35
+ tasksPanel .add (taskCountField );
38
36
39
- controls .add (new StyledJLabel ("Duration:" ));
37
+ contentPanel .add (tasksPanel );
38
+
39
+ JPanel loopTaskDurationPanel = new StyledJPanel (new FlowLayout (FlowLayout .LEFT , 5 , 5 ));
40
+ contentPanel .add (loopTaskDurationPanel );
41
+
42
+ loopTaskDurationPanel .add (new StyledJLabel ("Duration:" ));
40
43
41
44
loopDurationTypeSelector = new StyledJComboBox <>(LoopDurationType .values ());
42
- controls .add (loopDurationTypeSelector );
45
+ loopTaskDurationPanel .add (loopDurationTypeSelector );
43
46
44
47
JPanel iterationsPanel = new StyledJPanel (new FlowLayout (FlowLayout .LEFT , 5 , 5 ));
45
48
iterationsPanel .add (new StyledJLabel ("Num Iterations:" ));
46
- iterationCountField = new NumberField ();
49
+ iterationCountField = new IntegerField ();
47
50
iterationCountField .setColumns (4 );
48
51
iterationsPanel .add (iterationCountField );
49
- controls .add (iterationsPanel );
52
+ loopTaskDurationPanel .add (iterationsPanel );
50
53
51
54
durationPanel = new DurationPanel ();
52
55
durationPanel .setVisible (false );
53
- controls .add (durationPanel );
54
-
55
- contentPanel .add (controls , BorderLayout .SOUTH );
56
+ loopTaskDurationPanel .add (durationPanel );
56
57
57
58
loopDurationTypeSelector .addActionListener (e -> {
58
59
LoopDurationType loopDurationType = (LoopDurationType ) loopDurationTypeSelector .getSelectedItem ();
@@ -82,7 +83,7 @@ public Task toTask() {
82
83
} else if (loopDurationType == LoopDurationType .INFINITE ) {
83
84
return LoopTask .forIterations (taskCount , LoopTask .INFINITE_ITERATIONS );
84
85
} else if (durationPanel .getSelectedTimeType () == DurationPanel .TimeType .MINUTES ) {
85
- return LoopTask .forDuration (taskCount , TimeUnit . MINUTES . toMillis ( durationPanel .getDuration () ));
86
+ return LoopTask .forDuration (taskCount , durationPanel .getDurationMS ( ));
86
87
} else {
87
88
return LoopTask .untilDateTime (taskCount , durationPanel .getSelectedDateTime ());
88
89
}
0 commit comments