Skip to content

Commit

Permalink
Fix issue #47
Browse files Browse the repository at this point in the history
Usability improvements when editing cells containing xml or json
  • Loading branch information
Igor Cher committed Aug 28, 2013
1 parent 3cb477d commit d6a49dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/main/java/hrider/ui/controls/json/JsonEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/hrider/ui/controls/xml/XmlEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hrider/ui/design/JCellEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d6a49dd

Please sign in to comment.