From 6233fc39e8e32a4ae561f20a5620ae9938f8df00 Mon Sep 17 00:00:00 2001 From: jensp Date: Wed, 17 Apr 2013 07:16:24 +0000 Subject: [PATCH] =?UTF-8?q?Fehlende=20Dateien=20f=C3=BCr=20ccm-atoz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@2128 8810af33-2d31-482b-a856-94f89814c4df --- .../atoz/ui/AtoZGlobalizationUtil.java | 22 ++ .../atoz/ui/AtoZResources.properties | 17 ++ .../atoz/ui/AtoZResources_de.properties | 17 ++ .../atoz/ui/admin/AtoZProviderTable.java | 216 ++++++++++++++++++ 4 files changed, 272 insertions(+) create mode 100644 ccm-atoz/src/com/arsdigita/atoz/ui/AtoZGlobalizationUtil.java create mode 100644 ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources.properties create mode 100644 ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources_de.properties create mode 100644 ccm-atoz/src/com/arsdigita/atoz/ui/admin/AtoZProviderTable.java diff --git a/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZGlobalizationUtil.java b/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZGlobalizationUtil.java new file mode 100644 index 000000000..deb839721 --- /dev/null +++ b/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZGlobalizationUtil.java @@ -0,0 +1,22 @@ +package com.arsdigita.atoz.ui; + +import com.arsdigita.globalization.GlobalizedMessage; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class AtoZGlobalizationUtil { + + public static final String BUNDLE_NAME = "com.arsdigita.atoz.ui.AtoZResources"; + + public static GlobalizedMessage globalize(String key) { + return new GlobalizedMessage(key, BUNDLE_NAME); + } + + public static GlobalizedMessage globalize(String key, Object[] args) { + return new GlobalizedMessage(key, BUNDLE_NAME, args); + } + +} diff --git a/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources.properties b/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources.properties new file mode 100644 index 000000000..3b46d51dd --- /dev/null +++ b/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources.properties @@ -0,0 +1,17 @@ +# To change this template, choose Tools | Templates +# and open the template in the editor. + +atoz.ui.provider_title=Title +atoz.ui.provider_description=Description +atoz.ui.load_paths=Attributes to retrieve +atoz.ui.category_filter=Category filter +atoz.ui.category_picker.root_category=Root category +atoz.ui.create_provider=Create provider +atoz.ui.provider.create=Create +atoz.ui.providers_table.empty=No providers found +atoz.ui.providers_table.provider_name=Name +atoz.ui.providers_table.description=Description +atoz.ui.providers_table.type=Type +atoz.ui.providers_table.edit=Edit +atoz.ui.providers_table.delete=Delete +atoz.ui.providers_table.delete.confirm=Are you sure to delete this provider? diff --git a/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources_de.properties b/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources_de.properties new file mode 100644 index 000000000..ea8577d28 --- /dev/null +++ b/ccm-atoz/src/com/arsdigita/atoz/ui/AtoZResources_de.properties @@ -0,0 +1,17 @@ +# To change this template, choose Tools | Templates +# and open the template in the editor. + +atoz.ui.provider_title=Titel +atoz.ui.provider_description=Beschreibung +atoz.ui.load_paths=Zu ladende Attribute +atoz.ui.category_filter=Kategorienfilter +atoz.ui.category_picker.root_category=Root Kategorie +atoz.ui.create_provider=Neuen Provider anlegen +atoz.ui.provider.create=Anlegen +atoz.ui.providers_table.empty=Keine Provider gefunden +atoz.ui.providers_table.provider_name=Name +atoz.ui.providers_table.description=Beschreibung +atoz.ui.providers_table.type=Typ +atoz.ui.providers_table.edit=Bearbeiten +atoz.ui.providers_table.delete=L\u00f6schen +atoz.ui.providers_table.delete.confirm=Sind Sie sicher, dass Sie diesen Provider l\u00f6schen m\u00f6chten? diff --git a/ccm-atoz/src/com/arsdigita/atoz/ui/admin/AtoZProviderTable.java b/ccm-atoz/src/com/arsdigita/atoz/ui/admin/AtoZProviderTable.java new file mode 100644 index 000000000..4e61720f6 --- /dev/null +++ b/ccm-atoz/src/com/arsdigita/atoz/ui/admin/AtoZProviderTable.java @@ -0,0 +1,216 @@ +package com.arsdigita.atoz.ui.admin; + +import com.arsdigita.atoz.AtoZ; +import com.arsdigita.atoz.AtoZProvider; +import com.arsdigita.atoz.ui.AtoZGlobalizationUtil; +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.ControlLink; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.Table; +import com.arsdigita.bebop.event.TableActionEvent; +import com.arsdigita.bebop.event.TableActionListener; +import com.arsdigita.bebop.table.TableCellRenderer; +import com.arsdigita.bebop.table.TableColumn; +import com.arsdigita.bebop.table.TableColumnModel; +import com.arsdigita.bebop.table.TableModel; +import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.domain.DomainCollection; +import com.arsdigita.domain.DomainObject; +import com.arsdigita.domain.DomainObjectFactory; +import com.arsdigita.kernel.Kernel; +import com.arsdigita.kernel.ui.ACSObjectSelectionModel; +import com.arsdigita.persistence.OID; +import com.arsdigita.util.LockableImpl; +import com.arsdigita.util.UncheckedWrapperException; +import java.io.IOException; +import java.math.BigDecimal; + +/** + * + * @author Jens Pelzetter + * @version $Id$ + */ +public class AtoZProviderTable extends Table implements TableActionListener { + + private static final String EDIT = "edit"; + private static final String DELETE = "delete"; + private final static String TABLE_COL_DELETE = "table_col_delete"; + private final static String TABLE_COL_EDIT = "table_col_edit"; + private final ACSObjectSelectionModel selectedProvider; + + public AtoZProviderTable(final ACSObjectSelectionModel provider) { + super(); + + this.selectedProvider = provider; + + setEmptyView(new Label(AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.empty"))); + + final TableColumnModel columnModel = getColumnModel(); + + columnModel.add(new TableColumn( + 0, + AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.provider_name").localize())); + + columnModel.add(new TableColumn( + 1, + AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.description").localize())); + + columnModel.add(new TableColumn( + 2, + AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.type").localize())); + + columnModel.add(new TableColumn( + 3, + AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.edit").localize(), + TABLE_COL_EDIT)); + + columnModel.add(new TableColumn( + 4, + AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete").localize(), + TABLE_COL_DELETE)); + + setModelBuilder(new AtoZTableModelBuilder()); + + columnModel.get(3).setCellRenderer(new EditCellRenderer()); + columnModel.get(4).setCellRenderer(new DeleteCellRenderer()); + + addTableActionListener(this); + } + + public void cellSelected(final TableActionEvent event) { + final PageState state = event.getPageState(); + + final OID providerId = OID.valueOf(event.getRowKey().toString()); + + final TableColumn column = getColumnModel().get(event.getColumn().intValue()); + + if (TABLE_COL_EDIT.equals(column.getHeaderKey().toString())) { + final AtoZProvider provider = (AtoZProvider) DomainObjectFactory.newInstance(providerId); + selectedProvider.setSelectedObject(state, provider); + } else if (TABLE_COL_DELETE.equals(column.getHeaderKey().toString())) { + final AtoZProvider provider = (AtoZProvider) DomainObjectFactory.newInstance(providerId); + provider.delete(); + selectedProvider.clearSelection(state); + } + } + + public void headSelected(final TableActionEvent event) { + //Nothing + } + + private class AtoZTableModelBuilder extends LockableImpl implements TableModelBuilder { + + public AtoZTableModelBuilder() { + super(); + } + + public TableModel makeModel(final Table table, + final PageState state) { + table.getRowSelectionModel().clearSelection(state); + return new AtoZTableModel(table); + } + + } + + private class AtoZTableModel implements TableModel { + + private final Table table; + private final DomainCollection providers; + + public AtoZTableModel(final Table table) { + this.table = table; + + final AtoZ atoz = (AtoZ) Kernel.getContext().getResource(); + providers = atoz.getProviders(); + } + + public int getColumnCount() { + return table.getColumnModel().size(); + } + + public boolean nextRow() { + return providers.next(); + } + + public Object getElementAt(final int columnIndex) { + switch (columnIndex) { + case 0: + return ((AtoZProvider) providers.getDomainObject()).getTitle(); + case 1: + return ((AtoZProvider) providers.getDomainObject()).getDescription(); + case 2: + return ((AtoZProvider) providers.getDomainObject()).getObjectType().getName(); + case 3: + return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.edit").localize(); + case 4: + return AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete").localize(); + default: + return null; + } + } + + public Object getKeyAt(final int columnIndex) { + return providers.getDomainObject().getOID(); + } + + } + + private class EditCellRenderer extends LockableImpl implements TableCellRenderer { + + public EditCellRenderer() { + super(); + } + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int col) { + return new ControlLink((String) AtoZGlobalizationUtil.globalize( + "atoz.ui.providers_table.edit").localize()); +// state.setControlEvent(table, EDIT, key.toString()); +// try { +// return new Link(value.toString(), state.stateAsURL()); +// } catch (IOException ex) { +// throw new UncheckedWrapperException("Failed to create edit link for AtoZ provider.", ex); +// } + } + + } + + private class DeleteCellRenderer extends LockableImpl implements TableCellRenderer { + + public DeleteCellRenderer() { + super(); + } + + public Component getComponent(final Table table, + final PageState state, + final Object value, + final boolean isSelected, + final Object key, + final int row, + final int column) { + final ControlLink link = new ControlLink((String) AtoZGlobalizationUtil.globalize( + "atoz.ui.providers_table.delete").localize()); + + link.setConfirmation((String) AtoZGlobalizationUtil.globalize("atoz.ui.providers_table.delete.confirm"). + localize()); + + return link; + + +// state.setControlEvent(table, DELETE, key.toString()); +// try { +// return new Link(value.toString(), state.stateAsURL()); +// } catch (IOException ex) { +// throw new UncheckedWrapperException("Failed to create delete link for AtoZ provider.", ex); +// } + } + + } +}