From 24f2903ef45dd86923ef6002597fb89d4af5af62 Mon Sep 17 00:00:00 2001 From: romanman Date: Sat, 31 May 2014 16:31:21 +0300 Subject: [PATCH] Serpent editor add Ctrl + Shift + S for change saving file --- .../java/org/ethereum/gui/SerpentEditor.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/gui/SerpentEditor.java b/ethereumj-core/src/main/java/org/ethereum/gui/SerpentEditor.java index 84ea19c0..3fe221f3 100644 --- a/ethereumj-core/src/main/java/org/ethereum/gui/SerpentEditor.java +++ b/ethereumj-core/src/main/java/org/ethereum/gui/SerpentEditor.java @@ -311,6 +311,21 @@ public class SerpentEditor extends JFrame { final JButton button = new JButton(imageIcon); button.setToolTipText("Save File < Ctrl + S >"); + + Action saveNewFile = new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + button.doClick(); + } + }; + + mainContentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW). + put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK), + "OpenSaveButtonAlways"); + + mainContentPane.getActionMap().put("OpenSaveButtonAlways",saveNewFile); + + Action saveFile = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { @@ -330,12 +345,16 @@ public class SerpentEditor extends JFrame { public void actionPerformed(ActionEvent e) { File file = null; - if (fileChooser == null || fileChooser.getSelectedFile() == null) { + + if (e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)){ file = callFileChooser(); - if (fileChooser.getSelectedFile() == null) + if (file == null) return; - } - else{ + } else if (fileChooser == null || fileChooser.getSelectedFile() == null) { + file = callFileChooser(); + if (file == null) + return; + } else{ file = fileChooser.getSelectedFile(); }