@Override
public final Component getEditor(Object o,
final ConfigurationChangeListener configListener,
final JComponent parent) {
final MatrixEditor matrixEditor = CreateMatrixEditor(o, configListener);
// Create asynchronous modal dialog to edit the matrix
//
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final Container parentContainer = parent.getRootPane().getParent();
final JDialog dialog = createDialog(parentContainer, matrixEditor);
// Create buttons
//
// The matrix editor will not use the configListener as a
// listener, but
// conversely notify it of changes. This is because the Config
// listener only support
// one type of "save" event.
//
JButton okButton, cancelButton;
{
matrixEditor.getControlPanel().add(new JSeparator(JSeparator.VERTICAL));
okButton = new JButton("Save Changes");
matrixEditor.getControlPanel().add(okButton);
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
matrixEditor.finishEditing();
configListener.commitChanges();
dialog.setVisible(false);
}
});
cancelButton = new JButton("Cancel");
matrixEditor.getControlPanel().add(cancelButton);
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
configListener.cancelChanges();
dialog.setVisible(false);
}
});
}
// Set preferred size
{
int desiredWidth = Math.min(matrixEditor.getColumnCount() * 70 + 100, 1024);
desiredWidth = Math.max(desiredWidth, 600);
int desiredHeight = Math.min(matrixEditor.getRowCount() * 30 + 150, 768);
dialog.setPreferredSize(new Dimension(desiredWidth, desiredHeight));
}
dialog.pack();
if (parentContainer != null) {