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