source: trunk/www/my_base/projects/set_active.jsp @ 5474

Last change on this file since 5474 was 5474, checked in by Nicklas Nordborg, 11 years ago

Merged pre-2.16-releases to the trunk.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.7 KB
Line 
1<%-- $Id: set_active.jsp 5474 2010-11-03 08:07:50Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
5  Copyright (C) 2007 Johan Enell
6
7  This file is part of BASE - BioArray Software Environment.
8  Available at http://base.thep.lu.se/
9
10  BASE is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 3
13  of the License, or (at your option) any later version.
14
15  BASE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with BASE. If not, see <http://www.gnu.org/licenses/>.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page pageEncoding="UTF-8" session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.Project"
32  import="net.sf.basedb.core.Include"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.StringUtil"
35  import="net.sf.basedb.clients.web.Base"
36  import="net.sf.basedb.util.Values"
37  import="net.sf.basedb.clients.web.util.HTML"
38  import="java.util.List"
39  import="java.util.ArrayList"
40  import="java.util.Arrays"
41%>
42<%@ taglib
43  prefix="base" uri="/WEB-INF/base.tld"
44%>
45<%
46SessionControl sc = Base.getExistingSessionControl(pageContext, true);
47String ID = sc.getId();
48int projectId = Values.getInt(request.getParameter("project_id"), 0);
49
50String title = "";
51String message = "";
52
53DbControl dc = sc.newDbControl();
54try
55{
56  Project p = null;
57  ItemContext allItems = sc.getCurrentContext(Item.PROJECT, "items");
58  allItems.getInclude().add(Include.MINE);
59  if (projectId != 0) 
60  {
61    p = Project.getById(dc, projectId);
62    allItems.getInclude().add(Include.OTHERS);
63  }
64  sc.setActiveProject(p);
65  sc.setUserClientSetting("projects.lastactive", projectId == 0 ? null : Integer.toString(projectId));
66  if (projectId != 0)
67  {
68    String recent = sc.getUserClientSetting("projects.recentActive");
69    List<String> recentActive = null;
70    if (recent == null)
71    {
72      recentActive = new ArrayList<String>();
73    }
74    else
75    {
76      // Need a new list since Arrays.asList returns a read-only list
77      recentActive = new ArrayList<String>(Arrays.asList(recent.split(":")));
78    }
79    String thisProject = Integer.toString(projectId);
80    recentActive.remove(thisProject);
81    recentActive.add(0, thisProject);
82    int maxRecent = Values.getInt(sc.getUserClientSetting("menu.mostRecent.maxViewed"), 6);
83    if (recentActive.size() > maxRecent) recentActive = recentActive.subList(0, maxRecent);
84    sc.setUserClientSetting("projects.recentActive", StringUtil.join(recentActive, ":", true));
85  }
86  sc.setSessionSetting("menu.standard.html", null);
87  if (p == null)
88  {
89    title = "All projects deactivated";
90    message = "No active project.";
91  }
92  else
93  {
94    title = "Project activated";
95    message = "The project <b><i>"+HTML.encodeTags(p.getName())+"</i></b> "+
96      "is now the active project.";
97  }
98}
99finally
100{
101  if (dc != null) dc.close();
102}
103%>
104<base:page type="popup" title="<%=title%>">
105<base:head>
106<script language="JavaScript">
107function reloadAndClose()
108{
109  window.opener.location.reload();
110  window.close();
111}
112</script>
113</base:head>
114<base:body onload="reloadAndClose()">
115  <base:note type="info" title="<%=title%>">
116    <%=message%>
117  </base:note>
118  <p>
119  <table align="center">
120  <tr>
121    <td><base:button onclick="window.close();" title="Ok" /></td>
122  </tr>
123  </table>
124</base:body>
125</base:page>
126
Note: See TracBrowser for help on using the repository browser.