-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWorkListUI.java
More file actions
193 lines (156 loc) · 7.47 KB
/
WorkListUI.java
File metadata and controls
193 lines (156 loc) · 7.47 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
package com.enventek.plant.worklist.newlist;
import com.enventek.plant.graphics.utils.ImageUtils;
import com.enventek.plant.worklist.WorkListConfigPanel;
import info.clearthought.layout.TableLayout;
import javax.swing.*;
import org.apache.commons.configuration2.HierarchicalConfiguration;
import java.awt.*;
/** Builds layout and holds Swing components only. */
public class WorkListUI {
private final JPanel mainPanel;
public final JList itemList;
public final JScrollPane scrollPane;
public final JPanel topPanel;
public final JLabel topText;
public final JButton backButton;
public final JPanel buttonPanel;
public final JButton refreshButton;
public final JButton manualButton;
public final JToggleButton doneButton;
public final JButton workOrderButton; // Added work order button
public final JToggleButton configButton;
public final WorkListConfigPanel configPanel;
// Icons
public final ImageIcon refreshIcon;
public final ImageIcon backIcon;
public final ImageIcon searchIcon;
public ImageIcon workOrderIcon; // Made non-final since it's loaded conditionally
// Renderer (injected later)
public NewWorkListRenderer renderer;
public WorkListUI() {
String iconpath = "/com/enventek/plant/components/icons/";
refreshIcon = ImageUtils.loadIcon(this, iconpath, "refreshfolder64px.png", 30, 30);
backIcon = ImageUtils.loadIcon(this, iconpath, "back64px.png", 30, 30);
searchIcon = ImageUtils.loadIcon(this, iconpath, "searchfolder64px.png", 30, 30);
// Don't load workOrderIcon here - it should be loaded conditionally later
mainPanel = new JPanel();
TableLayout mainLayout = new TableLayout(new double[][]{
{55.0, TableLayout.FILL},
{TableLayout.MINIMUM, 55.0, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.FILL, 55.0, 55.0}
});
mainLayout.setHGap(4); mainLayout.setVGap(4);
mainPanel.setLayout(mainLayout);
configButton = new JToggleButton();
configPanel = new WorkListConfigPanel(null);
configPanel.setVisible(false);
itemList = new JList<>();
itemList.setFixedCellHeight(40);
itemList.setFont(new Font("Tahoma", Font.PLAIN, 16));
itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
scrollPane = new JScrollPane(itemList);
scrollPane.setAutoscrolls(true);
buttonPanel = new JPanel();
// Start with 4 columns (refresh, manual, done, empty)
TableLayout buttonLayout = new TableLayout(new double[][]{
{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
{TableLayout.FILL}
});
buttonLayout.setHGap(5); buttonLayout.setVGap(5);
buttonPanel.setLayout(buttonLayout);
refreshButton = new JButton("Refresh");
refreshButton.setFont(new Font("Arial", Font.BOLD, 11));
refreshButton.setVerticalTextPosition(SwingConstants.BOTTOM);
refreshButton.setHorizontalTextPosition(SwingConstants.CENTER);
refreshButton.setFocusPainted(false);
refreshButton.setIcon(refreshIcon);
manualButton = new JButton("Manual");
manualButton.setFont(new Font("Arial", Font.BOLD, 11));
manualButton.setFocusPainted(false);
manualButton.setVerticalTextPosition(SwingConstants.BOTTOM);
manualButton.setHorizontalTextPosition(SwingConstants.CENTER);
doneButton = new JToggleButton("Done");
doneButton.setFont(new Font("Arial", Font.BOLD, 11));
doneButton.setEnabled(false);
doneButton.setFocusPainted(false);
doneButton.setVerticalTextPosition(SwingConstants.BOTTOM);
doneButton.setHorizontalTextPosition(SwingConstants.CENTER);
// Initialize workOrderButton but don't add it to the panel yet
workOrderButton = new JButton();
workOrderButton.setFont(new Font("Arial", Font.BOLD, 11));
workOrderButton.setFocusPainted(false);
workOrderButton.setVerticalTextPosition(SwingConstants.BOTTOM);
workOrderButton.setHorizontalTextPosition(SwingConstants.CENTER);
workOrderButton.setVisible(false); // Hide by default
buttonPanel.add(refreshButton, "0,0");
buttonPanel.add(manualButton, "1,0");
buttonPanel.add(doneButton, "2,0");
// Note: workOrderButton is NOT added here - it will be added conditionally later
topPanel = new JPanel();
TableLayout topLayout = new TableLayout(new double[][]{
{TableLayout.FILL, 0.0}, {TableLayout.FILL}
});
topLayout.setHGap(5); topLayout.setVGap(5);
topPanel.setLayout(topLayout);
backButton = new JButton("Search");
backButton.setFocusPainted(false);
backButton.setFont(new Font("Tahoma", Font.PLAIN, 14));
backButton.setHorizontalAlignment(SwingConstants.LEFT);
backButton.setIcon(searchIcon);
topText = new JLabel("Select A Batch Below", SwingConstants.CENTER);
topText.setBackground(Color.BLACK);
topPanel.add(backButton, "0,0");
topPanel.add(topText, "0,0");
mainPanel.add(scrollPane, "0,3,1,5");
mainPanel.add(configButton, "0,1");
mainPanel.add(configPanel, "0,2,1,6");
mainPanel.add(buttonPanel, "0,6,1,6");
mainPanel.add(topPanel, "1,1");
mainPanel.setSize(505, 545);
}
// In WorkListUI class - add this method:
public void setupWorkOrderButton(ImageIcon workOrderIcon) {
this.workOrderIcon = workOrderIcon;
workOrderButton.setIcon(workOrderIcon);
// Change the layout to accommodate the work order button
TableLayout buttonLayout = new TableLayout(new double[][]{
{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
{TableLayout.FILL}
});
buttonPanel.setLayout(buttonLayout);
// Remove all components and re-add them with work order button
buttonPanel.removeAll();
buttonPanel.add(refreshButton, "0,0");
buttonPanel.add(manualButton, "1,0");
buttonPanel.add(doneButton, "2,0");
buttonPanel.add(workOrderButton, "3,0");
workOrderButton.setVisible(true);
buttonPanel.revalidate();
buttonPanel.repaint();
}
public JButton getWorkOrderButton() {
return workOrderButton;
}
public JPanel getMainPanel() { return mainPanel; }
public void attachRenderer(WorkListController controller, WorkListState state) {
this.renderer = new NewWorkListRenderer(controller, state);
itemList.setCellRenderer(renderer);
}
public void setListFont(Font f) {
if (renderer != null) renderer.setFont(f);
}
public void changeDataSource(HierarchicalConfiguration updatedSettings) throws Exception {
configPanel.changeDataSource(updatedSettings);
}
public void setMyBackground(Color c){
mainPanel.setBackground(c);
buttonPanel.setBackground(c);
topPanel.setBackground(c);
}
public void setMyForeground(Color c){
itemList.setForeground(c);
}
// Check if work order button is visible/added
public boolean isWorkOrderButtonEnabled() {
return workOrderButton.isVisible();
}
}