-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkOrderController.java
More file actions
140 lines (115 loc) · 4.2 KB
/
WorkOrderController.java
File metadata and controls
140 lines (115 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package com.enventek.plant.worklist.newlist;
import com.enventek.plant.hibernate.objects.Board;
import com.enventek.plant.hibernate.objects.Truss;
import com.enventek.plant.utils.Item;
import com.enventek.plant.worklist.WorkOrderUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.swing.*;
import java.util.Optional;
/**
* WorkOrderController
*
* Encapsulates all logic for managing active work order streams.
* Handles progression through jobs, saving/restoring state, and
* interaction with the worklist UI/Controller.
*/
public class WorkOrderController {
private static final Logger logger = LogManager.getLogger(WorkOrderController.class);
private final WorkListState state;
private final WorkListUI ui;
private final WorkOrderUtils workOrderUtils;
private boolean activeWorkStream = false;
private boolean selectedByWO = false;
public WorkOrderController(WorkListUI ui, WorkListState state, WorkOrderUtils workOrderUtils) {
this.ui = ui;
this.state = state;
this.workOrderUtils = workOrderUtils;
}
/* ----------------------------
* Public API
* ---------------------------- */
public void startWorkStream() {
logger.info("Starting work order stream");
activeWorkStream = true;
selectedByWO = false;
// TODO: restore saved stream state if available
}
public void stopWorkStream() {
logger.info("Stopping work order stream");
activeWorkStream = false;
selectedByWO = false;
}
public boolean isActiveWorkStream() {
return activeWorkStream;
}
public void setSelectedByWO(boolean selectedByWO) {
this.selectedByWO = selectedByWO;
}
public boolean isSelectedByWO() {
return selectedByWO;
}
/**
* Called when a user selects an item while in work order mode.
* Handles progression logic.
*/
public void handleSelection(Object selectedValue) {
if (!activeWorkStream || selectedValue == null) {
return;
}
logger.debug("WorkOrder selection: {}", selectedValue);
if (selectedValue instanceof Item item) {
Object value = item.getValue();
if (value instanceof Board board) {
processBoard(board);
} else if (value instanceof Truss truss) {
processTruss(truss);
} else {
processGeneric(item);
}
} else {
logger.warn("Unknown selection type in WorkOrder: {}", selectedValue.getClass());
}
}
/**
* Move to the next item in the work stream.
*/
public void moveToNext(JList<?> list) {
if (!activeWorkStream || list == null) return;
int current = list.getSelectedIndex();
int next = current + 1;
if (next < list.getModel().getSize()) {
list.setSelectedIndex(next);
logger.debug("Moved WorkOrder stream to index {}", next);
} else {
logger.info("End of work order stream reached");
stopWorkStream();
}
}
/**
* Check if a saved work stream exists.
*/
public boolean hasWorkStreamSaved() {
// TODO: integrate with SavedStateUtils
return false;
}
public void loadWorkStreamSaved() {
// TODO: load saved work order stream from SavedStateUtils
logger.info("Loading saved work stream (not yet implemented)");
}
/* ----------------------------
* Internal Handlers
* ---------------------------- */
private void processBoard(Board board) {
logger.info("Processing Board in WorkOrder: {}", board.getJobName());
// TODO: implement progression logic
}
private void processTruss(Truss truss) {
logger.info("Processing Truss in WorkOrder: {}", truss.getJobName());
// TODO: implement progression logic
}
private void processGeneric(Item item) {
logger.info("Processing Item in WorkOrder: {}", item);
// TODO: implement progression logic
}
}