Erster Teil der GUI für das Setzen von Berechtigungen für Content Typen

git-svn-id: https://svn.libreccm.org/ccm/trunk@1027 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-07-20 15:34:53 +00:00
parent bede2ff498
commit dce690d63d
2 changed files with 64 additions and 23 deletions

View File

@ -91,6 +91,7 @@ public class TemplateCreate extends BasicItemForm {
/** /**
* Add the "use context" widget * Add the "use context" widget
*/ */
@Override
public void addWidgets() { public void addWidgets() {
super.addWidgets(); super.addWidgets();

View File

@ -19,7 +19,6 @@
package com.arsdigita.cms.ui.type; package com.arsdigita.cms.ui.type;
import com.arsdigita.bebop.ActionLink; import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Form; import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page; import com.arsdigita.bebop.Page;
@ -61,6 +60,7 @@ final class ContentTypeItemPane extends BaseItemPane {
private final TypeElements m_elements; private final TypeElements m_elements;
private final AddElement m_elementAddForm; private final AddElement m_elementAddForm;
private final SectionTemplatesListing m_templates; private final SectionTemplatesListing m_templates;
private final TypePermissionsTable m_permissions;
// private final RelationAttributeSection m_relationAttributes; // private final RelationAttributeSection m_relationAttributes;
ContentTypeItemPane(final ACSObjectSelectionModel model, ContentTypeItemPane(final ACSObjectSelectionModel model,
@ -77,16 +77,30 @@ final class ContentTypeItemPane extends BaseItemPane {
m_elements = new TypeElements(m_model); m_elements = new TypeElements(m_model);
m_elementAddForm = new AddElement(); m_elementAddForm = new AddElement();
m_templates = new SectionTemplatesListing(new ContentSectionRequestLocal(), m_type); m_templates =
new SectionTemplatesListing(new ContentSectionRequestLocal(), m_type);
final ActionLink templateAddLink = new ActionLink(new Label(gz("cms.ui.type.template.add"))); m_permissions = new TypePermissionsTable(
new ContentSectionRequestLocal(), m_type);
final ActionLink templateAddLink = new ActionLink(new Label(gz(
"cms.ui.type.template.add")));
final TemplateCreate templateFormSection = new TemplateCreate(m_model); final TemplateCreate templateFormSection = new TemplateCreate(m_model);
final Form templateForm = new CancellableForm("AddTemplate",
final Form templateForm = new CancellableForm("AddTemplate", templateFormSection.getSaveCancelSection().getCancelButton()); templateFormSection.
getSaveCancelSection().getCancelButton());
templateForm.add(templateFormSection); templateForm.add(templateFormSection);
add(templateForm); add(templateForm);
final ActionLink permissionAddLink = new ActionLink(new Label(gz(
"cms.ui.type.permission.add")));
final TypePermissions permissionsSection = new TypePermissions(m_model);
final Form permissionsForm = new CancellableForm("AddPermission",
permissionsSection.
getSaveCancelSection().getCancelButton());
permissionsForm.add(permissionsSection);
add(permissionsForm);
final AddTextElement textForm = new AddTextElement(m_model); final AddTextElement textForm = new AddTextElement(m_model);
add(textForm); add(textForm);
@ -105,7 +119,8 @@ final class ContentTypeItemPane extends BaseItemPane {
final AddFileElement fileForm = new AddFileElement(m_model); final AddFileElement fileForm = new AddFileElement(m_model);
add(fileForm); add(fileForm);
final AddContentItemElement itemForm = new AddContentItemElement(m_model); final AddContentItemElement itemForm =
new AddContentItemElement(m_model);
add(itemForm); add(itemForm);
m_detailPane.add(new SummarySection(editLink, deleteLink)); m_detailPane.add(new SummarySection(editLink, deleteLink));
@ -114,9 +129,13 @@ final class ContentTypeItemPane extends BaseItemPane {
m_detailPane.add(new TypeSecurityContainer(new ElementSection())); m_detailPane.add(new TypeSecurityContainer(new ElementSection()));
m_detailPane.add(new TemplateSection(templateAddLink)); m_detailPane.add(new TemplateSection(templateAddLink));
connect(templateAddLink, templateForm); m_detailPane.add(new PermissionsSection(permissionAddLink));
final SingleSelect elementSelect = m_elementAddForm.getElementTypeSelect(); connect(templateAddLink, templateForm);
connect(permissionAddLink, permissionsForm);
final SingleSelect elementSelect =
m_elementAddForm.getElementTypeSelect();
connect(m_elementAddForm, elementSelect, connect(m_elementAddForm, elementSelect,
AddElement.TEXT_ELEMENT, textForm); AddElement.TEXT_ELEMENT, textForm);
@ -216,6 +235,24 @@ final class ContentTypeItemPane extends BaseItemPane {
} }
} }
private class PermissionsSection extends Section {
public PermissionsSection(final ActionLink permissionsAddLink) {
setHeading(new Label(gz("cms.ui.type.permissions")));
final ActionGroup group = new ActionGroup();
setBody(group);
group.setSubject(m_permissions);
group.addAction(new TypeSecurityContainer(permissionsAddLink));
}
@Override
public final boolean isVisible(final PageState state) {
return m_model.isSelected(state) && !isDynamicType(state);
}
}
private class RelationAttributeSection extends Section { private class RelationAttributeSection extends Section {
RelationAttributeSection() { RelationAttributeSection() {
@ -233,10 +270,12 @@ final class ContentTypeItemPane extends BaseItemPane {
ContentItem ci = null; ContentItem ci = null;
try { try {
Class<? extends ContentItem> clazz = Class.forName(ct.getClassName()).asSubclass(ContentItem.class); Class<? extends ContentItem> clazz = Class.forName(ct.
getClassName()).asSubclass(ContentItem.class);
ci = clazz.newInstance(); ci = clazz.newInstance();
if (ci instanceof RelationAttributeInterface) { if (ci instanceof RelationAttributeInterface) {
RelationAttributeInterface rai = (RelationAttributeInterface) ci; RelationAttributeInterface rai =
(RelationAttributeInterface) ci;
retVal = rai.hasRelationAttributes(); retVal = rai.hasRelationAttributes();
} }
ci.delete(); ci.delete();
@ -302,7 +341,8 @@ final class ContentTypeItemPane extends BaseItemPane {
final String objectTypeString = final String objectTypeString =
"com.arsdigita.persistence.DynamicObjectType"; "com.arsdigita.persistence.DynamicObjectType";
final DataCollection collection = SessionManager.getSession().retrieve(objectTypeString); final DataCollection collection = SessionManager.getSession().retrieve(
objectTypeString);
collection.addEqualsFilter("dynamicType", type.getAssociatedObjectType()); collection.addEqualsFilter("dynamicType", type.getAssociatedObjectType());
final boolean b = collection.next(); final boolean b = collection.next();