- Neue Klasse für UserAdministrationTab
- Weitere ApplicationManager git-svn-id: https://svn.libreccm.org/ccm/trunk@2248 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
5ad27e91a7
commit
a7bd1acb14
|
|
@ -0,0 +1 @@
|
|||
com.arsdigita.bookmarks.BookmarksAppManager
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* 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.bookmarks;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bookmarks.util.GlobalizationUtil;
|
||||
import com.arsdigita.ui.admin.applications.AbstractApplicationManager;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class BookmarksAppManager extends AbstractApplicationManager<Bookmarks> {
|
||||
|
||||
public Class<Bookmarks> getApplication() {
|
||||
return Bookmarks.class;
|
||||
}
|
||||
|
||||
public ApplicationInstanceAwareContainer getApplicationAdminForm() {
|
||||
return new ApplicationAdminForm();
|
||||
}
|
||||
|
||||
private class ApplicationAdminForm extends ApplicationInstanceAwareContainer {
|
||||
|
||||
public ApplicationAdminForm() {
|
||||
super();
|
||||
|
||||
final BoxPanel panel = new BoxPanel();
|
||||
panel.add(new Label(GlobalizationUtil.globalize("bookmarks.ui.not_yet_included_into_app_tab")));
|
||||
final Link link = new Link(new PrintListener() {
|
||||
public void prepare(final PrintEvent event) {
|
||||
final Link link = (Link) event.getTarget();
|
||||
|
||||
final String path = String.format("%s/admin", getAppInstance().getPath());
|
||||
final String label = String.format("/ccm%s", path);
|
||||
|
||||
link.setTarget(path);
|
||||
link.setChild(new Label(label));
|
||||
}
|
||||
|
||||
});
|
||||
panel.add(link);
|
||||
|
||||
add(panel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -15,3 +15,4 @@ bookmarks.ui.modification_date=Modification Date
|
|||
bookmarks.ui.creator=Creator
|
||||
bookmarks.ui.are_you_sure_you_want_to_delete_this_bookmark=Are you sure you want to delete this Bookmark?
|
||||
bookmarks.ui.bookmark_in_new_window=Open in a new window
|
||||
bookmarks.ui.not_yet_included_into_app_tab=The bookmarks application is not included yet into the applications tab. Use the link below
|
||||
|
|
|
|||
|
|
@ -15,3 +15,4 @@ bookmarks.ui.modification_date=\u00c4nderungsdatum
|
|||
bookmarks.ui.creator=Ersteller
|
||||
bookmarks.ui.are_you_sure_you_want_to_delete_this_bookmark=Soll dieses Lesezeichen tats\u00e4chlich gel\u00f6scht werden?
|
||||
bookmarks.ui.bookmark_in_new_window=In einen neuen Fenster \u00f6ffnen
|
||||
bookmarks.ui.not_yet_included_into_app_tab=Die Bookmarks-Anwendung ist noch nicht in den Applications-Tab integriert. Nutzen Sie statt dessen den folgenden Link:
|
||||
|
|
|
|||
|
|
@ -15,3 +15,4 @@ bookmarks.ui.modification_date=Modification Date
|
|||
bookmarks.ui.creator=Creator
|
||||
bookmarks.ui.are_you_sure_you_want_to_delete_this_bookmark=Are you sure you want to delete this Bookmark?
|
||||
bookmarks.ui.bookmark_in_new_window=Open in a new window
|
||||
bookmarks.ui.not_yet_included_into_app_tab=
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
com.arsdigita.ui.admin.AdminAppManager
|
||||
com.arsdigita.ui.login.LoginAppManager
|
||||
com.arsdigita.ui.permissions.PermissionsAppManager
|
||||
|
|
@ -74,8 +74,8 @@ interface AdminConstants {
|
|||
BUNDLE_NAME);
|
||||
|
||||
/** Tabbed pane indices */
|
||||
int USER_TAB_INDEX = 0;
|
||||
int GROUP_TAB_INDEX = 1;
|
||||
int USER_TAB_INDEX = 2;
|
||||
int GROUP_TAB_INDEX = 3;
|
||||
|
||||
/**
|
||||
* User tab name
|
||||
|
|
|
|||
|
|
@ -157,15 +157,15 @@ public class AdminServlet extends BaseApplicationServlet implements AdminConstan
|
|||
* Create User split panel.
|
||||
* Note: Will change soon.
|
||||
*/
|
||||
final AdminSplitPanel userSplitPanel = new AdminSplitPanel(USER_NAVBAR_TITLE);
|
||||
//final AdminSplitPanel userSplitPanel = new AdminSplitPanel(USER_NAVBAR_TITLE);
|
||||
|
||||
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));
|
||||
// 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
|
||||
// Create the Admin's page tab bar
|
||||
final TabbedPane tabbedPane = new TabbedPane();
|
||||
tabbedPane.setIdAttr("page-body");
|
||||
|
||||
|
|
@ -178,17 +178,15 @@ public class AdminServlet extends BaseApplicationServlet implements AdminConstan
|
|||
*/
|
||||
tabbedPane.addTab(APPLICATIONS_TAB_TITLE, new ApplicationsAdministrationTab());
|
||||
/*
|
||||
* Add user panel.
|
||||
*/
|
||||
tabbedPane.addTab(USER_TAB_TITLE, userSplitPanel);
|
||||
/*
|
||||
* Create and add group administration panel
|
||||
* Create and add the user and group tabs.
|
||||
*/
|
||||
//tabbedPane.addTab(USER_TAB_TITLE, userSplitPanel);
|
||||
final GroupAdministrationTab groupAdminTab = new GroupAdministrationTab();
|
||||
tabbedPane.addTab(USER_TAB_TITLE, new UserAdministrationTab(tabbedPane, groupAdminTab));
|
||||
tabbedPane.addTab(GROUP_TAB_TITLE, groupAdminTab);
|
||||
|
||||
browsePane.setTabbedPane(tabbedPane);
|
||||
browsePane.setGroupAdministrationTab(groupAdminTab);
|
||||
// browsePane.setTabbedPane(tabbedPane);
|
||||
// browsePane.setGroupAdministrationTab(groupAdminTab);
|
||||
|
||||
page.add(tabbedPane);
|
||||
page.lock();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ import java.util.ArrayList;
|
|||
*
|
||||
* @author David Dao
|
||||
* @version $Id: AdminSplitPanel.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
* @deprecated Was only used for the User Administration Tab in {@link AdminServlet} which is now implmented as its own
|
||||
* class. Will be removed soon.
|
||||
*/
|
||||
|
||||
class AdminSplitPanel extends BoxPanel implements ChangeListener {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.arsdigita.bebop.SegmentedPanel;
|
|||
/**
|
||||
*
|
||||
* @author David Dao
|
||||
* @deprecated Replaced by {@link UserCreateSection}. Will be removed soon.
|
||||
*/
|
||||
class CreateUserPane extends SegmentedPanel
|
||||
implements AdminConstants,
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.ui.admin;
|
||||
|
||||
import com.arsdigita.ui.util.GlobalizationUtil;
|
||||
|
||||
import com.arsdigita.bebop.ActionLink;
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
|
|
@ -45,6 +43,7 @@ import com.arsdigita.kernel.Group;
|
|||
import com.arsdigita.kernel.GroupCollection;
|
||||
import com.arsdigita.kernel.User;
|
||||
import com.arsdigita.persistence.PersistenceException;
|
||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -56,67 +55,65 @@ import org.apache.log4j.Logger;
|
|||
* @author David Dao
|
||||
*
|
||||
*/
|
||||
class GroupAdministrationTab extends BoxPanel
|
||||
implements AdminConstants,
|
||||
ChangeListener {
|
||||
class GroupAdministrationTab extends BoxPanel implements AdminConstants, ChangeListener {
|
||||
|
||||
private static final Logger s_log = Logger.getLogger(GroupAdministrationTab.class);
|
||||
private Tree m_tree;
|
||||
private SearchAndList m_subMemberSearch;
|
||||
private ActionLink m_addSubmemberLink;
|
||||
private Component m_groupInfoPanel;
|
||||
private Component m_subGroupPanel;
|
||||
private Component m_subMemberPanel;
|
||||
private Component m_extremeActionPanel;
|
||||
private Component m_groupAddPanel;
|
||||
private Component m_groupEditPanel;
|
||||
private Component m_groupDeleteFailedPanel;
|
||||
private Component m_existingGroupAddPanel;
|
||||
private static final Logger LOGGER = Logger.getLogger(GroupAdministrationTab.class);
|
||||
private final Tree groupTree;
|
||||
private SearchAndList subMemberSearch;
|
||||
private ActionLink addSubmemberLink;
|
||||
private final Component groupInfoPanel;
|
||||
private final Component subGroupPanel;
|
||||
private final Component subMemberPanel;
|
||||
private final Component extremeActionPanel;
|
||||
private final Component groupAddPanel;
|
||||
private final Component groupEditPanel;
|
||||
private final Component groupDeleteFailedPanel;
|
||||
private final Component existingGroupAddPanel;
|
||||
private ExistingGroupAddPane m_existingGroupAdd;
|
||||
private ArrayList m_panelList = new ArrayList();
|
||||
private RequestLocal m_group;
|
||||
private final java.util.List<Component> panelList = new ArrayList<Component>();
|
||||
private final RequestLocal requestLocalGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
* @param page
|
||||
*/
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
for (int i = 0; i < m_panelList.size(); i++) {
|
||||
p.setVisibleDefault((Component) m_panelList.get(i), false);
|
||||
public void register(final Page page) {
|
||||
for (int i = 0; i < panelList.size(); i++) {
|
||||
page.setVisibleDefault((Component) panelList.get(i), false);
|
||||
}
|
||||
|
||||
p.setVisibleDefault(m_groupAddPanel, true);
|
||||
page.setVisibleDefault(groupAddPanel, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ps
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
public Group getGroup(PageState ps) {
|
||||
return (Group) m_group.get(ps);
|
||||
public Group getGroup(final PageState state) {
|
||||
return (Group) requestLocalGroup.get(state);
|
||||
}
|
||||
|
||||
public void setGroup(PageState ps, Group group) {
|
||||
String id = group.getID().toString();
|
||||
m_group.set(ps, group);
|
||||
m_tree.setSelectedKey(ps, id);
|
||||
public void setGroup(final PageState state, final Group group) {
|
||||
final String groupId = group.getID().toString();
|
||||
requestLocalGroup.set(state, group);
|
||||
groupTree.setSelectedKey(state, groupId);
|
||||
|
||||
if (!id.equals("-1")) {
|
||||
expandGroups(ps, group);
|
||||
m_tree.expand("-1", ps);
|
||||
if (!"-1".equals(groupId)) {
|
||||
expandGroups(state, group);
|
||||
groupTree.expand("-1", state);
|
||||
}
|
||||
}
|
||||
|
||||
private void expandGroups(PageState ps, Group group) {
|
||||
m_tree.expand(group.getID().toString(), ps);
|
||||
private void expandGroups(final PageState state, final Group group) {
|
||||
groupTree.expand(group.getID().toString(), state);
|
||||
|
||||
GroupCollection superGroups = group.getSupergroups();
|
||||
Group superGroup = null;
|
||||
final GroupCollection superGroups = group.getSupergroups();
|
||||
Group superGroup;
|
||||
while (superGroups.next()) {
|
||||
superGroup = (Group) superGroups.getDomainObject();
|
||||
expandGroups(ps, superGroup);
|
||||
expandGroups(state, superGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,104 +124,107 @@ class GroupAdministrationTab extends BoxPanel
|
|||
setClassAttr("sidebarNavPanel");
|
||||
setAttribute("navbar-title", "Groups");
|
||||
|
||||
m_group = new RequestLocal() {
|
||||
requestLocalGroup = new RequestLocal() {
|
||||
@Override
|
||||
protected Object initialValue(PageState ps) {
|
||||
String key = (String) m_tree.getSelectedKey(ps);
|
||||
|
||||
Group group = null;
|
||||
protected Object initialValue(final PageState state) {
|
||||
String key = (String) groupTree.getSelectedKey(state);
|
||||
|
||||
Group group;
|
||||
if (key != null) {
|
||||
BigDecimal id = new BigDecimal(key);
|
||||
|
||||
try {
|
||||
group = new Group(id);
|
||||
return group;
|
||||
} catch (DataObjectNotFoundException exc) {
|
||||
// Silently ignore if group does not
|
||||
// exist.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return group;
|
||||
return null;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BoxPanel c = new BoxPanel();
|
||||
c.setClassAttr("navbar");
|
||||
//BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
final LayoutPanel panel = new LayoutPanel();
|
||||
panel.setClassAttr("navbar");
|
||||
|
||||
//m_tree = new Tree(new GroupTreeModel());
|
||||
m_tree = new Tree(new GroupTreeModelBuilder());
|
||||
m_tree.addChangeListener(this);
|
||||
c.add(m_tree);
|
||||
groupTree = new Tree(new GroupTreeModelBuilder());
|
||||
groupTree.addChangeListener(this);
|
||||
//panel.add(m_tree);
|
||||
panel.setLeft(groupTree);
|
||||
|
||||
add(c);
|
||||
add(panel);
|
||||
|
||||
SegmentedPanel rightSide = new SegmentedPanel();
|
||||
final SegmentedPanel rightSide = new SegmentedPanel();
|
||||
rightSide.setClassAttr("main");
|
||||
|
||||
m_groupInfoPanel = buildGroupInfoPanel(rightSide);
|
||||
m_panelList.add(m_groupInfoPanel);
|
||||
groupInfoPanel = buildGroupInfoPanel(rightSide);
|
||||
panelList.add(groupInfoPanel);
|
||||
|
||||
m_groupEditPanel = buildGroupEditPanel(rightSide);
|
||||
m_panelList.add(m_groupEditPanel);
|
||||
groupEditPanel = buildGroupEditPanel(rightSide);
|
||||
panelList.add(groupEditPanel);
|
||||
|
||||
m_subGroupPanel = buildSubGroupPanel(rightSide);
|
||||
m_panelList.add(m_subGroupPanel);
|
||||
subGroupPanel = buildSubGroupPanel(rightSide);
|
||||
panelList.add(subGroupPanel);
|
||||
|
||||
m_groupAddPanel = buildGroupAddPanel(rightSide);
|
||||
m_panelList.add(m_groupAddPanel);
|
||||
groupAddPanel = buildGroupAddPanel(rightSide);
|
||||
panelList.add(groupAddPanel);
|
||||
|
||||
m_existingGroupAddPanel = buildExistingGroupAddPanel(rightSide);
|
||||
m_panelList.add(m_existingGroupAddPanel);
|
||||
existingGroupAddPanel = buildExistingGroupAddPanel(rightSide);
|
||||
panelList.add(existingGroupAddPanel);
|
||||
|
||||
m_subMemberPanel = buildMemberListPanel(rightSide);
|
||||
m_panelList.add(m_subMemberPanel);
|
||||
subMemberPanel = buildMemberListPanel(rightSide);
|
||||
panelList.add(subMemberPanel);
|
||||
|
||||
m_extremeActionPanel = buildExtremeActionPanel(rightSide);
|
||||
m_panelList.add(m_extremeActionPanel);
|
||||
extremeActionPanel = buildExtremeActionPanel(rightSide);
|
||||
panelList.add(extremeActionPanel);
|
||||
|
||||
m_groupDeleteFailedPanel = buildGroupDeleteFailedPanel(rightSide);
|
||||
m_panelList.add(m_groupDeleteFailedPanel);
|
||||
groupDeleteFailedPanel = buildGroupDeleteFailedPanel(rightSide);
|
||||
panelList.add(groupDeleteFailedPanel);
|
||||
|
||||
add(rightSide);
|
||||
//add(rightSide);
|
||||
panel.setRight(rightSide);
|
||||
}
|
||||
|
||||
public void displayAddGroupPanel(PageState ps) {
|
||||
hideAll(ps);
|
||||
m_groupAddPanel.setVisible(ps, true);
|
||||
public void displayAddGroupPanel(final PageState state) {
|
||||
hideAll(state);
|
||||
groupAddPanel.setVisible(state, true);
|
||||
}
|
||||
|
||||
private void displayAddExistingGroupPanel(PageState ps) {
|
||||
hideAll(ps);
|
||||
m_existingGroupAddPanel.setVisible(ps, true);
|
||||
private void displayAddExistingGroupPanel(final PageState state) {
|
||||
hideAll(state);
|
||||
existingGroupAddPanel.setVisible(state, true);
|
||||
}
|
||||
|
||||
public void displayEditPanel(PageState ps) {
|
||||
hideAll(ps);
|
||||
m_groupEditPanel.setVisible(ps, true);
|
||||
public void displayEditPanel(final PageState state) {
|
||||
hideAll(state);
|
||||
groupEditPanel.setVisible(state, true);
|
||||
}
|
||||
|
||||
public void displayGroupInfoPanel(PageState ps) {
|
||||
showAll(ps);
|
||||
m_groupEditPanel.setVisible(ps, false);
|
||||
m_groupAddPanel.setVisible(ps, false);
|
||||
m_groupDeleteFailedPanel.setVisible(ps, false);
|
||||
m_existingGroupAddPanel.setVisible(ps, false);
|
||||
public void displayGroupInfoPanel(final PageState state) {
|
||||
showAll(state);
|
||||
groupEditPanel.setVisible(state, false);
|
||||
groupAddPanel.setVisible(state, false);
|
||||
groupDeleteFailedPanel.setVisible(state, false);
|
||||
existingGroupAddPanel.setVisible(state, false);
|
||||
}
|
||||
|
||||
public void displayDeleteFailedPanel(PageState ps) {
|
||||
hideAll(ps);
|
||||
m_groupDeleteFailedPanel.setVisible(ps, true);
|
||||
public void displayDeleteFailedPanel(final PageState state) {
|
||||
hideAll(state);
|
||||
groupDeleteFailedPanel.setVisible(state, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
* @param event
|
||||
*/
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
|
||||
PageState ps = e.getPageState();
|
||||
String key = (String) m_tree.getSelectedKey(ps);
|
||||
final PageState ps = event.getPageState();
|
||||
final String key = (String) groupTree.getSelectedKey(ps);
|
||||
// added cg - reset existing group add panel to the search screen
|
||||
// when a new group is selected from the tree
|
||||
m_existingGroupAdd.showSearch(ps);
|
||||
|
|
@ -243,8 +243,8 @@ class GroupAdministrationTab extends BoxPanel
|
|||
/**
|
||||
* Build a panel to display group basic information.
|
||||
*/
|
||||
private Component buildGroupInfoPanel(SegmentedPanel main) {
|
||||
BoxPanel body = new BoxPanel();
|
||||
private Component buildGroupInfoPanel(final SegmentedPanel main) {
|
||||
final BoxPanel body = new BoxPanel();
|
||||
|
||||
body.add(new GroupInfo(this));
|
||||
ActionLink link = new ActionLink(EDIT_GROUP_LABEL);
|
||||
|
|
@ -266,39 +266,38 @@ class GroupAdministrationTab extends BoxPanel
|
|||
/**
|
||||
* Build group edit form.
|
||||
*/
|
||||
private Component buildGroupEditPanel(SegmentedPanel main) {
|
||||
|
||||
private Component buildGroupEditPanel(final SegmentedPanel main) {
|
||||
return main.addSegment(GROUP_EDIT_HEADER, new GroupEditForm(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build panel to display direct subgroup information.
|
||||
*/
|
||||
private Component buildSubGroupPanel(SegmentedPanel main) {
|
||||
BoxPanel body = new BoxPanel();
|
||||
BoxPanel labelStatus = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
private Component buildSubGroupPanel(final SegmentedPanel main) {
|
||||
final BoxPanel body = new BoxPanel();
|
||||
final BoxPanel labelStatus = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
labelStatus.add(SUBGROUP_COUNT_LABEL);
|
||||
|
||||
Label countLabel = new Label("");
|
||||
final Label countLabel = new Label("");
|
||||
countLabel.addPrintListener(new PrintListener() {
|
||||
public void prepare(PrintEvent e) {
|
||||
PageState ps = e.getPageState();
|
||||
public void prepare(final PrintEvent event) {
|
||||
final PageState ps = event.getPageState();
|
||||
|
||||
Label t = (Label) e.getTarget();
|
||||
final Label target = (Label) event.getTarget();
|
||||
Group g = getGroup(ps);
|
||||
if (g != null) {
|
||||
t.setLabel(String.valueOf(g.countSubgroups()));
|
||||
target.setLabel(String.valueOf(g.countSubgroups()));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ActionLink status = new ActionLink(countLabel);
|
||||
final ActionLink status = new ActionLink(countLabel);
|
||||
status.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState ps = e.getPageState();
|
||||
String key = (String) m_tree.getSelectedKey(ps);
|
||||
m_tree.expand(key, ps);
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
PageState ps = event.getPageState();
|
||||
String key = (String) groupTree.getSelectedKey(ps);
|
||||
groupTree.expand(key, ps);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -308,17 +307,17 @@ class GroupAdministrationTab extends BoxPanel
|
|||
body.add(labelStatus);
|
||||
|
||||
|
||||
List subGroupList = new List(new SubGroupListModelBuilder(this));
|
||||
final List subGroupList = new List(new SubGroupListModelBuilder(this));
|
||||
subGroupList.setCellRenderer(new ListCellRenderer() {
|
||||
public Component getComponent(List list,
|
||||
PageState state,
|
||||
Object value,
|
||||
String key,
|
||||
int index,
|
||||
boolean isSelected) {
|
||||
BoxPanel b = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
public Component getComponent(final List list,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final String key,
|
||||
final int index,
|
||||
final boolean isSelected) {
|
||||
final BoxPanel b = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
b.add(new Label(((Group) value).getName()));
|
||||
ControlLink removeLink = new ControlLink(REMOVE_SUBGROUP_LABEL);
|
||||
final ControlLink removeLink = new ControlLink(REMOVE_SUBGROUP_LABEL);
|
||||
removeLink.setClassAttr("actionLink");
|
||||
b.add(removeLink);
|
||||
return b;
|
||||
|
|
@ -327,15 +326,15 @@ class GroupAdministrationTab extends BoxPanel
|
|||
});
|
||||
|
||||
subGroupList.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState ps = e.getPageState();
|
||||
String key = (String) ((List) e.getSource()).getSelectedKey(ps);
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
final PageState ps = event.getPageState();
|
||||
final String key = (String) ((List) event.getSource()).getSelectedKey(ps);
|
||||
|
||||
if (key != null) {
|
||||
BigDecimal groupID = new BigDecimal(key);
|
||||
final BigDecimal groupID = new BigDecimal(key);
|
||||
try {
|
||||
Group group = new Group(groupID);
|
||||
Group parent = getGroup(ps);
|
||||
final Group group = new Group(groupID);
|
||||
final Group parent = getGroup(ps);
|
||||
if (parent != null) {
|
||||
parent.removeSubgroup(group);
|
||||
parent.save();
|
||||
|
|
@ -348,11 +347,11 @@ class GroupAdministrationTab extends BoxPanel
|
|||
});
|
||||
body.add(subGroupList);
|
||||
|
||||
ActionLink addLink = new ActionLink(ADD_SUBGROUP_LABEL);
|
||||
final ActionLink addLink = new ActionLink(ADD_SUBGROUP_LABEL);
|
||||
addLink.setClassAttr("actionLink");
|
||||
addLink.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState ps = e.getPageState();
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
PageState ps = event.getPageState();
|
||||
|
||||
displayAddGroupPanel(ps);
|
||||
}
|
||||
|
|
@ -362,12 +361,12 @@ class GroupAdministrationTab extends BoxPanel
|
|||
body.add(addLink);
|
||||
|
||||
// new actionlink and anonymous ActionListener class added cg
|
||||
ActionLink addExistingLink = new ActionLink(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL);
|
||||
final ActionLink addExistingLink = new ActionLink(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL);
|
||||
addExistingLink.setClassAttr("actionLink");
|
||||
addExistingLink.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
s_log.debug("Add existing group link pressed");
|
||||
PageState ps = e.getPageState();
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
LOGGER.debug("Add existing group link pressed");
|
||||
PageState ps = event.getPageState();
|
||||
displayAddExistingGroupPanel(ps);
|
||||
}
|
||||
|
||||
|
|
@ -381,52 +380,52 @@ class GroupAdministrationTab extends BoxPanel
|
|||
/**
|
||||
* Build group add form.
|
||||
*/
|
||||
private Component buildGroupAddPanel(SegmentedPanel main) {
|
||||
private Component buildGroupAddPanel(final SegmentedPanel main) {
|
||||
|
||||
return main.addSegment(ADD_GROUP_LABEL, new GroupAddForm(m_tree, this));
|
||||
return main.addSegment(ADD_GROUP_LABEL, new GroupAddForm(groupTree, this));
|
||||
}
|
||||
|
||||
private Component buildExistingGroupAddPanel(SegmentedPanel main) {
|
||||
m_existingGroupAdd = new ExistingGroupAddPane(m_tree, this);
|
||||
private Component buildExistingGroupAddPanel(final SegmentedPanel main) {
|
||||
m_existingGroupAdd = new ExistingGroupAddPane(groupTree, this);
|
||||
return main.addSegment(ADD_EXISTING_GROUP_TO_SUBGROUPS_LABEL, m_existingGroupAdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build group's member panel.
|
||||
*/
|
||||
private Component buildMemberListPanel(SegmentedPanel main) {
|
||||
private Component buildMemberListPanel(final SegmentedPanel main) {
|
||||
|
||||
BoxPanel body = new BoxPanel() {
|
||||
@Override
|
||||
public void register(Page p) {
|
||||
p.setVisibleDefault(m_subMemberSearch, false);
|
||||
public void register(final Page page) {
|
||||
page.setVisibleDefault(subMemberSearch, false);
|
||||
}
|
||||
|
||||
};
|
||||
body.add(new SubMemberPanel(this));
|
||||
|
||||
m_addSubmemberLink = new ActionLink(ADD_SUBMEMBER_LABEL);
|
||||
m_addSubmemberLink.setClassAttr("actionLink");
|
||||
m_addSubmemberLink.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState ps = e.getPageState();
|
||||
m_addSubmemberLink.setVisible(ps, false);
|
||||
m_subMemberSearch.setVisible(ps, true);
|
||||
addSubmemberLink = new ActionLink(ADD_SUBMEMBER_LABEL);
|
||||
addSubmemberLink.setClassAttr("actionLink");
|
||||
addSubmemberLink.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
PageState ps = event.getPageState();
|
||||
addSubmemberLink.setVisible(ps, false);
|
||||
subMemberSearch.setVisible(ps, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
m_subMemberSearch = new SearchAndList("searchsubmember");
|
||||
m_subMemberSearch.setListModel(new UserSearchAndListModel());
|
||||
m_subMemberSearch.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
PageState ps = e.getPageState();
|
||||
subMemberSearch = new SearchAndList("searchsubmember");
|
||||
subMemberSearch.setListModel(new UserSearchAndListModel());
|
||||
subMemberSearch.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
PageState ps = event.getPageState();
|
||||
|
||||
String key = (String) m_subMemberSearch.getSelectedKey(ps);
|
||||
String key = (String) subMemberSearch.getSelectedKey(ps);
|
||||
if (key != null) {
|
||||
BigDecimal userID = new BigDecimal(key);
|
||||
final BigDecimal userID = new BigDecimal(key);
|
||||
|
||||
Group group = getGroup(ps);
|
||||
final Group group = getGroup(ps);
|
||||
|
||||
if (group != null) {
|
||||
try {
|
||||
|
|
@ -441,15 +440,15 @@ class GroupAdministrationTab extends BoxPanel
|
|||
}
|
||||
}
|
||||
}
|
||||
m_subMemberSearch.reset(ps);
|
||||
m_subMemberSearch.setVisible(ps, false);
|
||||
m_addSubmemberLink.setVisible(ps, true);
|
||||
subMemberSearch.reset(ps);
|
||||
subMemberSearch.setVisible(ps, false);
|
||||
addSubmemberLink.setVisible(ps, true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
body.add(m_subMemberSearch);
|
||||
body.add(m_addSubmemberLink);
|
||||
body.add(subMemberSearch);
|
||||
body.add(addSubmemberLink);
|
||||
return main.addSegment(SUBMEMBER_HEADER, body);
|
||||
|
||||
}
|
||||
|
|
@ -457,24 +456,24 @@ class GroupAdministrationTab extends BoxPanel
|
|||
/**
|
||||
* Build extreme action panel.
|
||||
*/
|
||||
private Component buildExtremeActionPanel(SegmentedPanel main) {
|
||||
BoxPanel body = new BoxPanel();
|
||||
private Component buildExtremeActionPanel(final SegmentedPanel main) {
|
||||
final BoxPanel body = new BoxPanel();
|
||||
|
||||
ActionLink deleteLink = new ActionLink(DELETE_GROUP_LABEL);
|
||||
final ActionLink deleteLink = new ActionLink(DELETE_GROUP_LABEL);
|
||||
deleteLink.setClassAttr("actionLink");
|
||||
deleteLink.setConfirmation(GROUP_DELETE_CONFIRMATION);
|
||||
deleteLink.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
|
||||
PageState ps = e.getPageState();
|
||||
PageState ps = event.getPageState();
|
||||
|
||||
Group g = (Group) m_group.get(ps);
|
||||
if (g != null) {
|
||||
final Group group = (Group) requestLocalGroup.get(ps);
|
||||
if (group != null) {
|
||||
try {
|
||||
g.delete();
|
||||
m_tree.setSelectedKey(ps, "-1");
|
||||
group.delete();
|
||||
groupTree.setSelectedKey(ps, "-1");
|
||||
} catch (PersistenceException exc) {
|
||||
s_log.warn("Error deleting subgroup", exc);
|
||||
LOGGER.warn("Error deleting subgroup", exc);
|
||||
displayDeleteFailedPanel(ps);
|
||||
}
|
||||
}
|
||||
|
|
@ -493,34 +492,34 @@ class GroupAdministrationTab extends BoxPanel
|
|||
* Build a panel to display an error message when unable to delete
|
||||
* group.
|
||||
*/
|
||||
private Component buildGroupDeleteFailedPanel(SegmentedPanel main) {
|
||||
ActionLink link = new ActionLink(GROUP_ACTION_CONTINUE);
|
||||
private Component buildGroupDeleteFailedPanel(final SegmentedPanel main) {
|
||||
final ActionLink link = new ActionLink(GROUP_ACTION_CONTINUE);
|
||||
link.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PageState ps = e.getPageState();
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
PageState ps = event.getPageState();
|
||||
displayGroupInfoPanel(ps);
|
||||
}
|
||||
|
||||
});
|
||||
link.setClassAttr("actionLink");
|
||||
|
||||
Label label = new Label(GROUP_DELETE_FAILED_MSG);
|
||||
final Label label = new Label(GROUP_DELETE_FAILED_MSG);
|
||||
label.setClassAttr("deleteFailedMessage");
|
||||
|
||||
BoxPanel p = new BoxPanel();
|
||||
p.add(label);
|
||||
p.add(link);
|
||||
final BoxPanel panel = new BoxPanel();
|
||||
panel.add(label);
|
||||
panel.add(link);
|
||||
|
||||
return main.addSegment(GROUP_DELETE_FAILED_HEADER, p);
|
||||
return main.addSegment(GROUP_DELETE_FAILED_HEADER, panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides all components of the in preparation for
|
||||
* turning selected components back on.
|
||||
*/
|
||||
private void hideAll(PageState ps) {
|
||||
for (int i = 0; i < m_panelList.size(); i++) {
|
||||
((Component) m_panelList.get(i)).setVisible(ps, false);
|
||||
private void hideAll(final PageState state) {
|
||||
for (int i = 0; i < panelList.size(); i++) {
|
||||
((Component) panelList.get(i)).setVisible(state, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -528,25 +527,24 @@ class GroupAdministrationTab extends BoxPanel
|
|||
* Show all components of the in preparation for
|
||||
* turning visibility of selected components off .
|
||||
*/
|
||||
private void showAll(PageState ps) {
|
||||
for (int i = 0; i < m_panelList.size(); i++) {
|
||||
((Component) m_panelList.get(i)).setVisible(ps, true);
|
||||
private void showAll(final PageState state) {
|
||||
for (int i = 0; i < panelList.size(); i++) {
|
||||
((Component) panelList.get(i)).setVisible(state, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SubGroupListModelBuilder extends LockableImpl
|
||||
implements ListModelBuilder {
|
||||
class SubGroupListModelBuilder extends LockableImpl implements ListModelBuilder {
|
||||
|
||||
private GroupAdministrationTab m_parent;
|
||||
private final GroupAdministrationTab parent;
|
||||
|
||||
public SubGroupListModelBuilder(GroupAdministrationTab parent) {
|
||||
m_parent = parent;
|
||||
public SubGroupListModelBuilder(final GroupAdministrationTab parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public ListModel makeModel(List l, PageState state) {
|
||||
Group group = m_parent.getGroup(state);
|
||||
public ListModel makeModel(final List list, final PageState state) {
|
||||
final Group group = parent.getGroup(state);
|
||||
|
||||
if (group != null) {
|
||||
return new SubGroupListModel(group.getSubgroups());
|
||||
|
|
@ -567,10 +565,10 @@ class SubGroupListModel implements ListModel {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param coll
|
||||
* @param collection
|
||||
*/
|
||||
public SubGroupListModel(GroupCollection coll) {
|
||||
m_coll = coll;
|
||||
public SubGroupListModel(final GroupCollection collection) {
|
||||
m_coll = collection;
|
||||
m_coll.addOrder("lower(" + Group.DISPLAY_NAME + ") asc");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import com.arsdigita.kernel.security.SecurityConfig;
|
|||
* Form used to add a new user to the system.
|
||||
*
|
||||
* @version $Id: UserAddForm.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
* @deprecated Replaced by {@link UserCreateSection}. Will be removed soon.
|
||||
*/
|
||||
class UserAddForm extends UserForm
|
||||
implements FormProcessListener,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,186 @@
|
|||
/*
|
||||
* 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.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.List;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.TabbedPane;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.list.ListModel;
|
||||
import com.arsdigita.bebop.list.ListModelBuilder;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_NAVBAR_TITLE;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_TAB_SUMMARY;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import com.arsdigita.xml.Element;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
class UserAdministrationTab extends SimpleContainer implements AdminConstants {
|
||||
|
||||
private final List sections;
|
||||
private final java.util.List<Component> components = new ArrayList<Component>();
|
||||
private final java.util.List<Label> keys = new ArrayList<Label>();
|
||||
private final GlobalizedMessage title = USER_NAVBAR_TITLE;
|
||||
|
||||
public UserAdministrationTab(final TabbedPane parent, final GroupAdministrationTab groupAdminTab) {
|
||||
super();
|
||||
|
||||
final LayoutPanel panel = new LayoutPanel();
|
||||
setClassAttr("sidebarNavPanel");
|
||||
|
||||
sections = new List(new GlobalizedTabModelBuilder());
|
||||
sections.addChangeListener(new SectionChangeListener());
|
||||
sections.setClassAttr("navbar");
|
||||
panel.setLeft(sections);
|
||||
|
||||
final UserBrowsePane browsePane = new UserBrowsePane();
|
||||
final UserSummarySection summarySection = new UserSummarySection(this, browsePane);
|
||||
final UserSearchSection searchSection = new UserSearchSection(this, browsePane);
|
||||
final UserCreateSection createSection = new UserCreateSection(this);
|
||||
|
||||
browsePane.setTabbedPane(parent);
|
||||
browsePane.setGroupAdministrationTab(groupAdminTab);
|
||||
|
||||
final BoxPanel right = new BoxPanel();
|
||||
addSection(USER_TAB_SUMMARY, summarySection, right);
|
||||
addSection(USER_TAB_SEARCH, searchSection, right);
|
||||
addSection(USER_TAB_CREATE_USER, createSection, right);
|
||||
|
||||
panel.setRight(right);
|
||||
add(panel);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @pre label != null && c != null
|
||||
*/
|
||||
private void addSection(final Label label, final Component component, final BoxPanel panel) {
|
||||
Assert.isUnlocked(this);
|
||||
components.add(component);
|
||||
component.setClassAttr("main");
|
||||
panel.add(component);
|
||||
keys.add(label);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param page
|
||||
*/
|
||||
@Override
|
||||
public void register(final Page page) {
|
||||
Assert.isUnlocked(this);
|
||||
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
page.setVisibleDefault(components.get(i), false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSection(final int index, final PageState state) {
|
||||
sections.setSelectedKey(state, String.valueOf(index));
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
if (i == index) {
|
||||
(components.get(i)).setVisible(state, true);
|
||||
((Resettable) components.get(i)).reset(state);
|
||||
} else {
|
||||
(components.get(i)).setVisible(state, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateXML(final PageState state, final Element parent) {
|
||||
super.generateXML(state, parent);
|
||||
|
||||
/**
|
||||
* Globalized navbar title.
|
||||
* Why did I override generateXML method to globalize the title?
|
||||
* Because CMS put title bar as an attribute of element. This
|
||||
* is the only method I could come up with.
|
||||
*/
|
||||
final Element child = (Element) parent.getChildren().get(0);
|
||||
child.addAttribute("navbar-title",
|
||||
(String) title.localize(state.getRequest()));
|
||||
}
|
||||
|
||||
private class SectionChangeListener implements ChangeListener {
|
||||
|
||||
public SectionChangeListener() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
final int selectedIndex = Integer.parseInt((String) sections.getSelectedKey(state));
|
||||
setSection(selectedIndex, state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class GlobalizedTabModelBuilder extends LockableImpl implements ListModelBuilder {
|
||||
|
||||
public GlobalizedTabModelBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ListModel makeModel(final List list, final PageState state) {
|
||||
return new TabNameListModel(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class TabNameListModel implements ListModel {
|
||||
|
||||
private int index = -1;
|
||||
private final PageState pageState;
|
||||
|
||||
public TabNameListModel(final PageState state) {
|
||||
pageState = state;
|
||||
}
|
||||
|
||||
public Object getElement() {
|
||||
return keys.get(index).getLabel(pageState);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return String.valueOf(index);
|
||||
}
|
||||
|
||||
public boolean next() {
|
||||
final boolean result = (index < keys.size() - 1);
|
||||
//return (index++ < keys.size() - 1);
|
||||
index++;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* 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.FormProcessException;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.event.FormInitListener;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||
import com.arsdigita.kernel.EmailAddress;
|
||||
import com.arsdigita.kernel.PersonName;
|
||||
import com.arsdigita.kernel.User;
|
||||
import com.arsdigita.kernel.UserAuthentication;
|
||||
import com.arsdigita.kernel.security.SecurityConfig;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_FORM_INPUT_URL_DEFAULT;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
class UserCreateSection extends UserForm implements AdminConstants, Resettable {
|
||||
|
||||
private final SecurityConfig securityConfig = SecurityConfig.getConfig();
|
||||
private final UserAdministrationTab parent;
|
||||
|
||||
public UserCreateSection(final UserAdministrationTab parent) {
|
||||
super(USER_FORM_ADD);
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
addInitListener(new UserCreateInitListener());
|
||||
addProcessListener(new UserCreateProcessListener());
|
||||
|
||||
if (securityConfig.getEnableQuestion()) {
|
||||
// Add validation listeners for required parameters
|
||||
// but only if SecurityConfig.getEnableQuestion is true (jensp 2011-10-05)
|
||||
m_question.addValidationListener(new NotEmptyValidationListener());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void reset(final PageState state) {
|
||||
state.setValue(USER_ID_PARAM, null);
|
||||
}
|
||||
|
||||
private class UserCreateInitListener implements FormInitListener {
|
||||
|
||||
public UserCreateInitListener() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
showSecurityInfo(state);
|
||||
|
||||
USER_FORM_LABEL_ADDITIONAL_EMAIL_LIST.setVisible(state, false);
|
||||
m_emailList.setVisible(state, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class UserCreateProcessListener implements FormProcessListener {
|
||||
|
||||
public UserCreateProcessListener() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
public void process(final FormSectionEvent event) throws FormProcessException {
|
||||
final PageState state = event.getPageState();
|
||||
|
||||
final User user = new User();
|
||||
|
||||
final String email = ((InternetAddress) m_primaryEmail.getValue(state)).getAddress();
|
||||
|
||||
user.setPrimaryEmail(new EmailAddress(email));
|
||||
user.setScreenName((String) m_screenName.getValue(state));
|
||||
|
||||
final PersonName personName = user.getPersonName();
|
||||
personName.setGivenName((String) m_firstName.getValue(state));
|
||||
personName.setFamilyName((String) m_lastName.getValue(state));
|
||||
|
||||
// Check to see if the value has changed from the
|
||||
// default. If not just leave this set to null.
|
||||
final String uri = (String) m_url.getValue(state);
|
||||
if (!USER_FORM_INPUT_URL_DEFAULT.equals(uri) && !"".equals(uri)) {
|
||||
user.setURI(uri);
|
||||
}
|
||||
// Add optional additional email address
|
||||
final InternetAddress additional = (InternetAddress) m_additionalEmail.getValue(state);
|
||||
if (additional != null) {
|
||||
user.addEmailAddress(new EmailAddress(additional.getAddress()));
|
||||
}
|
||||
|
||||
// Make new user persistent
|
||||
user.save();
|
||||
|
||||
// Save user authentication credentials.
|
||||
final UserAuthentication auth = UserAuthentication.createForUser(user);
|
||||
|
||||
auth.setPassword((String) m_password.getValue(state));
|
||||
if (securityConfig.getEnableQuestion()) {
|
||||
auth.setPasswordQuestion((String) m_question.getValue(state));
|
||||
auth.setPasswordAnswer((String) m_answer.getValue(state));
|
||||
}
|
||||
auth.save();
|
||||
|
||||
// Switch to browse tab.
|
||||
parent.setSection(USER_TAB_BROWSE_INDEX, state);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -34,8 +34,8 @@ import java.math.BigDecimal;
|
|||
* User search panel.
|
||||
*
|
||||
* @author David Dao
|
||||
* @deprecated Replaced by {@link UserSearchSection}. Will be removed soon.
|
||||
*/
|
||||
|
||||
class UserSearchPane extends SegmentedPanel
|
||||
implements AdminConstants,
|
||||
Resettable,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* 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.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.List;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.SegmentedPanel;
|
||||
import com.arsdigita.bebop.SimpleContainer;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.list.ListCellRenderer;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_ID_PARAM;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_TAB_BROWSE_INDEX;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
class UserSearchSection extends SegmentedPanel implements AdminConstants, Resettable {
|
||||
|
||||
private final SearchAndList searchAndList;
|
||||
private final UserAdministrationTab parent;
|
||||
private final UserBrowsePane browsePane;
|
||||
|
||||
public UserSearchSection(final UserAdministrationTab parent, final UserBrowsePane browsePane) {
|
||||
super();
|
||||
|
||||
this.parent = parent;
|
||||
this.browsePane = browsePane;
|
||||
|
||||
searchAndList = new SearchAndList("user_search");
|
||||
searchAndList.addChangeListener(new UserSearchChangeListener());
|
||||
searchAndList.setListModel(new UserSearchAndListModel());
|
||||
searchAndList.setResultCellRenderer(new ListCellRenderer() {
|
||||
public Component getComponent(final List list,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final String key,
|
||||
final int index,
|
||||
final boolean isSelected) {
|
||||
return new ControlLink(value.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
final SimpleContainer body = new SimpleContainer();
|
||||
body.add(searchAndList);
|
||||
|
||||
addSegment(SEARCH_PANEL_HEADER, body);
|
||||
}
|
||||
|
||||
public void reset(final PageState state) {
|
||||
searchAndList.reset(state);
|
||||
}
|
||||
|
||||
private class UserSearchChangeListener implements ChangeListener {
|
||||
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
parent.setSection(USER_TAB_BROWSE_INDEX, event.getPageState());
|
||||
|
||||
final String userId = (String) searchAndList.getSelectedKey(state);
|
||||
if (userId == null) {
|
||||
reset(state);
|
||||
} else {
|
||||
state.setValue(USER_ID_PARAM, new BigDecimal(userId));
|
||||
browsePane.displayUserInfoPanel(state);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package com.arsdigita.ui.admin;
|
||||
|
||||
|
||||
import com.arsdigita.ui.util.GlobalizationUtil;
|
||||
|
||||
import com.arsdigita.bebop.Label;
|
||||
|
|
@ -40,13 +39,14 @@ import com.arsdigita.bebop.event.ChangeEvent;
|
|||
import java.math.BigDecimal;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.SegmentedPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author David Dao
|
||||
* @version $Id: UserSummaryPane.java 1486 2007-03-18 16:47:26Z apevec $
|
||||
* @deprecated Replaced by {@link UserSummarySection}. Will be removed soon.
|
||||
*/
|
||||
class UserSummaryPane extends SegmentedPanel implements AdminConstants,
|
||||
Resettable {
|
||||
class UserSummaryPane extends SegmentedPanel implements AdminConstants, Resettable {
|
||||
|
||||
private UserSummaryBodyPane m_body;
|
||||
|
||||
|
|
@ -60,6 +60,7 @@ class UserSummaryPane extends SegmentedPanel implements AdminConstants,
|
|||
public void reset(PageState ps) {
|
||||
m_body.reset(ps);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
||||
|
|
@ -68,7 +69,6 @@ class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
|||
Resettable {
|
||||
|
||||
private static final String EXCLUDE_GROUP_ID = "excludeGroupId";
|
||||
|
||||
private AdminSplitPanel m_splitPanel;
|
||||
private SearchAndList m_searchAndList;
|
||||
private UserBrowsePane m_userBrowsePane;
|
||||
|
|
@ -102,8 +102,7 @@ class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
|||
public void prepare(PrintEvent e) {
|
||||
DataQuery query =
|
||||
SessionManager.getSession().retrieveQuery(
|
||||
"com.arsdigita.kernel.RetrieveUsers"
|
||||
);
|
||||
"com.arsdigita.kernel.RetrieveUsers");
|
||||
// include all groups
|
||||
query.setParameter(EXCLUDE_GROUP_ID, new BigDecimal(0));
|
||||
// XXX NOT EXISTS ( ... g.group_id = null )
|
||||
|
|
@ -112,6 +111,7 @@ class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
|||
Label l = (Label) e.getTarget();
|
||||
l.setLabel(Long.toString(nUsers));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ActionLink nUsersLink = new ActionLink(nResults);
|
||||
|
|
@ -119,6 +119,7 @@ class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
|||
public void actionPerformed(ActionEvent e) {
|
||||
m_splitPanel.setTab(USER_TAB_BROWSE_INDEX, e.getPageState());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
p.add(nUsersLink);
|
||||
|
|
@ -130,7 +131,6 @@ class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
|||
m_splitPanel.setTab(USER_TAB_CREATE_USER_INDEX, e.getPageState());
|
||||
}
|
||||
|
||||
|
||||
private SearchAndList makeUserSearch() {
|
||||
SearchAndList s = new SearchAndList("user_search");
|
||||
s.addChangeListener(this);
|
||||
|
|
@ -144,6 +144,7 @@ class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
|||
return userLink;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
s.setListModel(new UserSearchAndListModel());
|
||||
|
|
@ -168,4 +169,5 @@ class UserSummaryBodyPane extends BoxPanel implements AdminConstants,
|
|||
public void reset(PageState ps) {
|
||||
m_searchAndList.reset(ps);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* 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.ActionLink;
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.List;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.event.ActionEvent;
|
||||
import com.arsdigita.bebop.event.ActionListener;
|
||||
import com.arsdigita.bebop.event.ChangeEvent;
|
||||
import com.arsdigita.bebop.event.ChangeListener;
|
||||
import com.arsdigita.bebop.event.PrintEvent;
|
||||
import com.arsdigita.bebop.event.PrintListener;
|
||||
import com.arsdigita.bebop.list.ListCellRenderer;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.TOTAL_USERS_LABEL;
|
||||
import static com.arsdigita.ui.admin.AdminConstants.USER_TAB_BROWSE_INDEX;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
class UserSummarySection extends BoxPanel implements AdminConstants, Resettable {
|
||||
|
||||
private static final String EXCLUDE_GROUP_ID = "excludeGroupId";
|
||||
private final UserAdministrationTab parent;
|
||||
private final SearchAndList searchAndList;
|
||||
private final UserBrowsePane userBrowsePane;
|
||||
|
||||
public UserSummarySection(final UserAdministrationTab parent, final UserBrowsePane userBrowsePane) {
|
||||
super();
|
||||
|
||||
this.parent = parent;
|
||||
this.userBrowsePane = userBrowsePane;
|
||||
|
||||
add(createTotalUsersLabel());
|
||||
|
||||
searchAndList = new SearchAndList("user_search");
|
||||
searchAndList.addChangeListener(new UserSearchChangeListener());
|
||||
searchAndList.setResultCellRenderer(new ListCellRenderer() {
|
||||
public Component getComponent(final List list,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final String key,
|
||||
final int index,
|
||||
final boolean isSelected) {
|
||||
return new ControlLink(value.toString());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
searchAndList.setListModel(new UserSearchAndListModel());
|
||||
add(searchAndList);
|
||||
|
||||
final ActionLink createLink = new ActionLink(CREATE_USER_LABEL);
|
||||
createLink.setClassAttr("actionLink");
|
||||
createLink.addActionListener(new UserCreateActionListener());
|
||||
add(createLink);
|
||||
}
|
||||
|
||||
private Component createTotalUsersLabel() {
|
||||
final BoxPanel panel = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
panel.add(TOTAL_USERS_LABEL);
|
||||
|
||||
final Label nResults = new Label(com.arsdigita.ui.util.GlobalizationUtil.globalize("ui.admin.nusers"));
|
||||
nResults.addPrintListener(new PrintListener() {
|
||||
public void prepare(final PrintEvent event) {
|
||||
final DataQuery query = SessionManager.getSession().retrieveQuery("com.arsdigita.kernel.RetrieveUsers");
|
||||
// include all groups
|
||||
query.setParameter(EXCLUDE_GROUP_ID, BigDecimal.ZERO);
|
||||
// XXX NOT EXISTS ( ... g.group_id = null )
|
||||
// 10g evaluates to null
|
||||
final long nUsers = query.size();
|
||||
final Label target = (Label) event.getTarget();
|
||||
target.setLabel(Long.toString(nUsers));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
final ActionLink nUsersLink = new ActionLink(nResults);
|
||||
nUsersLink.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
parent.setSection(USER_TAB_BROWSE_INDEX, event.getPageState());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
panel.add(nUsersLink);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void reset(final PageState state) {
|
||||
searchAndList.reset(state);
|
||||
}
|
||||
|
||||
private class UserCreateActionListener implements ActionListener {
|
||||
|
||||
public UserCreateActionListener() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
public void actionPerformed(final ActionEvent event) {
|
||||
parent.setSection(USER_TAB_CREATE_USER_INDEX, event.getPageState());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class UserSearchChangeListener implements ChangeListener {
|
||||
|
||||
public UserSearchChangeListener() {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
public void stateChanged(final ChangeEvent event) {
|
||||
final PageState state = event.getPageState();
|
||||
parent.setSection(USER_TAB_BROWSE_INDEX, event.getPageState());
|
||||
/* SDM #204846. Contemplate a situation where no user is actually selected */
|
||||
final String selectedKey = (String) searchAndList.getSelectedKey(state);
|
||||
if (null != selectedKey) {
|
||||
state.setValue(USER_ID_PARAM, new BigDecimal(selectedKey));
|
||||
userBrowsePane.displayUserInfoPanel(event.getPageState());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -46,9 +46,9 @@ public class ApplicationInstancePane extends SegmentedPanel {
|
|||
appInstInfoPanel);
|
||||
|
||||
if (appAdminPane == null) {
|
||||
addSegment(new Label(com.arsdigita.ui.util.GlobalizationUtil.globalize(
|
||||
addSegment(new Label(GlobalizationUtil.globalize(
|
||||
"ui.admin.MultiInstanceApplicationPane.manage.heading")),
|
||||
new Label(com.arsdigita.ui.util.GlobalizationUtil.globalize(
|
||||
new Label(GlobalizationUtil.globalize(
|
||||
"ui.admin.MultiInstancePane.manage.no_instance_admin_pane_found",
|
||||
new String[]{appInstance.getApplicationType().getApplicationObjectType()})));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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.permissions;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Link;
|
||||
import com.arsdigita.ui.admin.GlobalizationUtil;
|
||||
import com.arsdigita.ui.admin.applications.AbstractSingletonApplicationManager;
|
||||
import com.arsdigita.ui.admin.applications.ApplicationInstanceAwareContainer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter <jens@jp-digital.de>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PermissionsAppManager extends AbstractSingletonApplicationManager<Permissions> {
|
||||
|
||||
public Class<Permissions> getApplication() {
|
||||
return Permissions.class;
|
||||
}
|
||||
|
||||
public ApplicationInstanceAwareContainer getApplicationAdminForm() {
|
||||
final ApplicationInstanceAwareContainer container = new ApplicationInstanceAwareContainer();
|
||||
|
||||
final BoxPanel panel = new BoxPanel();
|
||||
panel.add(new Label(GlobalizationUtil.globalize("ui.admin.applications.form_not_compatible_now")));
|
||||
panel.add(new Link("/ccm/permissions", "/permissions"));
|
||||
|
||||
container.add(panel);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue