Skip to content

Commit

Permalink
fixed loss of values if test data dialog is opened in detached mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
hneemann committed May 1, 2017
1 parent 4f31549 commit aaa1409
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -54,6 +55,7 @@ public AttributeDialog(Component parent, Point pos, java.util.List<Key> 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());
Expand All @@ -72,9 +74,7 @@ public AttributeDialog(Component parent, Point pos, java.util.List<Key> 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();
}
Expand All @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit aaa1409

Please sign in to comment.