diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupAdmin.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupAdmin.java index 4a380ccf6..53a40555f 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupAdmin.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupAdmin.java @@ -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) { diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupDetails.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupDetails.java new file mode 100644 index 000000000..26547f01a --- /dev/null +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupDetails.java @@ -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 Jens Pelzetter + */ +public class GroupDetails extends BoxPanel { + + public GroupDetails( + final GroupAdmin groupAdmin, + final ParameterSingleSelectionModel 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); + + } + +} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupPropertySheetModel.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupPropertySheetModel.java new file mode 100644 index 000000000..c97d3ba68 --- /dev/null +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupPropertySheetModel.java @@ -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 Jens Pelzetter + */ +class GroupPropertySheetModel implements PropertySheetModel { + + private static enum GroupProperty { + GROUP_NAME; + } + + private final Group selectedGroup; + private final Iterator 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 ""; + } + } + +} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupPropertySheetModelBuilder.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupPropertySheetModelBuilder.java new file mode 100644 index 000000000..9549c6091 --- /dev/null +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/groups/GroupPropertySheetModelBuilder.java @@ -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 Jens Pelzetter + */ +class GroupPropertySheetModelBuilder + extends LockableImpl implements PropertySheetModelBuilder { + + private final ParameterSingleSelectionModel selectedGroupId; + + public GroupPropertySheetModelBuilder( + final ParameterSingleSelectionModel 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); + } +} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserAdmin.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserAdmin.java index 807ab278c..fc8585a0c 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserAdmin.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserAdmin.java @@ -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); diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserPropertySheetModelBuilder.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserPropertySheetModelBuilder.java index aaf1dac82..535729a52 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserPropertySheetModelBuilder.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/usersgroupsroles/users/UserPropertySheetModelBuilder.java @@ -38,7 +38,6 @@ public class UserPropertySheetModelBuilder private final ParameterSingleSelectionModel selectedUserId; public UserPropertySheetModelBuilder( - final UserAdmin parent, final ParameterSingleSelectionModel 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); diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties index ecce3e2da..7f2c7f435 100644 --- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties +++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources.properties @@ -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 diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties index e496f583d..b973581c3 100644 --- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties +++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_de.properties @@ -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 diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties index 4cd605ec1..52084b1f4 100755 --- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties +++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_en.properties @@ -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 diff --git a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties index 6d8a28399..6761655fe 100755 --- a/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties +++ b/ccm-core/src/main/resources/com/arsdigita/ui/admin/AdminResources_fr.properties @@ -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