Some cleanup work, prepared another tab for /ccm/admin which will display several informations about a CCM installation

git-svn-id: https://svn.libreccm.org/ccm/trunk@2221 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-06-19 17:03:42 +00:00
parent 67c7b90ded
commit ecf1f407a6
5 changed files with 242 additions and 218 deletions

View File

@ -67,6 +67,8 @@ interface AdminConstants {
(new GlobalizedMessage("ui.admin.tab.applications.title", (new GlobalizedMessage("ui.admin.tab.applications.title",
BUNDLE_NAME)); BUNDLE_NAME));
Label INFO_TAB_TITLE = new Label(new GlobalizedMessage("ui.admin.tab.info.title", BUNDLE_NAME));
GlobalizedMessage USER_NAVBAR_TITLE = GlobalizedMessage USER_NAVBAR_TITLE =
new GlobalizedMessage("ui.admin.tab.user.navbartitle", new GlobalizedMessage("ui.admin.tab.user.navbartitle",
BUNDLE_NAME); BUNDLE_NAME);

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 2013 Jens Pelzetter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.ui.admin;
import com.arsdigita.bebop.BoxPanel;
import com.arsdigita.bebop.Label;
/**
*
* @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$
*/
public class AdminInfoTab extends BoxPanel {
public AdminInfoTab() {
super(BoxPanel.VERTICAL);
final Label placeholder = new Label(GlobalizationUtil.globalize("ui.admin.infotab.placeholder"));
add(placeholder);
}
}

View File

@ -18,7 +18,6 @@
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin;
import com.arsdigita.ui.admin.ApplicationsAdministrationTab;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageFactory; import com.arsdigita.bebop.PageFactory;
import com.arsdigita.bebop.TabbedPane; import com.arsdigita.bebop.TabbedPane;
@ -29,24 +28,19 @@ import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.permissions.PermissionDescriptor; import com.arsdigita.kernel.permissions.PermissionDescriptor;
import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.kernel.permissions.PermissionService;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor; import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.templating.PresentationManager;
import com.arsdigita.templating.Templating; import com.arsdigita.templating.Templating;
import com.arsdigita.util.Assert; import com.arsdigita.util.Assert;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
import com.arsdigita.web.BaseApplicationServlet; import com.arsdigita.web.BaseApplicationServlet;
import com.arsdigita.web.LoginSignal; import com.arsdigita.web.LoginSignal;
import com.arsdigita.xml.Document; import com.arsdigita.xml.Document;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
/** /**
* Web Developer Support Application Servlet class, central entry point to create and process the applications UI. * Web Developer Support Application Servlet class, central entry point to create and process the applications UI.
* *
@ -55,21 +49,21 @@ import org.apache.log4j.Logger;
* *
* @see com.arsdigita.bebop.page.BebopApplicationServlet} * @see com.arsdigita.bebop.page.BebopApplicationServlet}
* *
* @author Jens Pelzetter
* @author pb * @author pb
*/ */
public class AdminServlet extends BaseApplicationServlet public class AdminServlet extends BaseApplicationServlet implements AdminConstants {
implements AdminConstants {
private static final long serialVersionUID = -3912367600768871630L;
/** /**
* Logger instance for debugging * Logger instance for debugging
*/ */
private static final Logger s_log = Logger.getLogger( //private static final Logger LOGGER = Logger.getLogger(AdminServlet.class.getName());
AdminServlet.class.getName());
/** /**
* URL (pathinfo) -> Page object mapping. Based on it (and the http request url) the doService method to selects a * URL (pathinfo) -> Page object mapping. Based on it (and the http request url) the doService method to selects a
* page to display * page to display
*/ */
private final Map m_pages = new HashMap(); private final Map<String, Page> pages = new HashMap<String, Page>();
/** /**
* User extension point, overwrite this method to setup a URL - page mapping * User extension point, overwrite this method to setup a URL - page mapping
@ -78,7 +72,6 @@ public class AdminServlet extends BaseApplicationServlet
*/ */
@Override @Override
public void doInit() throws ServletException { public void doInit() throws ServletException {
addPage("/", buildAdminIndexPage()); // index page at address ~/ds addPage("/", buildAdminIndexPage()); // index page at address ~/ds
// addPage("/index.jsp", buildIndexPage()); // index page at address ~/ds // addPage("/index.jsp", buildIndexPage()); // index page at address ~/ds
@ -87,23 +80,24 @@ public class AdminServlet extends BaseApplicationServlet
/** /**
* Central service method, checks for required permission, determines the requested page and passes the page object * Central service method, checks for required permission, determines the requested page and passes the page object
* to PresentationManager. * to PresentationManager.
*
* @param sreq
* @param sresp
* @param app
* @throws ServletException
* @throws IOException
*/ */
public final void doService(HttpServletRequest sreq, public final void doService(final HttpServletRequest sreq,
HttpServletResponse sresp, final HttpServletResponse sresp,
Application app) final Application app) throws ServletException, IOException {
throws ServletException, IOException {
// /////// Some preparational steps /////////////// // /////// Some preparational steps ///////////////
/* Determine access privilege: only logged in users may access DS */ /* Determine access privilege: only logged in users may access DS */
Party party = Kernel.getContext().getParty(); final Party party = Kernel.getContext().getParty();
if (party == null) { if (party == null) {
throw new LoginSignal(sreq); throw new LoginSignal(sreq);
} }
/* Determine access privilege: Admin privileges must be granted */ /* Determine access privilege: Admin privileges must be granted */
PermissionDescriptor admin = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, app, party); final PermissionDescriptor admin = new PermissionDescriptor(PrivilegeDescriptor.ADMIN, app, party);
if (!PermissionService.checkPermission(admin)) { if (!PermissionService.checkPermission(admin)) {
throw new AccessDeniedException("User is not an administrator"); throw new AccessDeniedException("User is not an administrator");
} }
@ -112,7 +106,6 @@ public class AdminServlet extends BaseApplicationServlet
// /////// Everything OK here - DO IT /////////////// // /////// Everything OK here - DO IT ///////////////
String pathInfo = sreq.getPathInfo(); String pathInfo = sreq.getPathInfo();
Assert.exists(pathInfo, "String pathInfo"); Assert.exists(pathInfo, "String pathInfo");
if (pathInfo.length() > 1 && pathInfo.endsWith("/")) { if (pathInfo.length() > 1 && pathInfo.endsWith("/")) {
@ -124,21 +117,13 @@ public class AdminServlet extends BaseApplicationServlet
pathInfo = pathInfo.substring(0, pathInfo.length() - 1); pathInfo = pathInfo.substring(0, pathInfo.length() - 1);
} }
final Page page = (Page) m_pages.get(pathInfo); final Page page = pages.get(pathInfo);
if (page == null) {
if (page != null) {
final Document doc = page.buildDocument(sreq, sresp);
PresentationManager pm = Templating.getPresentationManager();
pm.servePage(doc, sreq, sresp);
} else {
sresp.sendError(404, "No such page for path " + pathInfo); sresp.sendError(404, "No such page for path " + pathInfo);
} else {
final Document doc = page.buildDocument(sreq, sresp);
Templating.getPresentationManager().servePage(doc, sreq, sresp);
} }
} }
/** /**
@ -148,15 +133,14 @@ public class AdminServlet extends BaseApplicationServlet
* @param page Page object to display * @param page Page object to display
*/ */
private void addPage(final String pathInfo, final Page page) { private void addPage(final String pathInfo, final Page page) {
Assert.exists(pathInfo, String.class); Assert.exists(pathInfo, String.class);
Assert.exists(page, Page.class); Assert.exists(page, Page.class);
// Current Implementation requires pathInfo to start with a leading '/' // Current Implementation requires pathInfo to start with a leading '/'
// SUN Servlet API specifies: "PathInfo *may be empty* or will start // SUN Servlet API specifies: "PathInfo *may be empty* or will start
// with a '/' character." // with a '/' character."
Assert.isTrue(pathInfo.startsWith("/"), "path starts not with '/'"); Assert.isTrue(pathInfo.charAt(0) == '/', "path starts not with '/'");
m_pages.put(pathInfo, page); pages.put(pathInfo, page);
} }
/** /**
@ -164,60 +148,52 @@ public class AdminServlet extends BaseApplicationServlet
*/ */
private Page buildAdminIndexPage() { private Page buildAdminIndexPage() {
Page p = PageFactory.buildPage("admin", PAGE_TITLE_LABEL); final Page page = PageFactory.buildPage("admin", PAGE_TITLE_LABEL);
page.addGlobalStateParam(USER_ID_PARAM);
p.addGlobalStateParam(USER_ID_PARAM); page.addGlobalStateParam(GROUP_ID_PARAM);
p.addGlobalStateParam(GROUP_ID_PARAM); page.addGlobalStateParam(APPLICATIONS_ID_PARAM);
p.addGlobalStateParam(APPLICATIONS_ID_PARAM);
/* Create User split panel. */
AdminSplitPanel userSplitPanel =
new AdminSplitPanel(USER_NAVBAR_TITLE);
UserBrowsePane browsePane = new UserBrowsePane();
userSplitPanel.addTab(USER_TAB_SUMMARY,
new UserSummaryPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_BROWSE,
browsePane);
userSplitPanel.addTab(USER_TAB_SEARCH,
new UserSearchPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_CREATE_USER,
new CreateUserPane(userSplitPanel));
/* /*
* Create group administration panel * Create User split panel.
* Note: Will change soon.
*/ */
GroupAdministrationTab groupAdministrationTab = final AdminSplitPanel userSplitPanel = new AdminSplitPanel(USER_NAVBAR_TITLE);
new GroupAdministrationTab();
final UserBrowsePane browsePane = new UserBrowsePane();
userSplitPanel.addTab(USER_TAB_SUMMARY, new UserSummaryPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_BROWSE, browsePane);
userSplitPanel.addTab(USER_TAB_SEARCH, new UserSearchPane(userSplitPanel, browsePane));
userSplitPanel.addTab(USER_TAB_CREATE_USER, new CreateUserPane(userSplitPanel));
// Create the Admin's page tab bar, currently 2 elements: user & groups
final TabbedPane tabbedPane = new TabbedPane();
tabbedPane.setIdAttr("page-body");
/**
* Create and add info tab
*/
tabbedPane.addTab(INFO_TAB_TITLE, new AdminInfoTab());
/* /*
* Create application administration panel * Create application administration panel
*/ */
ApplicationsAdministrationTab appsAdministrationTab = tabbedPane.addTab(APPLICATIONS_TAB_TITLE, new ApplicationsAdministrationTab());
new ApplicationsAdministrationTab(); /*
* Add user panel.
*/
tabbedPane.addTab(USER_TAB_TITLE, userSplitPanel);
/*
* Create and add group administration panel
*/
final GroupAdministrationTab groupAdminTab = new GroupAdministrationTab();
tabbedPane.addTab(GROUP_TAB_TITLE, groupAdminTab);
//SettingsTab settingsTab = new SettingsTab(); browsePane.setTabbedPane(tabbedPane);
browsePane.setGroupAdministrationTab(groupAdminTab);
page.add(tabbedPane);
page.lock();
// Create the Admin's page tab bar, currently 2 elements: user & groups return page;
TabbedPane tb = new TabbedPane();
tb.setIdAttr("page-body");
tb.addTab(USER_TAB_TITLE, userSplitPanel);
tb.addTab(GROUP_TAB_TITLE, groupAdministrationTab);
tb.addTab(APPLICATIONS_TAB_TITLE, appsAdministrationTab);
//tb.addTab("Settings", settingsTab);
browsePane.setTabbedPane(tb);
browsePane.setGroupAdministrationTab(groupAdministrationTab);
//browsePane.setAppsAdministrationTab(appsAdministrationTab);
p.add(tb);
p.lock();
return p;
} }
} }

View File

@ -28,7 +28,6 @@ import com.arsdigita.bebop.event.ChangeEvent;
import com.arsdigita.bebop.event.ChangeListener; import com.arsdigita.bebop.event.ChangeListener;
import com.arsdigita.toolbox.ui.LayoutPanel; import com.arsdigita.toolbox.ui.LayoutPanel;
import com.arsdigita.toolbox.ui.Section; import com.arsdigita.toolbox.ui.Section;
import com.arsdigita.ui.admin.applications.ApplicationCreateForm;
import com.arsdigita.ui.admin.applications.ApplicationInstancePane; import com.arsdigita.ui.admin.applications.ApplicationInstancePane;
import com.arsdigita.ui.admin.applications.ApplicationManager; import com.arsdigita.ui.admin.applications.ApplicationManager;
import com.arsdigita.ui.admin.applications.BaseApplicationPane; import com.arsdigita.ui.admin.applications.BaseApplicationPane;

View File

@ -18,8 +18,7 @@
*/ */
package com.arsdigita.ui.admin; package com.arsdigita.ui.admin;
import com.arsdigita.ui.util.GlobalizationUtil;
import com.arsdigita.ui.util.GlobalizationUtil ;
import com.arsdigita.bebop.ActionLink; import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.BoxPanel; import com.arsdigita.bebop.BoxPanel;
@ -58,16 +57,13 @@ import org.apache.log4j.Logger;
* *
*/ */
class GroupAdministrationTab extends BoxPanel class GroupAdministrationTab extends BoxPanel
implements AdminConstants, implements AdminConstants,
ChangeListener { ChangeListener {
private static final Logger s_log =
Logger.getLogger(GroupAdministrationTab.class);
private static final Logger s_log = Logger.getLogger(GroupAdministrationTab.class);
private Tree m_tree; private Tree m_tree;
private SearchAndList m_subMemberSearch; private SearchAndList m_subMemberSearch;
private ActionLink m_addSubmemberLink; private ActionLink m_addSubmemberLink;
private Component m_groupInfoPanel; private Component m_groupInfoPanel;
private Component m_subGroupPanel; private Component m_subGroupPanel;
private Component m_subMemberPanel; private Component m_subMemberPanel;
@ -78,7 +74,6 @@ class GroupAdministrationTab extends BoxPanel
private Component m_existingGroupAddPanel; private Component m_existingGroupAddPanel;
private ExistingGroupAddPane m_existingGroupAdd; private ExistingGroupAddPane m_existingGroupAdd;
private ArrayList m_panelList = new ArrayList(); private ArrayList m_panelList = new ArrayList();
private RequestLocal m_group; private RequestLocal m_group;
/** /**
@ -108,20 +103,20 @@ class GroupAdministrationTab extends BoxPanel
m_group.set(ps, group); m_group.set(ps, group);
m_tree.setSelectedKey(ps, id); m_tree.setSelectedKey(ps, id);
if ( !id.equals("-1") ) { if (!id.equals("-1")) {
expandGroups (ps, group); expandGroups(ps, group);
m_tree.expand("-1", ps); m_tree.expand("-1", ps);
} }
} }
private void expandGroups (PageState ps, Group group) { private void expandGroups(PageState ps, Group group) {
m_tree.expand(group.getID().toString(), ps); m_tree.expand(group.getID().toString(), ps);
GroupCollection superGroups = group.getSupergroups(); GroupCollection superGroups = group.getSupergroups();
Group superGroup = null; Group superGroup = null;
while (superGroups.next()) { while (superGroups.next()) {
superGroup = (Group)superGroups.getDomainObject(); superGroup = (Group) superGroups.getDomainObject();
expandGroups (ps, superGroup); expandGroups(ps, superGroup);
} }
} }
@ -144,13 +139,14 @@ class GroupAdministrationTab extends BoxPanel
try { try {
group = new Group(id); group = new Group(id);
} catch(DataObjectNotFoundException exc) { } catch (DataObjectNotFoundException exc) {
// Silently ignore if group does not // Silently ignore if group does not
// exist. // exist.
} }
} }
return group; return group;
} }
}; };
BoxPanel c = new BoxPanel(); BoxPanel c = new BoxPanel();
@ -199,8 +195,8 @@ class GroupAdministrationTab extends BoxPanel
} }
private void displayAddExistingGroupPanel(PageState ps) { private void displayAddExistingGroupPanel(PageState ps) {
hideAll(ps); hideAll(ps);
m_existingGroupAddPanel.setVisible(ps, true); m_existingGroupAddPanel.setVisible(ps, true);
} }
public void displayEditPanel(PageState ps) { public void displayEditPanel(PageState ps) {
@ -213,7 +209,7 @@ class GroupAdministrationTab extends BoxPanel
m_groupEditPanel.setVisible(ps, false); m_groupEditPanel.setVisible(ps, false);
m_groupAddPanel.setVisible(ps, false); m_groupAddPanel.setVisible(ps, false);
m_groupDeleteFailedPanel.setVisible(ps, false); m_groupDeleteFailedPanel.setVisible(ps, false);
m_existingGroupAddPanel.setVisible(ps, false); m_existingGroupAddPanel.setVisible(ps, false);
} }
public void displayDeleteFailedPanel(PageState ps) { public void displayDeleteFailedPanel(PageState ps) {
@ -254,11 +250,12 @@ class GroupAdministrationTab extends BoxPanel
ActionLink link = new ActionLink(EDIT_GROUP_LABEL); ActionLink link = new ActionLink(EDIT_GROUP_LABEL);
link.setClassAttr("actionLink"); link.setClassAttr("actionLink");
link.addActionListener(new ActionListener() { link.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
displayEditPanel(ps); displayEditPanel(ps);
} }
});
});
body.add(link); body.add(link);
@ -284,25 +281,27 @@ class GroupAdministrationTab extends BoxPanel
Label countLabel = new Label(""); Label countLabel = new Label("");
countLabel.addPrintListener(new PrintListener() { countLabel.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) { public void prepare(PrintEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
Label t = (Label) e.getTarget(); Label t = (Label) e.getTarget();
Group g = getGroup(ps); Group g = getGroup(ps);
if (g != null) { if (g != null) {
t.setLabel(String.valueOf(g.countSubgroups())); t.setLabel(String.valueOf(g.countSubgroups()));
}
} }
}); }
});
ActionLink status = new ActionLink(countLabel); ActionLink status = new ActionLink(countLabel);
status.addActionListener(new ActionListener() { status.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
String key = (String) m_tree.getSelectedKey(ps); String key = (String) m_tree.getSelectedKey(ps);
m_tree.expand(key, ps); m_tree.expand(key, ps);
} }
});
});
labelStatus.add(status); labelStatus.add(status);
@ -324,54 +323,57 @@ class GroupAdministrationTab extends BoxPanel
b.add(removeLink); b.add(removeLink);
return b; return b;
} }
}); });
subGroupList.addActionListener(new ActionListener() { subGroupList.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
String key = (String) ((List) e.getSource()).getSelectedKey(ps); String key = (String) ((List) e.getSource()).getSelectedKey(ps);
if (key != null) { if (key != null) {
BigDecimal groupID = new BigDecimal(key); BigDecimal groupID = new BigDecimal(key);
try { try {
Group group = new Group(groupID); Group group = new Group(groupID);
Group parent = getGroup(ps); Group parent = getGroup(ps);
if (parent != null) { if (parent != null) {
parent.removeSubgroup(group); parent.removeSubgroup(group);
parent.save(); parent.save();
} }
} catch (DataObjectNotFoundException exc) { } catch (DataObjectNotFoundException exc) {
} }
} }
} }
});
body.add(subGroupList); });
body.add(subGroupList);
ActionLink addLink = new ActionLink(ADD_SUBGROUP_LABEL); ActionLink addLink = new ActionLink(ADD_SUBGROUP_LABEL);
addLink.setClassAttr("actionLink"); addLink.setClassAttr("actionLink");
addLink.addActionListener(new ActionListener() { addLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
displayAddGroupPanel(ps); displayAddGroupPanel(ps);
} }
});
});
body.add(addLink); body.add(addLink);
// new actionlink and anonymous ActionListener class added cg // new actionlink and anonymous ActionListener class added cg
ActionLink addExistingLink = new ActionLink(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL); ActionLink addExistingLink = new ActionLink(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL);
addExistingLink.setClassAttr("actionLink"); addExistingLink.setClassAttr("actionLink");
addExistingLink.addActionListener(new ActionListener() { addExistingLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
s_log.debug("Add existing group link pressed"); s_log.debug("Add existing group link pressed");
PageState ps = e.getPageState(); PageState ps = e.getPageState();
displayAddExistingGroupPanel(ps); displayAddExistingGroupPanel(ps);
} }
}); });
body.add(addExistingLink); body.add(addExistingLink);
return main.addSegment(SUBGROUP_HEADER, body); return main.addSegment(SUBGROUP_HEADER, body);
} }
@ -385,8 +387,8 @@ class GroupAdministrationTab extends BoxPanel
} }
private Component buildExistingGroupAddPanel(SegmentedPanel main) { private Component buildExistingGroupAddPanel(SegmentedPanel main) {
m_existingGroupAdd = new ExistingGroupAddPane(m_tree, this); m_existingGroupAdd = new ExistingGroupAddPane(m_tree, this);
return main.addSegment(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL, m_existingGroupAdd); return main.addSegment(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL, m_existingGroupAdd);
} }
/** /**
@ -395,53 +397,56 @@ class GroupAdministrationTab extends BoxPanel
private Component buildMemberListPanel(SegmentedPanel main) { private Component buildMemberListPanel(SegmentedPanel main) {
BoxPanel body = new BoxPanel() { BoxPanel body = new BoxPanel() {
@Override @Override
public void register(Page p) { public void register(Page p) {
p.setVisibleDefault(m_subMemberSearch, false); p.setVisibleDefault(m_subMemberSearch, false);
} }
};
};
body.add(new SubMemberPanel(this)); body.add(new SubMemberPanel(this));
m_addSubmemberLink = new ActionLink(ADD_SUBMEMBER_LABEL); m_addSubmemberLink = new ActionLink(ADD_SUBMEMBER_LABEL);
m_addSubmemberLink.setClassAttr("actionLink"); m_addSubmemberLink.setClassAttr("actionLink");
m_addSubmemberLink.addActionListener(new ActionListener() { m_addSubmemberLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
m_addSubmemberLink.setVisible(ps, false); m_addSubmemberLink.setVisible(ps, false);
m_subMemberSearch.setVisible(ps, true); m_subMemberSearch.setVisible(ps, true);
} }
});
});
m_subMemberSearch = new SearchAndList("searchsubmember"); m_subMemberSearch = new SearchAndList("searchsubmember");
m_subMemberSearch.setListModel(new UserSearchAndListModel()); m_subMemberSearch.setListModel(new UserSearchAndListModel());
m_subMemberSearch.addChangeListener(new ChangeListener() { m_subMemberSearch.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
String key = (String) m_subMemberSearch.getSelectedKey(ps); String key = (String) m_subMemberSearch.getSelectedKey(ps);
if (key != null) { if (key != null) {
BigDecimal userID = new BigDecimal(key); BigDecimal userID = new BigDecimal(key);
Group group = getGroup(ps); Group group = getGroup(ps);
if (group != null) { if (group != null) {
try { try {
User user = User.retrieve(userID); User user = User.retrieve(userID);
group.addMember(user); group.addMember(user);
group.save(); group.save();
} catch (DataObjectNotFoundException exc) { } catch (DataObjectNotFoundException exc) {
// Ignore if user id is not valid // Ignore if user id is not valid
} catch (PersistenceException pexc) { } catch (PersistenceException pexc) {
// Display error message that user // Display error message that user
// already existed in group. // already existed in group.
}
} }
} }
m_subMemberSearch.reset(ps);
m_subMemberSearch.setVisible(ps, false);
m_addSubmemberLink.setVisible(ps, true);
} }
}); m_subMemberSearch.reset(ps);
m_subMemberSearch.setVisible(ps, false);
m_addSubmemberLink.setVisible(ps, true);
}
});
body.add(m_subMemberSearch); body.add(m_subMemberSearch);
body.add(m_addSubmemberLink); body.add(m_addSubmemberLink);
@ -459,24 +464,25 @@ class GroupAdministrationTab extends BoxPanel
deleteLink.setClassAttr("actionLink"); deleteLink.setClassAttr("actionLink");
deleteLink.setConfirmation(GROUP_DELETE_CONFIRMATION); deleteLink.setConfirmation(GROUP_DELETE_CONFIRMATION);
deleteLink.addActionListener(new ActionListener() { deleteLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
Group g = (Group) m_group.get(ps); Group g = (Group) m_group.get(ps);
if (g != null) { if (g != null) {
try { try {
g.delete(); g.delete();
m_tree.setSelectedKey(ps, "-1"); m_tree.setSelectedKey(ps, "-1");
} catch(PersistenceException exc) { } catch (PersistenceException exc) {
s_log.warn("Error deleting subgroup", exc); s_log.warn("Error deleting subgroup", exc);
displayDeleteFailedPanel(ps); displayDeleteFailedPanel(ps);
}
} }
// Select root node
} }
}); // Select root node
}
});
body.add(deleteLink); body.add(deleteLink);
return main.addSegment(GROUP_EXTREME_ACTIONS_HEADER, return main.addSegment(GROUP_EXTREME_ACTIONS_HEADER,
body); body);
@ -490,11 +496,12 @@ class GroupAdministrationTab extends BoxPanel
private Component buildGroupDeleteFailedPanel(SegmentedPanel main) { private Component buildGroupDeleteFailedPanel(SegmentedPanel main) {
ActionLink link = new ActionLink(GROUP_ACTION_CONTINUE); ActionLink link = new ActionLink(GROUP_ACTION_CONTINUE);
link.addActionListener(new ActionListener() { link.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState(); PageState ps = e.getPageState();
displayGroupInfoPanel(ps); displayGroupInfoPanel(ps);
} }
});
});
link.setClassAttr("actionLink"); link.setClassAttr("actionLink");
Label label = new Label(GROUP_DELETE_FAILED_MSG); Label label = new Label(GROUP_DELETE_FAILED_MSG);
@ -513,27 +520,27 @@ class GroupAdministrationTab extends BoxPanel
*/ */
private void hideAll(PageState ps) { private void hideAll(PageState ps) {
for (int i = 0; i < m_panelList.size(); i++) { for (int i = 0; i < m_panelList.size(); i++) {
((Component) m_panelList.get(i)).setVisible ((Component) m_panelList.get(i)).setVisible(ps, false);
(ps, false);
} }
} }
/** /**
* Show all components of the in preparation for * Show all components of the in preparation for
* turning visibility of selected components off . * turning visibility of selected components off .
*/ */
private void showAll(PageState ps) { private void showAll(PageState ps) {
for (int i = 0; i < m_panelList.size(); i++) { for (int i = 0; i < m_panelList.size(); i++) {
((Component) m_panelList.get(i)).setVisible ((Component) m_panelList.get(i)).setVisible(ps, true);
(ps, true);
} }
} }
} }
class SubGroupListModelBuilder extends LockableImpl class SubGroupListModelBuilder extends LockableImpl
implements ListModelBuilder { implements ListModelBuilder {
private GroupAdministrationTab m_parent; private GroupAdministrationTab m_parent;
public SubGroupListModelBuilder(GroupAdministrationTab parent) { public SubGroupListModelBuilder(GroupAdministrationTab parent) {
m_parent = parent; m_parent = parent;
} }
@ -547,6 +554,7 @@ class SubGroupListModelBuilder extends LockableImpl
return new SubGroupListModel(null); return new SubGroupListModel(null);
} }
} }
/** /**
@ -593,4 +601,5 @@ class SubGroupListModel implements ListModel {
return false; return false;
} }
} }