View Javadoc
1   package fr.ifremer.quadrige3.synchro.server.pages.doc;
2   
3   /*-
4    * #%L
5    * Quadrige3 Core :: Quadrige3 Synchro server
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2017 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  import fr.ifremer.quadrige3.synchro.server.pages.BasePage;
27  import fr.ifremer.quadrige3.synchro.server.pages.doc.api.ServiceApiPage;
28  import fr.ifremer.quadrige3.synchro.server.pages.doc.synchro.SynchroTablePage;
29  import org.apache.wicket.ajax.AjaxRequestTarget;
30  import org.apache.wicket.ajax.markup.html.form.AjaxButton;
31  import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
32  import org.apache.wicket.markup.html.form.Form;
33  import org.apache.wicket.model.CompoundPropertyModel;
34  import org.apache.wicket.model.IModel;
35  import org.apache.wicket.request.mapper.parameter.PageParameters;
36  
37  @AuthorizeInstantiation("ROLE_USER")
38  public class DocPage extends BasePage {
39  
40      public DocPage(final PageParameters parameters) {
41          super(parameters);
42  
43          IModel<DocPage> model = new CompoundPropertyModel<>(this);
44  
45          setVersioned(false);
46  
47          final boolean isUserAdmin = getWebSession().isUserAdmin();
48  
49          Form<DocPage> form = new Form<>("form", model);
50          form.setOutputMarkupId(true);
51          add(form);
52  
53          // serviceApiLink button
54          AjaxButton synchroButton = new AjaxButton("serviceApiLink", form) {
55              @Override
56              protected void onConfigure() {
57                  super.onConfigure();
58                  setVisibilityAllowed(isUserAdmin);
59              }
60  
61              @Override
62              protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
63                  setResponsePage(ServiceApiPage.class);
64              }
65          };
66          form.add(synchroButton);
67  
68          // synchroTableLink button
69          AjaxButton jobManagerButton = new AjaxButton("synchroTableLink", form) {
70              @Override
71              protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
72                  setResponsePage(SynchroTablePage.class);
73              }
74          };
75          form.add(jobManagerButton);
76  
77      }
78  }