private static void initialize() {
Functions.logger("Initializing probe configuration",false);
probeDialog=new JDialog();
probeDialog.setLayout(new GridBagLayout());
probeDialog.setModalityType(ModalityType.MODELESS);
probeDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
int row=0;
JLabel headerLabel=new JLabel("Verify Blower & Probe Configuration");
Font headerFont=headerLabel.getFont();
headerFont=headerFont.deriveFont(Font.BOLD,(float) 20);
headerLabel.setFont(headerFont);
GridBagConstraints gbc=new GridBagConstraints();
gbc.gridwidth=2;
gbc.gridx=1;
gbc.gridy=row++;
gbc.fill=GridBagConstraints.HORIZONTAL;
JLabel nameLabel=new JLabel("Name");
JLabel idLabel=new JLabel("ID");
JLabel nameLabelB=new JLabel("Name");
JLabel idLabelB=new JLabel("ID");
JLabel blowerLabel=new JLabel("Blower");
JLabel blowersTitle=new JLabel("Blowers");
Font titleFont=blowersTitle.getFont().deriveFont(Font.BOLD, (float) 16);
blowersTitle.setFont(titleFont);
JLabel probesTitle=new JLabel("Probes");
probesTitle.setFont(titleFont);
JLabel adjustTitle=new JLabel("Adjustment (+/- \u00B0)");
probeDialog.add(headerLabel,gbc);
probeDialog.add(blowersTitle,Functions.makeGbc(2,row++));
probeDialog.add(nameLabelB,Functions.makeGbc(0,row));
probeDialog.add(idLabelB,Functions.makeGbc(1,row++));
String[] blowers=Configuration.getInstance().getBlowerIds();
Functions.logger("Blower ids "+Arrays.toString(blowers),true);
for (int i=0; i<blowers.length; i++) {
JTextField nme=new JTextField();
String name=blowers[i];
name=Configuration.getInstance().getBlower(blowers[i]).getName();
fields.put(nme,new String[] {"name",name});
nme.setText(name);
blwrs.put(blowers[i],name);
JLabel id=new JLabel();
id.setText(blowers[i]);
probeDialog.add(nme,Functions.makeGbc(0,row));
probeDialog.add(id,Functions.makeGbc(1,row++));
}
probeDialog.add(probesTitle,Functions.makeGbc(2,row++));
probeDialog.add(nameLabel,Functions.makeGbc(0,row));
probeDialog.add(idLabel,Functions.makeGbc(1,row));
probeDialog.add(blowerLabel,Functions.makeGbc(2,row));
probeDialog.add(adjustTitle,Functions.makeGbc(3,row++));
String[] monitors=Configuration.getInstance().getMonitorIds();
Functions.logger("Monitor ids "+Arrays.toString(monitors),true);
for (int i=0; i<monitors.length; i++) {;
String name=Configuration.getInstance().getMonitor(monitors[i]).getName();
String probeId=Configuration.getInstance().getMonitor(monitors[i]).getId();
if (name.equals("")) {
Functions.logger("Skipping unconnected probe "+probeId,false);
continue;
}
JTextField nme=new JTextField();
fields.put(nme,new String[] {"name",name});
nme.setText(name);
JLabel id=new JLabel();
id.setText(monitors[i]);
probeDialog.add(nme,Functions.makeGbc(0,row));
probeDialog.add(id,Functions.makeGbc(1,row));
JComboBox<String> list=new JComboBox<String>();
fields.put(list,new String[] {"combo",name});
list.addItem("");
for (Object entry : blwrs.values()) {
list.addItem((String) entry);
}
probeDialog.add(list,Functions.makeGbc(2,row));
if (!Configuration.getInstance().getMonitor(monitors[i]).getBlowerName().equals("")) {
list.setSelectedItem(Configuration.getInstance().getMonitor(monitors[i]).getBlowerName());
}
JFormattedTextField adjust=new JFormattedTextField(new DecimalFormat("#.00"));
if (Configuration.getInstance().getMonitor(monitors[i])!=null) {
adjust.setText(Double.toString(Configuration.getInstance().getAdjustment(Configuration.getInstance().getMonitor(monitors[i]).getId())));
}
else {
adjust.setText("0.");
}
fields.put(adjust,new String[] {"adjust",monitors[i]});
probeDialog.add(adjust,Functions.makeGbc(3, row));
colorButton=new JButton("Color");
colorButton.setForeground(Configuration.getInstance().getColor(probeId));
colorButton.addActionListener(new ColorListener(Configuration.getInstance().getMonitor(monitors[i])));
probeDialog.add(colorButton,Functions.makeGbc(4, row++));
}
JRadioButton stoker1=new JRadioButton("Stoker I");
stoker2=new JRadioButton("Stoker II");
ButtonGroup grp=new ButtonGroup();
grp.add(stoker1);
grp.add(stoker2);
stoker1.setSelected(!Configuration.getInstance().stokerII);
stoker2.setSelected(Configuration.getInstance().stokerII);
probeDialog.add(stoker1,Functions.makeGbc(1, row));
probeDialog.add(stoker2,Functions.makeGbc(2, row++));
JButton saveBtn = new JButton("OK");
saveBtn.addActionListener(new SaveButtonListener());
probeDialog.add(saveBtn,Functions.makeGbc(2, row));
probeDialog.pack();
probeDialog.setVisible(true);
Functions.logger("Probe configuration complete",false);
}