Skip to content

Package: SaveAction

SaveAction

nameinstructionbranchcomplexitylinemethod
SaveAction(ConfigurationGraph)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
actionPerformed(ActionEvent)
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
actionPerformed(WindowEvent)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
performSave()
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package networkconfigurator.actions;
2:
3: import java.awt.event.ActionEvent;
4: import java.awt.event.WindowEvent;
5: import java.io.IOException;
6:
7: import javax.swing.AbstractAction;
8: import javax.swing.JOptionPane;
9:
10: import basic.GuiConstants;
11: import networkconfigurator.ConfigurationGraph;
12:
13: /**
14: * saves all changes.
15: *
16: * @author admin
17: *
18: */
19: public class SaveAction extends AbstractAction {
20:         /**
21:          * the configuration graph.
22:          */
23:         private final ConfigurationGraph graph;
24:
25:         /**
26:          * the constructor.
27:          *
28:          * @param graph
29:          * the graph.
30:          */
31:         public SaveAction(final ConfigurationGraph graph) {
32:                 super();
33:                 this.graph = graph;
34:         }
35:
36:         @Override
37:         public void actionPerformed(final ActionEvent e) {
38:                 final int reply = JOptionPane.showConfirmDialog(null,
39:                                 GuiConstants.DO_YOU_WANT_TO_SAVE_ALL_CHANGES, "Save", JOptionPane.YES_NO_OPTION);
40:•                if (reply == JOptionPane.YES_OPTION) {
41:                         performSave();
42:                         JOptionPane.showMessageDialog(null, GuiConstants.ALL_CHANGES_WERE_SAVED);
43:                 } else {
44:                         JOptionPane.showMessageDialog(null, GuiConstants.NO_CHANGES_WERE_SAVED);
45:                 }
46:
47:         }
48:
49:         /**
50:          * performs the save process.
51:          *
52:          * @param we
53:          * the window event
54:          */
55:         public void actionPerformed(final WindowEvent we) {
56:                 performSave();
57:         }
58:
59:         /**
60:          * Performs the save action.
61:          */
62:         private void performSave() {
63:                 try {
64:                         graph.saveConfig();
65:                 } catch (final IOException ioe) {
66:                         JOptionPane.showMessageDialog(null, GuiConstants.CAN_NOT_SAVE_TO_THE_DIRECTORY,
67:                                         "Error", JOptionPane.ERROR_MESSAGE);
68:                 }
69:         }
70: }