CCM NG/ccm-core: Some work for the Vaadin prototype

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4836 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2017-07-03 18:13:03 +00:00
parent a57a121ebb
commit 55743d255e
5 changed files with 154 additions and 12 deletions

View File

@ -43,7 +43,6 @@ import com.vaadin.ui.themes.ValoTheme;
import org.libreccm.admin.ui.ConfirmDiscardDialog;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.security.Group;
import org.libreccm.security.GroupManager;
import org.libreccm.security.GroupRepository;
import org.libreccm.security.Role;
import org.libreccm.security.RoleRepository;
@ -72,7 +71,6 @@ public class GroupDetails extends Window {
private final UsersGroupsRoles usersGroupsRoles;
private final Group group;
private final GroupRepository groupRepo;
private final GroupManager groupManager;
private boolean dataHasChanged = false;
@ -83,15 +81,13 @@ public class GroupDetails extends Window {
public GroupDetails(final Group group,
final UsersGroupsRoles usersGroupsRoles,
final GroupRepository groupRepo,
final GroupManager groupManager) {
final GroupRepository groupRepo) {
super(String.format("Edit group %s", group.getName()));
this.group = group;
this.usersGroupsRoles = usersGroupsRoles;
this.groupRepo = groupRepo;
this.groupManager = groupManager;
addWidgets();
}

View File

@ -74,8 +74,7 @@ public class GroupsTable extends Grid<Group> {
final GroupDetails groupDetails = new GroupDetails(
event.getItem(),
usersGroupsRoles,
view.getGroupRepository(),
view.getGroupManager());
view.getGroupRepository());
groupDetails.center();
groupDetails.setWidth("50%");
groupDetails.setHeight("100%");

View File

@ -0,0 +1,135 @@
/*
* Copyright (C) 2017 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 org.libreccm.admin.ui.usersgroupsroles;
import com.arsdigita.ui.admin.AdminUiConstants;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.ui.Accordion;
import com.vaadin.ui.Button;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import org.libreccm.security.User;
import org.libreccm.security.UserManager;
import org.libreccm.security.UserRepository;
import java.util.ResourceBundle;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class UserDetails extends Window {
private static final long serialVersionUID = 7852981019990845392L;
private final UsersGroupsRoles usersGroupsRoles;
private final User user;
private final UserRepository userRepo;
private final UserManager userManager;
public UserDetails(final User user,
final UsersGroupsRoles usersGroupsRoles,
final UserRepository userRepo,
final UserManager userManager) {
super(String.format("Details of user %s", user.getName()));
this.usersGroupsRoles = usersGroupsRoles;
this.user = user;
this.userRepo = userRepo;
this.userManager = userManager;
addWidgets();
}
private void addWidgets() {
final ResourceBundle bundle = ResourceBundle
.getBundle(AdminUiConstants.ADMIN_BUNDLE,
UI.getCurrent().getLocale());
final Label userName = new Label(user.getName());
userName.setCaption(bundle
.getString("ui.admin.user_edit.username.label"));
final Label familyName = new Label(user.getFamilyName());
familyName.setCaption(bundle
.getString("ui.admin.user_edit.familyname.label"));
final Label givenName = new Label(user.getGivenName());
givenName.setCaption(bundle
.getString("ui.admin.user_edit.givenname.label"));
final Label emailAddress = new Label(user.getPrimaryEmailAddress()
.getAddress());
emailAddress.setCaption(bundle
.getString("ui.admin.user_edit.emailAddress.label"));
final Label passwordResetRequired = new Label();
if (user.isPasswordResetRequired()) {
passwordResetRequired.setValue("Yes");
} else {
passwordResetRequired.setValue("No");
}
passwordResetRequired.setCaption(bundle
.getString("ui.admin.user_edit.password_reset_required.label"));
final Label banned = new Label();
if (user.isBanned()) {
banned.setValue("Yes");
} else {
banned.setValue("No");
}
banned.setCaption(bundle.getString("ui.admin.user_edit.banned.label"));
final FormLayout formLayout = new FormLayout(userName,
familyName,
givenName,
emailAddress,
passwordResetRequired,
banned);
final Button editButton = new Button(
bundle.getString("ui.admin.users.table.edit"),
event -> {
final UserEditor editor = new UserEditor(user,
usersGroupsRoles,
userRepo,
userManager);
editor.center();
UI.getCurrent().addWindow(editor);
});
final VerticalLayout layout = new VerticalLayout(formLayout,
editButton);
final TabSheet tabs = new TabSheet();
tabs.addTab(layout, "Details");
tabs.addTab(layout, "Groups");
tabs.addTab(layout, "Roles");
setContent(tabs);
}
}

View File

@ -28,9 +28,11 @@ import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.RadioButtonGroup;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@ -296,6 +298,8 @@ public class UserEditor extends Window {
banned.setValue(user.isBanned());
passwordOptions.setValue(PasswordOptions.DO_NOTHING);
}
dataHasChanged = false;
}
@Override

View File

@ -58,7 +58,7 @@ public class UsersTable extends Grid<User> {
public UsersTable(final AdminView view,
final UsersGroupsRoles usersGroupsRoles) {
super();
final ResourceBundle bundle = ResourceBundle
@ -99,13 +99,21 @@ public class UsersTable extends Grid<User> {
.setCaption("Password reset required");
addColumn(user -> bundle.getString("ui.admin.users.table.edit"),
new ButtonRenderer<>(event -> {
final UserEditor editor = new UserEditor(
// final UserEditor editor = new UserEditor(
// event.getItem(),
// usersGroupsRoles,
// view.getUserRepository(),
// view.getUserManager());
// editor.center();
// UI.getCurrent().addWindow(editor);
final UserDetails details = new UserDetails(
event.getItem(),
usersGroupsRoles,
view.getUserRepository(),
view.getUserManager());
editor.center();
UI.getCurrent().addWindow(editor);
details.center();
details.setWidth("66.6%");
UI.getCurrent().addWindow(details);
}))
.setId(COL_EDIT);
@ -133,7 +141,7 @@ public class UsersTable extends Grid<User> {
clearFiltersButton.addClickListener(event -> {
userNameFilter.setValue("");
});
createUserButton = new Button("New User");
createUserButton.addStyleName(ValoTheme.BUTTON_TINY);
createUserButton.setIcon(VaadinIcons.PLUS);