From 24f0131056fdba43cf1c35b3d4d2d75d8168496c Mon Sep 17 00:00:00 2001 From: jensp Date: Tue, 16 Nov 2010 10:00:02 +0000 Subject: [PATCH] =?UTF-8?q?sci-types-organization:=20Bearbeiten-Links=20in?= =?UTF-8?q?=20Tabellen=20erg=C3=A4nzt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@611 8810af33-2d31-482b-a856-94f89814c4df --- .../ui/SciDepartmentProjectsTable.java | 31 +++++++++++- .../ui/SciDepartmentSubDepartmentsTable.java | 33 ++++++++++++- .../ui/SciOrganizationDepartmentsTable.java | 30 +++++++++++- .../ui/SciOrganizationProjectsTable.java | 33 +++++++++++-- .../ui/SciProjectDepartmentsTable.java | 47 +++++++++++++++++-- .../ui/SciProjectOrganizationsTable.java | 41 ++++++++++++---- .../ui/SciProjectSubProjectsTable.java | 35 ++++++++++++-- 7 files changed, 225 insertions(+), 25 deletions(-) diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTable.java index d2fe9cdcc..99fcc12da 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentProjectsTable.java @@ -24,6 +24,7 @@ import java.math.BigDecimal; 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; @@ -33,13 +34,18 @@ 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.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciDepartmentProjectsCollection; import com.arsdigita.cms.contenttypes.SciProject; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; import com.arsdigita.util.LockableImpl; +import org.apache.log4j.Logger; /** * Table for showing all {@link SciProject}s linked with a {@link SciDepartment} @@ -52,6 +58,8 @@ public class SciDepartmentProjectsTable extends Table implements TableActionListener { + private final Logger s_log = Logger.getLogger( + SciDepartmentProjectsTable.class); private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_UP = "table_col_up"; @@ -205,7 +213,25 @@ public class SciDepartmentProjectsTable department); if (canEdit) { - ControlLink link = new ControlLink(value.toString()); + SciProject project; + try { + project = new SciProject((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + + } + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = + new Link(value.toString(), + resolver.generateItemURL(state, + project, + section, + project.getVersion())); + return link; } else { Label label = new Label(value.toString()); @@ -292,7 +318,8 @@ public class SciDepartmentProjectsTable int row, int col) { - SciDepartment department = (SciDepartment) m_itemModel.getSelectedObject( + SciDepartment department = (SciDepartment) m_itemModel. + getSelectedObject( state); SciDepartmentProjectsCollection projects = department.getProjects(); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentsTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentsTable.java index 2fcd4fc11..1b398afab 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentsTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciDepartmentSubDepartmentsTable.java @@ -22,6 +22,7 @@ package com.arsdigita.cms.contenttypes.ui; 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; @@ -31,13 +32,18 @@ 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.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; import com.arsdigita.util.LockableImpl; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** * Table for showing the subdepartments of a {@link SciDepartment}. @@ -49,6 +55,8 @@ public class SciDepartmentSubDepartmentsTable extends Table implements TableActionListener { + private final Logger s_log = Logger.getLogger( + SciDepartmentSubDepartmentsTable.class); private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_UP = "table_col_up"; @@ -202,8 +210,29 @@ public class SciDepartmentSubDepartmentsTable department); if (canEdit) { - ControlLink link = new ControlLink(value.toString()); + SciDepartment subDepartment; + try { + subDepartment = new SciDepartment( + (BigDecimal) key); + } catch (ObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = new Link(value.toString(), + resolver.generateItemURL(state, + subDepartment, + section, + subDepartment. + getVersion())); + return link; + + } else { Label label = new Label(value.toString()); return label; @@ -292,7 +321,7 @@ public class SciDepartmentSubDepartmentsTable SciDepartment department = (SciDepartment) m_itemModel. getSelectedObject(state); SciDepartmentSubDepartmentsCollection subDepartments = - department.getSubDepartments(); + department.getSubDepartments(); if ((subDepartments.size() - 1) == row) { Label label = new Label(""); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentsTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentsTable.java index 7445e787a..6543a5ff7 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentsTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationDepartmentsTable.java @@ -22,6 +22,7 @@ package com.arsdigita.cms.contenttypes.ui; 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; @@ -31,14 +32,19 @@ 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.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciOrganization; import com.arsdigita.cms.contenttypes.SciOrganizationDepartmentsCollection; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; import com.arsdigita.util.LockableImpl; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** * Table for showing the {@link SciDepartment}s linked to a @@ -52,6 +58,8 @@ public class SciOrganizationDepartmentsTable extends Table implements TableActionListener { + private final Logger s_log = Logger.getLogger( + SciOrganizationDepartmentsTable.class); private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_UP = "table_col_up"; @@ -205,8 +213,28 @@ public class SciOrganizationDepartmentsTable orga); if (canEdit) { - ControlLink link = new ControlLink(value.toString()); + SciDepartment department; + try { + department = new SciDepartment((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = new Link(value.toString(), + resolver.generateItemURL(state, + department, + section, + department. + getVersion())); + return link; + } else { Label label = new Label(value.toString()); return label; diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectsTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectsTable.java index ab335fb1a..c9fea044e 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectsTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciOrganizationProjectsTable.java @@ -24,6 +24,7 @@ import java.math.BigDecimal; 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; @@ -33,13 +34,18 @@ 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.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.SciOrganization; import com.arsdigita.cms.contenttypes.SciOrganizationProjectsCollection; import com.arsdigita.cms.contenttypes.SciProject; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.dispatcher.ObjectNotFoundException; import com.arsdigita.util.LockableImpl; +import org.apache.log4j.Logger; /** * Table for showing the links between a {@link SciOrganization} and @@ -53,6 +59,8 @@ public class SciOrganizationProjectsTable extends Table implements TableActionListener { + private final Logger s_log = Logger.getLogger( + SciOrganizationProjectsTable.class); private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_UP = "table_col_up"; @@ -206,8 +214,26 @@ public class SciOrganizationProjectsTable orga); if (canEdit) { - ControlLink link = new ControlLink(value.toString()); + SciProject project; + try { + project = new SciProject((BigDecimal) key); + } catch (ObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + } + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = + new Link(value.toString(), + resolver.generateItemURL(state, + project, + section, + project.getVersion())); + return link; + } else { Label label = new Label(value.toString()); return label; @@ -293,10 +319,9 @@ public class SciOrganizationProjectsTable int row, int col) { - SciOrganization orga = (SciOrganization) m_itemModel. + SciOrganization orga = (SciOrganization) m_itemModel. getSelectedObject(state); - SciOrganizationProjectsCollection projects = orga. - getProjects(); + SciOrganizationProjectsCollection projects = orga.getProjects(); if ((projects.size() - 1) == row) { Label label = new Label(""); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentsTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentsTable.java index 8fbcac81b..c7d22d319 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentsTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDepartmentsTable.java @@ -22,6 +22,7 @@ package com.arsdigita.cms.contenttypes.ui; 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; @@ -31,14 +32,19 @@ 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.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.contenttypes.SciProjectDepartmentsCollection; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.util.LockableImpl; import java.math.BigDecimal; +import org.apache.log4j.Logger; /** * Table for showing the links between a {@link SciProject} and a @@ -50,6 +56,8 @@ public class SciProjectDepartmentsTable extends Table implements TableActionListener { + private final static Logger s_log = Logger.getLogger( + SciProjectDepartmentsTable.class); private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_UP = "table_col_up"; @@ -190,8 +198,39 @@ public class SciProjectDepartmentsTable Object key, int row, int column) { - Label label = new Label(value.toString()); - return label; + com.arsdigita.cms.SecurityManager securityManager = Utilities. + getSecurityManager(state); + SciProject project = (SciProject) m_itemModel.getSelectedObject( + state); + + boolean canEdit = securityManager.canAccess(state.getRequest(), + com.arsdigita.cms.SecurityManager.EDIT_ITEM, + project); + if (canEdit) { + SciDepartment department; + try { + department = new SciDepartment((BigDecimal) key); + } catch (DataObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + } + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = + new Link(value.toString(), + resolver.generateItemURL(state, + department, + section, + department.getVersion())); + + return link; + } else { + + Label label = new Label(value.toString()); + return label; + } } } @@ -232,7 +271,7 @@ public class SciProjectDepartmentsTable } } - private class UpCellRenderer + private class UpCellRenderer extends LockableImpl implements TableCellRenderer { @@ -291,7 +330,7 @@ public class SciProjectDepartmentsTable } } - @Override + @Override public void cellSelected(TableActionEvent event) { PageState state = event.getPageState(); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsTable.java index 463439037..20b559622 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectOrganizationsTable.java @@ -24,6 +24,7 @@ import java.math.BigDecimal; 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; @@ -33,14 +34,18 @@ 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.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.SciOrganization; import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.contenttypes.SciProjectOrganizationsCollection; -import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.util.LockableImpl; +import org.apache.log4j.Logger; /** * Table for showing the links between a {@link SciProject} and @@ -52,6 +57,8 @@ public class SciProjectOrganizationsTable extends Table implements TableActionListener { + private static final Logger s_log = Logger.getLogger( + SciProjectOrganizationsTable.class); private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_UP = "table_col_up"; @@ -204,13 +211,31 @@ public class SciProjectOrganizationsTable SecurityManager.EDIT_ITEM, project); - /*if (canEdit) { - ControlLink link = new ControlLink(value.toString()); + if (canEdit) { + SciOrganization orga; + try { + orga = new SciOrganization((BigDecimal) key); + } catch (DataObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = + new Link(value.toString(), + resolver.generateItemURL(state, + orga, + section, + orga.getVersion())); return link; - } else {*/ + + } else { Label label = new Label(value.toString()); return label; - //} + } } } @@ -295,7 +320,7 @@ public class SciProjectOrganizationsTable SciProject project = (SciProject) m_itemModel.getSelectedObject( state); SciProjectOrganizationsCollection orgas = - project.getOrganizations(); + project.getOrganizations(); if ((orgas.size() - 1) == row) { Label label = new Label(""); @@ -310,7 +335,7 @@ public class SciProjectOrganizationsTable } } - @Override + @Override public void cellSelected(TableActionEvent event) { PageState state = event.getPageState(); @@ -321,7 +346,7 @@ public class SciProjectOrganizationsTable (SciProject) m_itemModel.getSelectedObject(state); SciProjectOrganizationsCollection subprojects = - project.getOrganizations(); + project.getOrganizations(); TableColumn column = getColumnModel().get(event.getColumn().intValue()); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubProjectsTable.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubProjectsTable.java index 22b2fab54..2ddd0b62a 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubProjectsTable.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectSubProjectsTable.java @@ -24,6 +24,7 @@ import java.math.BigDecimal; 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; @@ -33,12 +34,17 @@ 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.cms.CMS; +import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection; +import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.util.LockableImpl; +import org.apache.log4j.Logger; /** * Table of showing the subprojects of a {@link SciProject}. @@ -49,6 +55,8 @@ public class SciProjectSubProjectsTable extends Table implements TableActionListener { + private static final Logger s_log = Logger.getLogger( + SciProjectSubProjectsTable.class); private final String TABLE_COL_EDIT = "table_col_edit"; private final String TABLE_COL_DEL = "table_col_del"; private final String TABLE_COL_UP = "table_col_up"; @@ -200,13 +208,32 @@ public class SciProjectSubProjectsTable SecurityManager.EDIT_ITEM, project); - /*if (canEdit) { - ControlLink link = new ControlLink(value.toString()); + if (canEdit) { + SciProject subProject; + try { + subProject = new SciProject((BigDecimal) key); + } catch (DataObjectNotFoundException ex) { + s_log.warn(String.format("No object with key '%s' found.", + key), + ex); + return new Label(value.toString()); + } + + ContentSection section = CMS.getContext().getContentSection(); + ItemResolver resolver = section.getItemResolver(); + Link link = new Link(value.toString(), + resolver.generateItemURL(state, + subProject, + section, + subProject. + getVersion())); + return link; - } else {*/ + + } else { Label label = new Label(value.toString()); return label; - //} + } } }