1 | |
package org.jtheque.primary; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.feature.AbstractMenu; |
20 | |
import org.jtheque.core.managers.feature.Feature; |
21 | |
import org.jtheque.primary.od.able.SimpleData; |
22 | |
import org.jtheque.primary.view.impl.actions.borrower.AcNewBorrower; |
23 | |
import org.jtheque.primary.view.impl.actions.choice.ChoiceViewAction; |
24 | |
import org.jtheque.primary.view.impl.actions.simple.NewSimpleDataAction; |
25 | |
import org.jtheque.utils.collections.CollectionUtils; |
26 | |
|
27 | |
import java.util.Collection; |
28 | |
import java.util.List; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
final class PrimaryMenu extends AbstractMenu { |
36 | |
private final Collection<Feature> addFeatures; |
37 | |
private final Collection<Feature> removeFeatures; |
38 | |
private final Collection<Feature> editFeatures; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
public PrimaryMenu(Collection<Feature> addFeatures, Collection<Feature> removeFeatures, Collection<Feature> editFeatures){ |
48 | 0 | super(); |
49 | |
|
50 | 0 | this.addFeatures = CollectionUtils.copyOf(addFeatures); |
51 | 0 | this.removeFeatures = CollectionUtils.copyOf(removeFeatures); |
52 | 0 | this.editFeatures = CollectionUtils.copyOf(editFeatures); |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
protected List<Feature> getMenuMainFeatures(){ |
57 | 0 | return features( |
58 | |
createMainFeature(500, "menu.others", |
59 | |
createNewFeature(), |
60 | |
createDeleteFeature(), |
61 | |
createEditFeature()) |
62 | |
); |
63 | |
} |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
private Feature createNewFeature(){ |
71 | 0 | Feature newFeature = createSubFeature(1, "menu.others.new", |
72 | |
createSubFeature(1, new NewSimpleDataAction("menu.others.kind", "kindController")), |
73 | |
createSubFeature(2, new NewSimpleDataAction("menu.others.type", "typeController")), |
74 | |
createSubFeature(3, new NewSimpleDataAction("menu.others.language", "languageController")), |
75 | |
createSubFeature(4, new NewSimpleDataAction("menu.others.country", "countryController")), |
76 | |
createSubFeature(5, new AcNewBorrower()), |
77 | |
createSubFeature(6, new NewSimpleDataAction("menu.others.saga", "sagaController"))); |
78 | |
|
79 | 0 | fillFeature(newFeature, addFeatures); |
80 | |
|
81 | 0 | return newFeature; |
82 | |
} |
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
private Feature createDeleteFeature(){ |
90 | 0 | Feature deleteFeature = createSubFeature(2, "menu.others.delete", |
91 | |
createSubFeature(1, new ChoiceViewAction("menu.others.kind", PrimaryConstants.ChoiceActions.DELETE, SimpleData.DataType.KIND.getDataType())), |
92 | |
createSubFeature(2, new ChoiceViewAction("menu.others.type", PrimaryConstants.ChoiceActions.DELETE, SimpleData.DataType.TYPE.getDataType())), |
93 | |
createSubFeature(3, new ChoiceViewAction("menu.others.language", PrimaryConstants.ChoiceActions.DELETE, SimpleData.DataType.LANGUAGE.getDataType())), |
94 | |
createSubFeature(4, new ChoiceViewAction("menu.others.country", PrimaryConstants.ChoiceActions.DELETE, SimpleData.DataType.COUNTRY.getDataType())), |
95 | |
createSubFeature(5, new ChoiceViewAction("menu.others.borrower", PrimaryConstants.ChoiceActions.DELETE, "Borrowers")), |
96 | |
createSubFeature(6, new ChoiceViewAction("menu.others.saga", PrimaryConstants.ChoiceActions.DELETE, SimpleData.DataType.SAGA.getDataType()))); |
97 | |
|
98 | |
|
99 | 0 | fillFeature(deleteFeature, removeFeatures); |
100 | |
|
101 | 0 | return deleteFeature; |
102 | |
} |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
private Feature createEditFeature(){ |
110 | 0 | Feature editFeature = createSubFeature(3, "menu.others.edit", |
111 | |
createSubFeature(1, new ChoiceViewAction("menu.others.kind", PrimaryConstants.ChoiceActions.EDIT, SimpleData.DataType.KIND.getDataType())), |
112 | |
createSubFeature(2, new ChoiceViewAction("menu.others.type", PrimaryConstants.ChoiceActions.EDIT, SimpleData.DataType.TYPE.getDataType())), |
113 | |
createSubFeature(3, new ChoiceViewAction("menu.others.language", PrimaryConstants.ChoiceActions.EDIT, SimpleData.DataType.LANGUAGE.getDataType())), |
114 | |
createSubFeature(4, new ChoiceViewAction("menu.others.country", PrimaryConstants.ChoiceActions.EDIT, SimpleData.DataType.COUNTRY.getDataType())), |
115 | |
createSubFeature(5, new ChoiceViewAction("menu.others.borrower", PrimaryConstants.ChoiceActions.EDIT, "Borrowers")), |
116 | |
createSubFeature(6, new ChoiceViewAction("menu.others.saga", PrimaryConstants.ChoiceActions.EDIT, SimpleData.DataType.SAGA.getDataType()))); |
117 | |
|
118 | 0 | fillFeature(editFeature, editFeatures); |
119 | |
|
120 | 0 | return editFeature; |
121 | |
} |
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
private static void fillFeature(Feature feature, Iterable<Feature> features){ |
130 | 0 | for (Feature f : features){ |
131 | 0 | feature.addSubFeature(f); |
132 | |
} |
133 | 0 | } |
134 | |
} |