1 package fr.ifremer.tutti.ui.swing.content.operation.catches.actions;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import com.google.common.base.Preconditions;
26 import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
27 import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
28 import fr.ifremer.tutti.ui.swing.util.actions.LongActionSupport;
29 import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUI;
30 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI;
31 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler;
32 import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
33 import fr.ifremer.tutti.ui.swing.content.operation.fishing.actions.EditFishingOperationAction;
34 import org.apache.commons.logging.Log;
35 import org.apache.commons.logging.LogFactory;
36
37
38
39
40
41
42
43 public class CancelEditCatchBatchAction extends LongActionSupport<EditCatchesUIModel, EditCatchesUI, EditCatchesUIHandler> {
44
45
46 private static final Log log =
47 LogFactory.getLog(CancelEditCatchBatchAction.class);
48
49
50
51
52
53
54
55
56 protected EditFishingOperationAction editAction;
57
58 public CancelEditCatchBatchAction(EditCatchesUIHandler handler) {
59 super(handler, true);
60 }
61
62 public EditFishingOperationAction getEditAction() {
63 if (editAction == null) {
64 FishingOperationsUI parentContainer = handler.getParentContainer(FishingOperationsUI.class);
65 editAction = getContext().getActionFactory().createLogicAction(parentContainer.getHandler(),
66 EditFishingOperationAction.class);
67 }
68 return editAction;
69 }
70
71 @Override
72 public void doAction() throws Exception {
73
74
75
76 Preconditions.checkState(
77 !getModel().isCreate(),
78 "Can't cancel edition of a not persisted catchBatch!");
79
80 if (log.isInfoEnabled()) {
81 log.info("Can edition of catchBatch (will reload catchBatch)");
82 }
83
84 FishingOperation operation = getModel().getFishingOperation();
85
86 getEditAction().loadCatchBatch(operation);
87 }
88
89 }