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 org.apache.syncope.client.console.wizards.mapping.ItemTransformersTogglePanel;
24  import org.apache.syncope.common.lib.to.Item;
25  import org.apache.wicket.ajax.AjaxRequestTarget;
26  import org.apache.wicket.ajax.markup.html.AjaxLink;
27  import org.apache.wicket.markup.html.link.AbstractLink;
28  
29  public class ItemTransformerWidget extends AlertWidget {
30  
31      private static final long serialVersionUID = 7667120094526529934L;
32  
33      private final Item item;
34  
35      private final ItemTransformersTogglePanel transformers;
36  
37      public ItemTransformerWidget(
38              final String id,
39              final Item item,
40              final ItemTransformersTogglePanel transformers) {
41  
42          super(id);
43          this.item = item;
44          this.transformers = transformers;
45      }
46  
47      @Override
48      protected long getLatestAlertsSize() {
49          return item.getTransformers().size();
50      }
51  
52      @Override
53      protected AbstractLink getEventsLink(final String linkid) {
54          return new AjaxLink<String>(linkid) {
55  
56              private static final long serialVersionUID = -7978723352517770644L;
57  
58              @Override
59              public void onClick(final AjaxRequestTarget target) {
60                  transformers.setItem(target, ItemTransformerWidget.this.item);
61                  transformers.toggle(target, true);
62              }
63          };
64      }
65  
66      @Override
67      protected Icon getIcon(final String iconid) {
68          return new Icon(iconid, FontAwesome5IconType.magic_s);
69      }
70  }