Serpent editor add Ctrl + Shift + S for change saving file

This commit is contained in:
romanman 2014-05-31 16:31:21 +03:00
parent 90962d0db1
commit 24f2903ef4
1 changed files with 23 additions and 4 deletions

View File

@ -311,6 +311,21 @@ public class SerpentEditor extends JFrame {
final JButton button = new JButton(imageIcon); final JButton button = new JButton(imageIcon);
button.setToolTipText("Save File < Ctrl + S >"); 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() { Action saveFile = new AbstractAction() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -330,12 +345,16 @@ public class SerpentEditor extends JFrame {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
File file = null; File file = null;
if (fileChooser == null || fileChooser.getSelectedFile() == null) {
if (e.getModifiers() == (InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK)){
file = callFileChooser(); file = callFileChooser();
if (fileChooser.getSelectedFile() == null) if (file == null)
return; return;
} } else if (fileChooser == null || fileChooser.getSelectedFile() == null) {
else{ file = callFileChooser();
if (file == null)
return;
} else{
file = fileChooser.getSelectedFile(); file = fileChooser.getSelectedFile();
} }