BrightSide Workbench Full Report + Source Code
StudentsMenu.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2019 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.students.menu;
20 
21 import java.util.HashMap;
22 import org.turro.annotation.ExternalMenu;
23 import org.turro.menu.ElephantMenu;
24 import static org.turro.menu.ElephantMenu.showEntity;
25 import org.turro.menu.ElephantMenuBar;
26 import org.turro.security.Permission;
27 import org.turro.students.entities.Challenge;
28 
34 public class StudentsMenu extends ElephantMenu {
35 
36  @Override
37  public void addToMenu(ElephantMenuBar bar) {
38  bar.addMenu("Students", Permission.from("challenge"))
39  .addSubmenu()
40  .addMenuitem("Talent categories", "/students/categories.zul", false, Permission.from("challenge:new"))
41  .addMenuitem("Challenges", "challenge", "/students/challenges.zul", true, Permission.from("challenge:new"));
42  }
43 
44  public static void showChallenge(Challenge challenge) {
45  HashMap<String, Object> map = new HashMap<String, Object>();
46  map.put("challengeGenerated", challenge);
47  showEntity(challenge.getId(), "challengeId", "Challenge", "/students/challenge.zul", map);
48  }
49 
50  public static void showChallenge(Long id) {
51  showEntity(id, "challengeId", "Challenge", "/students/challenge.zul");
52  }
53 
54 }
ElephantMenu addMenu(String label)
static void showEntity(Object id, String attribute, String label, String include)
ElephantSubmenu addSubmenu()
ElephantSubmenu addMenuitem(String label, String include)
static Permission from(String... roles)
Definition: Permission.java:79
static void showChallenge(Challenge challenge)
void addToMenu(ElephantMenuBar bar)