From aaa1409908683dd95fd5df987d29386c50e9e92b Mon Sep 17 00:00:00 2001 From: hneemann Date: Mon, 1 May 2017 11:52:57 +0200 Subject: [PATCH] fixed loss of values if test data dialog is opened in detached mode. --- .../digital/gui/components/AttributeDialog.java | 15 ++++++++++++--- .../gui/components/testing/TestDataEditor.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/neemann/digital/gui/components/AttributeDialog.java b/src/main/java/de/neemann/digital/gui/components/AttributeDialog.java index 98e05fa67..bbb9fec6d 100644 --- a/src/main/java/de/neemann/digital/gui/components/AttributeDialog.java +++ b/src/main/java/de/neemann/digital/gui/components/AttributeDialog.java @@ -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 AttributeDialog(Component parent, Point pos, java.util.List list, El 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 AttributeDialog(Component parent, Point pos, java.util.List list, El @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 void actionPerformed(ActionEvent e) { setAlwaysOnTop(true); } + /** + * Closes the dialog and stores modified values + */ + public void fireOk() { + setEditedValues(elementAttributes); + changed = true; + dispose(); + } + /** * Adds a button to this dialog * diff --git a/src/main/java/de/neemann/digital/gui/components/testing/TestDataEditor.java b/src/main/java/de/neemann/digital/gui/components/testing/TestDataEditor.java index 208aeb0aa..eb62b8f54 100644 --- a/src/main/java/de/neemann/digital/gui/components/testing/TestDataEditor.java +++ b/src/main/java/de/neemann/digital/gui/components/testing/TestDataEditor.java @@ -50,7 +50,7 @@ public void actionPerformed(ActionEvent e) { 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)