fixed loss of values if test data dialog is opened in detached mode.

This commit is contained in:
hneemann 2017-05-01 11:52:57 +02:00
parent 4f3154958f
commit aaa1409908
2 changed files with 13 additions and 4 deletions

View File

@ -28,6 +28,7 @@ public class AttributeDialog extends JDialog {
private final JPanel panel;
private final Component parent;
private final Point pos;
private final ElementAttributes elementAttributes;
private final JPanel buttonPanel;
private boolean changed = false;
@ -54,6 +55,7 @@ public class AttributeDialog extends JDialog {
super(SwingUtilities.getWindowAncestor(parent), Lang.get("attr_dialogTitle"), ModalityType.APPLICATION_MODAL);
this.parent = parent;
this.pos = pos;
this.elementAttributes = elementAttributes;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
panel = new JPanel(new DialogLayout());
@ -72,9 +74,7 @@ public class AttributeDialog extends JDialog {
@Override
public void actionPerformed(ActionEvent e) {
try {
setEditedValues(elementAttributes);
changed = true;
dispose();
fireOk();
} catch (RuntimeException err) {
new ErrorMessage(Lang.get("msg_errorEditingValue")).addCause(err).setComponent(AttributeDialog.this).show();
}
@ -101,6 +101,15 @@ public class AttributeDialog extends JDialog {
setAlwaysOnTop(true);
}
/**
* Closes the dialog and stores modified values
*/
public void fireOk() {
setEditedValues(elementAttributes);
changed = true;
dispose();
}
/**
* Adds a button to this dialog
*

View File

@ -50,7 +50,7 @@ public class TestDataEditor extends EditorFactory.LabelEditor<TestData> {
panel.add(new ToolTipAction(Lang.get("btn_editDetached")) {
@Override
public void actionPerformed(ActionEvent e) {
getAttributeDialog().dispose();
getAttributeDialog().fireOk();
TestDataDialog dialog = new TestDataDialog(getAttributeDialog().getDialogParent(), data, key, elementAttributes);
Main main = getAttributeDialog().getMain();
if (main!=null)