Serpent editor add Ctrl + Shift + S for change saving file
This commit is contained in:
parent
90962d0db1
commit
24f2903ef4
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue