diff --git a/src/main/java/hrider/ui/controls/json/JsonEditor.java b/src/main/java/hrider/ui/controls/json/JsonEditor.java index d791995..165899d 100644 --- a/src/main/java/hrider/ui/controls/json/JsonEditor.java +++ b/src/main/java/hrider/ui/controls/json/JsonEditor.java @@ -50,7 +50,7 @@ public class JsonEditor extends JPanel { /** * Initializes a new instance of the {@link JsonEditor} class. */ - public JsonEditor() { + public JsonEditor(final CellEditor cellEditor) { this.textPane = new JsonTextPane(); this.textPane.setLayout(new BorderLayout()); @@ -70,8 +70,8 @@ public JsonEditor() { JPanel buttonsPanel = new JPanel(); buttonsPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); - JButton saveButton = new JButton("Save"); - saveButton.setPreferredSize(new Dimension(75, 24)); + JButton saveButton = new JButton("Mark for save"); + saveButton.setPreferredSize(new Dimension(115, 24)); saveButton.addActionListener( new ActionListener() { @Override @@ -81,6 +81,7 @@ public void actionPerformed(ActionEvent e) { JsonEditor.this.textPane.validateJson(); JsonEditor.this.textField.setText(JsonEditor.this.textPane.getText()); + cellEditor.stopCellEditing(); } catch (JsonSyntaxException ex) { JOptionPane.showMessageDialog(JsonEditor.this, ex.getMessage(), "Invalid JSON", JOptionPane.ERROR_MESSAGE); diff --git a/src/main/java/hrider/ui/controls/xml/XmlEditor.java b/src/main/java/hrider/ui/controls/xml/XmlEditor.java index 37f3f4e..37c8438 100644 --- a/src/main/java/hrider/ui/controls/xml/XmlEditor.java +++ b/src/main/java/hrider/ui/controls/xml/XmlEditor.java @@ -48,7 +48,7 @@ public class XmlEditor extends JPanel { /** * Initializes a new instance of the {@link XmlEditor} class. */ - public XmlEditor() { + public XmlEditor(final CellEditor cellEditor) { this.textPane = new XmlTextPane(); this.textPane.setLayout(new BorderLayout()); @@ -68,8 +68,8 @@ public XmlEditor() { JPanel buttonsPanel = new JPanel(); buttonsPanel.setBorder(new EmptyBorder(0, 0, 0, 0)); - JButton saveButton = new JButton("Save"); - saveButton.setPreferredSize(new Dimension(75, 24)); + JButton saveButton = new JButton("Mark for save"); + saveButton.setPreferredSize(new Dimension(115, 24)); saveButton.addActionListener( new ActionListener() { @Override @@ -79,6 +79,7 @@ public void actionPerformed(ActionEvent e) { XmlEditor.this.textPane.validateXml(); XmlEditor.this.textField.setText(XmlEditor.this.textPane.getText()); + cellEditor.stopCellEditing(); } catch (Exception ex) { JOptionPane.showMessageDialog(XmlEditor.this, ex.getMessage(), "Invalid XML", JOptionPane.ERROR_MESSAGE); diff --git a/src/main/java/hrider/ui/design/JCellEditor.java b/src/main/java/hrider/ui/design/JCellEditor.java index 9c7d6b7..017d8e7 100644 --- a/src/main/java/hrider/ui/design/JCellEditor.java +++ b/src/main/java/hrider/ui/design/JCellEditor.java @@ -71,9 +71,9 @@ public JCellEditor(ChangeTracker changeTracker, int typeColumn, boolean canEdit) this.dateEditor.setBorder(BorderFactory.createEmptyBorder()); this.dateEditor.setDateFormat(new SimpleDateFormat(GlobalConfig.instance().getDateFormat(), Locale.ENGLISH)); this.dateEditor.setFieldEditable(canEdit); - this.xmlEditor = new XmlEditor(); + this.xmlEditor = new XmlEditor(this); this.xmlEditor.setEditable(canEdit); - this.jsonEditor = new JsonEditor(); + this.jsonEditor = new JsonEditor(this); this.jsonEditor.setEditable(canEdit); } //endregion