View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.console.widgets;
20  
21  import de.agilecoders.wicket.core.markup.html.bootstrap.image.Icon;
22  import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesome5IconType;
23  import java.util.List;
24  import org.apache.syncope.client.console.wizards.mapping.ItemTransformersTogglePanel;
25  import org.apache.syncope.common.lib.to.Item;
26  import org.apache.wicket.ajax.AjaxRequestTarget;
27  import org.apache.wicket.ajax.markup.html.AjaxLink;
28  import org.apache.wicket.markup.html.link.AbstractLink;
29  import org.apache.wicket.model.IModel;
30  import org.apache.wicket.model.util.ListModel;
31  
32  public class ItemTransformerWidget extends AlertWidget<String> {
33  
34      private static final long serialVersionUID = 7667120094526529934L;
35  
36      private final Item item;
37  
38      private final ItemTransformersTogglePanel transformers;
39  
40      public ItemTransformerWidget(
41              final String id,
42              final Item item,
43              final ItemTransformersTogglePanel transformers) {
44  
45          super(id);
46          this.item = item;
47          this.transformers = transformers;
48          setOutputMarkupId(true);
49      }
50  
51      @Override
52      protected IModel<List<String>> getLatestAlerts() {
53          return new ListModel<>() {
54  
55              private static final long serialVersionUID = 1232998477036705088L;
56  
57              @Override
58              public List<String> getObject() {
59                  return item.getTransformers();
60              }
61          };
62      }
63  
64      @Override
65      protected AbstractLink getEventsLink(final String linkid) {
66          return new AjaxLink<String>(linkid) {
67  
68              private static final long serialVersionUID = -7978723352517770644L;
69  
70              @Override
71              public void onClick(final AjaxRequestTarget target) {
72                  transformers.setItem(target, ItemTransformerWidget.this.item);
73                  transformers.toggle(target, true);
74              }
75          };
76      }
77  
78      @Override
79      protected Icon getIcon(final String iconid) {
80          return new Icon(iconid, FontAwesome5IconType.magic_s);
81      }
82  }