Skip to content

Package: ActionCollector

ActionCollector

nameinstructionbranchcomplexitylinemethod
ActionCollector()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
add(MasterDetailAction)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addAll(Collection)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
addCopyAction(EditingDomain)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addCutAction(EditingDomain)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addPasteAction(EditingDomain)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getList()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
newList()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Stefan Dirix - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.spi.swt.treemasterdetail.actions;
15:
16: import java.util.Collection;
17: import java.util.LinkedList;
18: import java.util.List;
19:
20: import org.eclipse.emf.edit.domain.EditingDomain;
21: import org.eclipse.emfforms.spi.swt.treemasterdetail.actions.delegating.CopyMasterDetailAction;
22: import org.eclipse.emfforms.spi.swt.treemasterdetail.actions.delegating.CutMasterDetailAction;
23: import org.eclipse.emfforms.spi.swt.treemasterdetail.actions.delegating.PasteMasterDetailAction;
24:
25: /**
26: * Helper class to dot-link the creation of {@link MasterDetailAction} collections.
27: *
28: * @author Stefan Dirix
29: * @since 1.8
30: *
31: */
32: public class ActionCollector {
33:
34:         private final List<MasterDetailAction> list;
35:
36:         /**
37:          * Constructor.
38:          */
39:         public ActionCollector() {
40:                 list = new LinkedList<MasterDetailAction>();
41:         }
42:
43:         /**
44:          * Adds the given {@link MasterDetailAction} to the collection.
45:          *
46:          * @param action
47:          * The {@link MasterDetailAction} to add.
48:          * @return
49:          *                 self.
50:          */
51:         public ActionCollector add(MasterDetailAction action) {
52:                 list.add(action);
53:                 return this;
54:         }
55:
56:         /**
57:          * Adds the given collection of {@link MasterDetailAction}s to the collection.
58:          *
59:          * @param collection
60:          * The collection of {@link MasterDetailAction}s to add.
61:          * @return
62:          *                 self.
63:          */
64:         public ActionCollector addAll(Collection<? extends MasterDetailAction> collection) {
65:                 list.addAll(collection);
66:                 return this;
67:         }
68:
69:         /**
70:          * Adds the {@link CopyMasterDetailAction} to the collection.
71:          *
72:          * @param editingDomain
73:          * The {@link EditingDomain} used to create the {@link CopyMasterDetailAction}.
74:          * @return
75:          *                 self.
76:          */
77:         public ActionCollector addCopyAction(EditingDomain editingDomain) {
78:                 list.add(new CopyMasterDetailAction(editingDomain));
79:                 return this;
80:         }
81:
82:         /**
83:          * Adds the {@link PasteMasterDetailAction} to the collection.
84:          *
85:          * @param editingDomain
86:          * The {@link EditingDomain} used to create the {@link PasteMasterDetailAction}.
87:          * @return
88:          *                 self.
89:          */
90:         public ActionCollector addPasteAction(EditingDomain editingDomain) {
91:                 list.add(new PasteMasterDetailAction(editingDomain));
92:                 return this;
93:         }
94:
95:         /**
96:          * Adds the {@link CutMasterDetailAction} to the collection.
97:          *
98:          * @param editingDomain
99:          * The {@link EditingDomain} used to create the {@link CutMasterDetailAction}.
100:          * @return
101:          *                 self.
102:          */
103:         public ActionCollector addCutAction(EditingDomain editingDomain) {
104:                 list.add(new CutMasterDetailAction(editingDomain));
105:                 return this;
106:         }
107:
108:         /**
109:          * Returns the collected list of {@link MasterDetailAction}s.
110:          *
111:          * @return
112:          *                 The collection of {@link MasterDetailAction}s.
113:          */
114:         public List<MasterDetailAction> getList() {
115:                 return list;
116:         }
117:
118:         /**
119:          * Start a new collection.
120:          *
121:          * @return
122:          *                 A new {@link ActionCollector}.
123:          */
124:         public static ActionCollector newList() {
125:                 return new ActionCollector();
126:         }
127: }