/** Update. */ public void update() { Protocol p = device.getProtocol(); p.setDeviceParms(device.getValues()); updateParameters(); protocolList.setSelectedItem(p); if (protocolList.getSelectedItem() != p) { protocolList.addItem(p); protocolList.setSelectedItem(p); } fixedData.getDocument().removeDocumentListener(this); protocolID.getDocument().removeDocumentListener(this); deviceNotes.getDocument().removeDocumentListener(this); fixedData.setText(device.getFixedData().toString()); Hex id = p.getID(remote); if (id != null) protocolID.setText(id.toString()); else protocolID.setText(null); deviceNotes.setText(device.getNotes()); fixedData.getDocument().addDocumentListener(this); protocolID.getDocument().addDocumentListener(this); deviceNotes.getDocument().addDocumentListener(this); protocolNotes.setText(p.getNotes()); protocolNotes.setCaretPosition(0); }
/* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (source == protocolList) { Protocol newProtocol = (Protocol) protocolList.getSelectedItem(); Protocol oldProtocol = device.getProtocol(); if (newProtocol != oldProtocol) { oldProtocol.reset(); protocolID.getDocument().removeDocumentListener(this); Hex id = newProtocol.getID(remote); if (id != null) protocolID.setText(id.toString()); else protocolID.setText(null); protocolID.getDocument().addDocumentListener(this); device.setProtocol(newProtocol); updateParameters(); fixedData.getDocument().removeDocumentListener(this); fixedData.setText(newProtocol.getFixedData(newProtocol.getDeviceParmValues()).toString()); fixedData.getDocument().addDocumentListener(this); boolean flag = (newProtocol.getClass() == ManualProtocol.class); fixedData.setEditable(flag); protocolID.setEditable(flag); validate(); protocolNotes.setText(newProtocol.getNotes()); protocolNotes.setCaretPosition(0); protocolNotes.revalidate(); } } if (source == cancelButton) { userAction = JOptionPane.CANCEL_OPTION; setVisible(false); removeParameters(parameters); device.getProtocol().reset(); dispose(); } else if (source == okButton) { userAction = JOptionPane.OK_OPTION; setVisible(false); removeParameters(parameters); device.getProtocol().reset(); dispose(); } else // must be a protocol parameter updateFixedData(); } // actionPerformed