From f5f4c6ee93fa6ca019df8488ab23b54c127b7361 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 25 Oct 2017 18:19:44 +0000 Subject: [PATCH] CCM NG: First part of admin UI for Sites git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5084 8810af33-2d31-482b-a856-94f89814c4df --- .../com/arsdigita/ui/admin/AdminServlet.java | 6 ++ .../arsdigita/ui/admin/sites/SitesTab.java | 47 +++++++++++ .../arsdigita/ui/admin/sites/SitesTable.java | 63 +++++++++++++++ .../ui/admin/sites/SitesTableModel.java | 80 +++++++++++++++++++ .../admin/sites/SitesTableModelBuilder.java | 41 ++++++++++ .../ui/admin/AdminResources.properties | 1 + .../ui/admin/AdminResources_de.properties | 1 + .../ui/admin/AdminResources_en.properties | 1 + .../ui/admin/AdminResources_fr.properties | 1 + 9 files changed, 241 insertions(+) create mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTab.java create mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTable.java create mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModel.java create mode 100644 ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModelBuilder.java diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/AdminServlet.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/AdminServlet.java index 4c0b2a343..5d1aed30e 100644 --- a/ccm-core/src/main/java/com/arsdigita/ui/admin/AdminServlet.java +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/AdminServlet.java @@ -33,6 +33,7 @@ import com.arsdigita.ui.admin.applications.ApplicationsTab; import com.arsdigita.ui.admin.categories.CategoriesTab; import com.arsdigita.ui.admin.configuration.ConfigurationTab; import com.arsdigita.ui.admin.importexport.ImportExportTab; +import com.arsdigita.ui.admin.sites.SitesTab; import com.arsdigita.web.BaseApplicationServlet; import com.arsdigita.web.LoginSignal; import com.arsdigita.xml.Document; @@ -135,6 +136,11 @@ public class AdminServlet extends BaseApplicationServlet { ADMIN_BUNDLE)), new ConfigurationTab()); + tabbedPane.addTab( + new Label(new GlobalizedMessage("ui.admin.tab.sites.title", + ADMIN_BUNDLE)), + new SitesTab()); + tabbedPane.addTab( new Label(new GlobalizedMessage("ui.admin.tab.workflows.title", ADMIN_BUNDLE)), diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTab.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTab.java new file mode 100644 index 000000000..14441f95b --- /dev/null +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTab.java @@ -0,0 +1,47 @@ +/* + * 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 com.arsdigita.ui.admin.sites; + +import com.arsdigita.bebop.BoxPanel; +import com.arsdigita.bebop.Text; +import com.arsdigita.toolbox.ui.LayoutPanel; + +/** + * + * @author Jens Pelzetter + */ +public class SitesTab extends LayoutPanel { + + public SitesTab() { + super(); + + super.setClassAttr("sidebarNavPanel"); + + final BoxPanel left = new BoxPanel(BoxPanel.VERTICAL); + + + final BoxPanel right = new BoxPanel(BoxPanel.VERTICAL); + + right.add(new Text("Sites placeholder")); + + setLeft(left); + setRight(right); + } + +} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTable.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTable.java new file mode 100644 index 000000000..8fef364d7 --- /dev/null +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTable.java @@ -0,0 +1,63 @@ +/* + * 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 com.arsdigita.ui.admin.sites; + +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.globalization.GlobalizedMessage; + +import static com.arsdigita.ui.admin.AdminUiConstants.*; + +/** + * + * @author Jens Pelzetter + */ +public class SitesTable extends Table { + + public static final int COL_SITE_DOMAIN = 0; + public static final int COL_IS_DEFAULT_SITE = 1; + public static final int COL_DEFAULT_THEME = 2; + + public SitesTable() { + + super(); + + super.setIdAttr("sitesTable"); + super.setStyleAttr("width: 30em"); + + setEmptyView(new Label(new GlobalizedMessage("ui.admin.sites.no_sites", + ADMIN_BUNDLE))); + + final TableColumnModel columnModel = getColumnModel(); + columnModel.add(new TableColumn( + COL_SITE_DOMAIN, + new Label(new GlobalizedMessage("ui.admin.sites.table.domain")))); + columnModel.add(new TableColumn( + COL_IS_DEFAULT_SITE, + new Label(new GlobalizedMessage("ui.admin.sites.table.default_site")))); + columnModel.add(new TableColumn( + COL_DEFAULT_THEME, + new Label(new GlobalizedMessage("ui.admin.sites.table.default_theme")))); + + super.setModelBuilder(new SitesTableModelBuilder()); + } + +} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModel.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModel.java new file mode 100644 index 000000000..19d83965a --- /dev/null +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModel.java @@ -0,0 +1,80 @@ +/* + * 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 com.arsdigita.ui.admin.sites; + +import com.arsdigita.bebop.table.TableModel; + +import org.libreccm.cdi.utils.CdiUtil; +import org.libreccm.sites.Site; +import org.libreccm.sites.SiteRepository; + +import java.util.Iterator; + +/** + * + * @author Jens Pelzetter + */ +public class SitesTableModel implements TableModel { + + private final Iterator iterator; + private Site current; + + public SitesTableModel() { + + final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); + final SiteRepository siteRepo = cdiUtil.findBean(SiteRepository.class); + iterator = siteRepo.findAll().iterator(); + } + + @Override + public int getColumnCount() { + return 3; + } + + @Override + public boolean nextRow() { + if (iterator.hasNext()) { + current = iterator.next(); + return true; + } else { + return false; + } + } + + @Override + public Object getElementAt(final int columnIndex) { + + switch (columnIndex) { + case SitesTable.COL_SITE_DOMAIN: + return current.getDomainOfSite(); + case SitesTable.COL_IS_DEFAULT_SITE: + return current.isDefaultSite(); + case SitesTable.COL_DEFAULT_THEME: + return current.getDefaultTheme(); + default: + throw new IllegalArgumentException("Illegal column index"); + } + } + + @Override + public Object getKeyAt(final int columnIndex) { + return current.getObjectId(); + } + +} diff --git a/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModelBuilder.java b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModelBuilder.java new file mode 100644 index 000000000..5472cd95a --- /dev/null +++ b/ccm-core/src/main/java/com/arsdigita/ui/admin/sites/SitesTableModelBuilder.java @@ -0,0 +1,41 @@ +/* + * 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 com.arsdigita.ui.admin.sites; + +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.util.LockableImpl; + +/** + * + * @author Jens Pelzetter + */ +public class SitesTableModelBuilder + extends LockableImpl + implements TableModelBuilder { + + @Override + public TableModel makeModel(final Table table, final PageState state) { + + return new SitesTableModel(); + } + +} 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 9c7def82e..b77fb1bc7 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 @@ -615,3 +615,4 @@ ui.user.groups.remove=Remove ui.user.roles.remove=Remove ui.role.parties.remove=Remove ui.admin.role_edit.description.label=Description +ui.admin.tab.sites.title=Sites 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 27de1d2e7..01f2ad4e3 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 @@ -619,3 +619,4 @@ ui.user.groups.remove=Entfernen ui.user.roles.remove=Entfernen ui.role.parties.remove=Entfernen ui.admin.role_edit.description.label=Beschreibung +ui.admin.tab.sites.title=Sites 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 e5beb9eb6..08e37f152 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 @@ -612,3 +612,4 @@ ui.user.groups.remove=Remove ui.user.roles.remove=Remove ui.role.parties.remove=Remove ui.admin.role_edit.description.label=Description +ui.admin.tab.sites.title=Sites 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 0ee4911f5..06fa3f844 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 @@ -603,3 +603,4 @@ ui.user.groups.remove=Remove ui.user.roles.remove=Remove ui.role.parties.remove=Remove ui.admin.role_edit.description.label=Description +ui.admin.tab.sites.title=Sites