CCM NG: Tables showing the email addresses of a user
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3916 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
7b354a4be4
commit
ea75416ed9
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
|
||||
*
|
||||
* 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.bebop;
|
||||
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.util.GlobalizationUtil;
|
||||
|
||||
/**
|
||||
* A form section with two buttons (Save and Cancel) aligned to
|
||||
* the right.
|
||||
*
|
||||
* @author Stanislav Freidin
|
||||
* @author Sören Bernstein <quasi@quasiweb.de>
|
||||
* @version $Id: SaveCancelSection.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class SaveCancelSection extends FormSection {
|
||||
|
||||
private Submit m_saveWidget, m_cancelWidget;
|
||||
|
||||
/**
|
||||
* Constructs a new SaveCancelSection.
|
||||
*/
|
||||
public SaveCancelSection() {
|
||||
super(new BoxPanel(BoxPanel.HORIZONTAL, false));
|
||||
|
||||
BoxPanel panel = (BoxPanel)getPanel();
|
||||
panel.setWidth("2%");
|
||||
|
||||
createWidgets();
|
||||
|
||||
add(m_saveWidget, BoxPanel.RIGHT);
|
||||
add(m_cancelWidget, BoxPanel.RIGHT);
|
||||
}
|
||||
|
||||
public SaveCancelSection(Container c) {
|
||||
super(c);
|
||||
|
||||
createWidgets();
|
||||
add(m_saveWidget);
|
||||
add(m_cancelWidget);
|
||||
}
|
||||
|
||||
private void createWidgets() {
|
||||
m_saveWidget = new Submit("save");
|
||||
m_saveWidget.setButtonLabel(GlobalizationUtil.globalize("bebop.save"));
|
||||
|
||||
m_cancelWidget = new Submit("cancel");
|
||||
m_cancelWidget.setButtonLabel(GlobalizationUtil.globalize("bebop.cancel"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Save button.
|
||||
* @return the Save button.
|
||||
*/
|
||||
public Submit getSaveButton() {
|
||||
return m_saveWidget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Cancel button.
|
||||
* @return the Cancel button.
|
||||
*/
|
||||
public Submit getCancelButton() {
|
||||
return m_cancelWidget;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,18 +20,37 @@ package com.arsdigita.ui.admin.usersgroupsroles;
|
|||
|
||||
import com.arsdigita.bebop.ActionLink;
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.ControlLink;
|
||||
import com.arsdigita.bebop.Form;
|
||||
import com.arsdigita.bebop.FormProcessException;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.PropertySheet;
|
||||
import com.arsdigita.bebop.SaveCancelSection;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.Text;
|
||||
import com.arsdigita.bebop.event.FormProcessListener;
|
||||
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionEvent;
|
||||
import com.arsdigita.bebop.event.TableActionListener;
|
||||
import com.arsdigita.bebop.form.CheckboxGroup;
|
||||
import com.arsdigita.bebop.form.Option;
|
||||
import com.arsdigita.bebop.form.Submit;
|
||||
import com.arsdigita.bebop.form.TextField;
|
||||
import com.arsdigita.bebop.parameters.LongParameter;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.dom4j.tree.BackedList;
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.core.EmailAddress;
|
||||
import org.libreccm.security.User;
|
||||
import org.libreccm.security.UserRepository;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
|
|
@ -42,7 +61,9 @@ import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
|||
public class UserAdmin extends BoxPanel {
|
||||
|
||||
private final LongParameter userIdParameter;
|
||||
private final StringParameter emailParameter;
|
||||
private final ParameterSingleSelectionModel<String> selectedUserId;
|
||||
private final ParameterSingleSelectionModel<String> selectedEmailAddress;
|
||||
private final TextField usersTableFilter;
|
||||
private final BoxPanel usersTablePanel;
|
||||
private final UsersTable usersTable;
|
||||
|
|
@ -51,24 +72,25 @@ public class UserAdmin extends BoxPanel {
|
|||
private final BoxPanel actionLinks;
|
||||
// private final UserDetails userDetails;
|
||||
private final BoxPanel userDetails;
|
||||
private final Form emailForm;
|
||||
|
||||
public UserAdmin() {
|
||||
super();
|
||||
|
||||
setIdAttr("userAdmin");
|
||||
|
||||
|
||||
usersTablePanel = new BoxPanel();
|
||||
usersTablePanel.setIdAttr("usersTablePanel");
|
||||
|
||||
|
||||
final Form filterForm = new Form("usersTableFilterForm");
|
||||
usersTableFilter = new TextField("usersTableFilter");
|
||||
usersTableFilter.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.users.table.filter.term", ADMIN_BUNDLE));
|
||||
"ui.admin.users.table.filter.term", ADMIN_BUNDLE));
|
||||
filterForm.add(usersTableFilter);
|
||||
filterForm.add(new Submit(new GlobalizedMessage(
|
||||
"ui.admin.users.table.filter.submit", ADMIN_BUNDLE)));
|
||||
"ui.admin.users.table.filter.submit", ADMIN_BUNDLE)));
|
||||
final ActionLink clearLink = new ActionLink(new GlobalizedMessage(
|
||||
"ui.admin.users.table.filter.clear", ADMIN_BUNDLE));
|
||||
"ui.admin.users.table.filter.clear", ADMIN_BUNDLE));
|
||||
clearLink.addActionListener((e) -> {
|
||||
final PageState state = e.getPageState();
|
||||
usersTableFilter.setValue(state, null);
|
||||
|
|
@ -80,11 +102,15 @@ public class UserAdmin extends BoxPanel {
|
|||
selectedUserId = new ParameterSingleSelectionModel<>(userIdParameter);
|
||||
//selectedUserId = new ParameterSingleSelectionModel<>(USER_ID_PARAM);
|
||||
|
||||
emailParameter = new StringParameter("selected_email_address");
|
||||
selectedEmailAddress = new ParameterSingleSelectionModel<>(
|
||||
emailParameter);
|
||||
|
||||
usersTable = new UsersTable(this, usersTableFilter, selectedUserId);
|
||||
usersTablePanel.add(usersTable);
|
||||
|
||||
add(usersTablePanel);
|
||||
|
||||
|
||||
// final Text text = new Text();
|
||||
// text.setPrintListener((final PrintEvent e) -> {
|
||||
// final Text target = (Text) e.getTarget();
|
||||
|
|
@ -94,10 +120,8 @@ public class UserAdmin extends BoxPanel {
|
|||
// }
|
||||
// });
|
||||
// add(text);
|
||||
|
||||
// userDetails = new UserDetails(this, selectedUserId);
|
||||
// add(new UserDetails(this, selectedUserId));
|
||||
|
||||
userDetails = new BoxPanel();
|
||||
userDetails.setIdAttr("userDetails");
|
||||
|
||||
|
|
@ -107,12 +131,12 @@ public class UserAdmin extends BoxPanel {
|
|||
backToUsersTable.addActionListener(
|
||||
e -> closeUserDetails(e.getPageState()));
|
||||
userDetails.add(backToUsersTable);
|
||||
|
||||
|
||||
userProperties = new PropertySheet(new UserPropertySheetModelBuilder(
|
||||
this, selectedUserId));
|
||||
userProperties.setIdAttr("userProperties");
|
||||
userDetails.add(userProperties);
|
||||
|
||||
|
||||
actionLinks = new BoxPanel(BoxPanel.HORIZONTAL);
|
||||
actionLinks.setIdAttr("userDetailsActionLinks");
|
||||
final ActionLink editUserDetailsLink = new ActionLink(
|
||||
|
|
@ -122,27 +146,249 @@ public class UserAdmin extends BoxPanel {
|
|||
});
|
||||
actionLinks.add(editUserDetailsLink);
|
||||
actionLinks.add(new Text(" | "));
|
||||
|
||||
|
||||
final ActionLink setPasswordLink = new ActionLink(
|
||||
new GlobalizedMessage("ui.admin.user_details.set_password",
|
||||
ADMIN_BUNDLE));
|
||||
new GlobalizedMessage("ui.admin.user_details.set_password",
|
||||
ADMIN_BUNDLE));
|
||||
setPasswordLink.addActionListener(e -> {
|
||||
//ToDo
|
||||
});
|
||||
actionLinks.add(setPasswordLink);
|
||||
actionLinks.add(new Text(" | "));
|
||||
|
||||
|
||||
final ActionLink generatePasswordLink = new ActionLink(
|
||||
new GlobalizedMessage("ui.admin.user_details.generate_password",
|
||||
ADMIN_BUNDLE));
|
||||
new GlobalizedMessage("ui.admin.user_details.generate_password",
|
||||
ADMIN_BUNDLE));
|
||||
generatePasswordLink.addActionListener(e -> {
|
||||
//ToDo
|
||||
});
|
||||
actionLinks.add(generatePasswordLink);
|
||||
|
||||
userDetails.add(actionLinks);
|
||||
|
||||
final Table primaryEmailTable = new Table();
|
||||
primaryEmailTable.setModelBuilder(
|
||||
new UserPrimaryEmailTableModelBuilder(selectedUserId));
|
||||
final TableColumnModel primaryEmailTableColModel = primaryEmailTable
|
||||
.getColumnModel();
|
||||
primaryEmailTableColModel.add(new TableColumn(
|
||||
UserPrimaryEmailTableModel.COL_ADDRESS,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.primary_email.address",
|
||||
ADMIN_BUNDLE))));
|
||||
primaryEmailTableColModel.add(new TableColumn(
|
||||
UserPrimaryEmailTableModel.COL_VERIFIED,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.primary_email.verified",
|
||||
ADMIN_BUNDLE))));
|
||||
primaryEmailTableColModel.add(new TableColumn(
|
||||
UserPrimaryEmailTableModel.COL_BOUNCING,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.primary_email.bouncing",
|
||||
ADMIN_BUNDLE))));
|
||||
primaryEmailTableColModel.add(new TableColumn(
|
||||
UserPrimaryEmailTableModel.COL_ACTION,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.primary_email.action",
|
||||
ADMIN_BUNDLE))));
|
||||
primaryEmailTableColModel.get(
|
||||
UserPrimaryEmailTableModel.COL_ACTION).setCellRenderer(
|
||||
new TableCellRenderer() {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
return new ControlLink((Label) value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
primaryEmailTable.addTableActionListener(new TableActionListener() {
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
final String key = (String) event.getRowKey();
|
||||
selectedEmailAddress.setSelectedKey(event.getPageState(), key);
|
||||
showEmailForm(event.getPageState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
userDetails.add(primaryEmailTable);
|
||||
|
||||
final Table emailTable = new Table();
|
||||
emailTable.setModelBuilder(
|
||||
new UserEmailTableModelBuilder(selectedUserId));
|
||||
final TableColumnModel emailTableColumnModel = emailTable
|
||||
.getColumnModel();
|
||||
emailTableColumnModel.add(new TableColumn(
|
||||
UserEmailTableModel.COL_ADDRESS,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.address",
|
||||
ADMIN_BUNDLE))));
|
||||
emailTableColumnModel.add(new TableColumn(
|
||||
UserEmailTableModel.COL_VERIFIED,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.verified",
|
||||
ADMIN_BUNDLE))));
|
||||
emailTableColumnModel.add(new TableColumn(
|
||||
UserEmailTableModel.COL_BOUNCING,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.bouncing",
|
||||
ADMIN_BUNDLE))));
|
||||
emailTableColumnModel.add(new TableColumn(
|
||||
UserEmailTableModel.COL_EDIT,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.edit",
|
||||
ADMIN_BUNDLE))));
|
||||
emailTableColumnModel.add(new TableColumn(
|
||||
UserEmailTableModel.COL_DELETE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.delete",
|
||||
ADMIN_BUNDLE))));
|
||||
emailTableColumnModel.get(UserEmailTableModel.COL_EDIT).setCellRenderer(
|
||||
new TableCellRenderer() {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
return new ControlLink((Label) value);
|
||||
}
|
||||
|
||||
});
|
||||
emailTableColumnModel.get(UserEmailTableModel.COL_DELETE)
|
||||
.setCellRenderer(
|
||||
new TableCellRenderer() {
|
||||
|
||||
@Override
|
||||
public Component getComponent(final Table table,
|
||||
final PageState state,
|
||||
final Object value,
|
||||
final boolean isSelected,
|
||||
final Object key,
|
||||
final int row,
|
||||
final int column) {
|
||||
return new ControlLink((Label) value);
|
||||
}
|
||||
|
||||
});
|
||||
emailTable.addTableActionListener(new TableActionListener() {
|
||||
|
||||
@Override
|
||||
public void cellSelected(final TableActionEvent event) {
|
||||
//ToDo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(final TableActionEvent event) {
|
||||
//Nothing
|
||||
}
|
||||
|
||||
});
|
||||
emailTable.setEmptyView(new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.none", ADMIN_BUNDLE)));
|
||||
|
||||
userDetails.add(emailTable);
|
||||
|
||||
final ActionLink addEmailLink = new ActionLink(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.add", ADMIN_BUNDLE));
|
||||
addEmailLink.addActionListener(e -> {
|
||||
//ToDo
|
||||
});
|
||||
userDetails.add(addEmailLink);
|
||||
|
||||
emailForm = new Form("email_form");
|
||||
// emailForm.add(new Label(new GlobalizedMessage(
|
||||
// "ui.admin.user.email_form.address",
|
||||
// ADMIN_BUNDLE)));
|
||||
final TextField emailFormAddress = new TextField("email_form_address");
|
||||
emailFormAddress.setLabel(new GlobalizedMessage(
|
||||
"ui.admin.user.email_form.address", ADMIN_BUNDLE));
|
||||
final CheckboxGroup emailFormVerified = new CheckboxGroup(
|
||||
"email_form_verified");
|
||||
emailFormVerified.addOption(
|
||||
new Option("true",
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_form.verified",
|
||||
ADMIN_BUNDLE))));
|
||||
final CheckboxGroup emailFormBouncing = new CheckboxGroup(
|
||||
"email_form_verified");
|
||||
emailFormBouncing.addOption(
|
||||
new Option("true",
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_form.bouncing",
|
||||
ADMIN_BUNDLE))));
|
||||
|
||||
emailForm.add(new SaveCancelSection());
|
||||
|
||||
emailForm.addInitListener(e -> {
|
||||
final PageState state = e.getPageState();
|
||||
|
||||
final String selected = selectedEmailAddress.getSelectedKey(state);
|
||||
final String userIdStr = selectedUserId.getSelectedKey(state);
|
||||
if (selected != null && !selected.isEmpty()) {
|
||||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final User user = userRepository.findById(Long.parseLong(
|
||||
userIdStr));
|
||||
EmailAddress email = null;
|
||||
if (user.getPrimaryEmailAddress().getAddress().equals(selected)) {
|
||||
email = user.getPrimaryEmailAddress();
|
||||
} else {
|
||||
for (EmailAddress current : user.getEmailAddresses()) {
|
||||
if (current.getAddress().equals(selected)) {
|
||||
email = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (email != null) {
|
||||
emailFormAddress.setValue(state, email.getAddress());
|
||||
if (email.isVerified()) {
|
||||
emailFormVerified.setValue(state, "true");
|
||||
}
|
||||
if (email.isBouncing()) {
|
||||
emailFormBouncing.setValue(state, "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
emailForm.addProcessListener(e -> {
|
||||
closeEmailForm(e.getPageState());
|
||||
});
|
||||
|
||||
emailForm.addCancelListener(e -> closeEmailForm(e.getPageState()));
|
||||
|
||||
// emailFormAddress.setLabel(new GlobalizedMessage(
|
||||
// "ui.admin.user.email_form.verified",
|
||||
// ADMIN_BUNDLE));
|
||||
// emailForm.add(new Label(new GlobalizedMessage(
|
||||
// "ui.admin.user.email_form.verified",
|
||||
// ADMIN_BUNDLE)));
|
||||
//
|
||||
// emailForm.add(new Label(new GlobalizedMessage(
|
||||
// "ui.admin.user.email_form.bouncing",
|
||||
// ADMIN_BUNDLE)));
|
||||
add(emailForm);
|
||||
|
||||
add(userDetails);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -150,20 +396,37 @@ public class UserAdmin extends BoxPanel {
|
|||
super.register(page);
|
||||
|
||||
page.addGlobalStateParam(userIdParameter);
|
||||
|
||||
page.addGlobalStateParam(emailParameter);
|
||||
|
||||
page.setVisibleDefault(usersTablePanel, true);
|
||||
page.setVisibleDefault(userDetails, false);
|
||||
page.setVisibleDefault(emailForm, false);
|
||||
}
|
||||
|
||||
protected void showUserDetails(final PageState state) {
|
||||
usersTablePanel.setVisible(state, false);
|
||||
userDetails.setVisible(state, true);
|
||||
emailForm.setVisible(state, false);
|
||||
}
|
||||
|
||||
|
||||
protected void closeUserDetails(final PageState state) {
|
||||
selectedUserId.clearSelection(state);
|
||||
usersTablePanel.setVisible(state, true);
|
||||
userDetails.setVisible(state, false);
|
||||
emailForm.setVisible(state, false);
|
||||
}
|
||||
|
||||
protected void showEmailForm(final PageState state) {
|
||||
usersTablePanel.setVisible(state, false);
|
||||
userDetails.setVisible(state, false);
|
||||
emailForm.setVisible(state, true);
|
||||
}
|
||||
|
||||
protected void closeEmailForm(final PageState state) {
|
||||
selectedEmailAddress.clearSelection(state);
|
||||
usersTablePanel.setVisible(state, false);
|
||||
userDetails.setVisible(state, true);
|
||||
emailForm.setVisible(state, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.libreccm.core.EmailAddress;
|
||||
import org.libreccm.security.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UserEmailTableModel implements TableModel {
|
||||
|
||||
protected static final int COL_ADDRESS = 0;
|
||||
protected static final int COL_VERIFIED = 1;
|
||||
protected static final int COL_BOUNCING = 2;
|
||||
protected static final int COL_EDIT = 3;
|
||||
protected static final int COL_DELETE = 4;
|
||||
|
||||
private final List<EmailAddress> emailAddresses;
|
||||
private int index;
|
||||
private boolean finished;
|
||||
|
||||
public UserEmailTableModel(final User user) {
|
||||
this.emailAddresses = user.getEmailAddresses();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
if (index < emailAddresses.size()) {
|
||||
index++;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case COL_ADDRESS:
|
||||
return emailAddresses.get(index).getAddress();
|
||||
case COL_VERIFIED:
|
||||
return Boolean.toString(emailAddresses.get(index).isVerified());
|
||||
case COL_BOUNCING:
|
||||
return Boolean.toString(emailAddresses.get(index).isBouncing());
|
||||
case COL_EDIT:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.edit",
|
||||
ADMIN_BUNDLE));
|
||||
case COL_DELETE:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.email_addresses.delete",
|
||||
ADMIN_BUNDLE));
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid column index.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return emailAddresses.get(index).getAddress();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.User;
|
||||
import org.libreccm.security.UserRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UserEmailTableModelBuilder extends LockableImpl
|
||||
implements TableModelBuilder{
|
||||
|
||||
private final ParameterSingleSelectionModel<String> selectedUserId;
|
||||
|
||||
public UserEmailTableModelBuilder(
|
||||
final ParameterSingleSelectionModel<String> selectedUserId) {
|
||||
this.selectedUserId = selectedUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
final String userIdStr = selectedUserId.getSelectedKey(state);
|
||||
final User selectedUser;
|
||||
if (userIdStr == null || userIdStr.isEmpty()) {
|
||||
selectedUser = null;
|
||||
} else {
|
||||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final long userId = Long.parseLong(userIdStr);
|
||||
selectedUser = userRepository.findById(userId);
|
||||
}
|
||||
|
||||
return new UserEmailTableModel(selectedUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
|
||||
import org.libreccm.security.User;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UserPrimaryEmailTableModel implements TableModel {
|
||||
|
||||
protected static final int COL_ADDRESS = 0;
|
||||
protected static final int COL_VERIFIED = 1;
|
||||
protected static final int COL_BOUNCING = 2;
|
||||
protected static final int COL_ACTION = 3;
|
||||
|
||||
private final User user;
|
||||
private boolean finished = false;
|
||||
|
||||
public UserPrimaryEmailTableModel(final User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
if (finished) {
|
||||
return false;
|
||||
} else {
|
||||
finished = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int columnIndex) {
|
||||
switch(columnIndex) {
|
||||
case COL_ADDRESS:
|
||||
return user.getPrimaryEmailAddress().getAddress();
|
||||
case COL_VERIFIED:
|
||||
return Boolean.toString(user.getPrimaryEmailAddress().isVerified());
|
||||
case COL_BOUNCING:
|
||||
return Boolean.toString(user.getPrimaryEmailAddress().isBouncing());
|
||||
case COL_ACTION:
|
||||
return new Label(new GlobalizedMessage(
|
||||
"ui.admin.user.primary_email_address.edit", ADMIN_BUNDLE));
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid column index.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(final int columnIndex) {
|
||||
return user.getPrimaryEmailAddress().getAddress();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.ParameterSingleSelectionModel;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import org.libreccm.cdi.utils.CdiUtil;
|
||||
import org.libreccm.security.User;
|
||||
import org.libreccm.security.UserRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UserPrimaryEmailTableModelBuilder extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private final ParameterSingleSelectionModel<String> selectedUserId;
|
||||
|
||||
public UserPrimaryEmailTableModelBuilder(
|
||||
final ParameterSingleSelectionModel<String> selectedUserId) {
|
||||
this.selectedUserId = selectedUserId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(final Table table, final PageState state) {
|
||||
final String userIdStr = selectedUserId.getSelectedKey(state);
|
||||
final User selectedUser;
|
||||
if (userIdStr == null || userIdStr.isEmpty()) {
|
||||
selectedUser = null;
|
||||
} else {
|
||||
final UserRepository userRepository = CdiUtil.createCdiUtil()
|
||||
.findBean(UserRepository.class);
|
||||
final long userId = Long.parseLong(userIdStr);
|
||||
selectedUser = userRepository.findById(userId);
|
||||
}
|
||||
|
||||
return new UserPrimaryEmailTableModel(selectedUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ public class UserPropertySheetModel implements PropertySheetModel {
|
|||
USER_NAME,
|
||||
FAMILY_NAME,
|
||||
GIVEN_NAME,
|
||||
PASSWORD_SET,
|
||||
BANNED,
|
||||
PASSWORD_RESET_REQUIRED,
|
||||
}
|
||||
|
|
@ -89,6 +90,10 @@ public class UserPropertySheetModel implements PropertySheetModel {
|
|||
return selectedUser.getFamilyName();
|
||||
case GIVEN_NAME:
|
||||
return selectedUser.getGivenName();
|
||||
case PASSWORD_SET:
|
||||
return Boolean.toString(
|
||||
(selectedUser.getPassword() != null
|
||||
&& !selectedUser.getPassword().isEmpty()));
|
||||
case BANNED:
|
||||
return Boolean.toString(selectedUser.isBanned());
|
||||
case PASSWORD_RESET_REQUIRED:
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ import org.libreccm.security.UserRepository;
|
|||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UserPropertySheetModelBuilder
|
||||
extends LockableImpl implements PropertySheetModelBuilder {
|
||||
extends LockableImpl implements PropertySheetModelBuilder {
|
||||
|
||||
private final ParameterSingleSelectionModel<String> selectedUserId;
|
||||
|
||||
public UserPropertySheetModelBuilder(
|
||||
final UserAdmin parent,
|
||||
final ParameterSingleSelectionModel<String> selectedUserId) {
|
||||
final UserAdmin parent,
|
||||
final ParameterSingleSelectionModel<String> selectedUserId) {
|
||||
this.selectedUserId = selectedUserId;
|
||||
}
|
||||
|
||||
|
|
@ -52,12 +52,12 @@ public class UserPropertySheetModelBuilder
|
|||
selectedUser = null;
|
||||
} else {
|
||||
final UserRepository userRepository = CdiUtil.createCdiUtil().
|
||||
findBean(
|
||||
UserRepository.class);
|
||||
findBean(UserRepository.class);
|
||||
final long userId = Long.parseLong(userIdStr);
|
||||
selectedUser = userRepository.findById(userId);
|
||||
}
|
||||
|
||||
return new UserPropertySheetModel(selectedUser);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,3 +183,16 @@ ui.admin.user_details.back=Back to users table
|
|||
ui.admin.user_details.edit=Edit user details
|
||||
ui.admin.user_details.generate_password=Generate password and it send to user
|
||||
ui.admin.user_details.set_password=Set new password
|
||||
ui.admin.user.property_sheet.password_set=Password set?
|
||||
ui.admin.user.primary_email.address=Address
|
||||
ui.admin.user.primary_email.verified=Verified?
|
||||
ui.admin.user.primary_email.bouncing=Bouncing?
|
||||
ui.admin.user.primary_email_address.edit=Edit
|
||||
ui.admin.user.email_addresses.address=Address
|
||||
ui.admin.user.email_addresses.verified=Verified?
|
||||
ui.admin.user.email_addresses.bouncing=Bouncing?
|
||||
ui.admin.user.email_addresses.edit=Edit
|
||||
ui.admin.user.email_addresses.delete=Delete
|
||||
ui.admin.user.primary_email.action=Action
|
||||
ui.admin.user.email_addresses.none=No additional email addresses
|
||||
ui.admin.user.email_addresses.add=Add email address
|
||||
|
|
|
|||
|
|
@ -183,3 +183,16 @@ ui.admin.user_details.back=Zur\u00fcck zur Benutzer\u00fcbersicht
|
|||
ui.admin.user_details.edit=Benutzerdaten bearbeiten
|
||||
ui.admin.user_details.generate_password=Passwort generieren und an Benutzer senden
|
||||
ui.admin.user_details.set_password=Neues Passwort setzen
|
||||
ui.admin.user.property_sheet.password_set=Passwort gesetzt?
|
||||
ui.admin.user.primary_email.address=Adresse
|
||||
ui.admin.user.primary_email.verified=Verifiziert?
|
||||
ui.admin.user.primary_email.bouncing=Wird zur\u00fcckgewiesen?
|
||||
ui.admin.user.primary_email_address.edit=Bearbeiten
|
||||
ui.admin.user.email_addresses.address=Adresse
|
||||
ui.admin.user.email_addresses.verified=Verifiziert?
|
||||
ui.admin.user.email_addresses.bouncing=Wird zur\u00fcckgewiesen?
|
||||
ui.admin.user.email_addresses.edit=Bearbeiten
|
||||
ui.admin.user.email_addresses.delete=L\u00f6schen
|
||||
ui.admin.user.primary_email.action=Aktion
|
||||
ui.admin.user.email_addresses.none=Keine weiteren E-Mail-Adressen
|
||||
ui.admin.user.email_addresses.add=E-Mail-Adresse hinzuf\u00fcgen
|
||||
|
|
|
|||
|
|
@ -156,3 +156,16 @@ ui.admin.user_details.back=Back to users table
|
|||
ui.admin.user_details.edit=Edit user details
|
||||
ui.admin.user_details.generate_password=Generate password and it send to user
|
||||
ui.admin.user_details.set_password=Set new password
|
||||
ui.admin.user.property_sheet.password_set=Password set?
|
||||
ui.admin.user.primary_email.address=Address
|
||||
ui.admin.user.primary_email.verified=Verified?
|
||||
ui.admin.user.primary_email.bouncing=Bouncing?
|
||||
ui.admin.user.primary_email_address.edit=Edit
|
||||
ui.admin.user.email_addresses.address=Adddress
|
||||
ui.admin.user.email_addresses.verified=Verified?
|
||||
ui.admin.user.email_addresses.bouncing=Bouncing?
|
||||
ui.admin.user.email_addresses.edit=Edit
|
||||
ui.admin.user.email_addresses.delete=Delete
|
||||
ui.admin.user.primary_email.action=Action
|
||||
ui.admin.user.email_addresses.none=No additional email addresses
|
||||
ui.admin.user.email_addresses.add=Add email address
|
||||
|
|
|
|||
|
|
@ -147,3 +147,16 @@ ui.admin.user_details.back=Back to users table
|
|||
ui.admin.user_details.edit=Edit user details
|
||||
ui.admin.user_details.generate_password=Generate password and it send to user
|
||||
ui.admin.user_details.set_password=Set new password
|
||||
ui.admin.user.property_sheet.password_set=Password set?
|
||||
ui.admin.user.primary_email.address=Address
|
||||
ui.admin.user.primary_email.verified=Verified?
|
||||
ui.admin.user.primary_email.bouncing=Bouncing?
|
||||
ui.admin.user.primary_email_address.edit=Edit
|
||||
ui.admin.user.email_addresses.address=Address
|
||||
ui.admin.user.email_addresses.verified=Verified?
|
||||
ui.admin.user.email_addresses.bouncing=Bouncing?
|
||||
ui.admin.user.email_addresses.edit=Edit
|
||||
ui.admin.user.email_addresses.delete=Delete
|
||||
ui.admin.user.primary_email.action=Action
|
||||
ui.admin.user.email_addresses.none=No additional email addresses
|
||||
ui.admin.user.email_addresses.add=Add email address
|
||||
|
|
|
|||
Loading…
Reference in New Issue