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 de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
22  import java.util.ArrayList;
23  import java.util.List;
24  import org.apache.syncope.client.console.SyncopeWebApplication;
25  import org.apache.syncope.client.console.panels.DashboardAccessTokensPanel;
26  import org.apache.syncope.client.console.panels.DashboardControlPanel;
27  import org.apache.syncope.client.console.panels.DashboardExtensionsPanel;
28  import org.apache.syncope.client.console.panels.DashboardOverviewPanel;
29  import org.apache.syncope.client.console.widgets.BaseExtWidget;
30  import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
31  import org.apache.wicket.extensions.markup.html.tabs.ITab;
32  import org.apache.wicket.markup.html.WebMarkupContainer;
33  import org.apache.wicket.markup.html.panel.Panel;
34  import org.apache.wicket.model.ResourceModel;
35  import org.apache.wicket.request.mapper.parameter.PageParameters;
36  
37  public class Dashboard extends BasePage {
38  
39      private static final long serialVersionUID = -1100228004207271270L;
40  
41      public Dashboard(final PageParameters parameters) {
42          super(parameters);
43  
44          WebMarkupContainer content = new WebMarkupContainer("content");
45          content.setOutputMarkupId(true);
46          content.add(new AjaxBootstrapTabbedPanel<>("tabbedPanel", buildTabList()));
47          body.add(content);
48      }
49  
50      private List<ITab> buildTabList() {
51          final List<ITab> tabs = new ArrayList<>();
52  
53          tabs.add(new AbstractTab(new ResourceModel("overview")) {
54  
55              private static final long serialVersionUID = -6815067322125799251L;
56  
57              @Override
58              public Panel getPanel(final String panelId) {
59                  return new DashboardOverviewPanel(panelId);
60              }
61          });
62  
63          tabs.add(new AbstractTab(new ResourceModel("accessTokens")) {
64  
65              private static final long serialVersionUID = -6815067322125799251L;
66  
67              @Override
68              public Panel getPanel(final String panelId) {
69                  return new DashboardAccessTokensPanel(panelId, getPageReference());
70              }
71          });
72  
73          tabs.add(new AbstractTab(new ResourceModel("control")) {
74  
75              private static final long serialVersionUID = -6815067322125799251L;
76  
77              @Override
78              public Panel getPanel(final String panelId) {
79                  return new DashboardControlPanel(panelId, getPageReference());
80              }
81          });
82  
83          List<Class<? extends BaseExtWidget>> extWidgetClasses =
84                  SyncopeWebApplication.get().getLookup().getClasses(BaseExtWidget.class);
85          if (!extWidgetClasses.isEmpty()) {
86              tabs.add(new AbstractTab(new ResourceModel("extensions")) {
87  
88                  private static final long serialVersionUID = -6815067322125799251L;
89  
90                  @Override
91                  public Panel getPanel(final String panelId) {
92                      return new DashboardExtensionsPanel(panelId, extWidgetClasses, getPageReference());
93                  }
94              });
95          }
96  
97          return tabs;
98      }
99  }