BrightSide Workbench Full Report + Source Code
DossierUserMenu.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.dossier.user.menu;
20 
21 import org.turro.action.UserSummaries;
22 import org.turro.elephant.context.Application;
23 import org.turro.elephant.user.menu.DefaultUserMenu;
24 import org.turro.elephant.user.menu.UserMenu;
25 
30 @UserMenu
31 public class DossierUserMenu extends DefaultUserMenu {
32 
33  public DossierUserMenu() {
34  super("Dossiers", null, null, 5);
35  }
36 
37  @Override
38  public void initMenu() {
39  addChild(new DefaultUserMenu("My dossiers", null, "/user/mydossiers") {
40  @Override
41  public boolean isInRole() {
42  return Application.getApplication().isInRole("dossier:list");
43  }
44  @Override
45  public Object getDetail() {
46  return UserSummaries.getAttribute("dossierCount");
47  }
48  });
49  addChild(new DefaultUserMenu("My projects", null, "/user/myprojects") {
50  @Override
51  public boolean isInRole() {
52  return Application.getApplication().isInRole("dossier:list");
53  }
54  @Override
55  public Object getDetail() {
56  return UserSummaries.getAttribute("projectCount");
57  }
58  });
59  addChild(new DefaultUserMenu("My issues", null, "/user/myissues") {
60  @Override
61  public boolean isInRole() {
62  return Application.getApplication().isInRole("issue:list");
63  }
64  @Override
65  public Object getDetail() {
66  return UserSummaries.getAttribute("issueOpenCount");
67  }
68  });
69  addChild(new DefaultUserMenu("Knowledge base", null, "/user/kbase") {
70  @Override
71  public boolean isInRole() {
72  return true;
73  }
74  @Override
75  public Object getDetail() {
76  return null;
77  }
78  });
79  addChild(new DefaultUserMenu("Project grants", null, "/user/projectgrants") {
80  @Override
81  public boolean isInRole() {
82  return Application.getApplication().isInRole("dossier:list");
83  }
84  @Override
85  public Object getDetail() {
86  return null;
87  }
88  });
89  addChild(new DefaultUserMenu("Pending revision", null, "/user/pendingrevision") {
90  @Override
91  public boolean isInRole() {
92  return Application.getApplication().isInRole("issue:list");
93  }
94  @Override
95  public Object getDetail() {
96  return UserSummaries.getAttribute("pendingCount");
97  }
98  });
99  addChild(new DefaultUserMenu("Report issue", null, "/user/newissue") {
100  @Override
101  public boolean isInRole() {
102  return Application.getApplication().isInRole("issue:list");
103  }
104  @Override
105  public Object getDetail() {
106  return null;
107  }
108  });
109  }
110 
111  @Override
112  public boolean isInRole() {
114  }
115 
116  @Override
117  public Object getDetail() {
118  return null;
119  }
120 
121 }
static Object getAttribute(String attribute)