CCM NG: Basic structure for new users/groups/roles tab in the admin application
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3878 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
7b81b5b1d5
commit
260978d1c1
|
|
@ -18,20 +18,153 @@
|
|||
*/
|
||||
package com.arsdigita.ui.admin;
|
||||
|
||||
import com.arsdigita.bebop.BoxPanel;
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.List;
|
||||
import com.arsdigita.bebop.Page;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Resettable;
|
||||
import com.arsdigita.bebop.list.ListModel;
|
||||
import com.arsdigita.bebop.list.ListModelBuilder;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.toolbox.ui.LayoutPanel;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.arsdigita.ui.admin.AdminUiConstants.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class UsersGroupsRolesTab extends LayoutPanel {
|
||||
|
||||
|
||||
private final List sections;
|
||||
private final java.util.List<Component> components = new ArrayList<>();
|
||||
private final java.util.List<Label> keys = new ArrayList<>();
|
||||
|
||||
public UsersGroupsRolesTab() {
|
||||
super();
|
||||
|
||||
setClassAttr("sidebarNavPanel");
|
||||
|
||||
sections = new List(new SectionsListModelBuilder());
|
||||
sections.addChangeListener(e -> {
|
||||
final PageState state = e.getPageState();
|
||||
final int selectedIndex = Integer.parseInt((String) sections
|
||||
.getSelectedKey(state));
|
||||
setSection(selectedIndex, state);
|
||||
});
|
||||
sections.setClassAttr("navbar");
|
||||
|
||||
final BoxPanel usersPanel = new BoxPanel();
|
||||
usersPanel.add(new Label("Users Panel"));
|
||||
|
||||
final BoxPanel groupsPanel = new BoxPanel();
|
||||
groupsPanel.add(new Label("Groups Panel"));
|
||||
|
||||
final BoxPanel rolesPanel = new BoxPanel();
|
||||
rolesPanel.add(new Label("Roles Panel"));
|
||||
|
||||
final BoxPanel body = new BoxPanel();
|
||||
addSection(
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.users_groups_roles.users.title",
|
||||
BUNDLE_NAME)),
|
||||
usersPanel,
|
||||
body);
|
||||
addSection(
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.users_groups_roles.groups.title",
|
||||
BUNDLE_NAME)),
|
||||
groupsPanel,
|
||||
body);
|
||||
addSection(
|
||||
new Label(new GlobalizedMessage(
|
||||
"ui.admin.users_roles_roles.users.title",
|
||||
BUNDLE_NAME)),
|
||||
rolesPanel,
|
||||
body);
|
||||
|
||||
setLeft(new Label("Users Groups Roles Left"));
|
||||
setBody(new Label("Users Groups Roles Body"));
|
||||
setLeft(sections);
|
||||
setBody(body);
|
||||
}
|
||||
|
||||
private void addSection(final Label label,
|
||||
final Component component,
|
||||
final BoxPanel panel) {
|
||||
Assert.isUnlocked(this);
|
||||
components.add(component);
|
||||
component.setClassAttr("main");
|
||||
panel.add(component);
|
||||
keys.add(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(final Page page) {
|
||||
Assert.isUnlocked(this);
|
||||
|
||||
components.forEach(c -> page.setVisibleDefault(c, false));
|
||||
page.setVisibleDefault(components.get(0), true);
|
||||
}
|
||||
|
||||
public void setSection(final int index, final PageState state) {
|
||||
sections.setSelectedKey(state, String.valueOf(index));
|
||||
for(int i = 0; i < components.size(); i++) {
|
||||
if (i == index) {
|
||||
final Component component = components.get(i);
|
||||
component.setVisible(state, true);
|
||||
if (component instanceof Resettable) {
|
||||
final Resettable resettable = (Resettable) component;
|
||||
resettable.reset(state);
|
||||
}
|
||||
} else {
|
||||
components.get(i).setVisible(state, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SectionsListModelBuilder extends LockableImpl
|
||||
implements ListModelBuilder {
|
||||
|
||||
@Override
|
||||
public ListModel makeModel(final List list,
|
||||
final PageState state) {
|
||||
sections.setSelectedKey(state, String.valueOf(0));
|
||||
return new SectionsListModel(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class SectionsListModel implements ListModel {
|
||||
|
||||
private int index = -1;
|
||||
private final PageState state;
|
||||
|
||||
public SectionsListModel(final PageState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean next() {
|
||||
final boolean result = (index < keys.size() - 1);
|
||||
index++;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElement() {
|
||||
return keys.get(index).getLabel(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return String.valueOf(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,3 +157,6 @@ ui.admin.tab.categories.title=Categories
|
|||
ui.admin.tab.registry.title=Registry
|
||||
ui.admin.change_password=Change password
|
||||
ui.admin.tab.workflows.title=Workflows
|
||||
ui.admin.users_groups_roles.users.title=Users
|
||||
ui.admin.users_groups_roles.groups.title=Groups
|
||||
ui.admin.users_roles_roles.users.title=Roles
|
||||
|
|
|
|||
|
|
@ -157,3 +157,6 @@ ui.admin.tab.categories.title=Kategorien
|
|||
ui.admin.tab.registry.title=Registry
|
||||
ui.admin.change_password=Passwort \u00e4ndern
|
||||
ui.admin.tab.workflows.title=Arbeitsabl\u00e4ufe
|
||||
ui.admin.users_groups_roles.users.title=Benutzer
|
||||
ui.admin.users_groups_roles.groups.title=Gruppen
|
||||
ui.admin.users_roles_roles.users.title=Rollen
|
||||
|
|
|
|||
|
|
@ -130,3 +130,6 @@ ui.admin.SingletonApplicationPane.manage.heading=Edit settings
|
|||
ui.admin.user.userinfo.name=Name:
|
||||
ui.admin.user.userinfo.primaryemail=Email:
|
||||
ui.admin.user.userinfo.screenname=Username:
|
||||
ui.admin.users_groups_roles.users.title=Users
|
||||
ui.admin.users_groups_roles.groups.title=Groups
|
||||
ui.admin.users_roles_roles.users.title=Roles
|
||||
|
|
|
|||
|
|
@ -121,3 +121,6 @@ ui.admin.user.userinfo.primaryemail=Email:
|
|||
ui.admin.user.unban.confirm=Are you sure you want to unban this user?
|
||||
ui.admin.user.unban.label=Unban user
|
||||
ui.admin.user.userinfo.screenname=Username:
|
||||
ui.admin.users_groups_roles.users.title=Users
|
||||
ui.admin.users_groups_roles.groups.title=Groups
|
||||
ui.admin.users_roles_roles.users.title=Roles
|
||||
|
|
|
|||
Loading…
Reference in New Issue