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.pages;
20  
21  import java.io.Serializable;
22  import org.apache.commons.lang3.StringUtils;
23  import org.apache.syncope.client.console.panels.ConnectorDirectoryPanel;
24  import org.apache.syncope.client.console.rest.ConnectorRestClient;
25  import org.apache.syncope.client.console.wizards.WizardMgtPanel;
26  import org.apache.syncope.client.console.wizards.resources.ConnectorWizardBuilder;
27  import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
28  import org.apache.syncope.common.lib.to.ConnInstanceTO;
29  import org.apache.wicket.PageReference;
30  import org.apache.wicket.ajax.AjaxRequestTarget;
31  import org.apache.wicket.ajax.markup.html.form.AjaxButton;
32  import org.apache.wicket.event.Broadcast;
33  import org.apache.wicket.markup.html.WebMarkupContainer;
34  import org.apache.wicket.markup.html.form.Form;
35  import org.apache.wicket.markup.html.panel.Panel;
36  import org.apache.wicket.model.Model;
37  import org.apache.wicket.spring.injection.annot.SpringBean;
38  
39  public class Connectors extends Panel {
40  
41      private static final long serialVersionUID = 305521359617401936L;
42  
43      @SpringBean
44      protected ConnectorRestClient connectorRestClient;
45  
46      public Connectors(final String id, final PageReference pageRef) {
47          super(id);
48  
49          Model<String> keywordModel = new Model<>(StringUtils.EMPTY);
50  
51          WebMarkupContainer searchBoxContainer = new WebMarkupContainer("searchBox");
52          add(searchBoxContainer);
53  
54          Form<?> form = new Form<>("form");
55          searchBoxContainer.add(form);
56  
57          AjaxTextFieldPanel filter = new AjaxTextFieldPanel("filter", "filter", keywordModel, true);
58          form.add(filter.hideLabel().setOutputMarkupId(true));
59  
60          AjaxButton search = new AjaxButton("search") {
61  
62              private static final long serialVersionUID = 8390605330558248736L;
63  
64              @Override
65              protected void onSubmit(final AjaxRequestTarget target) {
66                  send(Connectors.this, Broadcast.DEPTH,
67                          new ConnectorDirectoryPanel.ConnectorSearchEvent(target, keywordModel.getObject()));
68              }
69          };
70          search.setOutputMarkupId(true);
71          form.add(search);
72          form.setDefaultButton(search);
73  
74          WizardMgtPanel<Serializable> connectorDirectoryPanel =
75                  new ConnectorDirectoryPanel.Builder(connectorRestClient, pageRef).
76                          addNewItemPanelBuilder(new ConnectorWizardBuilder(
77                                  new ConnInstanceTO(), connectorRestClient, pageRef), true).
78                          build("connectorDirectoryPanel");
79          add(connectorDirectoryPanel.setOutputMarkupId(true));
80      }
81  }