572 |
12 May 05 |
nicklas |
1 |
<%-- $Id$ |
572 |
12 May 05 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Johan Enell |
572 |
12 May 05 |
nicklas |
6 |
|
2304 |
22 May 06 |
jari |
7 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
8 |
Available at http://base.thep.lu.se/ |
572 |
12 May 05 |
nicklas |
9 |
|
572 |
12 May 05 |
nicklas |
10 |
BASE is free software; you can redistribute it and/or |
572 |
12 May 05 |
nicklas |
11 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
12 |
as published by the Free Software Foundation; either version 3 |
572 |
12 May 05 |
nicklas |
13 |
of the License, or (at your option) any later version. |
572 |
12 May 05 |
nicklas |
14 |
|
572 |
12 May 05 |
nicklas |
15 |
BASE is distributed in the hope that it will be useful, |
572 |
12 May 05 |
nicklas |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
572 |
12 May 05 |
nicklas |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
572 |
12 May 05 |
nicklas |
18 |
GNU General Public License for more details. |
572 |
12 May 05 |
nicklas |
19 |
|
572 |
12 May 05 |
nicklas |
20 |
You should have received a copy of the GNU General Public License |
4511 |
11 Sep 08 |
jari |
21 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
572 |
12 May 05 |
nicklas |
22 |
------------------------------------------------------------------ |
572 |
12 May 05 |
nicklas |
23 |
|
572 |
12 May 05 |
nicklas |
24 |
@author Nicklas |
572 |
12 May 05 |
nicklas |
25 |
@version 2.0 |
572 |
12 May 05 |
nicklas |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
572 |
12 May 05 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
572 |
12 May 05 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
3501 |
15 Jun 07 |
enell |
30 |
import="net.sf.basedb.core.Item" |
572 |
12 May 05 |
nicklas |
31 |
import="net.sf.basedb.core.Project" |
3501 |
15 Jun 07 |
enell |
32 |
import="net.sf.basedb.core.Include" |
3501 |
15 Jun 07 |
enell |
33 |
import="net.sf.basedb.core.ItemContext" |
5474 |
03 Nov 10 |
nicklas |
34 |
import="net.sf.basedb.core.StringUtil" |
572 |
12 May 05 |
nicklas |
35 |
import="net.sf.basedb.clients.web.Base" |
2753 |
20 Oct 06 |
nicklas |
36 |
import="net.sf.basedb.util.Values" |
572 |
12 May 05 |
nicklas |
37 |
import="net.sf.basedb.clients.web.util.HTML" |
5474 |
03 Nov 10 |
nicklas |
38 |
import="java.util.List" |
5474 |
03 Nov 10 |
nicklas |
39 |
import="java.util.ArrayList" |
5474 |
03 Nov 10 |
nicklas |
40 |
import="java.util.Arrays" |
572 |
12 May 05 |
nicklas |
41 |
%> |
572 |
12 May 05 |
nicklas |
42 |
<%@ taglib |
572 |
12 May 05 |
nicklas |
43 |
prefix="base" uri="/WEB-INF/base.tld" |
572 |
12 May 05 |
nicklas |
44 |
%> |
572 |
12 May 05 |
nicklas |
45 |
<% |
572 |
12 May 05 |
nicklas |
46 |
SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
572 |
12 May 05 |
nicklas |
47 |
String ID = sc.getId(); |
572 |
12 May 05 |
nicklas |
48 |
int projectId = Values.getInt(request.getParameter("project_id"), 0); |
588 |
13 May 05 |
nicklas |
49 |
|
572 |
12 May 05 |
nicklas |
50 |
String title = ""; |
572 |
12 May 05 |
nicklas |
51 |
String message = ""; |
572 |
12 May 05 |
nicklas |
52 |
|
7954 |
12 May 21 |
nicklas |
53 |
DbControl dc = sc.newDbControl(":Set active project"); |
572 |
12 May 05 |
nicklas |
54 |
try |
572 |
12 May 05 |
nicklas |
55 |
{ |
572 |
12 May 05 |
nicklas |
56 |
Project p = null; |
3501 |
15 Jun 07 |
enell |
57 |
ItemContext allItems = sc.getCurrentContext(Item.PROJECT, "items"); |
3501 |
15 Jun 07 |
enell |
58 |
allItems.getInclude().add(Include.MINE); |
3501 |
15 Jun 07 |
enell |
59 |
if (projectId != 0) |
3501 |
15 Jun 07 |
enell |
60 |
{ |
3501 |
15 Jun 07 |
enell |
61 |
p = Project.getById(dc, projectId); |
3501 |
15 Jun 07 |
enell |
62 |
allItems.getInclude().add(Include.OTHERS); |
3501 |
15 Jun 07 |
enell |
63 |
} |
572 |
12 May 05 |
nicklas |
64 |
sc.setActiveProject(p); |
1907 |
06 Feb 06 |
nicklas |
65 |
sc.setUserClientSetting("projects.lastactive", projectId == 0 ? null : Integer.toString(projectId)); |
5474 |
03 Nov 10 |
nicklas |
66 |
if (projectId != 0) |
5474 |
03 Nov 10 |
nicklas |
67 |
{ |
5474 |
03 Nov 10 |
nicklas |
68 |
String recent = sc.getUserClientSetting("projects.recentActive"); |
5474 |
03 Nov 10 |
nicklas |
69 |
List<String> recentActive = null; |
5474 |
03 Nov 10 |
nicklas |
70 |
if (recent == null) |
5474 |
03 Nov 10 |
nicklas |
71 |
{ |
5474 |
03 Nov 10 |
nicklas |
72 |
recentActive = new ArrayList<String>(); |
5474 |
03 Nov 10 |
nicklas |
73 |
} |
5474 |
03 Nov 10 |
nicklas |
74 |
else |
5474 |
03 Nov 10 |
nicklas |
75 |
{ |
5474 |
03 Nov 10 |
nicklas |
76 |
// Need a new list since Arrays.asList returns a read-only list |
5474 |
03 Nov 10 |
nicklas |
77 |
recentActive = new ArrayList<String>(Arrays.asList(recent.split(":"))); |
5474 |
03 Nov 10 |
nicklas |
78 |
} |
5474 |
03 Nov 10 |
nicklas |
79 |
String thisProject = Integer.toString(projectId); |
5474 |
03 Nov 10 |
nicklas |
80 |
recentActive.remove(thisProject); |
5474 |
03 Nov 10 |
nicklas |
81 |
recentActive.add(0, thisProject); |
5474 |
03 Nov 10 |
nicklas |
82 |
int maxRecent = Values.getInt(sc.getUserClientSetting("menu.mostRecent.maxViewed"), 6); |
5474 |
03 Nov 10 |
nicklas |
83 |
if (recentActive.size() > maxRecent) recentActive = recentActive.subList(0, maxRecent); |
5474 |
03 Nov 10 |
nicklas |
84 |
sc.setUserClientSetting("projects.recentActive", StringUtil.join(recentActive, ":", true)); |
5474 |
03 Nov 10 |
nicklas |
85 |
} |
572 |
12 May 05 |
nicklas |
86 |
sc.setSessionSetting("menu.standard.html", null); |
1715 |
15 Dec 05 |
nicklas |
87 |
if (p == null) |
572 |
12 May 05 |
nicklas |
88 |
{ |
572 |
12 May 05 |
nicklas |
89 |
title = "All projects deactivated"; |
572 |
12 May 05 |
nicklas |
90 |
message = "No active project."; |
572 |
12 May 05 |
nicklas |
91 |
} |
572 |
12 May 05 |
nicklas |
92 |
else |
572 |
12 May 05 |
nicklas |
93 |
{ |
572 |
12 May 05 |
nicklas |
94 |
title = "Project activated"; |
572 |
12 May 05 |
nicklas |
95 |
message = "The project <b><i>"+HTML.encodeTags(p.getName())+"</i></b> "+ |
572 |
12 May 05 |
nicklas |
96 |
"is now the active project."; |
572 |
12 May 05 |
nicklas |
97 |
} |
572 |
12 May 05 |
nicklas |
98 |
} |
572 |
12 May 05 |
nicklas |
99 |
finally |
572 |
12 May 05 |
nicklas |
100 |
{ |
572 |
12 May 05 |
nicklas |
101 |
if (dc != null) dc.close(); |
572 |
12 May 05 |
nicklas |
102 |
} |
572 |
12 May 05 |
nicklas |
103 |
%> |
6307 |
15 Aug 13 |
nicklas |
104 |
<base:page type="popup" title="<%=title%>" id="set-active"> |
6307 |
15 Aug 13 |
nicklas |
105 |
<base:head scripts="~projects.js" /> |
6307 |
15 Aug 13 |
nicklas |
106 |
<base:body> |
5958 |
14 Feb 12 |
nicklas |
107 |
<h1><%=title %></h1> |
5958 |
14 Feb 12 |
nicklas |
108 |
<div class="content"> |
6607 |
19 Nov 14 |
nicklas |
109 |
<table class="fullcc bg-filled-50 bottomborder"><tr><td> |
5958 |
14 Feb 12 |
nicklas |
110 |
<%=message %> |
5958 |
14 Feb 12 |
nicklas |
111 |
</td></tr></table> |
5958 |
14 Feb 12 |
nicklas |
112 |
</div> |
5958 |
14 Feb 12 |
nicklas |
113 |
|
5958 |
14 Feb 12 |
nicklas |
114 |
<base:buttongroup subclass="dialogbuttons"> |
6307 |
15 Aug 13 |
nicklas |
115 |
<base:button id="close" title="Ok" /> |
5958 |
14 Feb 12 |
nicklas |
116 |
</base:buttongroup> |
572 |
12 May 05 |
nicklas |
117 |
</base:body> |
572 |
12 May 05 |
nicklas |
118 |
</base:page> |
572 |
12 May 05 |
nicklas |
119 |
|