1
2
3
4
5
6
7
8
9
10
11
12
13 package org.abstracthorizon.aequo.text.action;
14
15 import java.awt.event.ActionEvent;
16 import java.awt.event.KeyEvent;
17 import java.io.IOException;
18
19 import javax.swing.Action;
20 import javax.swing.KeyStroke;
21
22 import org.abstracthorizon.aequo.gui.ErrorDialog;
23 import org.abstracthorizon.aequo.text.TextModel;
24
25
26
27
28
29
30 public class SaveAction extends TextBaseAction {
31
32
33
34
35 public SaveAction() {
36 setName("Save");
37 setMessage("Save");
38 setDescription("Save");
39 putValue(Action.MNEMONIC_KEY, KeyEvent.VK_S);
40 putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
41 }
42
43
44
45
46
47 public void perform(ActionEvent e) {
48 TextModel model = getTextModel();
49
50 String fileName = null;
51 try {
52 if (column == 0) {
53 fileName = model.getLeftFile().getAbsolutePath();
54 model.saveLeft();
55 } else {
56 fileName = model.getRightFile().getAbsolutePath();
57 model.saveRight();
58 }
59 } catch (IOException ex) {
60 ErrorDialog.showError(null, "Error saving file " + fileName, ex);
61 }
62 }
63
64 }