CCM NG: Property sheet for group
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3992 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
bbfdf4f39c
commit
8bc1368b85
|
|
@ -48,6 +48,7 @@ public class GroupAdmin extends BoxPanel {
|
|||
private final BoxPanel groupsTablePanel;
|
||||
private final GroupsTable groupsTable;
|
||||
private final GroupForm groupForm;
|
||||
private final GroupDetails groupDetails;
|
||||
|
||||
public GroupAdmin() {
|
||||
super();
|
||||
|
|
@ -91,6 +92,9 @@ public class GroupAdmin extends BoxPanel {
|
|||
|
||||
groupForm = new GroupForm(this, selectedGroupId);
|
||||
add(groupForm);
|
||||
|
||||
groupDetails = new GroupDetails(this, selectedGroupId);
|
||||
add(groupDetails);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -102,6 +106,7 @@ public class GroupAdmin extends BoxPanel {
|
|||
|
||||
page.setVisibleDefault(groupsTablePanel, true);
|
||||
page.setVisibleDefault(groupForm, false);
|
||||
page.setVisibleDefault(groupDetails, false);
|
||||
}
|
||||
|
||||
private void setBasicProperties() {
|
||||
|
|
@ -112,11 +117,14 @@ public class GroupAdmin extends BoxPanel {
|
|||
protected void showGroupDetails(final PageState state) {
|
||||
groupsTablePanel.setVisible(state, false);
|
||||
groupForm.setVisible(state, false);
|
||||
groupDetails.setVisible(state, true);
|
||||
}
|
||||
|
||||
protected void hideGroupDetails(final PageState state) {
|
||||
selectedGroupId.clearSelection(state);
|
||||
groupsTablePanel.setVisible(state, true);
|
||||
groupForm.setVisible(state, false);
|
||||
groupDetails.setVisible(state, false);
|
||||
}
|
||||
|
||||
protected void showGroupForm(final PageState state) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package com.arsdigita.ui.admin.usersgroupsroles.groups;
|
||||
|
||||
import com.arsdigita.bebop.ActionLink;
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.PropertySheet;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class GroupDetails extends BoxPanel {
|
||||
|
||||
public GroupDetails(
|
||||
final GroupAdmin groupAdmin,
|
||||
final ParameterSingleSelectionModel<String> selectedGroupId) {
|
||||
super(BoxPanel.VERTICAL);
|
||||
|
||||
final ActionLink backLink = new ActionLink(new GlobalizedMessage(
|
||||
"ui.admin.group_details.back", ADMIN_BUNDLE));
|
||||
backLink.addActionListener(e -> {
|
||||
groupAdmin.hideGroupDetails(e.getPageState());
|
||||
});
|
||||
add(backLink);
|
||||
|
||||
final PropertySheet propertySheet = new PropertySheet(
|
||||
new GroupPropertySheetModelBuilder(selectedGroupId));
|
||||
|
||||
add(propertySheet);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package com.arsdigita.ui.admin.usersgroupsroles.groups;
|
||||
|
||||
import com.arsdigita.bebop.PropertySheetModel;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.libreccm.security.Group;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class GroupPropertySheetModel implements PropertySheetModel {
|
||||
|
||||
private static enum GroupProperty {
|
||||
GROUP_NAME;
|
||||
}
|
||||
|
||||
private final Group selectedGroup;
|
||||
private final Iterator<GroupProperty> propertyIterator;
|
||||
private GroupProperty currentProperty;
|
||||
|
||||
public GroupPropertySheetModel(final Group selectedGroup) {
|
||||
this.selectedGroup = selectedGroup;
|
||||
propertyIterator = Arrays.asList(GroupProperty.values()).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
if (selectedGroup == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propertyIterator.hasNext()) {
|
||||
currentProperty = propertyIterator.next();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return currentProperty.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlobalizedMessage getGlobalizedLabel() {
|
||||
return generateGlobalizedLabel(currentProperty);
|
||||
}
|
||||
|
||||
private GlobalizedMessage generateGlobalizedLabel(
|
||||
final GroupProperty property) {
|
||||
|
||||
final String key = String.join("", "ui.admin.group.property_sheet.",
|
||||
property.toString().toLowerCase());
|
||||
return new GlobalizedMessage(key, ADMIN_BUNDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
switch (currentProperty) {
|
||||
case GROUP_NAME:
|
||||
return selectedGroup.getName();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2016 LibreCCM Foundation.
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package com.arsdigita.ui.admin.usersgroupsroles.groups;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.PropertySheet;
|
||||
import com.arsdigita.bebop.PropertySheetModel;
|
||||
import com.arsdigita.bebop.PropertySheetModelBuilder;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.Group;
|
||||
import org.libreccm.security.GroupRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
class GroupPropertySheetModelBuilder
|
||||
extends LockableImpl implements PropertySheetModelBuilder {
|
||||
|
||||
private final ParameterSingleSelectionModel<String> selectedGroupId;
|
||||
|
||||
public GroupPropertySheetModelBuilder(
|
||||
final ParameterSingleSelectionModel<String> selectedGroupId) {
|
||||
this.selectedGroupId = selectedGroupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertySheetModel makeModel(final PropertySheet sheet,
|
||||
final PageState state) {
|
||||
final String groupIdStr = selectedGroupId.getSelectedKey(state);
|
||||
final Group selectedGroup;
|
||||
if (groupIdStr == null || groupIdStr.isEmpty()) {
|
||||
selectedGroup = null;
|
||||
} else {
|
||||
final GroupRepository groupRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(GroupRepository.class);
|
||||
selectedGroup = groupRepository.findById(Long.parseLong(groupIdStr));
|
||||
}
|
||||
|
||||
return new GroupPropertySheetModel(selectedGroup);
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ public class UserAdmin extends BoxPanel {
|
|||
userDetails.add(backToUsersTable);
|
||||
|
||||
userProperties = new PropertySheet(new UserPropertySheetModelBuilder(
|
||||
this, selectedUserId));
|
||||
selectedUserId));
|
||||
userProperties.setIdAttr("userProperties");
|
||||
userDetails.add(userProperties);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ public class UserPropertySheetModelBuilder
|
|||
private final ParameterSingleSelectionModel<String> selectedUserId;
|
||||
|
||||
public UserPropertySheetModelBuilder(
|
||||
final UserAdmin parent,
|
||||
final ParameterSingleSelectionModel<String> selectedUserId) {
|
||||
this.selectedUserId = selectedUserId;
|
||||
}
|
||||
|
|
@ -53,8 +52,7 @@ public class UserPropertySheetModelBuilder
|
|||
} else {
|
||||
final UserRepository userRepository = CdiUtil.createCdiUtil().
|
||||
findBean(UserRepository.class);
|
||||
final long userId = Long.parseLong(userIdStr);
|
||||
selectedUser = userRepository.findById(userId);
|
||||
selectedUser = userRepository.findById(Long.parseLong(userIdStr));
|
||||
}
|
||||
|
||||
return new UserPropertySheetModel(selectedUser);
|
||||
|
|
|
|||
|
|
@ -253,3 +253,5 @@ ui.admin.group.create_new=Create new group
|
|||
ui.admin.group.edit=Edit group
|
||||
ui.admin.group.name=Name of group
|
||||
ui.admin.group.delete.confirm=Are you sure to delete this group?
|
||||
ui.admin.group.property_sheet.group_name=Name of Group
|
||||
ui.admin.group_details.back=Back to groups table
|
||||
|
|
|
|||
|
|
@ -253,3 +253,5 @@ ui.admin.group.create_new=Neue Gruppe anlegen
|
|||
ui.admin.group.edit=Gruppe bearbeiten
|
||||
ui.admin.group.name=Name der Gruppe
|
||||
ui.admin.group.delete.confirm=Sind Sie sicher das Sie diese Gruppe l\u00f6schen wollen?
|
||||
ui.admin.group.property_sheet.group_name=Name der Gruppe
|
||||
ui.admin.group_details.back=Zur\u00fcck zur Gruppen\u00fcbersicht
|
||||
|
|
|
|||
|
|
@ -226,3 +226,5 @@ ui.admin.group.create_new=Create new group
|
|||
ui.admin.group.edit=Edit group
|
||||
ui.admin.group.name=Name of group
|
||||
ui.admin.group.delete.confirm=Are you sure to delete this group?
|
||||
ui.admin.group.property_sheet.group_name=Name of Group
|
||||
ui.admin.group_details.back=Back to groups table
|
||||
|
|
|
|||
|
|
@ -217,3 +217,5 @@ ui.admin.group.create_new=Create new group
|
|||
ui.admin.group.edit=Edit group
|
||||
ui.admin.group.name=Name of group
|
||||
ui.admin.group.delete.confirm=Are you sure to delete this group?
|
||||
ui.admin.group.property_sheet.group_name=Name of Group
|
||||
ui.admin.group_details.back=Back to groups table
|
||||
|
|
|
|||
Loading…
Reference in New Issue