Skip to content

Package: ResetAction

ResetAction

nameinstructionbranchcomplexitylinemethod
ResetAction(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: 7 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%
performReset()
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: import networkconfigurator.LoadConfigurationGraphException;
13:
14: /**
15: * resets all changes.
16: *
17: * @author admin
18: *
19: */
20: public class ResetAction extends AbstractAction {
21:
22:         /**
23:          * the configuration graph.
24:          */
25:         private final ConfigurationGraph graph;
26:
27:         /**
28:          * the constructor.
29:          *
30:          * @param graph
31:          * the graph.
32:          */
33:         public ResetAction(final ConfigurationGraph graph) {
34:                 super();
35:                 this.graph = graph;
36:         }
37:
38:         @Override
39:         public void actionPerformed(final ActionEvent e) {
40:                 final int reply =
41:                                 JOptionPane.showConfirmDialog(null, GuiConstants.DO_YOU_WANT_TO_RESET_ALL_CHANGES,
42:                                                 "Reset", JOptionPane.YES_NO_OPTION);
43:•                if (reply == JOptionPane.YES_OPTION) {
44:                         performReset();
45:                         JOptionPane.showMessageDialog(null, GuiConstants.ALL_CHANGES_WERE_RESET);
46:                 } else {
47:                         JOptionPane.showMessageDialog(null, GuiConstants.NO_CHANGES_WERE_RESET);
48:                 }
49:         }
50:
51:         /**
52:          * performs the reset process.
53:          *
54:          * @param we
55:          * the window event
56:          */
57:         public void actionPerformed(final WindowEvent we) {
58:                 performReset();
59:         }
60:
61:         /**
62:          * Performs the reset action.
63:          *
64:          */
65:         private void performReset() {
66:                 try {
67:                         graph.resetConfig();
68:                 } catch (final IOException | LoadConfigurationGraphException ioe) {
69:                         JOptionPane.showMessageDialog(null, GuiConstants.CAN_NOT_LOAD_FROM_THE_DIRECTORY,
70:                                         "Error", JOptionPane.ERROR_MESSAGE);
71:                 }
72:         }
73: }