1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.wizards.mapping;
20
21 import org.apache.syncope.common.lib.types.MappingPurpose;
22 import org.apache.wicket.AttributeModifier;
23 import org.apache.wicket.ajax.AjaxRequestTarget;
24 import org.apache.wicket.ajax.markup.html.AjaxLink;
25 import org.apache.wicket.markup.html.WebMarkupContainer;
26 import org.apache.wicket.markup.html.panel.Panel;
27 import org.apache.wicket.model.IModel;
28 import org.apache.wicket.model.Model;
29
30 public class MappingPurposePanel extends Panel {
31
32 private static final long serialVersionUID = 322966537010107771L;
33
34 private final AjaxLink<Void> propagation;
35
36 private final AjaxLink<Void> pull;
37
38 private final AjaxLink<Void> both;
39
40 private final AjaxLink<Void> none;
41
42 public MappingPurposePanel(final String componentId, final IModel<MappingPurpose> model,
43 final WebMarkupContainer container) {
44
45 super(componentId, model);
46
47 propagation = new AjaxLink<>("propagationPurposeLink") {
48
49 private static final long serialVersionUID = -6957616042924610305L;
50
51 @Override
52 public void onClick(final AjaxRequestTarget target) {
53 model.setObject(MappingPurpose.PROPAGATION);
54 setOpacity(MappingPurpose.PROPAGATION);
55 target.add(container);
56 }
57 };
58
59 pull = new AjaxLink<>("pullPurposeLink") {
60
61 private static final long serialVersionUID = -6957616042924610305L;
62
63 @Override
64 public void onClick(final AjaxRequestTarget target) {
65 model.setObject(MappingPurpose.PULL);
66 setOpacity(MappingPurpose.PULL);
67 target.add(container);
68 }
69 };
70
71 both = new AjaxLink<>("bothPurposeLink") {
72
73 private static final long serialVersionUID = -6957616042924610305L;
74
75 @Override
76 public void onClick(final AjaxRequestTarget target) {
77 model.setObject(MappingPurpose.BOTH);
78 setOpacity(MappingPurpose.BOTH);
79 target.add(container);
80 }
81 };
82
83 none = new AjaxLink<>("nonePurposeLink") {
84
85 private static final long serialVersionUID = -6957616042924610305L;
86
87 @Override
88 public void onClick(final AjaxRequestTarget target) {
89 model.setObject(MappingPurpose.NONE);
90 setOpacity(MappingPurpose.NONE);
91 target.add(container);
92 }
93 };
94
95 add(propagation);
96 add(pull);
97 add(both);
98 add(none);
99
100 setOpacity(model.getObject());
101 }
102
103 private void setOpacity(final MappingPurpose mappingPurpose) {
104 switch (mappingPurpose) {
105 case PROPAGATION:
106 propagation.add(new AttributeModifier("style", new Model<>("opacity: 1;")));
107 pull.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
108 both.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
109 none.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
110 break;
111
112 case PULL:
113 pull.add(new AttributeModifier("style", new Model<>("opacity: 1;")));
114 propagation.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
115 both.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
116 none.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
117 break;
118
119 case BOTH:
120 both.add(new AttributeModifier("style", new Model<>("opacity: 1;")));
121 propagation.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
122 pull.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
123 none.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
124 break;
125
126 case NONE:
127 none.add(new AttributeModifier("style", new Model<>("opacity: 1;")));
128 pull.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
129 propagation.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
130 both.add(new AttributeModifier("style", new Model<>("opacity: 0.3;")));
131 break;
132
133 default:
134
135 }
136 }
137 }