RelationAttribute

Auf der Webseite sollten jetzt für alle RelationAttribute statt des keys der lokalisierte Wert angezeigt. Dazu waren u.A. einige Änderungen am ContentItemXMLRenderer und dem RelationAttributeInterface nötig.

git-svn-id: https://svn.libreccm.org/ccm/trunk@696 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2011-01-19 08:38:35 +00:00
parent 12a8a41f85
commit 613c3a2d0b
2 changed files with 58 additions and 53 deletions

View File

@ -19,6 +19,7 @@
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;
@ -32,6 +33,7 @@ import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.RelationAttributeInterface;
import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.SecurityManager;
import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.cms.ui.BaseItemPane; import com.arsdigita.cms.ui.BaseItemPane;
@ -53,22 +55,18 @@ import org.apache.log4j.Logger;
final class ContentTypeItemPane extends BaseItemPane { final class ContentTypeItemPane extends BaseItemPane {
private static Logger s_log = Logger.getLogger(ContentTypeItemPane.class); private static Logger s_log = Logger.getLogger(ContentTypeItemPane.class);
private final ACSObjectSelectionModel m_model; private final ACSObjectSelectionModel m_model;
private final ContentTypeRequestLocal m_type; private final ContentTypeRequestLocal m_type;
private final SimpleContainer m_detailPane; private final SimpleContainer m_detailPane;
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 RelationAttributeSection m_relationAttributes; // private final RelationAttributeSection m_relationAttributes;
ContentTypeItemPane(final ACSObjectSelectionModel model, ContentTypeItemPane(final ACSObjectSelectionModel model,
final ContentTypeRequestLocal type, final ContentTypeRequestLocal type,
final ActionLink editLink, final ActionLink editLink,
final ActionLink deleteLink) { final ActionLink deleteLink) {
m_model = model; m_model = model;
m_type = type; m_type = type;
@ -79,16 +77,12 @@ 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 m_templates = new SectionTemplatesListing(new ContentSectionRequestLocal(), m_type);
(new ContentSectionRequestLocal(), m_type);
final ActionLink templateAddLink = new ActionLink final ActionLink templateAddLink = new ActionLink(new Label(gz("cms.ui.type.template.add")));
(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 final Form templateForm = new CancellableForm("AddTemplate", templateFormSection.getSaveCancelSection().getCancelButton());
("AddTemplate", templateFormSection.getSaveCancelSection
().getCancelButton());
templateForm.add(templateFormSection); templateForm.add(templateFormSection);
add(templateForm); add(templateForm);
@ -111,8 +105,7 @@ 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 final AddContentItemElement itemForm = new AddContentItemElement(m_model);
(m_model);
add(itemForm); add(itemForm);
m_detailPane.add(new SummarySection(editLink, deleteLink)); m_detailPane.add(new SummarySection(editLink, deleteLink));
@ -156,6 +149,7 @@ final class ContentTypeItemPane extends BaseItemPane {
// XXX A temporary, low-impact fix. // XXX A temporary, low-impact fix.
private class CancellableForm extends Form implements Cancellable { private class CancellableForm extends Form implements Cancellable {
private final Submit m_cancel; private final Submit m_cancel;
CancellableForm(final String name, final Submit cancel) { CancellableForm(final String name, final Submit cancel) {
@ -170,8 +164,9 @@ final class ContentTypeItemPane extends BaseItemPane {
} }
private class SummarySection extends Section { private class SummarySection extends Section {
SummarySection(final ActionLink editLink, SummarySection(final ActionLink editLink,
final ActionLink deleteLink) { final ActionLink deleteLink) {
setHeading(new Label(gz("cms.ui.type.details"))); setHeading(new Label(gz("cms.ui.type.details")));
final ActionGroup group = new ActionGroup(); final ActionGroup group = new ActionGroup();
@ -185,6 +180,7 @@ final class ContentTypeItemPane extends BaseItemPane {
} }
private class ElementSection extends Section { private class ElementSection extends Section {
ElementSection() { ElementSection() {
setHeading(new Label(gz("cms.ui.type.elements"))); setHeading(new Label(gz("cms.ui.type.elements")));
@ -197,12 +193,13 @@ final class ContentTypeItemPane extends BaseItemPane {
@Override @Override
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return m_model.isSelected(state) && isDynamicType(state) && return m_model.isSelected(state) && isDynamicType(state)
!ContentSection.getConfig().getHideUDCTUI(); && !ContentSection.getConfig().getHideUDCTUI();
} }
} }
private class TemplateSection extends Section { private class TemplateSection extends Section {
TemplateSection(final ActionLink templateAddLink) { TemplateSection(final ActionLink templateAddLink) {
setHeading(new Label(gz("cms.ui.type.templates"))); setHeading(new Label(gz("cms.ui.type.templates")));
@ -220,6 +217,7 @@ final class ContentTypeItemPane extends BaseItemPane {
} }
private class RelationAttributeSection extends Section { private class RelationAttributeSection extends Section {
RelationAttributeSection() { RelationAttributeSection() {
setHeading(new Label(gz("cms.ui.type.attributes"))); setHeading(new Label(gz("cms.ui.type.attributes")));
@ -237,7 +235,10 @@ final class ContentTypeItemPane extends BaseItemPane {
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();
retVal = clazz.cast(ci).hasRelationAttributes(); if (ci instanceof RelationAttributeInterface) {
RelationAttributeInterface rai = (RelationAttributeInterface) ci;
retVal = rai.hasRelationAttributes();
}
ci.delete(); ci.delete();
} catch (Exception ex) { } catch (Exception ex) {
//retVal = false; //retVal = false;
@ -252,19 +253,19 @@ final class ContentTypeItemPane extends BaseItemPane {
super.register(page); super.register(page);
page.addActionListener(new ActionListener() { page.addActionListener(new ActionListener() {
public final void actionPerformed(final ActionEvent e) {
final PageState state = e.getPageState();
if (state.isVisibleOnPage(ContentTypeItemPane.this) public final void actionPerformed(final ActionEvent e) {
final PageState state = e.getPageState();
if (state.isVisibleOnPage(ContentTypeItemPane.this)
&& m_model.isSelected(state) && m_model.isSelected(state)
&& !userCanEdit(state)) { && !userCanEdit(state)) {
m_templates.getRemoveColumn().setVisible(state, false); m_templates.getRemoveColumn().setVisible(state, false);
m_templates.getDefaultColumn().setVisible(state, false); m_templates.getDefaultColumn().setVisible(state, false);
m_elements.getTable().getColumn(3).setVisible m_elements.getTable().getColumn(3).setVisible(state, false);
(state, false);
}
} }
}); }
});
} }
/** /**
@ -286,7 +287,7 @@ final class ContentTypeItemPane extends BaseItemPane {
protected static boolean userCanEdit(final PageState state) { protected static boolean userCanEdit(final PageState state) {
SecurityManager sm = Utilities.getSecurityManager(state); SecurityManager sm = Utilities.getSecurityManager(state);
return sm.canAccess(state.getRequest(), return sm.canAccess(state.getRequest(),
SecurityManager.CONTENT_TYPE_ADMIN); SecurityManager.CONTENT_TYPE_ADMIN);
} }
/** /**
@ -300,9 +301,8 @@ final class ContentTypeItemPane extends BaseItemPane {
final ContentType type = m_type.getContentType(state); final ContentType type = m_type.getContentType(state);
final String objectTypeString = final String objectTypeString =
"com.arsdigita.persistence.DynamicObjectType"; "com.arsdigita.persistence.DynamicObjectType";
final DataCollection collection = SessionManager.getSession().retrieve final DataCollection collection = SessionManager.getSession().retrieve(objectTypeString);
(objectTypeString);
collection.addEqualsFilter("dynamicType", type.getAssociatedObjectType()); collection.addEqualsFilter("dynamicType", type.getAssociatedObjectType());
final boolean b = collection.next(); final boolean b = collection.next();

View File

@ -5,7 +5,7 @@
package com.arsdigita.cms.ui.type; package com.arsdigita.cms.ui.type;
import com.arsdigita.bebop.Component; import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.Link; import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.List; import com.arsdigita.bebop.List;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.list.AbstractListModelBuilder; import com.arsdigita.bebop.list.AbstractListModelBuilder;
@ -13,7 +13,7 @@ import com.arsdigita.bebop.list.ListCellRenderer;
import com.arsdigita.bebop.list.ListModel; import com.arsdigita.bebop.list.ListModel;
import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.RelationAttributeCollection; import com.arsdigita.cms.RelationAttributeInterface;
import java.util.StringTokenizer; import java.util.StringTokenizer;
/** /**
@ -23,15 +23,11 @@ import java.util.StringTokenizer;
public class RelationAttributeList extends List { public class RelationAttributeList extends List {
private ContentTypeRequestLocal m_type; private ContentTypeRequestLocal m_type;
private ContentType contentType;
private StringTokenizer relationAttributeList;
public RelationAttributeList(ContentTypeRequestLocal type) { public RelationAttributeList(ContentTypeRequestLocal type) {
super(new RelationAttributeListModelBuilder(type)); super(new RelationAttributeListModelBuilder(type));
m_type = type; m_type = type;
relationAttributeList = null;
setCellRenderer(new CellRenderer()); setCellRenderer(new CellRenderer());
} }
@ -47,8 +43,10 @@ public class RelationAttributeList extends List {
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();
retVal = clazz.cast(ci).hasRelationAttributes(); if (ci instanceof RelationAttributeInterface) {
relationAttributeList = clazz.cast(ci).getRelationAttributes(); RelationAttributeInterface rai = (RelationAttributeInterface) ci;
retVal = rai.hasRelationAttributes();
}
ci.delete(); ci.delete();
} catch (Exception ex) { } catch (Exception ex) {
//retVal = false; //retVal = false;
@ -60,7 +58,6 @@ public class RelationAttributeList extends List {
private static class RelationAttributeListModelBuilder extends AbstractListModelBuilder { private static class RelationAttributeListModelBuilder extends AbstractListModelBuilder {
private ContentTypeRequestLocal m_type; private ContentTypeRequestLocal m_type;
private ContentType contentType;
private StringTokenizer relationAttributeList; private StringTokenizer relationAttributeList;
public RelationAttributeListModelBuilder(ContentTypeRequestLocal type) { public RelationAttributeListModelBuilder(ContentTypeRequestLocal type) {
@ -71,15 +68,16 @@ public class RelationAttributeList extends List {
public final ListModel makeModel(final List list, final PageState state) { public final ListModel makeModel(final List list, final PageState state) {
boolean retVal = false;
ContentType ct = (ContentType) m_type.getContentType(state); ContentType ct = (ContentType) m_type.getContentType(state);
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();
retVal = clazz.cast(ci).hasRelationAttributes(); if (ci instanceof RelationAttributeInterface) {
relationAttributeList = clazz.cast(ci).getRelationAttributes(); RelationAttributeInterface rai = (RelationAttributeInterface) ci;
relationAttributeList = rai.getRelationAttributes();
}
ci.delete(); ci.delete();
} catch (Exception ex) { } catch (Exception ex) {
//retVal = false; //retVal = false;
@ -91,8 +89,8 @@ public class RelationAttributeList extends List {
private class Model implements ListModel { private class Model implements ListModel {
private final StringTokenizer m_items; private final StringTokenizer m_items;
// private String m_item; private String m_item;
private RelationAttributeCollection m_item; // private RelationAttributeCollection m_item;
Model(final StringTokenizer items) { Model(final StringTokenizer items) {
m_items = items; m_items = items;
@ -101,8 +99,8 @@ public class RelationAttributeList extends List {
public final boolean next() { public final boolean next() {
if (m_items.hasMoreTokens()) { if (m_items.hasMoreTokens()) {
// m_item = m_items.nextToken(); m_item = m_items.nextToken();
m_item = new RelationAttributeCollection(m_items.nextToken()); // m_item = new RelationAttributeCollection(m_items.nextToken());
return true; return true;
} else { } else {
m_item = null; m_item = null;
@ -112,13 +110,14 @@ public class RelationAttributeList extends List {
// Label // Label
public final Object getElement() { public final Object getElement() {
return m_item.getName(); return m_item;
// return m_item.getDisplayName(); // return m_item.getName();
} }
// URL // URL
public final String getKey() { public final String getKey() {
return m_item+"/";//.getName() + "/"; return m_item;
// return m_item.getName() + "/";
} }
} }
} }
@ -131,7 +130,13 @@ public class RelationAttributeList extends List {
final String key, final String key,
final int index, final int index,
final boolean isSelected) { final boolean isSelected) {
return new Link((String) value, key); ControlLink link = new ControlLink(key){
public void setControlEvent(PageState state) {
state.setControlEvent(list, "editRelationAttributes", key);
};
};
return link;
} }
} }
} }