if (m.canExecute()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final ManipulatorUI ui = m.getUI();
//Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
if (ui != null) {
final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
DialogControls dialogControls = new DialogControlsImpl(okButton);
ui.setup(m, dialogControls);
JPanel settingsPanel = ui.getSettingsPanel();
DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(okButton)) {
ui.unSetup();
executeManipulatorInOtherThread(m);
} else {
ui.unSetup();
}
}
});
dd.setOptions(new Object[]{okButton, DialogDescriptor.CANCEL_OPTION});
dd.setClosingOptions(null);//All options close
Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
ui.unSetup();
}
});
dialog.setVisible(true);
} else {
executeManipulatorInOtherThread(m);