|
|
@@ -8,12 +8,7 @@ import java.awt.event.ActionListener;
|
|
8
|
8
|
import java.text.SimpleDateFormat;
|
|
9
|
9
|
import java.util.Date;
|
|
10
|
10
|
|
|
11
|
|
-import javax.swing.JButton;
|
|
12
|
|
-import javax.swing.JComponent;
|
|
13
|
|
-import javax.swing.JFormattedTextField;
|
|
14
|
|
-import javax.swing.JFrame;
|
|
15
|
|
-import javax.swing.UIManager;
|
|
16
|
|
-import javax.swing.WindowConstants;
|
|
|
11
|
+import javax.swing.*;
|
|
17
|
12
|
import javax.swing.border.Border;
|
|
18
|
13
|
import javax.swing.border.CompoundBorder;
|
|
19
|
14
|
import javax.swing.border.LineBorder;
|
|
|
@@ -33,13 +28,14 @@ import com.jgoodies.forms.layout.FormLayout;
|
|
33
|
28
|
public class RegisterApp {
|
|
34
|
29
|
private static final DefaultFormatter DEFAULT_FORMATTER = new DefaultFormatter();
|
|
35
|
30
|
private static final SimpleDateFormat ISO8601_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:MM:SS.SSS");
|
|
36
|
|
- private static final String TITLE = "Handling Event Registration";
|
|
|
31
|
+ private static final String TITLE = "Incident Logging Application";
|
|
37
|
32
|
private JFrame frame;
|
|
38
|
33
|
private JFormattedTextField completionTimeField;
|
|
39
|
34
|
private JFormattedTextField trackingIdField;
|
|
40
|
35
|
private JFormattedTextField carrierMovementField;
|
|
41
|
36
|
private JFormattedTextField locationField;
|
|
42
|
|
- private JFormattedTextField eventTypeField;
|
|
|
37
|
+ //private JFormattedTextField eventTypeField;
|
|
|
38
|
+ private JComboBox eventTypeField;
|
|
43
|
39
|
private JButton registerButton;
|
|
44
|
40
|
|
|
45
|
41
|
private HandlingEventService handlingEventService;
|
|
|
@@ -53,16 +49,26 @@ public class RegisterApp {
|
|
53
|
49
|
/////////////////////////////////////////////////////////////////////////////
|
|
54
|
50
|
protected void onRegister(){
|
|
55
|
51
|
assert handlingEventService != null : "No HandlingEventService available";
|
|
56
|
|
-
|
|
57
|
|
- handlingEventService.register(ISO8601_DATE_FORMAT.format(completionTimeField.getValue()),
|
|
58
|
|
- getStringValue(trackingIdField),
|
|
59
|
|
- getStringValue(carrierMovementField),
|
|
60
|
|
- getStringValue(locationField),
|
|
61
|
|
- getStringValue(eventTypeField));
|
|
|
52
|
+
|
|
|
53
|
+ handlingEventService.register(ISO8601_DATE_FORMAT.format(completionTimeField.getValue()),
|
|
|
54
|
+ getStringValue(trackingIdField),
|
|
|
55
|
+ getStringValue(carrierMovementField),
|
|
|
56
|
+ getStringValue(locationField),
|
|
|
57
|
+ getStringValue(eventTypeField).toUpperCase());
|
|
62
|
58
|
|
|
63
|
59
|
clearForm();
|
|
64
|
60
|
}
|
|
65
|
61
|
|
|
|
62
|
+ private String getStringValue(JComboBox comboBox) {
|
|
|
63
|
+ Object value = comboBox.getSelectedItem();
|
|
|
64
|
+
|
|
|
65
|
+ if (value != null) {
|
|
|
66
|
+ return value.toString();
|
|
|
67
|
+ } else {
|
|
|
68
|
+ return null;
|
|
|
69
|
+ }
|
|
|
70
|
+ }
|
|
|
71
|
+
|
|
66
|
72
|
|
|
67
|
73
|
private String getStringValue(JFormattedTextField formattedTextField) {
|
|
68
|
74
|
Object value = formattedTextField.getValue();
|
|
|
@@ -117,7 +123,7 @@ public class RegisterApp {
|
|
117
|
123
|
trackingIdField.setText("");
|
|
118
|
124
|
carrierMovementField.setText("");
|
|
119
|
125
|
locationField.setText("");
|
|
120
|
|
- eventTypeField.setText("");
|
|
|
126
|
+ eventTypeField.setSelectedIndex(0);
|
|
121
|
127
|
}
|
|
122
|
128
|
|
|
123
|
129
|
public static Border getMandatoryBorder() {
|
|
|
@@ -129,7 +135,7 @@ public class RegisterApp {
|
|
129
|
135
|
trackingIdField = new JFormattedTextField(DEFAULT_FORMATTER);
|
|
130
|
136
|
carrierMovementField = new JFormattedTextField(DEFAULT_FORMATTER);
|
|
131
|
137
|
locationField = new JFormattedTextField(DEFAULT_FORMATTER);
|
|
132
|
|
- eventTypeField = new JFormattedTextField(DEFAULT_FORMATTER);
|
|
|
138
|
+ eventTypeField = new JComboBox(new String[] {"-- Select --","Receive","Load","Unload","Customs","Claim"});
|
|
133
|
139
|
|
|
134
|
140
|
registerButton = new JButton("Register");
|
|
135
|
141
|
registerButton.addActionListener(new ActionListener(){
|
|
|
@@ -149,7 +155,6 @@ public class RegisterApp {
|
|
149
|
155
|
private void initValidation(JFrame frame){
|
|
150
|
156
|
validator = new FormValidationSwingDecorator(frame);
|
|
151
|
157
|
|
|
152
|
|
- validator.add(eventTypeField, new MandatoryTextFieldValidator("Event type can't be empty"));
|
|
153
|
158
|
validator.add(trackingIdField, new MandatoryTextFieldValidator("Tracking id can't be empty"));
|
|
154
|
159
|
validator.add(locationField, new MandatoryTextFieldValidator("Location can't be empty"));
|
|
155
|
160
|
}
|
|
|
@@ -201,14 +206,14 @@ public class RegisterApp {
|
|
201
|
206
|
DefaultFormBuilder builder = createBuilder("right:pref, 3dlu, 100dlu");
|
|
202
|
207
|
|
|
203
|
208
|
builder.appendSeparator("Completion");
|
|
204
|
|
- builder.append("Completion Time", completionTimeField); builder.nextLine();
|
|
|
209
|
+ builder.append("Time", completionTimeField); builder.nextLine();
|
|
205
|
210
|
|
|
206
|
211
|
builder.appendSeparator("Cargo");
|
|
207
|
212
|
builder.append("Tracking Id", trackingIdField); builder.nextLine();
|
|
208
|
213
|
|
|
209
|
214
|
builder.appendSeparator("Event");
|
|
210
|
215
|
builder.append("Carrier Movement", carrierMovementField); builder.nextLine();
|
|
211
|
|
- builder.append("Location", locationField); builder.nextLine();
|
|
|
216
|
+ builder.append("Location UN/Locode", locationField); builder.nextLine();
|
|
212
|
217
|
builder.append("Event Type", eventTypeField); builder.nextLine();
|
|
213
|
218
|
|
|
214
|
219
|
builder.appendSeparator("");
|