CCM NG/ccm-core: Vaadin Example
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4705 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: 6950646a0d
pull/2/head
parent
697414851c
commit
f4eefe54de
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Window;
|
||||
import org.libreccm.security.User;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UserEditor extends Window {
|
||||
|
||||
private static final long serialVersionUID = 7024424532574023431L;
|
||||
|
||||
private final User user;
|
||||
|
||||
public UserEditor(final User user) {
|
||||
|
||||
this.user = user;
|
||||
|
||||
final Label label = new Label(String.format("Editor for user %s.",
|
||||
user.getName()));
|
||||
setContent(label);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ import com.vaadin.ui.TextField;
|
|||
import com.vaadin.ui.UI;
|
||||
import com.vaadin.ui.components.grid.HeaderCell;
|
||||
import com.vaadin.ui.components.grid.HeaderRow;
|
||||
import com.vaadin.ui.renderers.ButtonRenderer;
|
||||
import com.vaadin.ui.themes.ValoTheme;
|
||||
import org.libreccm.admin.ui.AdminView;
|
||||
import org.libreccm.security.User;
|
||||
|
|
@ -92,6 +93,13 @@ public class UsersGroupsRoles extends CustomComponent {
|
|||
})
|
||||
.setId(COL_BANNED)
|
||||
.setCaption("Banned?");
|
||||
usersTable
|
||||
.addColumn(user -> "Edit",
|
||||
new ButtonRenderer<>(event -> {
|
||||
final UserEditor editor = new UserEditor(event.getItem());
|
||||
editor.center();
|
||||
UI.getCurrent().addWindow(editor);
|
||||
}));
|
||||
|
||||
final HeaderRow filterRow = usersTable.appendHeaderRow();
|
||||
final HeaderCell userNameFilterCell = filterRow.getCell(COL_USER_NAME);
|
||||
|
|
@ -113,8 +121,10 @@ public class UsersGroupsRoles extends CustomComponent {
|
|||
COL_EMAIL,
|
||||
COL_BANNED);
|
||||
final Button clearFiltersButton = new Button("Clear filters");
|
||||
clearFiltersButton.addStyleName(ValoTheme.BUTTON_TINY);
|
||||
clearFiltersButton.addClickListener(event -> {
|
||||
usersTableDataProvider.setUserNameFilter(null);
|
||||
// usersTableDataProvider.setUserNameFilter(null);
|
||||
userNameFilter.setValue("");
|
||||
});
|
||||
final HorizontalLayout actionsLayout = new HorizontalLayout(
|
||||
clearFiltersButton);
|
||||
|
|
|
|||
|
|
@ -63,6 +63,12 @@ public class UsersTableDataProvider extends AbstractDataProvider<User, String> {
|
|||
|
||||
criteriaQuery = criteriaQuery.select(builder.count(from));
|
||||
|
||||
if (userNameFilter != null && !userNameFilter.trim().isEmpty()) {
|
||||
criteriaQuery
|
||||
.where(builder.like(builder.lower(from.get("name")),
|
||||
String.format("%s%%", userNameFilter)));
|
||||
}
|
||||
|
||||
return entityManager
|
||||
.createQuery(criteriaQuery)
|
||||
.getSingleResult()
|
||||
|
|
|
|||
Loading…
Reference in New Issue